Skip to content

Commit

Permalink
changes in the topological charge function to avoid DeprecationWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
kzqureshi committed May 29, 2024
1 parent 00415cf commit e4472c0
Showing 1 changed file with 10 additions and 2 deletions.
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

0 comments on commit e4472c0

Please sign in to comment.