diff --git a/.ci/build_wheel.py b/.ci/build_wheel.py index 358e3a05ea..2408c92ee7 100644 --- a/.ci/build_wheel.py +++ b/.ci/build_wheel.py @@ -2,14 +2,13 @@ # Input can be one of ["any", "win", "manylinux1", "manylinux_2_17"] import argparse -import subprocess -from pathlib import Path import os -import sys +from pathlib import Path import shutil +import subprocess +import sys import tempfile - supported_platforms = { "any": "any", "win": "win_amd64", diff --git a/.ci/code_generation.py b/.ci/code_generation.py index e073929848..ca24cf73e6 100644 --- a/.ci/code_generation.py +++ b/.ci/code_generation.py @@ -1,12 +1,12 @@ # import subprocess -from ansys.dpf import core -from ansys.dpf.core.operators import build -import os import glob +import os from pathlib import Path import shutil +from ansys.dpf import core +from ansys.dpf.core.operators import build local_dir = Path(__file__).parent TARGET_PATH = local_dir.parent / "src" / "ansys" / "dpf" / "core" / "operators" diff --git a/.ci/run_examples.py b/.ci/run_examples.py index 91d9d56628..298d883b3c 100644 --- a/.ci/run_examples.py +++ b/.ci/run_examples.py @@ -1,5 +1,5 @@ -import os import glob +import os from pathlib import Path import subprocess import sys @@ -7,7 +7,6 @@ import ansys.dpf.core as dpf from ansys.dpf.core.examples import get_example_required_minimum_dpf_version - os.environ["PYVISTA_OFF_SCREEN"] = "true" os.environ["MPLBACKEND"] = "Agg" diff --git a/.ci/run_non_regression_examples.py b/.ci/run_non_regression_examples.py index fc3dc8fedc..783858c2d5 100644 --- a/.ci/run_non_regression_examples.py +++ b/.ci/run_non_regression_examples.py @@ -1,10 +1,11 @@ -import os import glob -from ansys.dpf import core +import os import pathlib import subprocess import sys +from ansys.dpf import core + os.environ["PYVISTA_OFF_SCREEN"] = "true" os.environ["MPLBACKEND"] = "Agg" diff --git a/.ci/update_dpf_dependencies.py b/.ci/update_dpf_dependencies.py index c3426d8a9d..3cab04593d 100644 --- a/.ci/update_dpf_dependencies.py +++ b/.ci/update_dpf_dependencies.py @@ -13,14 +13,13 @@ or the repo defined by the environment variable "ANSYSDPFCORE_ROOT" if it exists. """ -import os import glob +import os from pathlib import Path import platform import shutil import zipfile - grpc_path_key = "DPFDV_ROOT" gate_path_key = "ANSYSDPFPYGATE_ROOT" core_path = Path(__file__).parent.parent diff --git a/examples/00-basic/05-use_local_data.py b/examples/00-basic/05-use_local_data.py index 7b1991bd57..87117ef671 100644 --- a/examples/00-basic/05-use_local_data.py +++ b/examples/00-basic/05-use_local_data.py @@ -36,9 +36,7 @@ # Import necessary modules from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops - +from ansys.dpf.core import examples, operators as ops ############################################################################### # Create a model object to establish a connection with an diff --git a/examples/00-basic/11-server_types.py b/examples/00-basic/11-server_types.py index c61b3e33f3..5a883c4ffd 100644 --- a/examples/00-basic/11-server_types.py +++ b/examples/00-basic/11-server_types.py @@ -53,6 +53,7 @@ """ import os + from ansys.dpf import core as dpf ############################################################################### diff --git a/examples/01-transient_analyses/00-basic_transient.py b/examples/01-transient_analyses/00-basic_transient.py index 31b2caba98..7332446c75 100644 --- a/examples/01-transient_analyses/00-basic_transient.py +++ b/examples/01-transient_analyses/00-basic_transient.py @@ -37,8 +37,7 @@ import numpy as np from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf.core import examples, operators as ops ############################################################################### # Download the transient result example. This example is diff --git a/examples/01-transient_analyses/01-transient_easy_time_scoping.py b/examples/01-transient_analyses/01-transient_easy_time_scoping.py index cf9e68ebd9..754928eb17 100644 --- a/examples/01-transient_analyses/01-transient_easy_time_scoping.py +++ b/examples/01-transient_analyses/01-transient_easy_time_scoping.py @@ -34,8 +34,7 @@ import matplotlib.pyplot as plt from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf.core import examples, operators as ops ############################################################################### # Create the model and display the state of the result. This transient result diff --git a/examples/02-modal_analyses/01-plot_and_animate_modes.py b/examples/02-modal_analyses/01-plot_and_animate_modes.py index a43e2fd733..d167150245 100644 --- a/examples/02-modal_analyses/01-plot_and_animate_modes.py +++ b/examples/02-modal_analyses/01-plot_and_animate_modes.py @@ -32,8 +32,7 @@ """ from ansys.dpf import core as dpf -from ansys.dpf.core import animation -from ansys.dpf.core import examples +from ansys.dpf.core import animation, examples ############################################################################### # Retrieve mode shapes diff --git a/examples/03-harmonic_analyses/00-multi_harmonic.py b/examples/03-harmonic_analyses/00-multi_harmonic.py index 5f86da384c..8e4427a134 100644 --- a/examples/03-harmonic_analyses/00-multi_harmonic.py +++ b/examples/03-harmonic_analyses/00-multi_harmonic.py @@ -34,9 +34,7 @@ import matplotlib.pyplot as pyplot from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops - +from ansys.dpf.core import examples, operators as ops ############################################################################### # Begin by downloading the example harmonic result. This result is diff --git a/examples/03-harmonic_analyses/01-modal_superposition.py b/examples/03-harmonic_analyses/01-modal_superposition.py index 2c3fa216b0..9d53eae701 100644 --- a/examples/03-harmonic_analyses/01-modal_superposition.py +++ b/examples/03-harmonic_analyses/01-modal_superposition.py @@ -38,7 +38,6 @@ from ansys.dpf import core as dpf from ansys.dpf.core import examples - ############################################################################### # Create data sources # ~~~~~~~~~~~~~~~~~~~ diff --git a/examples/04-advanced/00-multistage_advanced_options.py b/examples/04-advanced/00-multistage_advanced_options.py index 4558366cef..6eb4006bd4 100644 --- a/examples/04-advanced/00-multistage_advanced_options.py +++ b/examples/04-advanced/00-multistage_advanced_options.py @@ -32,8 +32,7 @@ """ from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf.core import examples, operators as ops ############################################################################### # Create the model and display the state of the result. diff --git a/examples/04-advanced/01-solve_harmonic_problem.py b/examples/04-advanced/01-solve_harmonic_problem.py index 0f8a77a84f..7f3f2626f9 100644 --- a/examples/04-advanced/01-solve_harmonic_problem.py +++ b/examples/04-advanced/01-solve_harmonic_problem.py @@ -37,7 +37,6 @@ from ansys.dpf import core as dpf from ansys.dpf.core import operators as ops - ############################################################################### # Create 2D (x,y) matrix fields for inertia, damping, and stiffness. diff --git a/examples/04-advanced/02-volume_averaged_stress.py b/examples/04-advanced/02-volume_averaged_stress.py index b5bd832197..7c2ccbf056 100644 --- a/examples/04-advanced/02-volume_averaged_stress.py +++ b/examples/04-advanced/02-volume_averaged_stress.py @@ -35,9 +35,7 @@ """ from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops - +from ansys.dpf.core import examples, operators as ops ############################################################################### # Create a model targeting a given result file diff --git a/examples/04-advanced/03-exchange_data_between_servers.py b/examples/04-advanced/03-exchange_data_between_servers.py index fff01684e7..d989edca5a 100644 --- a/examples/04-advanced/03-exchange_data_between_servers.py +++ b/examples/04-advanced/03-exchange_data_between_servers.py @@ -35,9 +35,7 @@ """ from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops - +from ansys.dpf.core import examples, operators as ops ############################################################################### # Create two servers diff --git a/examples/04-advanced/04-extrapolation_stress_3d.py b/examples/04-advanced/04-extrapolation_stress_3d.py index 86807919ad..a61ca2f36b 100644 --- a/examples/04-advanced/04-extrapolation_stress_3d.py +++ b/examples/04-advanced/04-extrapolation_stress_3d.py @@ -57,7 +57,6 @@ from ansys.dpf import core as dpf from ansys.dpf.core import examples - ############################################################################### # Get the data source's analysis of integration points and analysis reference datafile = examples.download_extrapolation_3d_result() diff --git a/examples/04-advanced/05-extrapolation_strain_2d.py b/examples/04-advanced/05-extrapolation_strain_2d.py index 091242212a..cb83609539 100644 --- a/examples/04-advanced/05-extrapolation_strain_2d.py +++ b/examples/04-advanced/05-extrapolation_strain_2d.py @@ -57,7 +57,6 @@ from ansys.dpf import core as dpf from ansys.dpf.core import examples - ############################################################################### # Get the data source's analyse of integration points and data source's analyse reference datafile = examples.download_extrapolation_2d_result() diff --git a/examples/04-advanced/06-stress_gradient_path.py b/examples/04-advanced/06-stress_gradient_path.py index 16ae40c025..f39ebd718f 100644 --- a/examples/04-advanced/06-stress_gradient_path.py +++ b/examples/04-advanced/06-stress_gradient_path.py @@ -41,11 +41,9 @@ import matplotlib.pyplot as plt from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf.core import examples, operators as ops from ansys.dpf.core.plotter import DpfPlotter - ############################################################################### # Open an example and print out the ``Model`` object. The # :class:`Model ` class helps to organize access diff --git a/examples/04-advanced/07-load_plugin.py b/examples/04-advanced/07-load_plugin.py index 7fb2b2109c..fb9ae6fffa 100644 --- a/examples/04-advanced/07-load_plugin.py +++ b/examples/04-advanced/07-load_plugin.py @@ -34,7 +34,6 @@ # Import DPF-Core: from ansys.dpf import core as dpf - server = dpf.global_server() ############################################################################### diff --git a/examples/04-advanced/11-cycles_to_failure.py b/examples/04-advanced/11-cycles_to_failure.py index 9e2dab55e7..7858c3d2b8 100644 --- a/examples/04-advanced/11-cycles_to_failure.py +++ b/examples/04-advanced/11-cycles_to_failure.py @@ -53,9 +53,10 @@ The higher the stress result, the lower the number of cycles to failure. """ +import numpy as np + from ansys.dpf import core as dpf from ansys.dpf.core import examples -import numpy as np ############################################################################### # The first step is to generate a simple model with high stress diff --git a/examples/04-advanced/14-incremental_evaluation.py b/examples/04-advanced/14-incremental_evaluation.py index 6ec0878571..586b69a271 100644 --- a/examples/04-advanced/14-incremental_evaluation.py +++ b/examples/04-advanced/14-incremental_evaluation.py @@ -33,7 +33,6 @@ from ansys.dpf import core as dpf from ansys.dpf.core import examples - ####################################################################################### # Retrieve an example to instantiate a DataSources object path = examples.download_transient_result() diff --git a/examples/05-file-IO/00-hdf5_double_float_comparison.py b/examples/05-file-IO/00-hdf5_double_float_comparison.py index 07de3aceeb..2b65aaf97e 100644 --- a/examples/05-file-IO/00-hdf5_double_float_comparison.py +++ b/examples/05-file-IO/00-hdf5_double_float_comparison.py @@ -39,8 +39,7 @@ from pathlib import Path from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf.core import examples, operators as ops ############################################################################### # Create the model and get the stresses, displacements, and mesh. diff --git a/examples/05-file-IO/01-reduced_matrices_export.py b/examples/05-file-IO/01-reduced_matrices_export.py index 76a0dae22b..0da2f844cc 100644 --- a/examples/05-file-IO/01-reduced_matrices_export.py +++ b/examples/05-file-IO/01-reduced_matrices_export.py @@ -36,8 +36,7 @@ # temporary directory. from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf.core import examples, operators as ops ############################################################################### # Create the operator and connect data sources. diff --git a/examples/05-file-IO/04-basic-load-file.py b/examples/05-file-IO/04-basic-load-file.py index 21c0efec16..77aa2aece2 100644 --- a/examples/05-file-IO/04-basic-load-file.py +++ b/examples/05-file-IO/04-basic-load-file.py @@ -40,7 +40,6 @@ from ansys.dpf import core as dpf from ansys.dpf.core import examples - model = dpf.Model(examples.find_simple_bar()) mesh = model.metadata.meshed_region diff --git a/examples/06-plotting/00-basic_plotting.py b/examples/06-plotting/00-basic_plotting.py index 497b24a827..83fae5c9a0 100644 --- a/examples/06-plotting/00-basic_plotting.py +++ b/examples/06-plotting/00-basic_plotting.py @@ -34,7 +34,6 @@ from ansys.dpf import core as dpf from ansys.dpf.core import examples - # Plot the bare mesh of a model model = dpf.Model(examples.find_multishells_rst()) model.plot(color="w", show_edges=True, title="Model", text="Model plot") diff --git a/examples/06-plotting/04-plot_on_path.py b/examples/06-plotting/04-plot_on_path.py index e63b57d4cf..f360ee5af6 100644 --- a/examples/06-plotting/04-plot_on_path.py +++ b/examples/06-plotting/04-plot_on_path.py @@ -35,11 +35,9 @@ import matplotlib.pyplot as plt from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf.core import examples, operators as ops from ansys.dpf.core.plotter import DpfPlotter - ############################################################################### # Plot path # ~~~~~~~~~ diff --git a/examples/06-plotting/05-plot_on_warped_mesh.py b/examples/06-plotting/05-plot_on_warped_mesh.py index 9cd8593e3d..8d8d5e01d6 100644 --- a/examples/06-plotting/05-plot_on_warped_mesh.py +++ b/examples/06-plotting/05-plot_on_warped_mesh.py @@ -34,7 +34,6 @@ from ansys.dpf import core as dpf from ansys.dpf.core import examples - # Get and show the initial model model = dpf.Model(examples.find_multishells_rst()) print(model) diff --git a/examples/06-plotting/06-animate_results.py b/examples/06-plotting/06-animate_results.py index 93e1dcddd6..5e3554cd2d 100644 --- a/examples/06-plotting/06-animate_results.py +++ b/examples/06-plotting/06-animate_results.py @@ -34,7 +34,6 @@ from ansys.dpf import core as dpf from ansys.dpf.core import examples - # Load the model model = dpf.Model(examples.find_msup_transient()) print(model) diff --git a/examples/06-plotting/07-plot_on_geometries.py b/examples/06-plotting/07-plot_on_geometries.py index 9fddfe689e..300d4022af 100644 --- a/examples/06-plotting/07-plot_on_geometries.py +++ b/examples/06-plotting/07-plot_on_geometries.py @@ -36,16 +36,14 @@ # ~~~~~~~~~~~~~~~~~~~~~~ # Import modules and set context as Premium. -import numpy as np import matplotlib.pyplot as plt +import numpy as np from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf.core import examples, operators as ops +from ansys.dpf.core.fields_factory import field_from_array from ansys.dpf.core.geometry import Line, Plane, Points from ansys.dpf.core.plotter import DpfPlotter -from ansys.dpf.core.fields_factory import field_from_array - ############################################################################### # Load model from examples and print information: diff --git a/examples/07-distributed-post/00-distributed_total_disp.py b/examples/07-distributed-post/00-distributed_total_disp.py index 9edbe6cbb8..56d23ec221 100644 --- a/examples/07-distributed-post/00-distributed_total_disp.py +++ b/examples/07-distributed-post/00-distributed_total_disp.py @@ -73,9 +73,9 @@ # Import the ``dpf-core`` module and its examples files. import os + from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf.core import examples, operators as ops ############################################################################### # Configure the servers. diff --git a/examples/07-distributed-post/01-distributed_workflows_on_remote.py b/examples/07-distributed-post/01-distributed_workflows_on_remote.py index 2405247611..e67fe4c4ab 100644 --- a/examples/07-distributed-post/01-distributed_workflows_on_remote.py +++ b/examples/07-distributed-post/01-distributed_workflows_on_remote.py @@ -71,9 +71,9 @@ # Import the ``dpf-core`` module and its examples files. import os + from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf.core import examples, operators as ops ############################################################################### # Configure the servers. diff --git a/examples/07-distributed-post/02-distributed-msup_expansion.py b/examples/07-distributed-post/02-distributed-msup_expansion.py index 6a8ea8dfb0..3ff354bb5c 100644 --- a/examples/07-distributed-post/02-distributed-msup_expansion.py +++ b/examples/07-distributed-post/02-distributed-msup_expansion.py @@ -94,10 +94,9 @@ # Import the ``dpf-core`` module and its examples files. import os -from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf import core as dpf +from ansys.dpf.core import examples, operators as ops ############################################################################### # Configure the servers diff --git a/examples/07-distributed-post/03-distributed-msup_expansion_steps.py b/examples/07-distributed-post/03-distributed-msup_expansion_steps.py index 8d56591ae7..f516f816db 100644 --- a/examples/07-distributed-post/03-distributed-msup_expansion_steps.py +++ b/examples/07-distributed-post/03-distributed-msup_expansion_steps.py @@ -97,10 +97,9 @@ # Import the ``dpf-core`` module and its examples files. import os -from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops +from ansys.dpf import core as dpf +from ansys.dpf.core import examples, operators as ops ############################################################################### # Configure the servers diff --git a/examples/07-distributed-post/06-distributed_stress_averaging.py b/examples/07-distributed-post/06-distributed_stress_averaging.py index c4f04720fd..9e3c71cfa2 100644 --- a/examples/07-distributed-post/06-distributed_stress_averaging.py +++ b/examples/07-distributed-post/06-distributed_stress_averaging.py @@ -36,9 +36,7 @@ # Import dpf module and its examples files from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops - +from ansys.dpf.core import examples, operators as ops ############################################################################### # Configure the servers diff --git a/examples/08-python-operators/00-wrapping_numpy_capabilities.py b/examples/08-python-operators/00-wrapping_numpy_capabilities.py index 1188a2ca5b..6c14b7fe52 100644 --- a/examples/08-python-operators/00-wrapping_numpy_capabilities.py +++ b/examples/08-python-operators/00-wrapping_numpy_capabilities.py @@ -56,9 +56,10 @@ # # Download and display the Python script. -from ansys.dpf.core.examples import download_easy_statistics from pathlib import Path +from ansys.dpf.core.examples import download_easy_statistics + operator_file_path = Path(download_easy_statistics()) with operator_file_path.open() as file: diff --git a/examples/09-averaging/01-average_across_bodies.py b/examples/09-averaging/01-average_across_bodies.py index 68857240e4..dad611b7e9 100644 --- a/examples/09-averaging/01-average_across_bodies.py +++ b/examples/09-averaging/01-average_across_bodies.py @@ -46,9 +46,7 @@ # Import the necessary modules from ansys.dpf import core as dpf -from ansys.dpf.core import operators as ops -from ansys.dpf.core import examples - +from ansys.dpf.core import examples, operators as ops ############################################################################### # Load the simulation results from an RST file and create a model of it. diff --git a/examples/10-mesh_operations/05-skin_extraction.py b/examples/10-mesh_operations/05-skin_extraction.py index ec1f0d7fde..8af79750a0 100644 --- a/examples/10-mesh_operations/05-skin_extraction.py +++ b/examples/10-mesh_operations/05-skin_extraction.py @@ -33,9 +33,7 @@ # Import necessary modules from ansys.dpf import core as dpf -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops - +from ansys.dpf.core import examples, operators as ops ############################################################################### # Create a model object to establish a connection with an diff --git a/examples/10-mesh_operations/13-nodes_in_local_coordinate_system.py b/examples/10-mesh_operations/13-nodes_in_local_coordinate_system.py index e6007c3eae..db13a8ac9d 100644 --- a/examples/10-mesh_operations/13-nodes_in_local_coordinate_system.py +++ b/examples/10-mesh_operations/13-nodes_in_local_coordinate_system.py @@ -44,7 +44,6 @@ from ansys.dpf.core import examples from ansys.dpf.gate.errors import DPFServerException - ############################################################################### # Create a model object to establish a connection with an example result file: model = dpf.Model(examples.download_hemisphere()) diff --git a/examples/14-lsdyna/00-lsdyna_operators.py b/examples/14-lsdyna/00-lsdyna_operators.py index fc56cd7679..643a4d53e1 100644 --- a/examples/14-lsdyna/00-lsdyna_operators.py +++ b/examples/14-lsdyna/00-lsdyna_operators.py @@ -36,6 +36,7 @@ """ import matplotlib.pyplot as plt + from ansys.dpf import core as dpf from ansys.dpf.core import examples diff --git a/pyproject.toml b/pyproject.toml index e0673b008f..946e1bf17c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,7 @@ select = [ # "E", # pycodestyle, see https://beta.ruff.rs/docs/rules/#pycodestyle-e-w "D", # pydocstyle, see https://beta.ruff.rs/docs/rules/#pydocstyle-d # "F", # pyflakes, see https://beta.ruff.rs/docs/rules/#pyflakes-f -# "I", # isort, see https://beta.ruff.rs/docs/rules/#isort-i + "I", # isort, see https://beta.ruff.rs/docs/rules/#isort-i # "N", # pep8-naming, see https://beta.ruff.rs/docs/rules/#pep8-naming-n "PTH", # flake9-use-pathlib, https://beta.ruff.rs/docs/rules/#flake8-use-pathlib-pth "TD", # flake8-todos, https://docs.astral.sh/ruff/rules/#flake8-todos-td diff --git a/src/ansys/dpf/core/_custom_operators_helpers.py b/src/ansys/dpf/core/_custom_operators_helpers.py index 449ea11f5b..cc1b48cb7f 100644 --- a/src/ansys/dpf/core/_custom_operators_helpers.py +++ b/src/ansys/dpf/core/_custom_operators_helpers.py @@ -20,28 +20,28 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from ansys.dpf.gate import capi, external_operator_capi from enum import Enum from ansys.dpf.core import ( - field, - property_field, - scoping, collection, + custom_type_field, data_sources, - meshed_region, - time_freq_support, - workflow, data_tree, dpf_operator, + field, fields_container, - scopings_container, + generic_data_container, + meshed_region, meshes_container, + property_field, result_info, + scoping, + scopings_container, string_field, - custom_type_field, - generic_data_container, + time_freq_support, + workflow, ) +from ansys.dpf.gate import capi, external_operator_capi external_operator_api = external_operator_capi.ExternalOperatorCAPI diff --git a/src/ansys/dpf/core/animation.py b/src/ansys/dpf/core/animation.py index 470c6438aa..3739245fa0 100644 --- a/src/ansys/dpf/core/animation.py +++ b/src/ansys/dpf/core/animation.py @@ -22,9 +22,10 @@ """Module contains the function for modal animation creation.""" -import ansys.dpf.core as dpf import numpy as np +import ansys.dpf.core as dpf + def animate_mode( fields_container, diff --git a/src/ansys/dpf/core/animator.py b/src/ansys/dpf/core/animator.py index 122facd6bf..3198319618 100644 --- a/src/ansys/dpf/core/animator.py +++ b/src/ansys/dpf/core/animator.py @@ -28,8 +28,9 @@ Contains classes used to animate results based on workflows using PyVista. """ +from typing import Sequence, Union + import numpy as np -from typing import Union, Sequence import ansys.dpf.core as core from ansys.dpf.core.helpers.utils import _sort_supported_kwargs diff --git a/src/ansys/dpf/core/any.py b/src/ansys/dpf/core/any.py index aa69f8976c..1e9c4d7f8d 100644 --- a/src/ansys/dpf/core/any.py +++ b/src/ansys/dpf/core/any.py @@ -31,13 +31,11 @@ import numpy as np -import ansys.dpf.core.server_types -from ansys.dpf.core import server as server_module -from ansys.dpf.core import errors +from ansys.dpf.core import errors, server as server_module from ansys.dpf.core.check_version import server_meet_version, server_meet_version_and_raise from ansys.dpf.core.common import create_dpf_instance -from ansys.dpf.gate import any_abstract_api, integral_types -from ansys.dpf.gate import dpf_vector +import ansys.dpf.core.server_types +from ansys.dpf.gate import any_abstract_api, dpf_vector, integral_types class Any: @@ -113,17 +111,17 @@ def _new_from_string_as_bytes_on_client(self, client, str): def _type_to_new_from_get_as_method(self, obj): from ansys.dpf.core import ( + collection, + custom_type_field, + data_tree, + dpf_operator, field, fields_container, - property_field, generic_data_container, - string_field, + property_field, scoping, - data_tree, - custom_type_field, - collection, + string_field, workflow, - dpf_operator, ) if issubclass(obj, int): diff --git a/src/ansys/dpf/core/available_result.py b/src/ansys/dpf/core/available_result.py index f75a36e512..8e978a81ac 100644 --- a/src/ansys/dpf/core/available_result.py +++ b/src/ansys/dpf/core/available_result.py @@ -26,10 +26,11 @@ Module contains the class representing the results that an operator can request. """ +from enum import Enum, unique from typing import List from warnings import warn -from ansys.dpf.core.common import _remove_spaces, _make_as_function_name, natures -from enum import Enum, unique + +from ansys.dpf.core.common import _make_as_function_name, _remove_spaces, natures @unique diff --git a/src/ansys/dpf/core/check_version.py b/src/ansys/dpf/core/check_version.py index e14c1b57fe..bf16c86e4a 100644 --- a/src/ansys/dpf/core/check_version.py +++ b/src/ansys/dpf/core/check_version.py @@ -26,10 +26,11 @@ Used to verify if the server version is a minimum value. """ -from ansys.dpf.core import errors as dpf_errors +from functools import wraps import sys import weakref -from functools import wraps + +from ansys.dpf.core import errors as dpf_errors def server_meet_version(required_version, server): diff --git a/src/ansys/dpf/core/collection.py b/src/ansys/dpf/core/collection.py index 57385d9955..ad3acde37c 100644 --- a/src/ansys/dpf/core/collection.py +++ b/src/ansys/dpf/core/collection.py @@ -24,10 +24,11 @@ """Module containing the class representing dpf objects organized by label spaces.""" from __future__ import annotations + +from ansys.dpf.core import errors, server as server_module from ansys.dpf.core.any import Any -from ansys.dpf.core.collection_base import CollectionBase, TYPE +from ansys.dpf.core.collection_base import TYPE, CollectionBase from ansys.dpf.core.common import create_dpf_instance -from ansys.dpf.core import server as server_module, errors class Collection(CollectionBase[TYPE]): diff --git a/src/ansys/dpf/core/collection_base.py b/src/ansys/dpf/core/collection_base.py index 007f898675..52d34b71cc 100644 --- a/src/ansys/dpf/core/collection_base.py +++ b/src/ansys/dpf/core/collection_base.py @@ -23,26 +23,27 @@ """Contains classes associated with the DPF collection.""" from __future__ import annotations + import abc -import warnings import traceback +from typing import TYPE_CHECKING, Generic, List, Optional, TypeVar +import warnings import numpy as np +from ansys.dpf.core import server as server_module from ansys.dpf.core.check_version import version_requires -from ansys.dpf.core.server_types import BaseServer -from ansys.dpf.core.scoping import Scoping from ansys.dpf.core.label_space import LabelSpace -from ansys.dpf.core import server as server_module +from ansys.dpf.core.scoping import Scoping +from ansys.dpf.core.server_types import BaseServer from ansys.dpf.gate import ( collection_capi, collection_grpcapi, data_processing_capi, data_processing_grpcapi, - dpf_vector, dpf_array, + dpf_vector, ) -from typing import List, Optional, Generic, TypeVar, TYPE_CHECKING if TYPE_CHECKING: from ansys.dpf.core.support import Support @@ -470,9 +471,9 @@ def _get_time_freq_support(self): """ from ansys.dpf.core.time_freq_support import TimeFreqSupport from ansys.dpf.gate import ( + object_handler, support_capi, support_grpcapi, - object_handler, ) data_api = self._server.get_api_for_type( diff --git a/src/ansys/dpf/core/common.py b/src/ansys/dpf/core/common.py index ea35aeea27..6eaa554b19 100644 --- a/src/ansys/dpf/core/common.py +++ b/src/ansys/dpf/core/common.py @@ -22,13 +22,13 @@ """Common.""" +from enum import Enum import re import sys -from enum import Enum from typing import Dict from ansys.dpf.core.misc import module_exists -from ansys.dpf.gate.common import locations, ProgressBarBase # noqa: F401 +from ansys.dpf.gate.common import ProgressBarBase, locations # noqa: F401 from ansys.dpf.gate.dpf_vector import ( # noqa: F401 get_size_of_list as _get_size_of_list, ) @@ -122,27 +122,27 @@ def types_enum_to_types(): Mapping of enum to the corresponding type. """ from ansys.dpf.core import ( + Any, + collection, + custom_type_field, cyclic_support, data_sources, + data_tree, + dpf_operator, field, fields_container, - collection, + generic_data_container, + mesh_info, meshed_region, meshes_container, property_field, - string_field, - custom_type_field, result_info, scoping, scopings_container, + streams_container, + string_field, time_freq_support, - dpf_operator, - data_tree, workflow, - streams_container, - generic_data_container, - mesh_info, - Any, ) from ansys.dpf.gate import dpf_vector @@ -380,26 +380,26 @@ def type_to_internal_object_keyword(): global _type_to_internal_object_keyword if _type_to_internal_object_keyword is None: from ansys.dpf.core import ( + any, + collection, + custom_type_field, cyclic_support, data_sources, + data_tree, + dpf_operator, field, fields_container, + generic_data_container, meshed_region, meshes_container, property_field, - string_field, - custom_type_field, result_info, scoping, scopings_container, + streams_container, + string_field, time_freq_support, - dpf_operator, - data_tree, workflow, - streams_container, - generic_data_container, - any, - collection, ) _type_to_internal_object_keyword = SubClassSmartDict( @@ -436,8 +436,8 @@ def type_to_special_dpf_constructors(): """Return dpf type mapped to special dpf constructors.""" global _type_to_special_dpf_constructors if _type_to_special_dpf_constructors is None: - from ansys.dpf.gate.dpf_vector import DPFVectorInt from ansys.dpf.core import collection_base + from ansys.dpf.gate.dpf_vector import DPFVectorInt _type_to_special_dpf_constructors = { DPFVectorInt: lambda obj, server: collection_base.IntCollection( diff --git a/src/ansys/dpf/core/config.py b/src/ansys/dpf/core/config.py index e7de0aaffa..16cbdb007d 100644 --- a/src/ansys/dpf/core/config.py +++ b/src/ansys/dpf/core/config.py @@ -23,16 +23,16 @@ """Operator Configuration.""" import functools -import warnings import traceback +import warnings from ansys.dpf.core import server as server_module +from ansys.dpf.core.operator_specification import Specification from ansys.dpf.gate import ( + operator_config_abstract_api, operator_config_capi, operator_config_grpcapi, - operator_config_abstract_api, ) -from ansys.dpf.core.operator_specification import Specification class Config: diff --git a/src/ansys/dpf/core/core.py b/src/ansys/dpf/core/core.py index 56564bfe92..b479cdb0e3 100644 --- a/src/ansys/dpf/core/core.py +++ b/src/ansys/dpf/core/core.py @@ -22,28 +22,27 @@ """Core.""" -import os import logging +import os +from pathlib import Path import warnings import weakref -from pathlib import Path -from ansys.dpf.core import errors, misc -from ansys.dpf.core import server as server_module -from ansys.dpf.core.check_version import version_requires, server_meet_version +from ansys.dpf.core import errors, misc, server as server_module +from ansys.dpf.core.check_version import server_meet_version, version_requires from ansys.dpf.core.runtime_config import ( RuntimeClientConfig, RuntimeCoreConfig, ) from ansys.dpf.gate import ( - data_processing_capi, - data_processing_grpcapi, - tmp_dir_capi, - tmp_dir_grpcapi, collection_capi, collection_grpcapi, + data_processing_capi, + data_processing_grpcapi, integral_types, object_handler, + tmp_dir_capi, + tmp_dir_grpcapi, ) try: @@ -300,8 +299,8 @@ def _deep_copy(dpf_entity, server=None): deep_copy of dpf_entity: core.Operator, core.Workflow, core.Scoping, core.Field, core.FieldsContainer, core.MeshedRegion... """ + from ansys.dpf.core.common import types, types_enum_to_types from ansys.dpf.core.operators.serialization import serializer_to_string, string_deserializer - from ansys.dpf.core.common import types_enum_to_types, types entity_server = dpf_entity._server if hasattr(dpf_entity, "_server") else None serializer = serializer_to_string(server=entity_server) diff --git a/src/ansys/dpf/core/custom_fields_container.py b/src/ansys/dpf/core/custom_fields_container.py index a99475ffdd..2bbfe99b55 100644 --- a/src/ansys/dpf/core/custom_fields_container.py +++ b/src/ansys/dpf/core/custom_fields_container.py @@ -29,8 +29,8 @@ results split by body or split by material. """ -from ansys.dpf.core.fields_container import FieldsContainer from ansys.dpf.core import elements +from ansys.dpf.core.fields_container import FieldsContainer class ElShapeFieldsContainer(FieldsContainer): diff --git a/src/ansys/dpf/core/custom_operator.py b/src/ansys/dpf/core/custom_operator.py index bf52e7bc2d..3b6f9e3dc0 100644 --- a/src/ansys/dpf/core/custom_operator.py +++ b/src/ansys/dpf/core/custom_operator.py @@ -32,30 +32,30 @@ import re import shutil import tempfile +import traceback import warnings import zipfile import numpy -import traceback from ansys.dpf import core as dpf from ansys.dpf.core import ( - settings, + AvailableServerContexts, + collection, + dpf_operator, + operator_specification, server, server_factory, - operator_specification, - dpf_operator, - collection, - AvailableServerContexts, + settings, ) from ansys.dpf.core._custom_operators_helpers import ( __operator_main__, - functions_registry, - external_operator_api, - _type_to_output_method, _type_to_input_method, + _type_to_output_method, + external_operator_api, + functions_registry, ) -from ansys.dpf.gate import object_handler, capi, dpf_vector, integral_types +from ansys.dpf.gate import capi, dpf_vector, integral_types, object_handler def update_virtual_environment_for_custom_operators( diff --git a/src/ansys/dpf/core/custom_type_field.py b/src/ansys/dpf/core/custom_type_field.py index cd60f039ff..4df666b32e 100644 --- a/src/ansys/dpf/core/custom_type_field.py +++ b/src/ansys/dpf/core/custom_type_field.py @@ -26,10 +26,8 @@ import numpy as np -from ansys.dpf.core import server as server_module -from ansys.dpf.core import errors -from ansys.dpf.core import scoping -from ansys.dpf.core.common import locations, _get_size_of_list +from ansys.dpf.core import errors, scoping, server as server_module +from ansys.dpf.core.common import _get_size_of_list, locations from ansys.dpf.core.field_base import _FieldBase from ansys.dpf.core.field_definition import FieldDefinition from ansys.dpf.core.support import Support diff --git a/src/ansys/dpf/core/cyclic_support.py b/src/ansys/dpf/core/cyclic_support.py index 87274fc909..e53bb136e0 100644 --- a/src/ansys/dpf/core/cyclic_support.py +++ b/src/ansys/dpf/core/cyclic_support.py @@ -25,11 +25,9 @@ import traceback import warnings -from ansys.dpf.gate import cyclic_support_capi, cyclic_support_grpcapi - -from ansys.dpf.core import server as server_module +from ansys.dpf.core import field, property_field, server as server_module from ansys.dpf.core.scoping import Scoping -from ansys.dpf.core import field, property_field +from ansys.dpf.gate import cyclic_support_capi, cyclic_support_grpcapi class CyclicSupport: diff --git a/src/ansys/dpf/core/data_sources.py b/src/ansys/dpf/core/data_sources.py index d176b024f3..f7f2e952a7 100644 --- a/src/ansys/dpf/core/data_sources.py +++ b/src/ansys/dpf/core/data_sources.py @@ -24,22 +24,20 @@ import os from pathlib import Path -import warnings import traceback from typing import Union +import warnings -from ansys.dpf.core import server as server_module +from ansys.dpf.core import errors, server as server_module +from ansys.dpf.core.check_version import version_requires from ansys.dpf.gate import ( + data_processing_capi, + data_processing_grpcapi, data_sources_capi, data_sources_grpcapi, integral_types, - data_processing_capi, - data_processing_grpcapi, ) -from ansys.dpf.core.check_version import version_requires -from ansys.dpf.core import errors - class DataSources: """Contains files with analysis results. diff --git a/src/ansys/dpf/core/data_tree.py b/src/ansys/dpf/core/data_tree.py index e8237ce15d..4d24174f7e 100644 --- a/src/ansys/dpf/core/data_tree.py +++ b/src/ansys/dpf/core/data_tree.py @@ -27,16 +27,14 @@ import warnings import weakref +from ansys.dpf.core import collection_base, common, errors, server as server_module from ansys.dpf.core.mapping_types import types -from ansys.dpf.core import server as server_module -from ansys.dpf.core import collection_base -from ansys.dpf.core import errors, common from ansys.dpf.gate import ( + data_processing_capi, + data_processing_grpcapi, dpf_data_tree_abstract_api, dpf_data_tree_capi, dpf_data_tree_grpcapi, - data_processing_capi, - data_processing_grpcapi, integral_types, ) diff --git a/src/ansys/dpf/core/dpf_operator.py b/src/ansys/dpf/core/dpf_operator.py index 12af7f2cdd..981525d00f 100644 --- a/src/ansys/dpf/core/dpf_operator.py +++ b/src/ansys/dpf/core/dpf_operator.py @@ -22,38 +22,39 @@ """Operator.""" +from enum import Enum import logging import os import traceback import warnings + import numpy -from enum import Enum +from ansys.dpf.core import server as server_module from ansys.dpf.core.check_version import ( - version_requires, server_meet_version, server_meet_version_and_raise, + version_requires, ) +from ansys.dpf.core.common import types_enum_to_types from ansys.dpf.core.config import Config from ansys.dpf.core.errors import DpfVersionNotSupported from ansys.dpf.core.inputs import Inputs from ansys.dpf.core.mapping_types import types -from ansys.dpf.core.common import types_enum_to_types -from ansys.dpf.core.outputs import Output, Outputs, _Outputs -from ansys.dpf.core import server as server_module from ansys.dpf.core.operator_specification import Specification +from ansys.dpf.core.outputs import Output, Outputs, _Outputs from ansys.dpf.core.unit_system import UnitSystem from ansys.dpf.gate import ( - operator_capi, - operator_abstract_api, - operator_grpcapi, - data_processing_capi, - data_processing_grpcapi, collection_capi, collection_grpcapi, + data_processing_capi, + data_processing_grpcapi, dpf_vector, - object_handler, integral_types, + object_handler, + operator_abstract_api, + operator_capi, + operator_grpcapi, ) LOG = logging.getLogger(__name__) @@ -357,28 +358,28 @@ def _connect_string_as_bytes(self, pin, str): @property def _type_to_output_method(self): from ansys.dpf.core import ( + any, + collection, + collection_base, + custom_container_base, + custom_type_field, cyclic_support, data_sources, + data_tree, field, fields_container, + generic_data_container, + mesh_info, meshed_region, meshes_container, property_field, - string_field, - custom_type_field, result_info, scoping, scopings_container, + streams_container, + string_field, time_freq_support, - data_tree, workflow, - collection, - streams_container, - generic_data_container, - mesh_info, - collection_base, - any, - custom_container_base, ) out = [ @@ -499,22 +500,22 @@ def _type_to_output_method(self): @property def _type_to_input_method(self): from ansys.dpf.core import ( + any, + collection_base, + custom_type_field, cyclic_support, data_sources, + data_tree, field, - collection_base, + generic_data_container, meshed_region, + model, property_field, - string_field, - custom_type_field, scoping, + streams_container, + string_field, time_freq_support, - data_tree, workflow, - model, - generic_data_container, - any, - streams_container, ) out = [ diff --git a/src/ansys/dpf/core/elements.py b/src/ansys/dpf/core/elements.py index d4dd53a75e..15515401f8 100644 --- a/src/ansys/dpf/core/elements.py +++ b/src/ansys/dpf/core/elements.py @@ -23,13 +23,16 @@ """Elements.""" from __future__ import annotations + from enum import Enum + import numpy as np + from ansys.dpf.core import nodes -from ansys.dpf.core.common import locations, elemental_properties +from ansys.dpf.core.check_version import version_requires +from ansys.dpf.core.common import elemental_properties, locations from ansys.dpf.core.element_descriptor import ElementDescriptor from ansys.dpf.gate import integral_types -from ansys.dpf.core.check_version import version_requires class Element: diff --git a/src/ansys/dpf/core/errors.py b/src/ansys/dpf/core/errors.py index fdaab9ade5..fb7332c57c 100644 --- a/src/ansys/dpf/core/errors.py +++ b/src/ansys/dpf/core/errors.py @@ -23,6 +23,7 @@ """Errors.""" from functools import wraps + from ansys.dpf.gate.errors import ( # noqa: F401 DPFServerException, DPFServerNullObject, diff --git a/src/ansys/dpf/core/examples/__init__.py b/src/ansys/dpf/core/examples/__init__.py index 8ac8884584..1e521a0a27 100644 --- a/src/ansys/dpf/core/examples/__init__.py +++ b/src/ansys/dpf/core/examples/__init__.py @@ -21,8 +21,8 @@ # SOFTWARE. """Provide utility functions for downloading and locating DPF example files.""" -from .examples import * from .downloads import * +from .examples import * # called if module. fails diff --git a/src/ansys/dpf/core/examples/downloads.py b/src/ansys/dpf/core/examples/downloads.py index 0a9c9135ba..898bc8ccdb 100644 --- a/src/ansys/dpf/core/examples/downloads.py +++ b/src/ansys/dpf/core/examples/downloads.py @@ -28,9 +28,9 @@ import os from pathlib import Path +from typing import Union import urllib.request import warnings -from typing import Union from ansys.dpf.core.examples.examples import find_files diff --git a/src/ansys/dpf/core/examples/examples.py b/src/ansys/dpf/core/examples/examples.py index c90def9e05..53ae359f82 100644 --- a/src/ansys/dpf/core/examples/examples.py +++ b/src/ansys/dpf/core/examples/examples.py @@ -25,10 +25,8 @@ import os from pathlib import Path -from ansys.dpf.core import server as server_module +from ansys.dpf.core import DataSources, path_utilities, server as server_module from ansys.dpf.core.core import upload_file_in_tmp_folder -from ansys.dpf.core import path_utilities -from ansys.dpf.core import DataSources def get_example_required_minimum_dpf_version(file: os.PathLike) -> str: diff --git a/src/ansys/dpf/core/faces.py b/src/ansys/dpf/core/faces.py index 01618d883f..66ab25614e 100644 --- a/src/ansys/dpf/core/faces.py +++ b/src/ansys/dpf/core/faces.py @@ -23,10 +23,11 @@ """Faces.""" import numpy as np + from ansys.dpf.core import scoping +from ansys.dpf.core.check_version import version_requires from ansys.dpf.core.common import face_properties from ansys.dpf.core.elements import element_types -from ansys.dpf.core.check_version import version_requires @version_requires("7.0") diff --git a/src/ansys/dpf/core/field.py b/src/ansys/dpf/core/field.py index b76563e711..f98b34fe8d 100644 --- a/src/ansys/dpf/core/field.py +++ b/src/ansys/dpf/core/field.py @@ -23,18 +23,18 @@ """Field.""" import numpy as np + from ansys import dpf -from ansys.dpf.core import errors, meshed_region, time_freq_support, scoping -from ansys.dpf.core import dimensionality -from ansys.dpf.core.common import locations, natures, types, _get_size_of_list +from ansys.dpf.core import dimensionality, errors, meshed_region, scoping, time_freq_support +from ansys.dpf.core.common import _get_size_of_list, locations, natures, types from ansys.dpf.core.field_base import _FieldBase, _LocalFieldBase from ansys.dpf.core.field_definition import FieldDefinition from ansys.dpf.gate import ( + dpf_array, + dpf_vector, field_abstract_api, field_capi, field_grpcapi, - dpf_array, - dpf_vector, ) diff --git a/src/ansys/dpf/core/field_base.py b/src/ansys/dpf/core/field_base.py index 12a14f6494..36046522d1 100644 --- a/src/ansys/dpf/core/field_base.py +++ b/src/ansys/dpf/core/field_base.py @@ -21,23 +21,20 @@ # SOFTWARE. """Provide base APIs for DPF's field concept and means of caching field data.""" +from abc import abstractmethod import traceback import warnings -from abc import abstractmethod -from ansys.dpf.gate.generated import field_abstract_api +import numpy as np -from ansys.dpf.core import scoping -from ansys.dpf.core.common import natures, locations -from ansys.dpf.core import errors -from ansys.dpf.core import server as server_module +from ansys.dpf.core import errors, scoping, server as server_module from ansys.dpf.core.cache import _setter +from ansys.dpf.core.common import locations, natures from ansys.dpf.gate import ( data_processing_capi, data_processing_grpcapi, ) - -import numpy as np +from ansys.dpf.gate.generated import field_abstract_api class _FieldBase: diff --git a/src/ansys/dpf/core/field_definition.py b/src/ansys/dpf/core/field_definition.py index 4a55f324e8..2271c469f1 100644 --- a/src/ansys/dpf/core/field_definition.py +++ b/src/ansys/dpf/core/field_definition.py @@ -25,10 +25,10 @@ import traceback import warnings -from ansys.dpf.core.common import natures, shell_layers +from ansys.dpf.core import server as server_module from ansys.dpf.core.check_version import version_requires +from ansys.dpf.core.common import natures, shell_layers from ansys.dpf.core.dimensionality import Dimensionality -from ansys.dpf.core import server as server_module from ansys.dpf.gate import ( field_definition_capi, field_definition_grpcapi, diff --git a/src/ansys/dpf/core/fields_container.py b/src/ansys/dpf/core/fields_container.py index 07161c3b1e..d34dbc1302 100644 --- a/src/ansys/dpf/core/fields_container.py +++ b/src/ansys/dpf/core/fields_container.py @@ -27,12 +27,11 @@ """ from ansys import dpf +from ansys.dpf.core import errors as dpf_errors, field from ansys.dpf.core.collection_base import CollectionBase -from ansys.dpf.core import errors as dpf_errors -from ansys.dpf.core import field -class FieldsContainer(CollectionBase[field.Field]): +class FieldsContainer(CollectionBase["field.Field"]): """Represents a fields container, which contains fields belonging to a common result. A fields container is a set of fields ordered by labels and IDs. Each field @@ -88,8 +87,6 @@ class FieldsContainer(CollectionBase[field.Field]): """ - entries_type = field.Field - def __init__(self, fields_container=None, server=None): super().__init__(collection=fields_container, server=server) if self._internal_obj is None: @@ -333,7 +330,7 @@ def get_imaginary_field(self, timeid=None): return super()._get_entry(label_space) - def __getitem__(self, key) -> field.Field: + def __getitem__(self, key) -> "field.Field": """Retrieve the field at a requested index. Parameters @@ -660,8 +657,7 @@ def __add__(self, fields_b): ------- add : operators.math.add_fc """ - from ansys.dpf.core import dpf_operator - from ansys.dpf.core import operators + from ansys.dpf.core import dpf_operator, operators if hasattr(operators, "math") and hasattr(operators.math, "add_fc"): op = operators.math.add_fc(self, fields_b, server=self._server) @@ -678,8 +674,7 @@ def __sub__(self, fields_b): ------- minus : operators.math.minus_fc """ - from ansys.dpf.core import dpf_operator - from ansys.dpf.core import operators + from ansys.dpf.core import dpf_operator, operators if hasattr(operators, "math") and hasattr(operators.math, "minus_fc"): op = operators.math.minus_fc(server=self._server) @@ -693,8 +688,7 @@ def __pow__(self, value): """Compute element-wise field[i]^2.""" if value != 2: raise ValueError('DPF only the value is "2" supported') - from ansys.dpf.core import dpf_operator - from ansys.dpf.core import operators + from ansys.dpf.core import dpf_operator, operators if hasattr(operators, "math") and hasattr(operators.math, "sqr_fc"): op = operators.math.sqr_fc(server=self._server) @@ -711,8 +705,7 @@ def __mul__(self, value): ------- mul : operators.math.generalized_inner_product_fc """ - from ansys.dpf.core import dpf_operator - from ansys.dpf.core import operators + from ansys.dpf.core import dpf_operator, operators if hasattr(operators, "math") and hasattr(operators.math, "generalized_inner_product_fc"): op = operators.math.generalized_inner_product_fc(server=self._server) diff --git a/src/ansys/dpf/core/fields_container_factory.py b/src/ansys/dpf/core/fields_container_factory.py index e689170458..de5f8f0741 100644 --- a/src/ansys/dpf/core/fields_container_factory.py +++ b/src/ansys/dpf/core/fields_container_factory.py @@ -26,9 +26,7 @@ Contains functions to simplify creating a fields container. """ -from ansys.dpf.core import FieldsContainer, TimeFreqSupport -from ansys.dpf.core import errors as dpf_errors -from ansys.dpf.core import fields_factory +from ansys.dpf.core import FieldsContainer, TimeFreqSupport, errors as dpf_errors, fields_factory from ansys.dpf.core.common import locations diff --git a/src/ansys/dpf/core/fields_factory.py b/src/ansys/dpf/core/fields_factory.py index 86f448c529..fd10704199 100644 --- a/src/ansys/dpf/core/fields_factory.py +++ b/src/ansys/dpf/core/fields_factory.py @@ -26,13 +26,12 @@ Contains functions to simplify creating fields. """ -from ansys.dpf.core.common import natures, locations -from ansys.dpf.core import Field -from ansys.dpf.core import server as server_module -from ansys.dpf.gate import field_capi, field_grpcapi - import numpy as np +from ansys.dpf.core import Field, server as server_module +from ansys.dpf.core.common import locations, natures +from ansys.dpf.gate import field_capi, field_grpcapi + def field_from_array(arr, server=None): """Create a DPF vector or scalar field from a numpy array or a Python list. diff --git a/src/ansys/dpf/core/generic_data_container.py b/src/ansys/dpf/core/generic_data_container.py index 6f7c5b0f6e..7bab2bc2e9 100644 --- a/src/ansys/dpf/core/generic_data_container.py +++ b/src/ansys/dpf/core/generic_data_container.py @@ -23,10 +23,11 @@ """GenericDataContainer.""" from __future__ import annotations + +import builtins import traceback +from typing import TYPE_CHECKING, Union import warnings -import builtins -from typing import Union, TYPE_CHECKING import numpy as np @@ -34,15 +35,11 @@ from ansys.dpf.gate import dpf_vector if TYPE_CHECKING: # pragma: no cover - from ansys.dpf.core import Field, Scoping, StringField, GenericDataContainer + from ansys.dpf.core import Field, GenericDataContainer, Scoping, StringField -from ansys.dpf.core.dpf_operator import _write_output_type_to_type - - -from ansys.dpf.core import server as server_module -from ansys.dpf.core import errors, types +from ansys.dpf.core import collection_base, errors, server as server_module, types from ansys.dpf.core.any import Any -from ansys.dpf.core import collection_base +from ansys.dpf.core.dpf_operator import _write_output_type_to_type from ansys.dpf.core.mapping_types import map_types_to_python diff --git a/src/ansys/dpf/core/generic_support.py b/src/ansys/dpf/core/generic_support.py index 2781e1609c..0bbd720f42 100644 --- a/src/ansys/dpf/core/generic_support.py +++ b/src/ansys/dpf/core/generic_support.py @@ -22,9 +22,9 @@ """GenericSupport.""" -from ansys.dpf.gate import generic_support_capi, generic_support_grpcapi +from ansys.dpf.core import errors, field, property_field, string_field from ansys.dpf.core.support import Support -from ansys.dpf.core import field, property_field, string_field, errors +from ansys.dpf.gate import generic_support_capi, generic_support_grpcapi class GenericSupport(Support): diff --git a/src/ansys/dpf/core/geometry.py b/src/ansys/dpf/core/geometry.py index 073a3a6a8f..a2a328a818 100644 --- a/src/ansys/dpf/core/geometry.py +++ b/src/ansys/dpf/core/geometry.py @@ -27,14 +27,13 @@ """ -from ansys.dpf import core as dpf +import numpy as np +from ansys.dpf import core as dpf from ansys.dpf.core import Field from ansys.dpf.core.fields_factory import field_from_array from ansys.dpf.core.plotter import DpfPlotter -import numpy as np - def normalize_vector(vector): """Normalize vector.""" diff --git a/src/ansys/dpf/core/geometry_factory.py b/src/ansys/dpf/core/geometry_factory.py index f0d4daf2c3..ac042505ab 100644 --- a/src/ansys/dpf/core/geometry_factory.py +++ b/src/ansys/dpf/core/geometry_factory.py @@ -29,12 +29,12 @@ import numpy as np from ansys.dpf.core.geometry import ( - Points, Line, Plane, - normalize_vector, - get_plane_local_axis, + Points, get_local_coords_from_global, + get_plane_local_axis, + normalize_vector, ) diff --git a/src/ansys/dpf/core/helpers/streamlines.py b/src/ansys/dpf/core/helpers/streamlines.py index ce5c589230..c5360847bf 100644 --- a/src/ansys/dpf/core/helpers/streamlines.py +++ b/src/ansys/dpf/core/helpers/streamlines.py @@ -22,9 +22,10 @@ """Streamlines computation specific helpers.""" -import numpy as np import warnings +import numpy as np + from ansys.dpf.core.common import locations from ansys.dpf.core.fields_container import FieldsContainer from ansys.dpf.core.helpers.utils import _sort_supported_kwargs diff --git a/src/ansys/dpf/core/incremental.py b/src/ansys/dpf/core/incremental.py index 208bb1c82b..0e8e024b34 100644 --- a/src/ansys/dpf/core/incremental.py +++ b/src/ansys/dpf/core/incremental.py @@ -22,9 +22,9 @@ """Incremental.""" -from ansys.dpf import core +from typing import Any, Dict -from typing import Dict, Any +from ansys.dpf import core class IncrementalHelper: diff --git a/src/ansys/dpf/core/inputs.py b/src/ansys/dpf/core/inputs.py index cde64a9a78..16fda8534f 100644 --- a/src/ansys/dpf/core/inputs.py +++ b/src/ansys/dpf/core/inputs.py @@ -22,11 +22,12 @@ """Inputs.""" -import weakref from textwrap import wrap -from ansys.dpf.core.mapping_types import map_types_to_python -from ansys.dpf.core.outputs import _Outputs, Output +import weakref + from ansys.dpf import core +from ansys.dpf.core.mapping_types import map_types_to_python +from ansys.dpf.core.outputs import Output, _Outputs class Input: diff --git a/src/ansys/dpf/core/label_space.py b/src/ansys/dpf/core/label_space.py index 4b2ac68569..ea38180c02 100644 --- a/src/ansys/dpf/core/label_space.py +++ b/src/ansys/dpf/core/label_space.py @@ -22,16 +22,17 @@ """Internal Usage.""" -import warnings import traceback from typing import Dict +import warnings + +from ansys.dpf.core import server as server_module from ansys.dpf.gate import ( - label_space_capi, - label_space_grpcapi, data_processing_capi, data_processing_grpcapi, + label_space_capi, + label_space_grpcapi, ) -from ansys.dpf.core import server as server_module class LabelSpace: diff --git a/src/ansys/dpf/core/mapping_types.py b/src/ansys/dpf/core/mapping_types.py index e345af2418..d23dcbd48c 100644 --- a/src/ansys/dpf/core/mapping_types.py +++ b/src/ansys/dpf/core/mapping_types.py @@ -21,23 +21,23 @@ # SOFTWARE. """Provides utilities for mapping and transforming data types between Python and C++ representations.""" -import sys import inspect +import sys -## to do : change that one the module is done -from ansys.dpf.core.meshed_region import * # noqa: F401, F403 from ansys.dpf.core.available_result import * # noqa: F401, F403 -from ansys.dpf.core.data_sources import * # noqa: F401, F403 -from ansys.dpf.core.field import * # noqa: F401, F403 -from ansys.dpf.core.fields_container import * # noqa: F401, F403 -from ansys.dpf.core.scoping import * # noqa: F401, F403 -from ansys.dpf.core.time_freq_support import * # noqa: F401, F403 from ansys.dpf.core.common import ( - _smart_dict_camel, _camel_to_snake_case, + _smart_dict_camel, _snake_to_camel_case, ) +from ansys.dpf.core.data_sources import * # noqa: F401, F403 +from ansys.dpf.core.field import * # noqa: F401, F403 +from ansys.dpf.core.fields_container import * # noqa: F401, F403 +## to do : change that one the module is done +from ansys.dpf.core.meshed_region import * # noqa: F401, F403 +from ansys.dpf.core.scoping import * # noqa: F401, F403 +from ansys.dpf.core.time_freq_support import * # noqa: F401, F403 map_types_to_cpp = _smart_dict_camel() for classes in inspect.getmembers(sys.modules[__name__], inspect.isclass): diff --git a/src/ansys/dpf/core/mesh_scoping_factory.py b/src/ansys/dpf/core/mesh_scoping_factory.py index 0f8900e2e6..c81ab5910b 100644 --- a/src/ansys/dpf/core/mesh_scoping_factory.py +++ b/src/ansys/dpf/core/mesh_scoping_factory.py @@ -31,9 +31,9 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: # pragma: nocover - from ansys.dpf.core.server_types import AnyServerType - from ansys.dpf.core.scoping import IdVectorType from ansys.dpf.core.model import Model + from ansys.dpf.core.scoping import IdVectorType + from ansys.dpf.core.server_types import AnyServerType from ansys.dpf.core import Scoping from ansys.dpf.core.common import locations diff --git a/src/ansys/dpf/core/meshed_region.py b/src/ansys/dpf/core/meshed_region.py index 29fb7e2ff9..f17bdf6467 100644 --- a/src/ansys/dpf/core/meshed_region.py +++ b/src/ansys/dpf/core/meshed_region.py @@ -27,27 +27,25 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: # pragma: nocover - from ansys.dpf.core.server_types import AnyServerType from ansys.dpf.core.scoping import Scoping + from ansys.dpf.core.server_types import AnyServerType import traceback import warnings -import ansys.dpf.core.errors - -from ansys.dpf.core import scoping, field, property_field +from ansys.dpf.core import field, property_field, scoping, server as server_module +from ansys.dpf.core.cache import class_handling_cache from ansys.dpf.core.check_version import server_meet_version, version_requires from ansys.dpf.core.common import ( locations, - types, nodal_properties, + types, ) from ansys.dpf.core.elements import Elements, element_types -from ansys.dpf.core.nodes import Nodes +import ansys.dpf.core.errors from ansys.dpf.core.faces import Faces +from ansys.dpf.core.nodes import Nodes from ansys.dpf.core.plotter import DpfPlotter, Plotter -from ansys.dpf.core.cache import class_handling_cache -from ansys.dpf.core import server as server_module from ansys.dpf.gate import meshed_region_capi, meshed_region_grpcapi diff --git a/src/ansys/dpf/core/meshes_container.py b/src/ansys/dpf/core/meshes_container.py index e2e43e8ee8..e3c6cd8043 100644 --- a/src/ansys/dpf/core/meshes_container.py +++ b/src/ansys/dpf/core/meshes_container.py @@ -27,10 +27,9 @@ Contains classes associated with the DPF MeshesContainer. """ -from ansys.dpf.core import meshed_region +from ansys.dpf.core import errors as dpf_errors, meshed_region from ansys.dpf.core.collection_base import CollectionBase from ansys.dpf.core.plotter import DpfPlotter -from ansys.dpf.core import errors as dpf_errors class MeshesContainer(CollectionBase[meshed_region.MeshedRegion]): diff --git a/src/ansys/dpf/core/misc.py b/src/ansys/dpf/core/misc.py index 13ccee9d62..2ba6e93956 100644 --- a/src/ansys/dpf/core/misc.py +++ b/src/ansys/dpf/core/misc.py @@ -22,16 +22,16 @@ """Miscellaneous functions for the DPF module.""" -import platform import glob import os -import re from pathlib import Path - from pkgutil import iter_modules +import platform +import re + from ansys.dpf.core import errors -from ansys.dpf.gate._version import __ansys_version__ from ansys.dpf.gate import load_api +from ansys.dpf.gate._version import __ansys_version__ DEFAULT_FILE_CHUNK_SIZE = 524288 DYNAMIC_RESULTS = True diff --git a/src/ansys/dpf/core/model.py b/src/ansys/dpf/core/model.py index 6b5ef71cb1..95ca770996 100644 --- a/src/ansys/dpf/core/model.py +++ b/src/ansys/dpf/core/model.py @@ -31,19 +31,18 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: # pragma: nocover - from ansys.dpf.core.server_types import AnyServerType from ansys.dpf.core.scoping import Scoping + from ansys.dpf.core.server_types import AnyServerType from ansys import dpf -from ansys.dpf.core import Operator +from ansys.dpf.core import Operator, misc +from ansys.dpf.core._model_helpers import DataSourcesOrStreamsConnector +from ansys.dpf.core.check_version import version_requires from ansys.dpf.core.common import types from ansys.dpf.core.data_sources import DataSources -from ansys.dpf.core.results import Results, CommonResults -from ansys.dpf.core.server_types import LOG -from ansys.dpf.core import misc from ansys.dpf.core.errors import protect_source_op_not_found -from ansys.dpf.core._model_helpers import DataSourcesOrStreamsConnector -from ansys.dpf.core.check_version import version_requires +from ansys.dpf.core.results import CommonResults, Results +from ansys.dpf.core.server_types import LOG class Model: diff --git a/src/ansys/dpf/core/nodes.py b/src/ansys/dpf/core/nodes.py index 241c142571..668922148e 100644 --- a/src/ansys/dpf/core/nodes.py +++ b/src/ansys/dpf/core/nodes.py @@ -23,9 +23,9 @@ """Nodes.""" import numpy as np -from ansys.dpf.core.common import nodal_properties, locations -from ansys.dpf.core.check_version import version_requires + from ansys.dpf.core.check_version import version_requires +from ansys.dpf.core.common import locations, nodal_properties class Node: diff --git a/src/ansys/dpf/core/operator_specification.py b/src/ansys/dpf/core/operator_specification.py index 55315c5290..5fe6070e64 100644 --- a/src/ansys/dpf/core/operator_specification.py +++ b/src/ansys/dpf/core/operator_specification.py @@ -27,17 +27,17 @@ """ from __future__ import annotations + import abc from typing import Union -from ansys.dpf.core import server as server_module + +from ansys.dpf.core import common, mapping_types, server as server_module +from ansys.dpf.core.check_version import server_meet_version, version_requires from ansys.dpf.gate import ( + integral_types, operator_specification_capi, operator_specification_grpcapi, - integral_types, ) -from ansys.dpf.core import mapping_types, common -from ansys.dpf.core.check_version import version_requires -from ansys.dpf.core.check_version import server_meet_version class PinSpecification: diff --git a/src/ansys/dpf/core/outputs.py b/src/ansys/dpf/core/outputs.py index 64f691869c..51eb731eeb 100644 --- a/src/ansys/dpf/core/outputs.py +++ b/src/ansys/dpf/core/outputs.py @@ -22,10 +22,11 @@ """Outputs.""" -from ansys.dpf.core.mapping_types import map_types_to_python +import re + from ansys.dpf.core.common import types +from ansys.dpf.core.mapping_types import map_types_to_python from ansys.dpf.core.operator_specification import PinSpecification -import re class Output: diff --git a/src/ansys/dpf/core/path_utilities.py b/src/ansys/dpf/core/path_utilities.py index 844afd71fe..7cdad7d070 100644 --- a/src/ansys/dpf/core/path_utilities.py +++ b/src/ansys/dpf/core/path_utilities.py @@ -28,10 +28,10 @@ """ import os +from pathlib import Path -import ansys.dpf.core.server_types from ansys.dpf.core import server as server_module -from pathlib import Path +import ansys.dpf.core.server_types def join(*args, **kwargs): diff --git a/src/ansys/dpf/core/plotter.py b/src/ansys/dpf/core/plotter.py index 9c957c4198..b7a7558bcb 100644 --- a/src/ansys/dpf/core/plotter.py +++ b/src/ansys/dpf/core/plotter.py @@ -30,20 +30,20 @@ from __future__ import annotations -import tempfile import os -import sys -import numpy as np -import warnings from pathlib import Path +import sys +import tempfile from typing import TYPE_CHECKING, List, Union +import warnings + +import numpy as np from ansys import dpf from ansys.dpf import core -from ansys.dpf.core.common import locations, DefinitionLabels -from ansys.dpf.core.common import shell_layers as eshell_layers -from ansys.dpf.core.helpers.streamlines import _sort_supported_kwargs from ansys.dpf.core import errors as dpf_errors +from ansys.dpf.core.common import DefinitionLabels, locations, shell_layers as eshell_layers +from ansys.dpf.core.helpers.streamlines import _sort_supported_kwargs from ansys.dpf.core.nodes import Node, Nodes if TYPE_CHECKING: # pragma: no cover @@ -186,10 +186,9 @@ def get_label_at_grid_point(index): # Filter kwargs kwargs_in = _sort_supported_kwargs(bound_method=self._plotter.add_point_labels, **kwargs) - import pyvista as pv - # The scalar data used will be the one of the last field added. from packaging.version import parse + import pyvista as pv active_scalars = None if parse(pv.__version__) >= parse("0.35.2"): diff --git a/src/ansys/dpf/core/property_field.py b/src/ansys/dpf/core/property_field.py index aad26188f4..aa07ee8ce0 100644 --- a/src/ansys/dpf/core/property_field.py +++ b/src/ansys/dpf/core/property_field.py @@ -23,18 +23,18 @@ """PropertyField.""" import numpy as np -from ansys.dpf.core.check_version import version_requires -from ansys.dpf.core.common import natures, locations, _get_size_of_list -from ansys.dpf.core import scoping, dimensionality + +from ansys.dpf.core import dimensionality, scoping +from ansys.dpf.core.check_version import meets_version, version_requires +from ansys.dpf.core.common import _get_size_of_list, locations, natures from ansys.dpf.core.field_base import _FieldBase, _LocalFieldBase -from ansys.dpf.core.check_version import meets_version from ansys.dpf.core.field_definition import FieldDefinition from ansys.dpf.gate import ( + dpf_array, + dpf_vector, property_field_abstract_api, property_field_capi, property_field_grpcapi, - dpf_array, - dpf_vector, ) diff --git a/src/ansys/dpf/core/result_info.py b/src/ansys/dpf/core/result_info.py index 14f5a7f4b8..336a571e0f 100644 --- a/src/ansys/dpf/core/result_info.py +++ b/src/ansys/dpf/core/result_info.py @@ -22,33 +22,30 @@ """ResultInfo.""" +from enum import Enum, unique import traceback +from types import SimpleNamespace +from typing import List, Union import warnings -from typing import List, Union -from enum import Enum, unique -from types import SimpleNamespace +from ansys.dpf.core import available_result, collection_base, server as server_module, support +from ansys.dpf.core.available_result import Homogeneity +from ansys.dpf.core.check_version import version_requires +from ansys.dpf.core.common import locations +from ansys.dpf.core.cyclic_support import CyclicSupport +from ansys.dpf.core.dimensionality import natures +from ansys.dpf.core.label_space import LabelSpace from ansys.dpf.gate import ( - result_info_capi, - result_info_grpcapi, + data_processing_capi, + data_processing_grpcapi, integral_types, label_space_capi, label_space_grpcapi, object_handler, - data_processing_grpcapi, - data_processing_capi, + result_info_capi, + result_info_grpcapi, ) -from ansys.dpf.core import collection_base -from ansys.dpf.core import server as server_module -from ansys.dpf.core import available_result, support -from ansys.dpf.core.cyclic_support import CyclicSupport -from ansys.dpf.core.label_space import LabelSpace -from ansys.dpf.core.check_version import version_requires -from ansys.dpf.core.dimensionality import natures -from ansys.dpf.core.common import locations -from ansys.dpf.core.available_result import Homogeneity - @unique class physics_types(Enum): diff --git a/src/ansys/dpf/core/results.py b/src/ansys/dpf/core/results.py index 89ad91c46b..a1801ee4f5 100644 --- a/src/ansys/dpf/core/results.py +++ b/src/ansys/dpf/core/results.py @@ -29,13 +29,12 @@ import functools -from ansys.dpf.core import Operator -from ansys.dpf.core import errors -from ansys.dpf.core.scoping import Scoping +from ansys.dpf.core import Operator, errors from ansys.dpf.core.custom_fields_container import ( - ElShapeFieldsContainer, BodyFieldsContainer, + ElShapeFieldsContainer, ) +from ansys.dpf.core.scoping import Scoping class Results: diff --git a/src/ansys/dpf/core/runtime_config.py b/src/ansys/dpf/core/runtime_config.py index c3cdf4247f..e3f36a996f 100644 --- a/src/ansys/dpf/core/runtime_config.py +++ b/src/ansys/dpf/core/runtime_config.py @@ -22,9 +22,9 @@ """RuntimeConfig.""" -from ansys.dpf.core.data_tree import DataTree -from ansys.dpf.core.common import types from ansys.dpf.core import misc +from ansys.dpf.core.common import types +from ansys.dpf.core.data_tree import DataTree class _RuntimeConfig: diff --git a/src/ansys/dpf/core/scoping.py b/src/ansys/dpf/core/scoping.py index 8b7729f695..14bd2fafd9 100644 --- a/src/ansys/dpf/core/scoping.py +++ b/src/ansys/dpf/core/scoping.py @@ -23,34 +23,35 @@ """Scoping.""" from __future__ import annotations + +import ctypes import traceback -from typing import Union, TYPE_CHECKING +from typing import TYPE_CHECKING, Union import warnings -import ctypes import numpy as np +from ansys.dpf.core import server as server_module, server_types +from ansys.dpf.core.cache import _setter from ansys.dpf.core.check_version import version_requires from ansys.dpf.core.common import locations -from ansys.dpf.core import server as server_module -from ansys.dpf.core import server_types -from ansys.dpf.core.cache import _setter from ansys.dpf.gate import ( - scoping_capi, - scoping_grpcapi, data_processing_capi, data_processing_grpcapi, - dpf_vector_capi, - dpf_vector_abstract_api, dpf_vector, + dpf_vector_abstract_api, + dpf_vector_capi, + scoping_capi, + scoping_grpcapi, utils, ) from ansys.dpf.gate.dpf_array import DPFArray if TYPE_CHECKING: # pragma: nocover + from ctypes import c_void_p as ScopingPointer + from ansys.dpf.core.server_types import AnyServerType import ansys.grpc.dpf.scoping_pb2.Scoping as ScopingMessage - from ctypes import c_void_p as ScopingPointer IdVectorType = Union[list[int], range] diff --git a/src/ansys/dpf/core/server.py b/src/ansys/dpf/core/server.py index 81888c4435..00d0e48a64 100644 --- a/src/ansys/dpf/core/server.py +++ b/src/ansys/dpf/core/server.py @@ -26,30 +26,27 @@ Contains the directives necessary to start the DPF server. """ +import copy import functools +import inspect import os +import platform import socket import sys -import weakref -import copy -import platform -import inspect -import warnings import traceback from typing import Union +import warnings +import weakref from ansys import dpf - -from ansys.dpf.core.misc import is_ubuntu, get_ansys_path -from ansys.dpf.core import errors - +from ansys.dpf.core import errors, server_context +from ansys.dpf.core.misc import get_ansys_path, is_ubuntu from ansys.dpf.core.server_factory import ( + CommunicationProtocols, ServerConfig, ServerFactory, - CommunicationProtocols, ) from ansys.dpf.core.server_types import DPF_DEFAULT_PORT, LOCALHOST, RUNNING_DOCKER, BaseServer -from ansys.dpf.core import server_context def shutdown_global_server(): diff --git a/src/ansys/dpf/core/server_context.py b/src/ansys/dpf/core/server_context.py index d8e80193fa..3587989716 100644 --- a/src/ansys/dpf/core/server_context.py +++ b/src/ansys/dpf/core/server_context.py @@ -35,11 +35,11 @@ ANSYS_DPF_SERVER_CONTEXT=ENTRY and ANSYS_DPF_SERVER_CONTEXT=PREMIUM can be used. """ +from enum import Enum import os import warnings -from enum import Enum -from ansys.dpf.core import dpf_operator -from ansys.dpf.core import errors + +from ansys.dpf.core import dpf_operator, errors class LicensingContextType(Enum): diff --git a/src/ansys/dpf/core/server_factory.py b/src/ansys/dpf/core/server_factory.py index 6268767bf4..2be2f8a069 100644 --- a/src/ansys/dpf/core/server_factory.py +++ b/src/ansys/dpf/core/server_factory.py @@ -27,15 +27,15 @@ protocols and server configurations available. """ +import io import logging import os import subprocess import time -import io from ansys.dpf.gate.load_api import ( - _get_path_in_install, _find_outdated_ansys_version, + _get_path_in_install, ) @@ -700,9 +700,9 @@ def get_server_type_from_config( ): """Return server type determined from the server configuration.""" from ansys.dpf.core.server_types import ( - LegacyGrpcServer, GrpcServer, InProcessServer, + LegacyGrpcServer, ) # dpf.core.SERVER_CONFIGURATION is required to know what type of connection to set diff --git a/src/ansys/dpf/core/server_types.py b/src/ansys/dpf/core/server_types.py index d88e4cc47e..b98d243e3b 100644 --- a/src/ansys/dpf/core/server_types.py +++ b/src/ansys/dpf/core/server_types.py @@ -28,29 +28,29 @@ """ from __future__ import annotations + import abc +from abc import ABC +import ctypes import io import os +from pathlib import Path import socket import subprocess import sys +from threading import Lock, Thread import time -import warnings import traceback -from threading import Thread, Lock -from abc import ABC -import ctypes from typing import TYPE_CHECKING, Union -from pathlib import Path +import warnings import psutil import ansys.dpf.core as core -from ansys.dpf.core.check_version import server_meet_version -from ansys.dpf.core import errors, server_factory, __version__ +from ansys.dpf.core import __version__, errors, server_context, server_factory from ansys.dpf.core._version import min_server_version, server_to_ansys_version -from ansys.dpf.core import server_context -from ansys.dpf.gate import load_api, data_processing_grpcapi +from ansys.dpf.core.check_version import server_meet_version +from ansys.dpf.gate import data_processing_grpcapi, load_api if TYPE_CHECKING: from ansys.dpf.core.server_factory import DockerConfig @@ -329,6 +329,7 @@ def launch_remote_dpf(version=None): def _compare_ansys_grpc_dpf_version(right_grpc_module_version_str: str, grpc_module_version: str): if right_grpc_module_version_str: import re + from packaging.version import parse as parse_version right_version_first_numbers = re.search(r"\d", right_grpc_module_version_str) diff --git a/src/ansys/dpf/core/session.py b/src/ansys/dpf/core/session.py index bb2166366e..1dc22a5de9 100644 --- a/src/ansys/dpf/core/session.py +++ b/src/ansys/dpf/core/session.py @@ -30,17 +30,13 @@ import warnings import weakref -from ansys.dpf.gate import session_capi, session_grpcapi, capi - -from ansys.dpf.core import server as server_module -from ansys.dpf.core import server_types, errors -from ansys.dpf.core.check_version import version_requires, server_meet_version +from ansys.dpf.core import data_tree, errors, server as server_module, server_types +from ansys.dpf.core.check_version import version_requires from ansys.dpf.core.common import ( _common_percentage_progress_bar, _progress_bar_is_available, ) -from ansys.dpf.core import data_tree - +from ansys.dpf.gate import capi, session_capi, session_grpcapi LOG = logging.getLogger(__name__) LOG.setLevel("DEBUG") diff --git a/src/ansys/dpf/core/settings.py b/src/ansys/dpf/core/settings.py index 4e1b8ea295..9d5e381cb5 100644 --- a/src/ansys/dpf/core/settings.py +++ b/src/ansys/dpf/core/settings.py @@ -26,12 +26,11 @@ Customize the behavior of the module. """ +from ansys.dpf.core import core, misc from ansys.dpf.core.misc import module_exists -from ansys.dpf.core import misc from ansys.dpf.core.server import set_server_configuration # noqa: F401 from ansys.dpf.core.server_context import set_default_server_context # noqa: F401 from ansys.dpf.core.server_factory import ServerConfig # noqa: F401 -from ansys.dpf.core import core from ansys.dpf.gate import ( data_processing_capi, data_processing_grpcapi, @@ -121,9 +120,9 @@ def set_dynamic_available_results_capability(value) -> None: def _forward_to_gate(): - from ansys.dpf.gate import settings - from ansys.dpf.core.misc import DEFAULT_FILE_CHUNK_SIZE from ansys.dpf.core.common import _common_progress_bar, _progress_bar_is_available + from ansys.dpf.core.misc import DEFAULT_FILE_CHUNK_SIZE + from ansys.dpf.gate import settings settings.forward_settings( DEFAULT_FILE_CHUNK_SIZE, @@ -152,8 +151,8 @@ def get_runtime_client_config(server=None): with Ans.Dpf.GrpcClient configuration. """ - from ansys.dpf.core.runtime_config import RuntimeClientConfig from ansys.dpf import core as root + from ansys.dpf.core.runtime_config import RuntimeClientConfig if server is None: server = root.SERVER diff --git a/src/ansys/dpf/core/streams_container.py b/src/ansys/dpf/core/streams_container.py index 0b59677fc5..8e61a97514 100644 --- a/src/ansys/dpf/core/streams_container.py +++ b/src/ansys/dpf/core/streams_container.py @@ -27,17 +27,16 @@ Contains classes associated with the DPF StreamsContainer. """ -import warnings import traceback +import warnings +from ansys.dpf.core import data_sources, errors, server as server_module from ansys.dpf.core.server_types import BaseServer -from ansys.dpf.core import server as server_module from ansys.dpf.gate import ( - streams_capi, data_processing_capi, data_processing_grpcapi, + streams_capi, ) -from ansys.dpf.core import errors, data_sources class StreamsContainer: diff --git a/src/ansys/dpf/core/string_field.py b/src/ansys/dpf/core/string_field.py index a547441843..d8e6da0d72 100644 --- a/src/ansys/dpf/core/string_field.py +++ b/src/ansys/dpf/core/string_field.py @@ -22,20 +22,20 @@ """StringField.""" +from typing import List + import numpy as np -from ansys.dpf.core.common import natures, locations, _get_size_of_list -from ansys.dpf.core import scoping -from ansys.dpf.core import server as server_module -from ansys.dpf.core import errors + +from ansys.dpf.core import errors, scoping, server as server_module +from ansys.dpf.core.common import _get_size_of_list, locations, natures from ansys.dpf.core.field_base import _FieldBase from ansys.dpf.gate import ( + dpf_vector, + integral_types, string_field_abstract_api, string_field_capi, string_field_grpcapi, - dpf_vector, - integral_types, ) -from typing import List class StringField(_FieldBase): diff --git a/src/ansys/dpf/core/support.py b/src/ansys/dpf/core/support.py index 9bc9076d17..26a6acbf12 100644 --- a/src/ansys/dpf/core/support.py +++ b/src/ansys/dpf/core/support.py @@ -24,11 +24,10 @@ import traceback import warnings -from ansys.dpf.gate import support_capi, support_grpcapi -from ansys.dpf.core.check_version import version_requires -from ansys.dpf.core import server as server_module -from ansys.dpf.core import collection_base +from ansys.dpf.core import collection_base, server as server_module +from ansys.dpf.core.check_version import version_requires +from ansys.dpf.gate import support_capi, support_grpcapi class Support: diff --git a/src/ansys/dpf/core/time_freq_scoping_factory.py b/src/ansys/dpf/core/time_freq_scoping_factory.py index adfc8a2592..3c87f06306 100644 --- a/src/ansys/dpf/core/time_freq_scoping_factory.py +++ b/src/ansys/dpf/core/time_freq_scoping_factory.py @@ -26,16 +26,14 @@ Contains functions to simplify creating time frequency scopings. """ -from ansys.dpf.core import Scoping -from ansys.dpf.core import errors as dpf_errors +from typing import Union + +from ansys.dpf.core import Scoping, errors as dpf_errors, types from ansys.dpf.core.common import locations -from ansys.dpf.core.model import Model -from ansys.dpf.core.time_freq_support import TimeFreqSupport from ansys.dpf.core.data_sources import DataSources +from ansys.dpf.core.model import Model from ansys.dpf.core.operators.metadata import time_freq_provider - -from ansys.dpf.core import types -from typing import Union +from ansys.dpf.core.time_freq_support import TimeFreqSupport def scoping_by_load_step(load_step: int, server=None): diff --git a/src/ansys/dpf/core/time_freq_support.py b/src/ansys/dpf/core/time_freq_support.py index 9497aae523..e010bd58b1 100644 --- a/src/ansys/dpf/core/time_freq_support.py +++ b/src/ansys/dpf/core/time_freq_support.py @@ -22,12 +22,11 @@ """TimeFreqSupport.""" -from ansys.dpf.gate import time_freq_support_capi, time_freq_support_grpcapi - from ansys import dpf from ansys.dpf import core from ansys.dpf.core import errors as dpf_errors from ansys.dpf.core.support import Support +from ansys.dpf.gate import time_freq_support_capi, time_freq_support_grpcapi class TimeFreqSupport(Support): diff --git a/src/ansys/dpf/core/unit_system.py b/src/ansys/dpf/core/unit_system.py index f6f318ff65..819279146d 100644 --- a/src/ansys/dpf/core/unit_system.py +++ b/src/ansys/dpf/core/unit_system.py @@ -23,8 +23,7 @@ """UnitSystem.""" from ansys.dpf import core as dpf -from ansys.dpf.core import errors as dpf_errors -from ansys.dpf.core import server as server_module +from ansys.dpf.core import errors as dpf_errors, server as server_module class UnitSystem: diff --git a/src/ansys/dpf/core/vtk_helper.py b/src/ansys/dpf/core/vtk_helper.py index 0be3efa9c5..ad5c49a556 100644 --- a/src/ansys/dpf/core/vtk_helper.py +++ b/src/ansys/dpf/core/vtk_helper.py @@ -22,9 +22,10 @@ """Provides for vtk helper functions.""" +from typing import Union + import numpy as np import pyvista as pv -from typing import Union from vtk import ( VTK_HEXAHEDRON, VTK_LINE, diff --git a/src/ansys/dpf/core/workflow.py b/src/ansys/dpf/core/workflow.py index 6d93283574..7c26580219 100644 --- a/src/ansys/dpf/core/workflow.py +++ b/src/ansys/dpf/core/workflow.py @@ -22,34 +22,32 @@ """Workflow.""" +from enum import Enum import logging import os -import traceback -import warnings from pathlib import Path - -from enum import Enum +import traceback from typing import Union +import warnings import numpy from ansys import dpf -from ansys.dpf.core import dpf_operator, inputs, outputs +from ansys.dpf.core import dpf_operator, inputs, outputs, server as server_module from ansys.dpf.core.check_version import ( server_meet_version, - version_requires, server_meet_version_and_raise, + version_requires, ) -from ansys.dpf.core import server as server_module from ansys.dpf.gate import ( - workflow_abstract_api, - workflow_grpcapi, - workflow_capi, data_processing_capi, data_processing_grpcapi, dpf_vector, - object_handler, integral_types, + object_handler, + workflow_abstract_api, + workflow_capi, + workflow_grpcapi, ) LOG = logging.getLogger(__name__) @@ -240,22 +238,22 @@ def connect(self, pin_name, inpt, pin_out=0): @property def _type_to_input_method(self): from ansys.dpf.core import ( + any, + collection, + custom_type_field, cyclic_support, data_sources, + data_tree, field, - collection, + generic_data_container, meshed_region, + model, property_field, - string_field, - custom_type_field, scoping, + streams_container, + string_field, time_freq_support, - data_tree, workflow, - model, - generic_data_container, - any, - streams_container, ) out = [ @@ -303,26 +301,26 @@ def _type_to_input_method(self): @property def _type_to_output_method(self): from ansys.dpf.core import ( + any, + collection, + collection_base, + custom_type_field, cyclic_support, data_sources, + data_tree, field, fields_container, + generic_data_container, meshed_region, meshes_container, property_field, - string_field, - custom_type_field, result_info, scoping, scopings_container, + streams_container, + string_field, time_freq_support, - data_tree, workflow, - collection, - generic_data_container, - any, - collection_base, - streams_container, ) from ansys.dpf.core.custom_container_base import CustomContainerBase diff --git a/src/ansys/dpf/core/workflow_topology/__init__.py b/src/ansys/dpf/core/workflow_topology/__init__.py index 013884911d..20abf694a8 100644 --- a/src/ansys/dpf/core/workflow_topology/__init__.py +++ b/src/ansys/dpf/core/workflow_topology/__init__.py @@ -21,7 +21,7 @@ # SOFTWARE. """Workflow topology module.""" -from .workflow_topology import WorkflowTopology -from .operator_connection import OperatorConnection from .data_connection import DataConnection from .exposed_pin import ExposedPin +from .operator_connection import OperatorConnection +from .workflow_topology import WorkflowTopology diff --git a/src/ansys/dpf/core/workflow_topology/data_connection.py b/src/ansys/dpf/core/workflow_topology/data_connection.py index 6217e51d61..ff3d7f13a2 100644 --- a/src/ansys/dpf/core/workflow_topology/data_connection.py +++ b/src/ansys/dpf/core/workflow_topology/data_connection.py @@ -29,6 +29,7 @@ """ from typing import Any, Iterator, Optional + from ansys.dpf.core import GenericDataContainersCollection from ansys.dpf.core.custom_container_base import CustomContainerBase from ansys.dpf.core.dpf_operator import Operator diff --git a/src/ansys/dpf/core/workflow_topology/exposed_pin.py b/src/ansys/dpf/core/workflow_topology/exposed_pin.py index fbc36b1ce1..1ef4e50e71 100644 --- a/src/ansys/dpf/core/workflow_topology/exposed_pin.py +++ b/src/ansys/dpf/core/workflow_topology/exposed_pin.py @@ -30,6 +30,7 @@ """ from typing import Iterator, Optional + from ansys.dpf.core import GenericDataContainersCollection from ansys.dpf.core.custom_container_base import CustomContainerBase from ansys.dpf.core.dpf_operator import Operator diff --git a/src/ansys/dpf/core/workflow_topology/operator_connection.py b/src/ansys/dpf/core/workflow_topology/operator_connection.py index 881f5600a9..fbd7552870 100644 --- a/src/ansys/dpf/core/workflow_topology/operator_connection.py +++ b/src/ansys/dpf/core/workflow_topology/operator_connection.py @@ -29,6 +29,7 @@ """ from typing import Iterator, Optional + from ansys.dpf.core import GenericDataContainersCollection from ansys.dpf.core.custom_container_base import CustomContainerBase from ansys.dpf.core.dpf_operator import Operator diff --git a/src/ansys/dpf/core/workflow_topology/workflow_topology.py b/src/ansys/dpf/core/workflow_topology/workflow_topology.py index e1bb6892ac..18268c325f 100644 --- a/src/ansys/dpf/core/workflow_topology/workflow_topology.py +++ b/src/ansys/dpf/core/workflow_topology/workflow_topology.py @@ -29,6 +29,7 @@ """ from typing import Optional + from ansys.dpf.core import OperatorsCollection from ansys.dpf.core.custom_container_base import CustomContainerBase from ansys.dpf.core.generic_data_container import GenericDataContainer diff --git a/tests/conftest.py b/tests/conftest.py index 9c83b3ad2c..634396aee9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -26,20 +26,20 @@ pytest as a session fixture """ -import os import functools +import os from pathlib import Path +import warnings import psutil import pytest -import ansys.dpf.core.server_types from ansys.dpf import core from ansys.dpf.core import examples -from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols -from ansys.dpf.core.check_version import meets_version, get_server_version +from ansys.dpf.core.check_version import get_server_version, meets_version +from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig +import ansys.dpf.core.server_types from ansys.dpf.gate.load_api import _try_use_gatebin -import warnings ACCEPTABLE_FAILURE_RATE = 0 diff --git a/tests/entry/conftest.py b/tests/entry/conftest.py index 236c6c09b0..01e1a0bf70 100644 --- a/tests/entry/conftest.py +++ b/tests/entry/conftest.py @@ -28,18 +28,18 @@ pytest as a session fixture """ +import functools import os from pathlib import Path -import functools + import pytest os.environ["ANSYS_DPF_SERVER_CONTEXT"] = "ENTRY" # MANDATORY -import ansys.dpf.core.server_types from ansys.dpf import core -from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols -from ansys.dpf.core.check_version import meets_version, get_server_version - +from ansys.dpf.core.check_version import get_server_version, meets_version +from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig +import ansys.dpf.core.server_types core.set_default_server_context(core.AvailableServerContexts.entry) # MANDATORY diff --git a/tests/entry/test_entry.py b/tests/entry/test_entry.py index af7f78b184..7ab00f28ff 100644 --- a/tests/entry/test_entry.py +++ b/tests/entry/test_entry.py @@ -23,11 +23,11 @@ import os import pytest -import conftest import ansys.dpf.core as dpf from ansys.dpf.core import examples from ansys.dpf.core.core import errors +import conftest from conftest import running_docker diff --git a/tests/operators/test_coordinate_system.py b/tests/operators/test_coordinate_system.py index f8947b04ec..00261741a9 100644 --- a/tests/operators/test_coordinate_system.py +++ b/tests/operators/test_coordinate_system.py @@ -21,10 +21,11 @@ # SOFTWARE. # Tests the result.coordinate_system operator +import numpy as np + import ansys.dpf.core as dpf from ansys.dpf.core import examples import conftest -import numpy as np def test_operator_coordinate_system_rst(server_type): diff --git a/tests/operators/test_operator_elemental_mass.py b/tests/operators/test_operator_elemental_mass.py index e33940d6dc..14e51aef99 100644 --- a/tests/operators/test_operator_elemental_mass.py +++ b/tests/operators/test_operator_elemental_mass.py @@ -20,9 +20,10 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import conftest import pytest + import ansys.dpf.core as dpf +import conftest @pytest.mark.skipif( diff --git a/tests/operators/test_operator_mesh_plan_clip.py b/tests/operators/test_operator_mesh_plan_clip.py index 9e634ee9b2..bf8917448d 100644 --- a/tests/operators/test_operator_mesh_plan_clip.py +++ b/tests/operators/test_operator_mesh_plan_clip.py @@ -20,9 +20,10 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import pytest + import ansys.dpf.core as dpf import conftest -import pytest @pytest.mark.skipif( diff --git a/tests/slow/test_remoteworkflow.py b/tests/slow/test_remoteworkflow.py index 31b9bcb58c..357cddf6c8 100644 --- a/tests/slow/test_remoteworkflow.py +++ b/tests/slow/test_remoteworkflow.py @@ -24,9 +24,8 @@ import pytest from ansys.dpf import core -from ansys.dpf.core import examples -from ansys.dpf.core import operators as ops -from ansys.dpf.core.check_version import meets_version, get_server_version +from ansys.dpf.core import examples, operators as ops +from ansys.dpf.core.check_version import get_server_version, meets_version from conftest import local_servers SERVER_VERSION_HIGHER_THAN_3_0 = meets_version(get_server_version(core._global_server()), "3.0") diff --git a/tests/slow/test_slow.py b/tests/slow/test_slow.py index 3be3525dfa..4ac8975ee5 100644 --- a/tests/slow/test_slow.py +++ b/tests/slow/test_slow.py @@ -20,8 +20,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import pytest import numpy as np +import pytest from ansys.dpf import core as dpf from ansys.dpf.core import examples diff --git a/tests/test_animation.py b/tests/test_animation.py index a5662ced49..4c95f8c71f 100644 --- a/tests/test_animation.py +++ b/tests/test_animation.py @@ -26,10 +26,7 @@ import pytest from ansys.dpf import core as dpf -from ansys.dpf.core import misc -from ansys.dpf.core import examples -from ansys.dpf.core import animation - +from ansys.dpf.core import animation, examples, misc if misc.module_exists("pyvista"): HAS_PYVISTA = True diff --git a/tests/test_animator.py b/tests/test_animator.py index 4986546ab6..402e4f6617 100644 --- a/tests/test_animator.py +++ b/tests/test_animator.py @@ -26,8 +26,7 @@ import pytest from ansys.dpf import core as dpf -from ansys.dpf.core import misc, Workflow -from ansys.dpf.core import examples +from ansys.dpf.core import Workflow, examples, misc if misc.module_exists("pyvista"): HAS_PYVISTA = True diff --git a/tests/test_any.py b/tests/test_any.py index 85965e843b..28a29a5631 100644 --- a/tests/test_any.py +++ b/tests/test_any.py @@ -22,8 +22,8 @@ import pytest -import conftest from ansys.dpf import core as dpf +import conftest @conftest.raises_for_servers_version_under("7.0") diff --git a/tests/test_cff.py b/tests/test_cff.py index 70ebc18edf..5c0c4fdb03 100644 --- a/tests/test_cff.py +++ b/tests/test_cff.py @@ -21,8 +21,9 @@ # SOFTWARE. import pytest -import conftest + from ansys.dpf import core as dpf +import conftest @pytest.mark.skipif( diff --git a/tests/test_checkversion.py b/tests/test_checkversion.py index 5df50ce4ab..4596a0b665 100644 --- a/tests/test_checkversion.py +++ b/tests/test_checkversion.py @@ -22,9 +22,7 @@ import pytest -from ansys.dpf.core import check_version -from ansys.dpf.core import errors as dpf_errors - +from ansys.dpf.core import check_version, errors as dpf_errors from ansys.dpf.gate.load_api import _find_outdated_ansys_version diff --git a/tests/test_codegeneration.py b/tests/test_codegeneration.py index 8c90344f8a..e0543ae8f0 100644 --- a/tests/test_codegeneration.py +++ b/tests/test_codegeneration.py @@ -21,17 +21,17 @@ # SOFTWARE. # -*- coding: utf-8 -*- -import os import copy -import tempfile +import os from pathlib import Path +import tempfile -import ansys.grpc.dpf import numpy as np -import ansys.dpf.core.operators as op from ansys.dpf import core from ansys.dpf.core import examples +import ansys.dpf.core.operators as op +import ansys.grpc.dpf def test_workflowwithgeneratedcode(allkindofcomplexity): diff --git a/tests/test_collection.py b/tests/test_collection.py index 1a87fd2950..799d567321 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -22,26 +22,27 @@ # -*- coding: utf-8 -*- -import conftest +from dataclasses import dataclass, field +import random -import pytest import numpy as np +import pytest + from ansys.dpf.core import ( CustomTypeField, CustomTypeFieldsCollection, + GenericDataContainer, GenericDataContainersCollection, - StringFieldsCollection, StringField, - GenericDataContainer, - operators, + StringFieldsCollection, Workflow, fields_factory, + operators, ) from ansys.dpf.core.collection import Collection -from ansys.dpf.core.time_freq_support import TimeFreqSupport from ansys.dpf.core.generic_support import GenericSupport -import random -from dataclasses import dataclass, field +from ansys.dpf.core.time_freq_support import TimeFreqSupport +import conftest @conftest.raises_for_servers_version_under("8.1") diff --git a/tests/test_custom_type_field.py b/tests/test_custom_type_field.py index 2cd0d68ba0..c7b3a126a6 100644 --- a/tests/test_custom_type_field.py +++ b/tests/test_custom_type_field.py @@ -22,10 +22,9 @@ import numpy as np -import conftest - from ansys import dpf from ansys.dpf import core +import conftest @conftest.raises_for_servers_version_under("5.0") diff --git a/tests/test_cyclic_support.py b/tests/test_cyclic_support.py index 31ca521870..25afdc7fcb 100644 --- a/tests/test_cyclic_support.py +++ b/tests/test_cyclic_support.py @@ -22,13 +22,13 @@ import gc import weakref -import numpy as np -import conftest +import numpy as np import pytest from ansys import dpf from ansys.dpf import core as dpf +import conftest def test_cyc_support_from_model(cyclic_lin_rst): diff --git a/tests/test_data_tree.py b/tests/test_data_tree.py index b3226ca153..15215cd482 100644 --- a/tests/test_data_tree.py +++ b/tests/test_data_tree.py @@ -20,11 +20,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from ansys.dpf import core as dpf import os +from pathlib import Path + import pytest + +from ansys.dpf import core as dpf import conftest -from pathlib import Path @conftest.raises_for_servers_version_under("4.0") diff --git a/tests/test_datasources.py b/tests/test_datasources.py index 1c06c110d5..162b55cd41 100644 --- a/tests/test_datasources.py +++ b/tests/test_datasources.py @@ -20,11 +20,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import weakref + import pytest from ansys import dpf import conftest -import weakref skip_always = pytest.mark.skipif(True, reason="Investigate why this is failing") diff --git a/tests/test_examples.py b/tests/test_examples.py index 19fa84c9d7..5fd5a91461 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -27,9 +27,7 @@ import pytest from ansys.dpf import core as dpf -from ansys.dpf.core import Model -from ansys.dpf.core import DataSources -from ansys.dpf.core import examples +from ansys.dpf.core import DataSources, Model, examples def test_download_all_kinds_of_complexity_modal(): diff --git a/tests/test_faces.py b/tests/test_faces.py index a6ea86429e..208ad1627d 100644 --- a/tests/test_faces.py +++ b/tests/test_faces.py @@ -21,10 +21,11 @@ # SOFTWARE. import pytest -import conftest + from ansys.dpf import core as dpf -from ansys.dpf.core.elements import element_types from ansys.dpf.core import mesh_scoping_factory +from ansys.dpf.core.elements import element_types +import conftest @pytest.fixture() diff --git a/tests/test_factories.py b/tests/test_factories.py index 7cad6be157..7b1d84a050 100644 --- a/tests/test_factories.py +++ b/tests/test_factories.py @@ -23,14 +23,16 @@ import numpy as np import pytest -from ansys.dpf.core import Model -from ansys.dpf.core import errors as dpf_errors -from ansys.dpf.core import fields_container_factory -from ansys.dpf.core import fields_factory -from ansys.dpf.core import mesh_scoping_factory -from ansys.dpf.core import server -from ansys.dpf.core import server_factory -from ansys.dpf.core import time_freq_scoping_factory +from ansys.dpf.core import ( + Model, + errors as dpf_errors, + fields_container_factory, + fields_factory, + mesh_scoping_factory, + server, + server_factory, + time_freq_scoping_factory, +) from ansys.dpf.core.common import locations diff --git a/tests/test_field.py b/tests/test_field.py index a25b768313..fa77deec0b 100644 --- a/tests/test_field.py +++ b/tests/test_field.py @@ -20,18 +20,19 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import numpy as np -import pytest import copy import gc + +import numpy as np +import pytest + from ansys import dpf -import conftest from ansys.dpf import core -from ansys.dpf.core import FieldDefinition -from ansys.dpf.core import operators as ops -from ansys.dpf.core.common import locations, shell_layers -from conftest import running_docker, SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0 +from ansys.dpf.core import FieldDefinition, operators as ops from ansys.dpf.core.check_version import server_meet_version +from ansys.dpf.core.common import locations, shell_layers +import conftest +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0, running_docker @pytest.fixture() diff --git a/tests/test_fieldscontainer.py b/tests/test_fieldscontainer.py index 0fd8434030..325fdb4da3 100644 --- a/tests/test_fieldscontainer.py +++ b/tests/test_fieldscontainer.py @@ -20,24 +20,28 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import os import weakref import numpy as np import pytest -import os -import conftest -from ansys.dpf.core.check_version import server_meet_version from ansys.dpf import core as dpf -from ansys.dpf.core import FieldsContainer, Field, TimeFreqSupport -from ansys.dpf.core import errors as dpf_errors -from ansys.dpf.core import examples -from ansys.dpf.core import fields_factory -from ansys.dpf.core import operators as ops +from ansys.dpf.core import ( + Field, + FieldsContainer, + TimeFreqSupport, + errors as dpf_errors, + examples, + fields_factory, + operators as ops, +) +from ansys.dpf.core.check_version import server_meet_version from ansys.dpf.core.custom_fields_container import ( - ElShapeFieldsContainer, BodyFieldsContainer, + ElShapeFieldsContainer, ) +import conftest @pytest.fixture() diff --git a/tests/test_generic_data_container.py b/tests/test_generic_data_container.py index d9de81feeb..4aae6fb233 100644 --- a/tests/test_generic_data_container.py +++ b/tests/test_generic_data_container.py @@ -21,15 +21,15 @@ # SOFTWARE. import numpy as np +import pytest from ansys.dpf import core as dpf +import conftest from conftest import ( SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0, raises_for_servers_version_under, ) -import pytest -import conftest @conftest.raises_for_servers_version_under("7.0") diff --git a/tests/test_genericsupport.py b/tests/test_genericsupport.py index 4b98379568..1e287d175f 100644 --- a/tests/test_genericsupport.py +++ b/tests/test_genericsupport.py @@ -20,8 +20,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import conftest from ansys.dpf import core as dpf +import conftest @conftest.raises_for_servers_version_under("5.0") diff --git a/tests/test_geometry.py b/tests/test_geometry.py index 3153bf62f2..d7d5dffd28 100644 --- a/tests/test_geometry.py +++ b/tests/test_geometry.py @@ -24,22 +24,22 @@ import pytest from ansys.dpf.core.geometry import ( - Points, Line, Plane, - normalize_vector, - get_plane_local_axis, - get_local_coords_from_global, + Points, get_global_coords_from_local, + get_local_coords_from_global, + get_plane_local_axis, + normalize_vector, ) from ansys.dpf.core.geometry_factory import ( - create_points, create_line_from_points, create_line_from_vector, create_plane_from_center_and_normal, - create_plane_from_points, create_plane_from_lines, create_plane_from_point_and_line, + create_plane_from_points, + create_points, get_center_from_coords, ) diff --git a/tests/test_hdf5.py b/tests/test_hdf5.py index b42cfa8e40..ce3e9e2806 100644 --- a/tests/test_hdf5.py +++ b/tests/test_hdf5.py @@ -22,7 +22,6 @@ from ansys.dpf import core - # try: # core.BaseService(load_operators=False)._load_hdf5_operators() # hdf5_loaded = True diff --git a/tests/test_incremental.py b/tests/test_incremental.py index db49c51294..25e25f47bb 100644 --- a/tests/test_incremental.py +++ b/tests/test_incremental.py @@ -20,10 +20,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from ansys.dpf import core -from ansys.dpf.core import common import numpy as np import pytest + +from ansys.dpf import core +from ansys.dpf.core import common import conftest diff --git a/tests/test_launcher.py b/tests/test_launcher.py index ad5a6e9fc2..f8569cd54d 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -20,19 +20,20 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import io import os from pathlib import Path - -import pytest -import psutil import subprocess import sys -import io + +import psutil +import pytest + from ansys.dpf import core from conftest import ( SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_4_0, - configsserver_type, config_namesserver_type, + configsserver_type, running_docker, ) @@ -217,9 +218,10 @@ def test_launch_server_full_path(self, server_config): @pytest.mark.skipif(running_docker, reason="Not made to work on docker") def test_start_local_failed_executable(remote_config_server_type): - from ansys.dpf.core.misc import get_ansys_path from pathlib import Path + from ansys.dpf.core.misc import get_ansys_path + with pytest.raises(FileNotFoundError): path = Path(get_ansys_path()).parent.absolute() core.start_local_server(ansys_path=str(path), config=remote_config_server_type) diff --git a/tests/test_launcher_remote.py b/tests/test_launcher_remote.py index a05d7b3205..31b8734913 100644 --- a/tests/test_launcher_remote.py +++ b/tests/test_launcher_remote.py @@ -23,12 +23,12 @@ import sys from unittest.mock import create_autospec -import ansys.platform.instancemanagement as pypim import grpc import pytest from ansys.dpf.core import server_types from ansys.dpf.core.server_factory import ServerFactory +import ansys.platform.instancemanagement as pypim from conftest import running_docker @@ -38,7 +38,7 @@ def test_start_remote(monkeypatch): # Start a local DPF server and create a mock PyPIM pretending it is starting it from ansys.dpf import core - from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols + from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig conf = ServerConfig(protocol=CommunicationProtocols.gRPC, legacy=True) local_server = core.start_local_server(as_global=False, config=conf) diff --git a/tests/test_local_server.py b/tests/test_local_server.py index 2acb6741a9..48a5e8a52d 100644 --- a/tests/test_local_server.py +++ b/tests/test_local_server.py @@ -22,8 +22,8 @@ import numpy as np -from ansys.dpf.core import operators as ops from ansys import dpf +from ansys.dpf.core import operators as ops def test_add_operator_server_field(local_server): diff --git a/tests/test_lsdyna.py b/tests/test_lsdyna.py index 6de8729f8d..4e746aae3b 100644 --- a/tests/test_lsdyna.py +++ b/tests/test_lsdyna.py @@ -22,9 +22,10 @@ import numpy as np import pytest -import conftest + from ansys.dpf import core as dpf from ansys.dpf.core.check_version import server_meet_version +import conftest @pytest.mark.skipif( diff --git a/tests/test_mesh_info.py b/tests/test_mesh_info.py index 5c11532179..8b449d7901 100644 --- a/tests/test_mesh_info.py +++ b/tests/test_mesh_info.py @@ -20,13 +20,14 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import ansys.dpf.core.generic_data_container +import pytest + from ansys.dpf import core as dpf +from ansys.dpf.core import examples +import ansys.dpf.core.generic_data_container from conftest import ( SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, ) -import pytest -from ansys.dpf.core import examples @pytest.mark.skipif( diff --git a/tests/test_meshescontainer.py b/tests/test_meshescontainer.py index 8ce6112244..7fd2d69d69 100644 --- a/tests/test_meshescontainer.py +++ b/tests/test_meshescontainer.py @@ -26,9 +26,9 @@ import pytest -import conftest from ansys import dpf from ansys.dpf.core import MeshesContainer +import conftest # TO DO: add server type diff --git a/tests/test_meshregion.py b/tests/test_meshregion.py index a47dff7ac8..d4f2574efe 100644 --- a/tests/test_meshregion.py +++ b/tests/test_meshregion.py @@ -25,8 +25,8 @@ import vtk from ansys import dpf -import conftest from ansys.dpf.core.check_version import server_meet_version +import conftest @pytest.fixture() diff --git a/tests/test_model.py b/tests/test_model.py index 54567769ce..b6122ffd30 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -27,9 +27,9 @@ from ansys import dpf from ansys.dpf.core import examples, misc +from ansys.dpf.core.check_version import server_meet_version from ansys.dpf.core.errors import ServerTypeError from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_4_0 -from ansys.dpf.core.check_version import server_meet_version NO_PLOTTING = True diff --git a/tests/test_multi_server.py b/tests/test_multi_server.py index 53e5ee21e0..5778822941 100644 --- a/tests/test_multi_server.py +++ b/tests/test_multi_server.py @@ -22,11 +22,11 @@ import numpy as np import pytest -import conftest from ansys.dpf import core as dpf -from ansys.dpf.core import examples, server_types, server -from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols +from ansys.dpf.core import examples, server, server_types +from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig +import conftest if conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_6_0: dpf.set_default_server_context(dpf.AvailableServerContexts.entry) diff --git a/tests/test_operator.py b/tests/test_operator.py index 381ec03a88..bee55564dd 100644 --- a/tests/test_operator.py +++ b/tests/test_operator.py @@ -20,21 +20,20 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import copy import gc import os +from pathlib import Path import shutil import types import weakref -from pathlib import Path import numpy import numpy as np import pytest -import copy from ansys import dpf -from ansys.dpf.core import errors -from ansys.dpf.core import operators as ops +from ansys.dpf.core import errors, operators as ops from ansys.dpf.core.common import derived_class_name_to_type, record_derived_class from ansys.dpf.core.custom_container_base import CustomContainerBase from ansys.dpf.core.misc import get_ansys_path diff --git a/tests/test_parallel.py b/tests/test_parallel.py index d8e4b53efa..441045016e 100644 --- a/tests/test_parallel.py +++ b/tests/test_parallel.py @@ -26,8 +26,9 @@ """ import pytest -from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_4_0 + from ansys.dpf import core as dpf +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_4_0 @pytest.mark.skipif( diff --git a/tests/test_pathsupport.py b/tests/test_pathsupport.py index bde98c0f1b..11d67992cd 100644 --- a/tests/test_pathsupport.py +++ b/tests/test_pathsupport.py @@ -21,13 +21,14 @@ # SOFTWARE. # Tests specific to pathlib.Path support as path argument instead of str -import pytest import functools import os -from conftest import running_docker +from pathlib import Path + +import pytest from ansys import dpf -from pathlib import Path +from conftest import running_docker skip_always = pytest.mark.skipif(True, reason="Investigate why this is failing") diff --git a/tests/test_plotter.py b/tests/test_plotter.py index 8129a87744..ce39cc3173 100644 --- a/tests/test_plotter.py +++ b/tests/test_plotter.py @@ -26,17 +26,15 @@ from ansys import dpf from ansys.dpf import core -from ansys.dpf.core import Model, Operator -from ansys.dpf.core import errors as dpf_errors -from ansys.dpf.core import misc +from ansys.dpf.core import Model, Operator, element_types, errors as dpf_errors, misc from ansys.dpf.core.plotter import plot_chart -from conftest import running_docker, SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0 -from ansys.dpf.core import element_types +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, running_docker if misc.module_exists("pyvista"): HAS_PYVISTA = True - from ansys.dpf.core.plotter import DpfPlotter, Plotter from pyvista.plotting.renderer import CameraPosition # noqa: F401 + + from ansys.dpf.core.plotter import DpfPlotter, Plotter else: HAS_PYVISTA = False diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 7ba5bbadec..506e552039 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -24,9 +24,9 @@ import pytest -from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0 from ansys.dpf import core as dpf from ansys.dpf.core import examples +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0 @pytest.fixture() diff --git a/tests/test_property_fields_container.py b/tests/test_property_fields_container.py index 104ede4bb8..5c8525b4aa 100644 --- a/tests/test_property_fields_container.py +++ b/tests/test_property_fields_container.py @@ -22,8 +22,8 @@ import pytest -from ansys.dpf.core.property_fields_container import _MockPropertyFieldsContainer, _LabelSpaceKV from ansys.dpf import core as dpf +from ansys.dpf.core.property_fields_container import _LabelSpaceKV, _MockPropertyFieldsContainer def test_property_fields_container(allkindofcomplexity, server_type): diff --git a/tests/test_propertyfield.py b/tests/test_propertyfield.py index c086802dae..031d1e9c69 100644 --- a/tests/test_propertyfield.py +++ b/tests/test_propertyfield.py @@ -20,15 +20,16 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import numpy as np -import pytest import copy -import conftest import gc +import numpy as np +import pytest + from ansys import dpf from ansys.dpf import core from ansys.dpf.core.common import locations, natures +import conftest @pytest.fixture() diff --git a/tests/test_python_plugins.py b/tests/test_python_plugins.py index 25d75b39d1..a13892612f 100644 --- a/tests/test_python_plugins.py +++ b/tests/test_python_plugins.py @@ -20,23 +20,25 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import pytest import os from pathlib import Path import platform + import numpy as np -from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_4_0 +import pytest + from ansys.dpf import core as dpf -import conftest from ansys.dpf.core.custom_operator import update_virtual_environment_for_custom_operators from ansys.dpf.core.errors import DPFServerException from ansys.dpf.core.operator_specification import ( - CustomSpecification, - SpecificationProperties, CustomConfigOptionSpec, + CustomSpecification, PinSpecification, + SpecificationProperties, ) +import conftest from conftest import ( + SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_4_0, SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, ) diff --git a/tests/test_remote_operator.py b/tests/test_remote_operator.py index f596e8aded..29b2f252f3 100644 --- a/tests/test_remote_operator.py +++ b/tests/test_remote_operator.py @@ -21,11 +21,12 @@ # SOFTWARE. import numpy as np -from conftest import local_servers -import conftest +import pytest + from ansys.dpf import core from ansys.dpf.core import operators as ops -import pytest +import conftest +from conftest import local_servers @pytest.mark.skipif( diff --git a/tests/test_remote_workflow.py b/tests/test_remote_workflow.py index 096d37aa10..3d893eec51 100644 --- a/tests/test_remote_workflow.py +++ b/tests/test_remote_workflow.py @@ -26,11 +26,10 @@ import pytest from ansys.dpf import core -from ansys.dpf.core import examples +from ansys.dpf.core import examples, operators as ops from ansys.dpf.core.errors import ServerTypeError -from ansys.dpf.core import operators as ops -from conftest import local_servers, running_docker import conftest +from conftest import local_servers, running_docker @pytest.mark.xfail(raises=ServerTypeError) diff --git a/tests/test_scoping.py b/tests/test_scoping.py index 90990aedeb..8822f36a6c 100644 --- a/tests/test_scoping.py +++ b/tests/test_scoping.py @@ -20,15 +20,15 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import copy + import numpy as np import pytest from ansys import dpf +from ansys.dpf.core import Scoping, errors as dpf_errors import conftest from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_2_0 -import copy -from ansys.dpf.core import Scoping -from ansys.dpf.core import errors as dpf_errors def test_create_scoping(): diff --git a/tests/test_scopingscontainer.py b/tests/test_scopingscontainer.py index 558983faac..70c860ff8b 100644 --- a/tests/test_scopingscontainer.py +++ b/tests/test_scopingscontainer.py @@ -23,11 +23,11 @@ # -*- coding: utf-8 -*- import weakref -import pytest import numpy as np +import pytest -import conftest from ansys.dpf.core import Scoping, ScopingsContainer +import conftest @pytest.fixture() diff --git a/tests/test_server.py b/tests/test_server.py index b852f583f7..b58b90f2c3 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -20,28 +20,32 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import time - -import pytest -import subprocess +import os import platform -import psutil +import subprocess import sys -import os +import time + import packaging.version +import psutil +import pytest from ansys import dpf -from ansys.dpf.core import errors, server_types -from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols -from ansys.dpf.core.server import set_server_configuration, _global_server -from ansys.dpf.core.server import start_local_server, connect_to_server -from ansys.dpf.core.server import shutdown_all_session_servers, has_local_server -from ansys.dpf.core.server import get_or_create_server -from ansys.dpf.core import server +from ansys.dpf.core import errors, server, server_types +from ansys.dpf.core.server import ( + _global_server, + connect_to_server, + get_or_create_server, + has_local_server, + set_server_configuration, + shutdown_all_session_servers, + start_local_server, +) +from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig from conftest import ( SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_4_0, - running_docker, remove_none_available_config, + running_docker, ) server_configs, server_configs_names = remove_none_available_config( diff --git a/tests/test_service.py b/tests/test_service.py index c246aa2b38..69b9503e99 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -20,19 +20,18 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import datetime +from importlib import reload import os from pathlib import Path - -import pytest -import conftest import pkgutil -import datetime import platform -from importlib import reload + +import pytest from ansys import dpf -from ansys.dpf.core import path_utilities -from ansys.dpf.core import examples +from ansys.dpf.core import examples, path_utilities +import conftest from conftest import running_docker @@ -295,7 +294,7 @@ def test_dpf_join(server_type): reason="GrpcServer class is " "supported starting server version 4.0", ) def test_load_api_without_awp_root(restore_awp_root): - from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols + from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig legacy_conf = ServerConfig(protocol=CommunicationProtocols.gRPC, legacy=True) loc_serv = dpf.core.start_local_server(config=legacy_conf, as_global=False) @@ -328,7 +327,7 @@ def test_load_api_without_awp_root(restore_awp_root): ) def test_load_api_with_awp_root(): # with awp_root - from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols + from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig conf = ServerConfig(protocol=CommunicationProtocols.gRPC, legacy=False) serv_2 = dpf.core.start_local_server(config=conf, as_global=False) @@ -346,7 +345,7 @@ def test_load_api_with_awp_root(): reason="GrpcServer class is " "supported starting server version 4.0", ) def test_load_api_with_awp_root_2(): - from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols + from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig legacy_conf = ServerConfig(protocol=CommunicationProtocols.gRPC, legacy=True) loc_serv = dpf.core.start_local_server(config=legacy_conf, as_global=False) @@ -373,7 +372,7 @@ def test_load_api_with_awp_root_2(): reason="GrpcServer class is " "supported starting server version 4.0", ) def test_load_api_without_awp_root_no_gatebin(restore_awp_root): - from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols + from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig legacy_conf = ServerConfig(protocol=CommunicationProtocols.gRPC, legacy=True) loc_serv = dpf.core.start_local_server(config=legacy_conf, as_global=False) @@ -408,7 +407,7 @@ def test_load_api_without_awp_root_no_gatebin(restore_awp_root): ) def test_load_api_with_awp_root_no_gatebin(): # with awp_root - from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols + from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig conf = ServerConfig(protocol=CommunicationProtocols.gRPC, legacy=False) serv_2 = dpf.core.start_local_server(config=conf, as_global=False) @@ -430,7 +429,7 @@ def test_load_api_with_awp_root_no_gatebin(): reason="GrpcServer class is " "supported starting server version 4.0", ) def test_load_api_with_awp_root_2_no_gatebin(): - from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols + from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig legacy_conf = ServerConfig(protocol=CommunicationProtocols.gRPC, legacy=True) loc_serv = dpf.core.start_local_server(config=legacy_conf, as_global=False) diff --git a/tests/test_session.py b/tests/test_session.py index 868f5500ac..40ad0ff945 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -21,10 +21,11 @@ # SOFTWARE. from pathlib import Path -import conftest import tempfile + from ansys.dpf import core from ansys.dpf.core import examples +import conftest def get_log_file(log_path, server): diff --git a/tests/test_stringfield.py b/tests/test_stringfield.py index b4b081bb75..2bff28325b 100644 --- a/tests/test_stringfield.py +++ b/tests/test_stringfield.py @@ -21,11 +21,11 @@ # SOFTWARE. import numpy as np -import conftest from ansys import dpf from ansys.dpf import core from ansys.dpf.core.common import locations +import conftest @conftest.raises_for_servers_version_under("5.0") diff --git a/tests/test_timefreqsupport.py b/tests/test_timefreqsupport.py index 75e2447dfd..a8862fd95d 100644 --- a/tests/test_timefreqsupport.py +++ b/tests/test_timefreqsupport.py @@ -20,14 +20,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import weakref + import numpy as np import pytest -import weakref from ansys import dpf -from ansys.dpf.core import TimeFreqSupport, Model -from ansys.dpf.core import examples -from ansys.dpf.core import fields_factory +from ansys.dpf.core import Model, TimeFreqSupport, examples, fields_factory from ansys.dpf.core.common import locations import conftest @@ -319,8 +318,9 @@ def test_workflow_connect_get_output_time_freq_support(velocity_acceleration): @pytest.mark.skipif(True, reason="used to check memory leaks") def test_timefreqsupport_memory_leaks(): import gc + from ansys.dpf.core import start_local_server - from ansys.dpf.core.server_factory import ServerConfig, CommunicationProtocols + from ansys.dpf.core.server_factory import CommunicationProtocols, ServerConfig config = ServerConfig(protocol=CommunicationProtocols.gRPC, legacy=True) # config = ServerConfig(protocol=CommunicationProtocols.gRPC) diff --git a/tests/test_unit_systems.py b/tests/test_unit_systems.py index f62cc531b9..7f4b07e76f 100644 --- a/tests/test_unit_systems.py +++ b/tests/test_unit_systems.py @@ -21,9 +21,10 @@ # SOFTWARE. import pytest -import conftest + from ansys.dpf import core as dpf from ansys.dpf.core import errors as dpf_errors +import conftest @pytest.mark.skipif( diff --git a/tests/test_vtk_translate.py b/tests/test_vtk_translate.py index e7e70aa69a..cfb47d44e3 100644 --- a/tests/test_vtk_translate.py +++ b/tests/test_vtk_translate.py @@ -21,18 +21,19 @@ # SOFTWARE. import pytest -import conftest + import ansys.dpf.core as dpf from ansys.dpf.core import errors, misc from ansys.dpf.core.vtk_helper import ( - dpf_mesh_to_vtk, + append_field_to_grid, + append_fieldscontainer_to_grid, dpf_field_to_vtk, - dpf_meshes_to_vtk, dpf_fieldscontainer_to_vtk, + dpf_mesh_to_vtk, + dpf_meshes_to_vtk, dpf_property_field_to_vtk, - append_field_to_grid, - append_fieldscontainer_to_grid, ) +import conftest if misc.module_exists("pyvista"): HAS_PYVISTA = True diff --git a/tests/test_workflow.py b/tests/test_workflow.py index 58c4d480a0..1a89d98c6f 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -21,17 +21,17 @@ # SOFTWARE. from pathlib import Path +import platform import numpy import numpy as np import pytest -import platform +from ansys import dpf +from ansys.dpf.core import misc import ansys.dpf.core.operators as op from ansys.dpf.core.workflow_topology import WorkflowTopology import conftest -from ansys import dpf -from ansys.dpf.core import misc if misc.module_exists("graphviz"): HAS_GRAPHVIZ = True @@ -914,8 +914,8 @@ def test_create_on_other_server_and_connect_workflow(allkindofcomplexity, local_ def deep_copy_using_workflow(dpf_entity, server, stream_type=1): + from ansys.dpf.core.common import types, types_enum_to_types from ansys.dpf.core.operators.serialization import serializer_to_string, string_deserializer - from ansys.dpf.core.common import types_enum_to_types, types entity_server = dpf_entity._server if hasattr(dpf_entity, "_server") else None serializer_wf = dpf.core.Workflow(server=entity_server) diff --git a/tests/testfiles/pythonPlugins/all_types/dpf_types_op.py b/tests/testfiles/pythonPlugins/all_types/dpf_types_op.py index 14173dca17..1a47d4ea24 100644 --- a/tests/testfiles/pythonPlugins/all_types/dpf_types_op.py +++ b/tests/testfiles/pythonPlugins/all_types/dpf_types_op.py @@ -20,20 +20,20 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from ansys.dpf.core.custom_operator import CustomOperatorBase from ansys.dpf.core import ( + data_sources, + data_tree, field, - scoping, fields_container, + generic_data_container, meshes_container, - scopings_container, property_field, - data_sources, + scoping, + scopings_container, types, workflow, - data_tree, - generic_data_container, ) +from ansys.dpf.core.custom_operator import CustomOperatorBase class ForwardFieldOperator(CustomOperatorBase): diff --git a/tests/testfiles/pythonPlugins/all_types/integral_types_op.py b/tests/testfiles/pythonPlugins/all_types/integral_types_op.py index 8dd2b9a392..53c6e5242e 100644 --- a/tests/testfiles/pythonPlugins/all_types/integral_types_op.py +++ b/tests/testfiles/pythonPlugins/all_types/integral_types_op.py @@ -20,13 +20,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +from ansys.dpf.core import types from ansys.dpf.core.custom_operator import CustomOperatorBase from ansys.dpf.core.operator_specification import ( CustomSpecification, PinSpecification, SpecificationProperties, ) -from ansys.dpf.core import types class ForwardIntOperator(CustomOperatorBase): diff --git a/tests/testfiles/pythonPlugins/all_types/load_operators_func.py b/tests/testfiles/pythonPlugins/all_types/load_operators_func.py index e70c71f8b6..2c444b2afa 100644 --- a/tests/testfiles/pythonPlugins/all_types/load_operators_func.py +++ b/tests/testfiles/pythonPlugins/all_types/load_operators_func.py @@ -20,8 +20,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +from all_types import dpf_types_op, integral_types_op from ansys.dpf.core.custom_operator import record_operator -from all_types import integral_types_op, dpf_types_op def load_operators(*args): diff --git a/tests/testfiles/pythonPlugins/operator_with_spec.py b/tests/testfiles/pythonPlugins/operator_with_spec.py index 761f4e7eb8..4743ff0ae4 100644 --- a/tests/testfiles/pythonPlugins/operator_with_spec.py +++ b/tests/testfiles/pythonPlugins/operator_with_spec.py @@ -20,12 +20,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from ansys.dpf.core.custom_operator import CustomOperatorBase, record_operator from ansys.dpf.core import Field +from ansys.dpf.core.custom_operator import CustomOperatorBase, record_operator from ansys.dpf.core.operator_specification import ( CustomSpecification, - SpecificationProperties, PinSpecification, + SpecificationProperties, ) diff --git a/tests/testfiles/pythonPlugins/syntax_error_plugin/load_operators_func.py b/tests/testfiles/pythonPlugins/syntax_error_plugin/load_operators_func.py index bb6e9e0dfa..49a6ad997e 100644 --- a/tests/testfiles/pythonPlugins/syntax_error_plugin/load_operators_func.py +++ b/tests/testfiles/pythonPlugins/syntax_error_plugin/load_operators_func.py @@ -20,8 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from ansys.dpf.core.custom_operator import record_operator -from ansys.dpf.core.custom_operator import CustomOperatorBase +from ansys.dpf.core.custom_operator import CustomOperatorBase, record_operator class SyntaxeError(CustomOperatorBase):