Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test deprecation warning #518

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion discretisedfield/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion discretisedfield/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion discretisedfield/tests/test_interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
12 changes: 10 additions & 2 deletions discretisedfield/tools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 9 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -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
Loading