Skip to content

Commit

Permalink
Merge pull request #176 from floesche/fix_numpy_doctest
Browse files Browse the repository at this point in the history
Fix numpy doctest
  • Loading branch information
schlegelp authored Dec 30, 2024
2 parents aba1df1 + 628c0c1 commit 9c6e78c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ jobs:
with:
run: |
export NAVIS_HEADLESS=TRUE
export NAVIS_TEST_ENV=TRUE
pytest --verbose
6 changes: 6 additions & 0 deletions navis/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ def get_logger(name: str):
return logging.getLogger(name)
return logger

# 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':
import numpy as np
np.set_printoptions(legacy="1.25")

# Default settings for progress bars
pbar_hide = False
Expand Down
1 change: 1 addition & 0 deletions navis/morpho/mmetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# Set up logging
logger = config.get_logger(__name__)


__all__ = sorted(
[
"strahler_index",
Expand Down
4 changes: 2 additions & 2 deletions navis/plotting/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def make_tube(segments, radii=1.0, tube_points=8, use_normals=True):
faces : np.ndarray
"""
vertices = np.empty((0, 3), dtype=np.float_)
vertices = np.empty((0, 3), dtype=np.float64)
indices = np.empty((0, 3), dtype=np.uint32)

if not isinstance(radii, Iterable):
Expand Down Expand Up @@ -219,7 +219,7 @@ def make_tube(segments, radii=1.0, tube_points=8, use_normals=True):
# Vertices for each point on the circle
verts = np.repeat(points, tube_points, axis=0)

v = np.arange(tube_points, dtype=np.float_) / tube_points * 2 * np.pi
v = np.arange(tube_points, dtype=np.float64) / tube_points * 2 * np.pi

all_cx = (
radius
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ doctest_optionflags = IGNORE_EXCEPTION_DETAIL NUMBER NORMALIZE_WHITESPACE
addopts = --doctest-modules
env =
NAVIS_HEADLESS=TRUE
NAVIS_TEST_ENV=TRUE

0 comments on commit 9c6e78c

Please sign in to comment.