Skip to content

Commit

Permalink
Update discretisedfield/tools/tools.py
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Lang <[email protected]>
  • Loading branch information
samjrholt and lang-m authored Jun 4, 2024
1 parent e4472c0 commit 986be08
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions discretisedfield/tools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,7 @@ def topological_charge(field, /, method="continuous", absolute=False):
assert np.isscalar(result), "Expected a scalar result from integration"
return float(result)
else:
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)
return q.integrate().item()


def emergent_magnetic_field(field):
Expand Down

0 comments on commit 986be08

Please sign in to comment.