Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added README.md
Empty file.
7 changes: 3 additions & 4 deletions devel/undocumented_fields/search_undocumented_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import sys
from typing import Dict, Set

import ast_comments as ast

Expand Down Expand Up @@ -121,7 +120,7 @@ def visit_FunctionDef(self, node):
self.classes[self.current_class].add(child.target.attr)


def analyze_file(file_path: str) -> Dict[str, Set[str]]:
def analyze_file(file_path: str) -> dict[str, set[str]]:
"""Analyze a Python file and return classes with their public fields."""
with open(file_path, "r", encoding="utf-8") as file:
try:
Expand All @@ -134,7 +133,7 @@ def analyze_file(file_path: str) -> Dict[str, Set[str]]:
return {}


def analyze_package(package_path: str) -> Dict[str, Dict[str, Set[str]]]:
def analyze_package(package_path: str) -> dict[str, dict[str, set[str]]]:
"""Analyze all Python files in a package directory."""
result = {}

Expand All @@ -160,7 +159,7 @@ def analyze_package(package_path: str) -> Dict[str, Dict[str, Set[str]]]:
return result


def write_results(results: Dict[str, Dict[str, Set[str]]], f) -> str:
def write_results(results: dict[str, dict[str, set[str]]], f) -> None:
"""Format the analysis results."""
for module_name, classes in sorted(results.items()):

Expand Down
2 changes: 1 addition & 1 deletion doc/modify_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def modify_html(soup: BeautifulSoup) -> None:
/ "settings"
)
for html_file in html_dir.glob("*.html"):
with open(html_file, "r", encoding="utf-8") as f:
with open(html_file, encoding="utf-8") as f:
soup = BeautifulSoup(f, "html.parser", from_encoding="utf-8")

modify_html(soup)
Expand Down
13 changes: 6 additions & 7 deletions examples/00-fluent/DOE_ML.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
# flake8: noqa: E402

import os
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -250,8 +249,8 @@
def display_scores(scores):
"""Display scores."""
print("\nCross-Validation Scores:", scores)
print("Mean:%0.2f" % (scores.mean()))
print("Std. Dev.:%0.2f" % (scores.std()))
print(f"Mean:{scores.mean():0.2f}")
print(f"Std. Dev.:{scores.std():0.2f}")


def fit_and_predict(model):
Expand All @@ -268,8 +267,8 @@ def fit_and_predict(model):
test_predictions = model.predict(X_test)
print(train_predictions.shape[0])
print("\n\nCoefficient Of Determination")
print("Train Data R2 Score: %0.3f" % (r2_score(train_predictions, y_train)))
print("Test Data R2 Score: %0.3f" % (r2_score(test_predictions, y_test)))
print(f"Train Data R2 Score: {r2_score(train_predictions, y_train):0.3f}")
print(f"Test Data R2 Score: {r2_score(test_predictions, y_test):0.3f}")
print(
"\n\nPredictions - Ground Truth (Kelvin): ", (test_predictions - y_test), "\n"
)
Expand Down Expand Up @@ -439,8 +438,8 @@ def fit_and_predict(model):
test_predictions = np.ravel(test_predictions.T)
print(test_predictions.shape)

print("\n\nTrain R2: %0.3f" % (r2_score(train_predictions, y_train)))
print("Test R2: %0.3f" % (r2_score(test_predictions, y_test)))
print(f"\n\nTrain R2: {r2_score(train_predictions, y_train):0.3f}")
print(f"Test R2: {r2_score(test_predictions, y_test):0.3f}")
print("Predictions - Ground Truth (Kelvin): ", (test_predictions - y_test))

fig = plt.figure(figsize=(12, 5))
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies = [
"pandas>=1.1.0,<3.0.0",
"pyansys-tools-report>=0.8.1",
"pyyaml>=6.0",
"typing-extensions>=4.12"
]
dynamic = ["version"]

Expand Down Expand Up @@ -233,3 +234,8 @@ skips = [
"B604",
"B607",
]

[tool.basedpyright]
reportUnknownMemberType = false
reportExplicitAny = false
reportPrivateUsage = false
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
import os
from typing import TypeAlias

PathType: TypeAlias = "os.PathLike[str] | os.PathLike[bytes] | str | bytes"
PathType: TypeAlias = "os.PathLike[str] | str"
"""Type alias for file system paths."""
4 changes: 2 additions & 2 deletions src/ansys/fluent/core/codegen/datamodelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from pathlib import Path
import shutil
import string
from typing import Any, Dict
from typing import Any

