Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix numpy doctest #176

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading