From b6d27b191cd738adf63d4f79746c7e27c0ebb2e9 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Wed, 4 Dec 2024 10:21:17 +0100 Subject: [PATCH] fix: pyflake style --- .pre-commit-config.yaml | 2 +- .../09-averaging/00-compute_and_average.py | 4 +- src/ansys/dpf/core/core.py | 6 +- src/ansys/dpf/core/examples/__init__.py | 18 ++- src/ansys/dpf/core/inputs.py | 1 - tests/test_cyclic_support.py | 17 ++- tests/test_data_tree.py | 4 +- tests/test_datasources.py | 4 +- tests/test_field.py | 25 ---- tests/test_local_server.py | 110 ------------------ tests/test_model.py | 2 +- tests/test_multi_server.py | 4 +- tests/test_operator.py | 51 +------- tests/test_plotter.py | 16 +-- tests/test_plugins.py | 2 +- tests/test_resultinfo.py | 4 +- tests/test_scoping.py | 2 +- tests/test_server.py | 4 +- tests/test_service.py | 16 ++- tests/test_session.py | 2 +- tests/test_timefreqsupport.py | 8 +- tests/test_workflow.py | 34 ++---- .../pythonPlugins/all_types/__init__.py | 2 + .../syntax_error_plugin/__init__.py | 2 + 24 files changed, 81 insertions(+), 259 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fe93f07e7a..ecc086d361 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ exclude: > repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.7.3 + rev: v0.8.1 hooks: - id: ruff args: [--fix] diff --git a/examples/09-averaging/00-compute_and_average.py b/examples/09-averaging/00-compute_and_average.py index 7d284776f2..f37f39afc8 100644 --- a/examples/09-averaging/00-compute_and_average.py +++ b/examples/09-averaging/00-compute_and_average.py @@ -98,7 +98,7 @@ def compute_von_mises_then_average(analysis): # Create a model from the results of the simulation and retrieve its mesh model = dpf.Model(analysis) - mesh = model.metadata.meshed_region + model.metadata.meshed_region # Apply the stress operator to obtain the stresses in the body stress_op = dpf.operators.result.stress() @@ -135,7 +135,7 @@ def compute_von_mises_then_average(analysis): def average_then_compute_von_mises(analysis): # Creating the model from the results of the simulation model = dpf.Model(analysis) - mesh = model.metadata.meshed_region + model.metadata.meshed_region # Retrieving the stresses stress_op = dpf.operators.result.stress() diff --git a/src/ansys/dpf/core/core.py b/src/ansys/dpf/core/core.py index f7fbf6dadf..9fa06141ff 100644 --- a/src/ansys/dpf/core/core.py +++ b/src/ansys/dpf/core/core.py @@ -537,9 +537,9 @@ def release_dpf(self): Available with server's version starting at 6.0 (Ansys 2023R2). """ if self._server().has_client(): - error = self._api.data_processing_release_on_client(self._server().client, 1) + self._api.data_processing_release_on_client(self._server().client, 1) else: - error = self._api.data_processing_release(1) + self._api.data_processing_release(1) @version_requires("4.0") def get_runtime_core_config(self): @@ -667,7 +667,7 @@ def download_file(self, server_file_path, to_client_file_path): download service only available for server with gRPC communication protocol """ raise errors.ServerTypeError(txt) - client_path = self._api.data_processing_download_file( + self._api.data_processing_download_file( client=self._server().client, server_file_path=str(server_file_path), to_client_file_path=str(to_client_file_path), diff --git a/src/ansys/dpf/core/examples/__init__.py b/src/ansys/dpf/core/examples/__init__.py index 22caad3b60..b4f9283ee8 100644 --- a/src/ansys/dpf/core/examples/__init__.py +++ b/src/ansys/dpf/core/examples/__init__.py @@ -20,8 +20,19 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from .examples import * -from .downloads import * +from .examples import get_example_required_minimum_dpf_version, find_files, fluid_axial_model +from .downloads import ( + find_simple_bar, + find_static_rst, + find_complex_rst, + find_multishells_rst, + find_electric_therm, + find_steady_therm, + find_transient_therm, + find_msup_transient, + find_simple_cyclic, + find_distributed_msup_folder, +) # called if module. fails @@ -67,3 +78,6 @@ def __getattr__(name): distributed_msup_folder = find_distributed_msup_folder() return distributed_msup_folder raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + + +__all__ = ["get_example_required_minimum_dpf_version", "find_files", "fluid_axial_model"] diff --git a/src/ansys/dpf/core/inputs.py b/src/ansys/dpf/core/inputs.py index 1968212386..97739a9af2 100644 --- a/src/ansys/dpf/core/inputs.py +++ b/src/ansys/dpf/core/inputs.py @@ -241,7 +241,6 @@ def connect(self, inpt): elif isinstance(inpt, Path): inpt = str(inpt) - input_type_name = type(inpt).__name__ for input_pin in self._inputs: self._operator()._find_outputs_corresponding_pins( input_pin._python_expected_types, diff --git a/tests/test_cyclic_support.py b/tests/test_cyclic_support.py index bd19aae8f5..cd40df18a6 100644 --- a/tests/test_cyclic_support.py +++ b/tests/test_cyclic_support.py @@ -27,7 +27,6 @@ import conftest import pytest -from ansys import dpf from ansys.dpf import core as dpf @@ -105,7 +104,7 @@ def test_cyc_support_from_to_operator(cyclic_lin_rst, server_type): cyclic_support=cyc_support, server=server_type ) exp = op.outputs.cyclic_support() - mesh = op.outputs.meshed_region() + op.outputs.meshed_region() assert exp.num_sectors() == 15 assert exp.num_stages == 1 assert np.allclose( @@ -145,7 +144,7 @@ def test_cyc_support_from_to_workflow(cyclic_lin_rst, server_type): wf.set_output_name("sup", op.outputs.cyclic_support) wf.connect("sup", cyc_support) exp = wf.get_output("sup", dpf.types.cyclic_support) - mesh = op.outputs.meshed_region() + op.outputs.meshed_region() assert exp.num_sectors() == 15 assert exp.num_stages == 1 assert np.allclose( @@ -248,14 +247,14 @@ def test_delete_auto_cyc_support(cyclic_lin_rst): def test_cyc_support_memory_leaks(cyclic_lin_rst): import gc - for i in range(2000): + for _ in range(2000): gc.collect() data_sources = dpf.DataSources(cyclic_lin_rst) model = dpf.Model(data_sources) result_info = model.metadata.result_info cyc_support = result_info.cyclic_support - a = cyc_support.num_stages - b = cyc_support.num_sectors() - c = cyc_support.sectors_set_for_expansion() - d = cyc_support.base_elements_scoping() - e = cyc_support.base_nodes_scoping() + cyc_support.num_stages + cyc_support.num_sectors() + cyc_support.sectors_set_for_expansion() + cyc_support.base_elements_scoping() + cyc_support.base_nodes_scoping() diff --git a/tests/test_data_tree.py b/tests/test_data_tree.py index 08a660c31c..55604fdd86 100644 --- a/tests/test_data_tree.py +++ b/tests/test_data_tree.py @@ -93,7 +93,7 @@ def test_add_dict_data_tree(server_type): @conftest.raises_for_servers_version_under("4.0") def test_add_data_to_fill_data_tree(): data_tree = dpf.DataTree() - with data_tree.to_fill() as to_fill: + with data_tree.to_fill() as _: data_tree.int = 1 data_tree.double = 1.0 data_tree.string = "hello" @@ -412,7 +412,7 @@ def test_attribute_errors_data_tree(server_type): @conftest.raises_for_servers_version_under("4.0") def test_add_data_bool_data_tree(): data_tree = dpf.DataTree() - with data_tree.to_fill() as to_fill: + with data_tree.to_fill() as _: data_tree.int = 1 data_tree.bool = True assert data_tree.get_as("int", dpf.types.int) == 1 diff --git a/tests/test_datasources.py b/tests/test_datasources.py index f12b65647e..f8c27b1006 100644 --- a/tests/test_datasources.py +++ b/tests/test_datasources.py @@ -130,10 +130,10 @@ def test_print_data_sources(allkindofcomplexity, server_type): def test_data_sources_from_data_sources(allkindofcomplexity, server_type): with pytest.raises(ValueError) as e: - data_sources_false = dpf.core.DataSources(data_sources="Wrong Input", server=server_type) + dpf.core.DataSources(data_sources="Wrong Input", server=server_type) assert "gRPC data sources" in e data_sources = dpf.core.DataSources(server=server_type) - data_sources2 = dpf.core.DataSources(data_sources=data_sources, server=server_type) + dpf.core.DataSources(data_sources=data_sources, server=server_type) @pytest.mark.skipif( diff --git a/tests/test_field.py b/tests/test_field.py index 640ab83bfc..37092bbb31 100644 --- a/tests/test_field.py +++ b/tests/test_field.py @@ -976,31 +976,6 @@ def get_simple_field(server_clayer): return field -@conftest.raises_for_servers_version_under("4.0") -def test_mutable_entity_data_contiguous_field(server_clayer): - simple_field = get_simple_field(server_clayer) - vec = simple_field.get_entity_data(0) - assert np.allclose(vec, np.array(range(0, 6))) - - vec[0][0] = 1 - vec[0][5] = 4 - - assert np.allclose(vec, np.array([1, 1, 2, 3, 4, 4])) - - vec.commit() - - assert np.allclose(simple_field.get_entity_data(0), np.array([1, 1, 2, 3, 4, 4])) - - vec = simple_field.get_entity_data_by_id(2) - assert np.allclose(vec, np.array(range(6, 12))) - - vec[0][0] = 1 - vec[0][5] = 4 - assert np.allclose(vec, np.array([1, 7, 8, 9, 10, 4])) - vec = None - assert np.allclose(simple_field.get_entity_data_by_id(2), np.array([1, 7, 8, 9, 10, 4])) - - @pytest.mark.skipif( not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, reason="change in memory ownership in server 5.0", diff --git a/tests/test_local_server.py b/tests/test_local_server.py index 8a93df3d77..4d1fdd842f 100644 --- a/tests/test_local_server.py +++ b/tests/test_local_server.py @@ -227,113 +227,3 @@ def test_dot_operator_server_fields_container(local_server): out = add.outputs.fields_container() assert np.allclose(out[0].scoping.ids, [1, 2]) assert np.allclose(out[0].data, -field.data) - - -def test_add_operator_server_fields_container(local_server): - field = dpf.core.fields_factory.create_3d_vector_field(2, server=local_server) - field.data = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0] - field.scoping.ids = [1, 2] - - fc = dpf.core.fields_container_factory.over_time_freq_fields_container( - [field, field], server=local_server - ) - - # operator with field out - forward = ops.utility.forward_field(field, server=local_server) - add = fc + forward - assert type(add) == ops.math.add_fc - out = add.outputs.fields_container() - assert len(out) == 2 - assert np.allclose(out[0].scoping.ids, [1, 2]) - assert np.allclose(out[0].data, np.array(field.data) * 2.0) - - # fc + list - add = fc + [0.0, 1.0, 2.0] - assert type(add) == ops.math.add_fc - out = add.outputs.fields_container() - assert len(out) == 2 - assert np.allclose(out[0].scoping.ids, [1, 2]) - assert np.allclose(out[0].data, field.data + np.array([[0.0, 1.0, 2.0], [0.0, 1.0, 2.0]])) - - # fc + float - add = fc + 1.0 - assert type(add) == ops.math.add_fc - out = add.outputs.fields_container() - assert np.allclose(out[0].scoping.ids, [1, 2]) - assert np.allclose(out[0].data, np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])) - - -def test_minus_operator_server_fields_container(local_server): - field = dpf.core.fields_factory.create_3d_vector_field(2, server=local_server) - field.data = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0] - field.scoping.ids = [1, 2] - - fc = dpf.core.fields_container_factory.over_time_freq_fields_container( - [field, field], server=local_server - ) - - # operator with field out - forward = ops.utility.forward_field(field, server=local_server) - add = fc - forward - assert type(add) == ops.math.minus_fc - out = add.outputs.fields_container() - assert len(out) == 2 - assert np.allclose(out[0].scoping.ids, [1, 2]) - assert np.allclose(out[0].data, np.zeros((2, 3))) - - # fc - list - add = fc - [0.0, 1.0, 2.0] - assert type(add) == ops.math.minus_fc - out = add.outputs.fields_container() - assert len(out) == 2 - assert np.allclose(out[0].scoping.ids, [1, 2]) - assert np.allclose(out[0].data, np.array([[0.0, 0.0, 0.0], [3.0, 3.0, 3.0]])) - - # fc - float - add = fc - 1.0 - assert type(add) == ops.math.minus_fc - out = add.outputs.fields_container() - assert np.allclose(out[0].scoping.ids, [1, 2]) - assert np.allclose(out[0].data, np.array([[-1.0, 0.0, 1.0], [2.0, 3.0, 4.0]])) - - -def test_dot_operator_server_fields_container(local_server): - field = dpf.core.fields_factory.create_3d_vector_field(2, server=local_server) - field.data = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0] - field.scoping.ids = [1, 2] - - fc = dpf.core.fields_container_factory.over_time_freq_fields_container( - [field, field], server=local_server - ) - - # fc * op - forward = ops.utility.forward_field(field, server=local_server) - add = fc * forward - assert type(add) == ops.math.generalized_inner_product_fc - out = add.outputs.fields_container() - assert len(out) == 2 - assert np.allclose(out[0].scoping.ids, [1, 2]) - assert np.allclose(out[0].data, np.array([5.0, 50.0])) - - # fc * field - add = fc * field - assert type(add) == ops.math.generalized_inner_product_fc - out = add.outputs.fields_container() - assert len(out) == 2 - assert np.allclose(out[0].scoping.ids, [1, 2]) - assert np.allclose(out[0].data, np.array([5.0, 50.0])) - - # fc * list - add = fc * [0.0, 1.0, 2.0] - assert type(add) == ops.math.generalized_inner_product_fc - out = add.outputs.fields_container() - assert len(out) == 2 - assert np.allclose(out[0].scoping.ids, [1, 2]) - assert np.allclose(out[0].data, np.array([5.0, 14.0])) - - # fc * float - add = fc * -1.0 - assert type(add) == ops.math.generalized_inner_product_fc - out = add.outputs.fields_container() - assert np.allclose(out[0].scoping.ids, [1, 2]) - assert np.allclose(out[0].data, -field.data) diff --git a/tests/test_model.py b/tests/test_model.py index e134af8d8f..317ec42f2a 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -234,7 +234,7 @@ def test_result_not_dynamic(plate_msup): assert len(fc) == 2 assert np.allclose(fc.time_freq_support.time_frequencies.data, np.array([0.115, 0.125])) assert fc[0].unit == "Pa" - dis = model.results.displacement().eval() + model.results.displacement().eval() dpf.core.settings.set_dynamic_available_results_capability(True) diff --git a/tests/test_multi_server.py b/tests/test_multi_server.py index c8a879df72..7d05a10a22 100644 --- a/tests/test_multi_server.py +++ b/tests/test_multi_server.py @@ -192,7 +192,7 @@ def test_model_cyc_support_multi_server(cyc_models): def test_model_displacement_multi_server(transient_models): - tf = transient_models[0].metadata.time_freq_support + transient_models[0].metadata.time_freq_support time_scoping = range(1, 3) disp = transient_models[0].results.displacement() disp.inputs.time_scoping(time_scoping) @@ -226,7 +226,7 @@ def check_fc(fc, fc2): def test_model_stress_multi_server(transient_models): - tf = transient_models[0].metadata.time_freq_support + transient_models[0].metadata.time_freq_support time_scoping = range(1, 3) disp = transient_models[0].results.stress() disp.inputs.time_scoping(time_scoping) diff --git a/tests/test_operator.py b/tests/test_operator.py index 356295d9db..6eb90fdb27 100644 --- a/tests/test_operator.py +++ b/tests/test_operator.py @@ -573,7 +573,7 @@ def test_inputs_outputs_meshes_container(allkindofcomplexity): opsc = dpf.core.Operator("scoping::by_property") opsc.inputs.mesh.connect(model.metadata.meshed_region) - sc = opsc.outputs.mesh_scoping() + opsc.outputs.mesh_scoping() stress = model.results.stress() stress.inputs.connect(op.outputs) @@ -838,17 +838,6 @@ def test_connect_result2(plate_msup, server_type): assert len(out) == len(out2) -@pytest.mark.skipif( - not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_3_0, - reason="Bug in server version lower than 3.0", -) -def test_connect_get_output_int_list_operator(server_type): - d = list(range(0, 1000000)) - op = dpf.core.operators.utility.forward(d, server=server_type) - d_out = op.get_output(0, dpf.core.types.vec_int) - assert np.allclose(d, d_out) - - @pytest.mark.skipif( not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_3_0, reason="Bug in server version lower than 3.0", @@ -1166,7 +1155,7 @@ def test_get_static_spec_operator_in_proc(server_clayer): spec = dpf.core.Operator.operator_specification(name, server=server_clayer) assert len(spec.operator_name) > 0 l = len(spec.inputs) - d = spec.description + spec.description @conftest.raises_for_servers_version_under("3.0") @@ -1201,40 +1190,6 @@ def test_with_progress_operator_in_proc(allkindofcomplexity, server_clayer): assert len(fc) == 2 -@conftest.raises_for_servers_version_under("3.0") -def test_list_operators(server_type_legacy_grpc): - l = dpf.core.dpf_operator.available_operator_names(server=server_type_legacy_grpc) - assert len(l) > 400 - assert "merge::result_info" in l - assert "unit_convert" in l - assert "stream_provider" in l - - -@conftest.raises_for_servers_version_under("3.0") -def test_get_static_spec_operator(server_type_legacy_grpc): - l = dpf.core.dpf_operator.available_operator_names(server=server_type_legacy_grpc) - for i, name in enumerate(l): - spec = dpf.core.Operator.operator_specification(name, server=server_type_legacy_grpc) - assert len(spec.operator_name) > 0 - assert len(spec.inputs) > 0 - assert len(spec.description) > 0 - - -@conftest.raises_for_servers_version_under("3.0") -def test_with_progress_operator(allkindofcomplexity, server_type): - model = dpf.core.Model(allkindofcomplexity, server=server_type) - op = model.results.stress() - op.inputs.read_cyclic(3) - opnorm = dpf.core.operators.averaging.to_nodal_fc(op, server=server_type) - add = dpf.core.operators.math.add_fc(opnorm, opnorm, server=server_type) - add2 = dpf.core.operators.math.add_fc(add, add, server=server_type) - add3 = dpf.core.operators.math.add_fc(add2, server=server_type) - add4 = dpf.core.operators.math.add_fc(add3, add3, server=server_type) - add4.progress_bar = True - fc = add4.outputs.fields_container() - assert len(fc) == 2 - - def test_operator_specification_simple(server_type): spec = Specification(operator_name="U", server=server_type) assert "displacement" in spec.description @@ -1318,7 +1273,7 @@ def test_delete_operator(server_type): def test_memory_outputs_operator(allkindofcomplexity): model = dpf.core.Model(allkindofcomplexity) - mesh = model.metadata.meshed_region + model.metadata.meshed_region stress_fc = model.results.stress().eqv().eval() assert len(stress_fc) == 2 diff --git a/tests/test_plotter.py b/tests/test_plotter.py index 577bda5fb9..e3511067cc 100644 --- a/tests/test_plotter.py +++ b/tests/test_plotter.py @@ -127,7 +127,7 @@ def test_plotter_on_fields_container_elemental(allkindofcomplexity): avg_op.inputs.fields_container.connect(stress.outputs.fields_container) fc = avg_op.outputs.fields_container() pl = Plotter(model.metadata.meshed_region) - cpos = pl.plot_contour(fc) + pl.plot_contour(fc) @pytest.mark.skipif(not HAS_PYVISTA, reason="Please install pyvista") @@ -139,7 +139,7 @@ def test_plotter_on_fields_container_nodal(allkindofcomplexity): avg_op.inputs.fields_container.connect(stress.outputs.fields_container) fc = avg_op.outputs.fields_container() pl = Plotter(model.metadata.meshed_region) - cpos = pl.plot_contour(fc) + pl.plot_contour(fc) @pytest.mark.skipif(not HAS_PYVISTA, reason="Please install pyvista") @@ -169,7 +169,7 @@ def test_fields_container_plot(allkindofcomplexity): @pytest.mark.skipif(not HAS_PYVISTA, reason="Please install pyvista") def test_field_elemental_plot(allkindofcomplexity): model = Model(allkindofcomplexity) - mesh = model.metadata.meshed_region + model.metadata.meshed_region stress = model.results.stress() stress.inputs.requested_location.connect("Elemental") avg_op = Operator("to_elemental_fc") @@ -182,7 +182,7 @@ def test_field_elemental_plot(allkindofcomplexity): @pytest.mark.skipif(not HAS_PYVISTA, reason="Please install pyvista") def test_field_nodal_plot(allkindofcomplexity): model = Model(allkindofcomplexity) - mesh = model.metadata.meshed_region + model.metadata.meshed_region stress = model.results.stress() stress.inputs.requested_location.connect("Elemental") avg_op = Operator("to_nodal_fc") @@ -200,7 +200,7 @@ def test_field_nodal_plot(allkindofcomplexity): @pytest.mark.skipif(not HAS_PYVISTA, reason="Please install pyvista") def test_field_solid_plot(allkindofcomplexity): model = Model(allkindofcomplexity) - mesh = model.metadata.meshed_region + model.metadata.meshed_region stress = model.results.stress() stress.inputs.requested_location.connect("Nodal") fc = stress.outputs.fields_container() @@ -211,7 +211,7 @@ def test_field_solid_plot(allkindofcomplexity): @pytest.mark.skipif(not HAS_PYVISTA, reason="Please install pyvista") def test_field_shell_plot(allkindofcomplexity): model = Model(allkindofcomplexity) - mesh = model.metadata.meshed_region + model.metadata.meshed_region stress = model.results.stress() stress.inputs.requested_location.connect("Nodal") fc = stress.outputs.fields_container() @@ -222,7 +222,7 @@ def test_field_shell_plot(allkindofcomplexity): @pytest.mark.skipif(not HAS_PYVISTA, reason="Please install pyvista") def test_field_solid_plot_scoping_nodal(multishells): model = core.Model(multishells) - mesh = model.metadata.meshed_region + model.metadata.meshed_region stress = model.results.stress() stress.inputs.requested_location.connect("Nodal") scoping = core.Scoping() @@ -240,7 +240,7 @@ def test_field_solid_plot_scoping_nodal(multishells): @pytest.mark.skipif(not HAS_PYVISTA, reason="Please install pyvista") def test_field_shell_plot_scoping_elemental(multishells): model = core.Model(multishells) - mesh = model.metadata.meshed_region + model.metadata.meshed_region stress = model.results.stress() scoping = core.Scoping() scoping.location = "Elemental" diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 55b2f34a86..6b5308d33e 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -125,7 +125,7 @@ def test_vtk(server_type, tmpdir): op.inputs.fields1.connect(u) op.inputs.mesh.connect(model.metadata.mesh_provider) op.inputs.directory.connect(os.path.dirname(rst_file)) - out_path = op.eval() + op.eval() # assert out_path.result_files is not [] # try: # out_path = dpf.core.download_file( diff --git a/tests/test_resultinfo.py b/tests/test_resultinfo.py index 516322bafc..99687afc04 100644 --- a/tests/test_resultinfo.py +++ b/tests/test_resultinfo.py @@ -180,8 +180,8 @@ def test_result_info_memory_leaks(model): res = metadata.result_info # Still leaking, but maybe from the Operator.connect # in Metadata._load_result_info() - u = res.unit_system_name - c = res.cyclic_support + res.unit_system_name + res.cyclic_support # v = res.solver_version # date = res.solver_date # time = res.solver_time diff --git a/tests/test_scoping.py b/tests/test_scoping.py index c1cd39db59..68f6eda910 100644 --- a/tests/test_scoping.py +++ b/tests/test_scoping.py @@ -163,7 +163,7 @@ def test_delete_scoping(server_type): scop = Scoping(server=server_type) del scop with pytest.raises(Exception): - scop.ids + scop.ids # noqa: F821 @pytest.mark.skipif( diff --git a/tests/test_server.py b/tests/test_server.py index 4ee2a0b49c..4af6eb409f 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -160,13 +160,13 @@ def test_available_api_types(self, server_config): set_server_configuration(server_config) server = get_or_create_server(None) assert has_local_server() - types = server.available_api_types + server.available_api_types def test_client(self, server_config): set_server_configuration(server_config) server = get_or_create_server(None) assert has_local_server() - client = server.client + server.client @pytest.mark.skipif( diff --git a/tests/test_service.py b/tests/test_service.py index f654323558..cb49dd74c1 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -136,10 +136,10 @@ def test_download_with_subdir(multishells, tmpdir, server_type_remote_process): filename = ntpath.basename(file) parent_path = os.path.dirname(file) to_server_path = parent_path + separator + "subdir" + separator + filename - subdir_filepath = dpf.core.upload_file(file, to_server_path, server=server_type_remote_process) + dpf.core.upload_file(file, to_server_path, server=server_type_remote_process) folder = parent_path - out = dpf.core.download_files_in_folder(folder, tmpdir, server=server_type_remote_process) + dpf.core.download_files_in_folder(folder, tmpdir, server=server_type_remote_process) p1 = os.path.join(tmpdir, filename) p2 = os.path.join(tmpdir, "subdir", filename) # p1 = tmpdir + "/" + filename @@ -174,9 +174,7 @@ def test_downloadinfolder_uploadinfolder(multishells, tmpdir, server_type_remote # download it new_tmpdir = os.path.join(tmpdir, "my_tmp_dir") os.mkdir(new_tmpdir) - out = dpf.core.download_files_in_folder( - TARGET_PATH, new_tmpdir, server=server_type_remote_process - ) + dpf.core.download_files_in_folder(TARGET_PATH, new_tmpdir, server=server_type_remote_process) # check if the architecture of the download is ok path1_check = os.path.join(new_tmpdir, os.path.basename(multishells)) path2_check = os.path.join(new_tmpdir, "subdirA", os.path.basename(multishells)) @@ -524,7 +522,7 @@ def test_server_without_context(remote_config_server_type): ) @conftest.raises_for_servers_version_under("6.0") def test_release_dpf(server_type): - op = dpf.core.Operator("expansion::modal_superposition", server=server_type) + dpf.core.Operator("expansion::modal_superposition", server=server_type) server_type.release() with pytest.raises((KeyError, dpf.core.errors.DPFServerException)): @@ -540,7 +538,7 @@ def test_license_context_manager_as_context(server_type): op.inputs.field(field) op.inputs.threshold(0.0) with dpf.core.LicenseContextManager(server=server_type) as lic: - out = op.outputs.field() + op.outputs.field() st = lic.status assert len(st) != 0 @@ -549,7 +547,7 @@ def test_license_context_manager_as_context(server_type): lic = dpf.core.LicenseContextManager(server=server_type) op.inputs.field(field) op.inputs.threshold(0.0) - out = op.outputs.field() + op.outputs.field() new_st = lic.status assert str(new_st) == str(st) lic = None @@ -560,7 +558,7 @@ def test_license_context_manager_as_context(server_type): with dpf.core.LicenseContextManager( increment_name="ansys", license_timeout_in_seconds=1.0, server=server_type ) as lic: - out = op.outputs.field() + op.outputs.field() st = lic.status assert "ansys" in st st = lic.status diff --git a/tests/test_session.py b/tests/test_session.py index b9b4e8074d..0111aecf8d 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -53,7 +53,7 @@ def test_logging(tmpdir, server_type): result_file = examples.find_static_rst(server=server_type) # download it - new_tmpdir = os.path.join(tmpdir, "my_tmp_dir") + os.path.join(tmpdir, "my_tmp_dir") server_type.session.handle_events_with_file_logger(log_path, 2) wf = core.Workflow(server=server_type) diff --git a/tests/test_timefreqsupport.py b/tests/test_timefreqsupport.py index 6e8b39b12b..eff1fc562b 100644 --- a/tests/test_timefreqsupport.py +++ b/tests/test_timefreqsupport.py @@ -333,13 +333,13 @@ def test_timefreqsupport_memory_leaks(): frequencies = fields_factory.create_scalar_field(3, server=server) frequencies.data = [0.1, 0.32, 0.4] tfq.time_frequencies = frequencies - frequencies_check = tfq.time_frequencies # Call to get + tfq.time_frequencies # Call to get tfq.complex_frequencies = frequencies - frequencies_cplx_check = tfq.complex_frequencies # Call to get + tfq.complex_frequencies # Call to get tfq.rpms = frequencies - rpm_check = tfq.rpms # Call to get + tfq.rpms # Call to get tfq.set_harmonic_indices(frequencies) - harm_check = tfq.get_harmonic_indices() # Call to get + tfq.get_harmonic_indices() # Call to get @conftest.raises_for_servers_version_under("5.0") diff --git a/tests/test_workflow.py b/tests/test_workflow.py index 5576cbe555..7605326d2a 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -359,7 +359,7 @@ def test_output_mesh_workflow(cyclic_lin_rst, cyclic_ds, server_type): == meshed_region.elements.connectivities_field.size ) - fields = wf.get_output("fields", dpf.core.types.fields_container) + wf.get_output("fields", dpf.core.types.fields_container) def test_outputs_bool_workflow(server_type): @@ -583,14 +583,14 @@ def test_transfer_owner_workflow(allkindofcomplexity, server_type): wf.connect("prop", "elshape") wf.set_output_name("scopings", op, 0) id = wf.record(transfer_ownership=True) - wf_copy = dpf.core.Workflow.get_recorded_workflow(id, server=server_type) + dpf.core.Workflow.get_recorded_workflow(id, server=server_type) with pytest.raises(Exception): - wf_copy = dpf.core.Workflow.get_recorded_workflow(id, server=server_type) + dpf.core.Workflow.get_recorded_workflow(id, server=server_type) id = wf.record(transfer_ownership=False) - wf_copy = dpf.core.Workflow.get_recorded_workflow(id, server=server_type) - wf_copy = dpf.core.Workflow.get_recorded_workflow(id, server=server_type) + dpf.core.Workflow.get_recorded_workflow(id, server=server_type) + dpf.core.Workflow.get_recorded_workflow(id, server=server_type) @conftest.raises_for_servers_version_under("3.0") @@ -618,8 +618,8 @@ def test_connect_with_workflow(cyclic_lin_rst, cyclic_ds, server_type): wf2.set_output_name("u", op, 0) wf2.connect_with(wf) - meshed_region = wf2.get_output("mesh_expand", dpf.core.types.meshed_region) - fc = wf2.get_output("u", dpf.core.types.fields_container) + wf2.get_output("mesh_expand", dpf.core.types.meshed_region) + wf2.get_output("u", dpf.core.types.fields_container) @conftest.raises_for_servers_version_under("3.0") @@ -647,8 +647,8 @@ def test_connect_with_2_workflow(cyclic_lin_rst, cyclic_ds, server_type): wf2.set_output_name("u", op, 0) wf2.connect_with(wf, ("support1", "support2")) - meshed_region = wf2.get_output("mesh_expand", dpf.core.types.meshed_region) - fc = wf2.get_output("u", dpf.core.types.fields_container) + wf2.get_output("mesh_expand", dpf.core.types.meshed_region) + wf2.get_output("u", dpf.core.types.fields_container) @conftest.raises_for_servers_version_under("3.0") @@ -676,8 +676,8 @@ def test_connect_with_dict_workflow(cyclic_lin_rst, cyclic_ds, server_type): wf2.set_output_name("u", op, 0) wf2.connect_with(wf, {"support1": "support2"}) - meshed_region = wf2.get_output("mesh_expand", dpf.core.types.meshed_region) - fc = wf2.get_output("u", dpf.core.types.fields_container) + wf2.get_output("mesh_expand", dpf.core.types.meshed_region) + wf2.get_output("u", dpf.core.types.fields_container) @pytest.mark.xfail(raises=dpf.core.errors.ServerTypeError) @@ -934,18 +934,6 @@ def test_connect_get_output_big_strings(server_type, server_in_process): assert np.allclose(out.data, data) -@pytest.mark.skipif( - not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0, reason="Available for servers >=8.0" -) -def test_connect_get_output_big_strings(server_type, server_type_remote_process): - data = np.random.random(100000) - field_a = dpf.core.field_from_array(data, server=server_type) - assert np.allclose(field_a.data, data) - - out = deep_copy_using_workflow(field_a, server_type_remote_process) - assert np.allclose(out.data, data) - - @conftest.raises_for_servers_version_under("8.0") def test_connect_get_non_ascii_string(server_type): str = "\N{GREEK CAPITAL LETTER DELTA}" diff --git a/tests/testfiles/pythonPlugins/all_types/__init__.py b/tests/testfiles/pythonPlugins/all_types/__init__.py index 82ddf6b4e9..ee51149973 100644 --- a/tests/testfiles/pythonPlugins/all_types/__init__.py +++ b/tests/testfiles/pythonPlugins/all_types/__init__.py @@ -21,3 +21,5 @@ # SOFTWARE. from all_types.load_operators_func import load_operators + +__all__ = ["load_operators"] diff --git a/tests/testfiles/pythonPlugins/syntax_error_plugin/__init__.py b/tests/testfiles/pythonPlugins/syntax_error_plugin/__init__.py index fa6c589131..68d545bafa 100644 --- a/tests/testfiles/pythonPlugins/syntax_error_plugin/__init__.py +++ b/tests/testfiles/pythonPlugins/syntax_error_plugin/__init__.py @@ -21,3 +21,5 @@ # SOFTWARE. from syntax_error_plugin.load_operators_func import load_operators + +__all__ = ["load_operators"]