diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 00de485a..0a1da86b 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -58,4 +58,5 @@ jobs: with: run: | export NAVIS_HEADLESS=TRUE + export NAVIS_TEST_ENV=TRUE pytest --verbose diff --git a/navis/morpho/mmetrics.py b/navis/morpho/mmetrics.py index 93a4feca..d7986791 100644 --- a/navis/morpho/mmetrics.py +++ b/navis/morpho/mmetrics.py @@ -15,6 +15,7 @@ """This module contains functions to analyse and manipulate neuron morphology.""" import math +import os import itertools import scipy import warnings @@ -30,6 +31,12 @@ # Set up logging logger = config.get_logger(__name__) +# Set up numpy number representation, see NEP51 +# Once numpy<=2 is dropped from requirements, the doctest comparissons +# should become `np.float64(1.074)` instead of `1.074` +if os.environ.get('NAVIS_TEST_ENV', '').lower() == 'true': + np.set_printoptions(legacy="1.25") + __all__ = sorted( [ "strahler_index", @@ -1321,12 +1328,7 @@ def tortuosity( Examples -------- - (Set up numpy number representation within the test, see NEP51. - Once numpy<=2 is dropped from requirements, the doctest comparissons - should become `np.float64(1.074)` instead of `1.074`) >>> import navis - >>> if int(np.version.version.split('.')[0])>=2: - np.set_printoptions(legacy="1.25") >>> n = navis.example_neurons(1) >>> # Calculate tortuosity as-is >>> T = navis.tortuosity(n) diff --git a/pytest.ini b/pytest.ini index 6754b78f..f7278cac 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,3 +3,4 @@ doctest_optionflags = IGNORE_EXCEPTION_DETAIL NUMBER NORMALIZE_WHITESPACE addopts = --doctest-modules env = NAVIS_HEADLESS=TRUE + NAVIS_TEST_ENV=TRUE