From d946380e8354cf5655849f6160d6330a7c53a761 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Mon, 3 Jun 2024 14:53:10 +0200 Subject: [PATCH 1/8] use DerivedQuantities as a list --- docs/source/userguide/export_post_processing.rst | 2 +- festim/generic_simulation.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/userguide/export_post_processing.rst b/docs/source/userguide/export_post_processing.rst index 5fbcbb5b1..6f1a597bf 100644 --- a/docs/source/userguide/export_post_processing.rst +++ b/docs/source/userguide/export_post_processing.rst @@ -189,7 +189,7 @@ The data can be accessed in three different ways: print(flux_surf_3.t) print(flux_surf_3.data) - print(my_derived_quantities.derived_quantities[2].data) + print(my_derived_quantities[2].data) - export and read from a .csv file: diff --git a/festim/generic_simulation.py b/festim/generic_simulation.py index 1426a5985..6aeb0036c 100644 --- a/festim/generic_simulation.py +++ b/festim/generic_simulation.py @@ -322,7 +322,7 @@ def initialise(self): for export in self.exports: if isinstance(export, festim.DerivedQuantities): - for q in export.derived_quantities: + for q in export: if not isinstance(q, tuple(allowed_quantities[self.mesh.type])): warnings.warn( f"{type(q)} may not work as intended for {self.mesh.type} meshes" From bb2cb10c66391ffb75daad01de4032132faf4fff Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Mon, 3 Jun 2024 14:59:06 +0200 Subject: [PATCH 2/8] removed unused line --- .../test_derived_quantities/test_surface_quantity.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/test_exports/test_derived_quantities/test_surface_quantity.py b/test/unit/test_exports/test_derived_quantities/test_surface_quantity.py index e790ef9d2..20849490e 100644 --- a/test/unit/test_exports/test_derived_quantities/test_surface_quantity.py +++ b/test/unit/test_exports/test_derived_quantities/test_surface_quantity.py @@ -1,4 +1,3 @@ -from nis import match import festim as F import pytest From 93e2715cd41e70744b16576cf3b7e8daefd000d7 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Mon, 3 Jun 2024 15:13:09 +0200 Subject: [PATCH 3/8] reduce warnings in tests --- test/simulation/test_postprocessing_integration.py | 2 ++ .../test_derived_quantities/test_volume_quantity.py | 1 - test/unit/test_exports/test_trap_density_xdmf_export.py | 1 + test/unit/test_exports/test_xdmf_export.py | 6 +++--- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/simulation/test_postprocessing_integration.py b/test/simulation/test_postprocessing_integration.py index 6681dc398..8cae53a7c 100644 --- a/test/simulation/test_postprocessing_integration.py +++ b/test/simulation/test_postprocessing_integration.py @@ -174,6 +174,7 @@ def test_fluxes(self, my_sim): assert np.isclose(data[1][3], -1 * grad_T * lambda_x_0) assert np.isclose(data[1][4], -1 * grad_T * lambda_x_1 * -1) + @pytest.mark.filterwarnings("ignore:in 1D") def test_performance_xdmf_export_every_N_iterations(self, my_sim, tmpdir): """Runs run_post_processing several times with different export.mode values and checks that the xdmf @@ -215,6 +216,7 @@ def test_performance_xdmf_export_every_N_iterations(self, my_sim, tmpdir): for t_expected, t in zip(expected_times, times): assert t_expected == pytest.approx(float(t)) + @pytest.mark.filterwarnings("ignore:in 1D") def test_xdmf_export_only_last_timestep(self, my_sim, tmpdir): """Runs run_post_processing with mode="last": - when the time is not the final time and checks that nothing has been diff --git a/test/unit/test_exports/test_derived_quantities/test_volume_quantity.py b/test/unit/test_exports/test_derived_quantities/test_volume_quantity.py index 4a2cb56b2..7ec88f0f8 100644 --- a/test/unit/test_exports/test_derived_quantities/test_volume_quantity.py +++ b/test/unit/test_exports/test_derived_quantities/test_volume_quantity.py @@ -1,4 +1,3 @@ -from nis import match import festim as F import pytest diff --git a/test/unit/test_exports/test_trap_density_xdmf_export.py b/test/unit/test_exports/test_trap_density_xdmf_export.py index a0f7a41d1..d3cfc347d 100644 --- a/test/unit/test_exports/test_trap_density_xdmf_export.py +++ b/test/unit/test_exports/test_trap_density_xdmf_export.py @@ -133,6 +133,7 @@ def test_trap_density_xdmf_export_traps_materials_mixed(tmpdir): trap=trap_1, label="density1", filename=str(Path(density_file)), + checkpoint=False, ) my_exports = festim.Exports([my_export]) my_model.exports = my_exports diff --git a/test/unit/test_exports/test_xdmf_export.py b/test/unit/test_exports/test_xdmf_export.py index 900ae5ab7..f7973d153 100644 --- a/test/unit/test_exports/test_xdmf_export.py +++ b/test/unit/test_exports/test_xdmf_export.py @@ -10,7 +10,7 @@ def folder(tmpdir): def test_define_file_upon_construction(folder): - mesh = f.UnitIntervalMesh(10) + mesh = f.UnitSquareMesh(8, 8) filename = "{}/my_filename.xdmf".format(folder) my_xdmf = XDMFExport("solute", label="solute_label", filename=filename) @@ -30,7 +30,7 @@ def test_default_filename(): class TestDefineFile: - mesh = f.UnitIntervalMesh(10) + mesh = f.UnitSquareMesh(8, 8) my_xdmf = XDMFExport("solute", "my_label", filename="my_filename.xdmf") def test_file_exists(self, folder): @@ -44,7 +44,7 @@ def test_file_exists(self, folder): class TestWrite: - mesh = f.UnitIntervalMesh(10) + mesh = f.UnitSquareMesh(8, 8) V = f.FunctionSpace(mesh, "P", 1) u = f.Function(V) label_to_function = {"solute": u} From c0c99815bf3a3b80a76e8d75cac34f9960b662e0 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Mon, 3 Jun 2024 15:14:33 +0200 Subject: [PATCH 4/8] fixed test --- test/unit/test_exports/test_trap_density_xdmf_export.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/test_exports/test_trap_density_xdmf_export.py b/test/unit/test_exports/test_trap_density_xdmf_export.py index d3cfc347d..2b02d9425 100644 --- a/test/unit/test_exports/test_trap_density_xdmf_export.py +++ b/test/unit/test_exports/test_trap_density_xdmf_export.py @@ -3,6 +3,7 @@ import sympy as sp from pathlib import Path import numpy as np +import pytest def test_trap_density_xdmf_export_intergration_with_simultion(tmpdir): @@ -96,6 +97,7 @@ def test_trap_density_xdmf_export_write(tmpdir): assert error_L2 < 1e-10 +@pytest.mark.filterwarnings("ignore:in 1D") def test_trap_density_xdmf_export_traps_materials_mixed(tmpdir): """Integration test for TrapDensityXDMF.write() with a trap material given as a string. Creates a festim simulation and exports the trap density as an @@ -133,7 +135,6 @@ def test_trap_density_xdmf_export_traps_materials_mixed(tmpdir): trap=trap_1, label="density1", filename=str(Path(density_file)), - checkpoint=False, ) my_exports = festim.Exports([my_export]) my_model.exports = my_exports From ee424efcd4b3fa7b6ffc9e226aa6ca9875506cae Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Mon, 3 Jun 2024 15:27:56 +0200 Subject: [PATCH 5/8] numpy 1.24 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5bce7d4c..d656839b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: run: | # conda upgrade --strict-channel-priority -c conda-forge --all conda install -c conda-forge 'conda-libmamba-solver<23.9' - mamba install -c conda-forge fenics + mamba install -c conda-forge fenics numpy=1.24 - name: Install dependencies shell: bash -l {0} From a0652587a4c2dd442af1bc4ac00cab08e72a00c9 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Mon, 3 Jun 2024 15:31:37 +0200 Subject: [PATCH 6/8] specific version python --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d656839b5..fec4d3e46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,15 +13,14 @@ jobs: uses: conda-incubator/setup-miniconda@v2 with: activate-environment: myenv - mamba-version: "*" + # mamba-version: "*" channels: conda-forge, defaults - name: Create Conda environment shell: bash -l {0} run: | # conda upgrade --strict-channel-priority -c conda-forge --all - conda install -c conda-forge 'conda-libmamba-solver<23.9' - mamba install -c conda-forge fenics numpy=1.24 + conda install -c conda-forge fenics numpy=1.24 py=3.10 - name: Install dependencies shell: bash -l {0} From 93426b533a60d50b607941e1172ad240756f1eb3 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Mon, 3 Jun 2024 15:38:59 +0200 Subject: [PATCH 7/8] py<3.12 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fec4d3e46..f6b77aaf8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: shell: bash -l {0} run: | # conda upgrade --strict-channel-priority -c conda-forge --all - conda install -c conda-forge fenics numpy=1.24 py=3.10 + conda install -c conda-forge fenics numpy=1.24 py<3.12 - name: Install dependencies shell: bash -l {0} From f30ba73a500dfa2a932332e29114b58c82f4e84e Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Mon, 3 Jun 2024 15:58:32 +0200 Subject: [PATCH 8/8] python 3.10 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6b77aaf8..16db758fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: shell: bash -l {0} run: | # conda upgrade --strict-channel-priority -c conda-forge --all - conda install -c conda-forge fenics numpy=1.24 py<3.12 + conda install -c conda-forge fenics numpy=1.24 python=3.10 - name: Install dependencies shell: bash -l {0}