From 986be08db995414c70265e6b33584716e71fee90 Mon Sep 17 00:00:00 2001 From: Sam Holt <48217392+samjrholt@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:05:10 +0200 Subject: [PATCH] Update discretisedfield/tools/tools.py Co-authored-by: Martin Lang <67915889+lang-m@users.noreply.github.com> --- discretisedfield/tools/tools.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/discretisedfield/tools/tools.py b/discretisedfield/tools/tools.py index 97f58df4..8ed6acfc 100644 --- a/discretisedfield/tools/tools.py +++ b/discretisedfield/tools/tools.py @@ -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):