import ansys.fluent.core as pyfluent
from ansys.fluent.core import FluentMode, launch_fluent
Expand Down Expand Up @@ -230,7 +230,7 @@ class DataModelGenerator:
def __init__(self, version, static_infos: dict, verbose: bool = False):
self.version = version
self._server_static_infos = static_infos
self._static_info: Dict[str, DataModelStaticInfo] = {}
self._static_info: dict[str, DataModelStaticInfo] = {}
self._verbose = verbose
if StaticInfoType.DATAMODEL_WORKFLOW in static_infos:
self._static_info["workflow"] = DataModelStaticInfo(
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/fluent/core/codegen/tuigen.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import shutil
import string
import subprocess
from typing import Any, Dict
from typing import Any
import uuid

from defusedxml.ElementTree import parse
Expand Down Expand Up @@ -194,7 +194,7 @@ def find_class(self, module, name):
if module == "tuigen":
renamed_module = "ansys.fluent.core.codegen.tuigen"

return super(_RenameModuleUnpickler, self).find_class(renamed_module, name)
return super().find_class(renamed_module, name)


class TUIGenerator:
Expand All @@ -217,7 +217,7 @@ def __init__(
self._static_infos = static_infos
self._verbose = verbose

def _populate_menu(self, menu: _TUIMenu, info: Dict[str, Any]):
def _populate_menu(self, menu: _TUIMenu, info: dict[str, Any]):
for child_menu_name, child_menu_info in sorted(info["menus"].items()):
if _is_valid_tui_menu_name(child_menu_name):
child_menu = _TUIMenu(
Expand Down
3 changes: 1 addition & 2 deletions src/ansys/fluent/core/codegen/walk_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@
"""

from inspect import signature
from typing import List

import ansys.fluent.core.solver.flobject as flobject


def walk_api(
api_cls, on_each_path, current_path: str | List[str] = "", api_item_type: str = ""
api_cls, on_each_path, current_path: str | list[str] = "", api_item_type: str = ""
):
"""
Recursively traverse the API hierarchy, calling `on_each_path` for each item.
Expand Down
30 changes: 15 additions & 15 deletions src/ansys/fluent/core/data_model_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import copy
from enum import Enum
from threading import RLock
from typing import Any, Dict, List, Optional
from typing import Any

from ansys.api.fluent.v0.variant_pb2 import Variant
from ansys.fluent.core.utils.fluent_version import FluentVersion
Expand All @@ -37,12 +37,12 @@
| int
| float
| str
| List[bool]
| List[int]
| List[float]
| List[str]
| List["StateType"]
| Dict[str, "StateType"]
| list[bool]
| list[int]
| list[float]
| list[str]
| list["StateType"]
| dict[str, "StateType"]
)


Expand Down Expand Up @@ -225,7 +225,7 @@ def set_config(self, rules: str, name: str, value: Any):
def _update_cache_from_variant_state(
self,
rules: str,
source: Dict[str, StateType],
source: dict[str, StateType],
key: str,
state: Variant,
updater_fn,
Expand Down Expand Up @@ -309,7 +309,7 @@ def update_source_with_state(state_field):

def _determine_key(
self,
source: Dict[str, StateType],
source: dict[str, StateType],
internal_names_as_keys: bool,
key: str,
state: Variant,
Expand Down Expand Up @@ -338,7 +338,7 @@ def _determine_key(
return new_key

def update_cache(
self, rules: str, state: Variant, deleted_paths: List[str], version=None
self, rules: str, state: Variant, deleted_paths: list[str], version=None
):
"""Update datamodel cache from streamed state.

Expand Down Expand Up @@ -377,8 +377,8 @@ def update_cache(

def _process_deleted_paths(
self,
cache: Dict[str, Any],
deleted_paths: List[str],
cache: dict[str, Any],
deleted_paths: list[str],
internal_names_as_keys: bool,
):
"""Process and delete paths from the cache based on the deleted paths list."""
Expand All @@ -387,7 +387,7 @@ def _process_deleted_paths(
self._delete_from_cache(cache, comps, internal_names_as_keys)

def _delete_from_cache(
self, sub_cache: Dict[str, Any], comps: List[str], internal_names_as_keys: bool
self, sub_cache: dict[str, Any], comps: list[str], internal_names_as_keys: bool
):
"""Recursively delete components from the cache."""
for i, comp in enumerate(comps):
Expand All @@ -407,12 +407,12 @@ def _delete_from_cache(

def _find_key_to_delete(
self,
sub_cache: Dict[str, Any],
sub_cache: dict[str, Any],
comp: str,
iname: str,
is_last_component: bool,
internal_names_as_keys: bool,
) -> Optional[str]:
) -> str | None:
"""Find the key to delete from the sub-cache."""
for k, v in sub_cache.items():
if (internal_names_as_keys and k == comp) or (
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/fluent/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
# SOFTWARE.

"""Custom common higher level exceptions."""
from typing import Any, Iterable
from collections.abc import Iterable
from typing import Any

from ansys.fluent.core.solver.error_message import allowed_name_error_message

Expand Down
Loading