From 0baab3c8edec7700b429e7f6ccc5af4b49ed034a Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Tue, 19 Mar 2024 12:47:29 +0100 Subject: [PATCH 1/5] changed np.product to np.prod in mesh.dV to avoid DeprecationWarning --- discretisedfield/mesh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discretisedfield/mesh.py b/discretisedfield/mesh.py index c63efc03..d0d6ec88 100644 --- a/discretisedfield/mesh.py +++ b/discretisedfield/mesh.py @@ -1546,7 +1546,7 @@ def dV(self): 8.0 """ - return np.product(self.cell) + return np.prod(self.cell) def scale(self, factor, reference_point=None, inplace=False): """Scale the underlying region and all subregions. From d37672bb1a0e06e3d737e59799a0774fa926821f Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Tue, 19 Mar 2024 13:00:14 +0100 Subject: [PATCH 2/5] ensuring scalar from integrate function --- discretisedfield/tools/tools.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/discretisedfield/tools/tools.py b/discretisedfield/tools/tools.py index 5f9053f3..fc601778 100644 --- a/discretisedfield/tools/tools.py +++ b/discretisedfield/tools/tools.py @@ -273,9 +273,17 @@ def topological_charge(field, /, method="continuous", absolute=False): q = topological_charge_density(field, method=method) if absolute: - return float(abs(q).integrate()) + result = abs(q).integrate() + if isinstance(result, np.ndarray) and result.size == 1: + result = result.item() + assert np.isscalar(result), "Expected a scalar result from integration" + return float(result) else: - return float(q.integrate()) + result = q.integrate() + if isinstance(result, np.ndarray) and result.size == 1: + result = result.item() + assert np.isscalar(result), "Expected a scalar result from integration" + return float(result) def emergent_magnetic_field(field): From 4c3ffd052a2e28d3bf1c33fa2f157e0874872e15 Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Tue, 19 Mar 2024 13:02:44 +0100 Subject: [PATCH 3/5] correction from field.plane to filed.sel --- discretisedfield/tests/test_interact.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discretisedfield/tests/test_interact.py b/discretisedfield/tests/test_interact.py index 55a883c2..9bea5135 100644 --- a/discretisedfield/tests/test_interact.py +++ b/discretisedfield/tests/test_interact.py @@ -11,4 +11,4 @@ def test_interact(): # Only test whether it runs. @df.interact(x=field.mesh.slider("x")) def myplot(x): - field.plane(x=x).mpl() + field.sel(x=x).mpl() From ecb696cfe1a8c174a7251cec256d3f0d0a3cea82 Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Wed, 20 Mar 2024 10:45:15 +0100 Subject: [PATCH 4/5] config file for ignoring warnings --- pytest.ini | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..7b497deb --- /dev/null +++ b/pytest.ini @@ -0,0 +1,9 @@ +[pytest] +python_files = test_*.py +python_functions = test_* +filterwarnings = + ignore::DeprecationWarning:traitlets.*: + #ignore:Automatic coloring is only supported for 3d fields.*:UserWarning + ignore:The truth value of an empty array is ambiguous.*:DeprecationWarning + ignore:invalid value encountered in divide:RuntimeWarning + ignore:`ipykernel.pylab.backend_inline` is deprecated.*:DeprecationWarning From d27e50fc9c2663f675b6b46a541e27442a39417c Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Tue, 16 Apr 2024 19:00:04 +0200 Subject: [PATCH 5/5] changed point_columns dependency from 3 to n dims --- discretisedfield/line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discretisedfield/line.py b/discretisedfield/line.py index 96803576..2a84c9b1 100644 --- a/discretisedfield/line.py +++ b/discretisedfield/line.py @@ -170,7 +170,7 @@ def point_columns(self): @point_columns.setter def point_columns(self, val): - if len(val) != 3: + if len(val) != len(self._point_columns): msg = f"Cannot change column names with a list of lenght {len(val)}." raise ValueError(msg)