Skip to content

Commit 2873ee6

Browse files
committed
Add test to validate longitude rounding and data integrity in shiftdata()
1 parent ab01532 commit 2873ee6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_shiftdata_rounding.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import numpy as np
2+
from mpl_toolkits.basemap import Basemap
3+
4+
def test_shiftdata_rounding():
5+
m = Basemap(projection='cyl', llcrnrlon=-180, urcrnrlon=180,
6+
llcrnrlat=-90, urcrnrlat=90, lon_0=0)
7+
8+
lonsin = np.array([104.123456789, -75.987654321])
9+
datain = np.array([1.0, 2.0])
10+
11+
lonsout, dataout = m.shiftdata(lonsin, datain)
12+
13+
expected_lons = np.round(lonsin, 6)
14+
np.testing.assert_allclose(np.sort(lonsout), np.sort(expected_lons), rtol=1e-8, atol=1e-8)
15+
assert np.array_equal(np.sort(dataout), np.sort(datain))

0 commit comments

Comments
 (0)