Skip to content

Commit

Permalink
Revert "Update doctest for numpy 2.0.0"
Browse files Browse the repository at this point in the history
This reverts commit e280646.
  • Loading branch information
angus-g committed Jul 1, 2024
1 parent fa96541 commit 265418f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions regional_mom6/regional_mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ def hyperbolictan_thickness_profile(nlayers, ratio, total_depth):
54.91569316, 63.76993631, 70.3615673 , 74.6060059 , 77.08936249,
78.46160957, 79.19600916, 79.58232451, 79.7836947 , 79.88816229])
>>> dz.sum()
np.float64(1000.0)
1000.0
>>> dz[-1] / dz[0]
np.float64(3.9721960481753706)
3.9721960481753706
If we want the top layer to be thicker then we need to prescribe ``ratio < 1``.
Expand All @@ -214,9 +214,9 @@ def hyperbolictan_thickness_profile(nlayers, ratio, total_depth):
45.08430684, 36.23006369, 29.6384327 , 25.3939941 , 22.91063751,
21.53839043, 20.80399084, 20.41767549, 20.2163053 , 20.11183771])
>>> dz.sum()
np.float64(1000.0)
1000.0
>>> dz[-1] / dz[0]
np.float64(0.25174991059652)
0.25174991059652
Now how about a grid with the same total depth as above but with equally-spaced
layers.
Expand Down
14 changes: 7 additions & 7 deletions regional_mom6/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def angle_between(v1, v2, v3):
>>> v2 = (1, 0, 0)
>>> v3 = (0, 1, 0)
>>> angle_between(v1, v2, v3)
np.float64(1.5707963267948966)
1.5707963267948966
>>> from numpy import rad2deg
>>> rad2deg(angle_between(v1, v2, v3))
np.float64(90.0)
90.0
"""

v1xv2 = np.cross(v1, v2)
Expand Down Expand Up @@ -58,10 +58,10 @@ def quadrilateral_area(v1, v2, v3, v4):
>>> v3 = latlon_to_cartesian(90, 0, R)
>>> v4 = latlon_to_cartesian(0, -90, R)
>>> quadrilateral_area(v1, v2, v3, v4)
np.float64(592556.1793298927)
592556.1793298927
>>> from numpy import pi
>>> quadrilateral_area(v1, v2, v3, v4) == pi * R**2
np.True_
True
"""

v1 = np.array(v1)
Expand Down Expand Up @@ -106,14 +106,14 @@ def latlon_to_cartesian(lat, lon, R=1):
>>> from regional_mom6.utils import latlon_to_cartesian
>>> latlon_to_cartesian(0, 0)
(np.float64(1.0), np.float64(0.0), np.float64(0.0))
(1.0, 0.0, 0.0)
Now let's do the same on a sphere with Earth's radius
>>> from regional_mom6.utils import latlon_to_cartesian
>>> R = 6371e3
>>> latlon_to_cartesian(0, 0, R)
(np.float64(6371000.0), np.float64(0.0), np.float64(0.0))
(6371000.0, 0.0, 0.0)
"""

x = R * np.cos(np.deg2rad(lat)) * np.cos(np.deg2rad(lon))
Expand Down Expand Up @@ -169,7 +169,7 @@ def quadrilateral_areas(lat, lon, R=1):
[1.96911611e+13, 1.96911611e+13, 1.96911611e+13, 1.96911611e+13,
1.96911611e+13, 1.96911611e+13]])
>>> np.isclose(areas.sum(), 4 * np.pi * R**2, atol=np.finfo(areas.dtype).eps)
np.True_
True
"""

coords = np.dstack(latlon_to_cartesian(lat, lon, R))
Expand Down

0 comments on commit 265418f

Please sign in to comment.