Skip to content

Commit

Permalink
Merge pull request #20 from nennigb/fix-test-np2
Browse files Browse the repository at this point in the history
Change default printing options in __main__ (tests).
  • Loading branch information
MartinGhienne authored Jul 23, 2024
2 parents 17b2531 + 7771305 commit cc4fae0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions eastereig/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"""
import doctest
import sys
import numpy as np
from eastereig import _petscHere
# immport the file containing the doctest
from eastereig.examples import WGimpedance_numpy
Expand All @@ -39,6 +40,12 @@
from eastereig import eigSolvers
from eastereig import fpoly

# Numpy 2.0 change default printing options making doctest failing.
# https://numpy.org/neps/nep-0051-scalar-representation.html
# Use legacy mode for testing
if np.lib.NumpyVersion(np.__version__) >= '2.0.0b1':
np.set_printoptions(legacy="1.25")

if _petscHere:
from eastereig.examples import WGimpedance_petsc

Expand Down
8 changes: 4 additions & 4 deletions eastereig/fpoly/_fpoly.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,22 @@ def polyvalnd(nu, a):
>>> a1 = np.random.rand(5)*(1+1j)
>>> pvalf = polyvalnd(2.253+0.1j, a1)
>>> pvalnp = polyval(2.253+0.1j, a1)
>>> abs(pvalf - pvalnp) < 1e-12
>>> abs(pvalf - pvalnp) < 1e-11
True
>>> a2 = np.random.rand(5, 5)*(1+1j)
>>> pvalf = polyvalnd((2.253+0j, 1+1j), a2)
>>> pvalnp = polyval2d(2.253+0j, 1+1j, a2)
>>> abs(pvalf - pvalnp) < 1e-12
>>> abs(pvalf - pvalnp) < 1e-11
True
>>> a3 = np.random.rand(5, 5, 5)*(1+1j)
>>> pvalf = polyvalnd((2.253, 1+1j, 0.1+2j), a3)
>>> pvalnp = polyval3d(2.253, 1+1j, 0.1+2j, a3)
>>> abs(pvalf - pvalnp) < 1e-12
>>> abs(pvalf - pvalnp) < 1e-11
True
>>> a4 = np.random.rand(5, 5, 5, 5)*(1+1j)
>>> pvalf = polyvalnd((2.253, 1+1j, 0.1+2j, -0.8+0.2j), a4)
>>> pvalnp = pu._valnd(polyval, a4, 2.253, 1+1j, 0.1+2j, -0.8+0.2j)
>>> abs(pvalf - pvalnp) < 1e-12
>>> abs(pvalf - pvalnp) < 1e-11
True
"""
d = len(a.shape)
Expand Down

0 comments on commit cc4fae0

Please sign in to comment.