Skip to content

Commit 348e7be

Browse files
committed
Merge pull request #212 from guziy/projecting_issue209
Projecting issue209
2 parents f70b00c + c3e4952 commit 348e7be

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

lib/mpl_toolkits/basemap/pyproj.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ def _copytobuffer(x):
521521
# (this makes a copy - which is crucial
522522
# since buffer is modified in place)
523523
x.dtype.char
524-
inx = x.astype('d')
524+
inx = x.astype('d', order="C")
525+
525526
# inx,isfloat,islist,istuple
526527
return inx,False,False,False
527528
except:

lib/mpl_toolkits/basemap/test.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,41 @@ def test_no_cyc2(self):
9696
assert (grid==gridout).all()
9797

9898

99+
class TestProjectCoords(TestCase):
100+
def get_data(self):
101+
lons, lats = np.arange(-180, 180, 20), np.arange(-90, 90, 10)
102+
lats, lons = np.meshgrid(lats, lons)
103+
lons, lats = lons.copy(order="F"), lats.copy(order="F")
104+
return lons, lats, Basemap(projection="sinu", lon_0=0)
105+
106+
107+
def test_convert(self):
108+
"""
109+
Should not fail on C non-contiguous arrays
110+
"""
111+
lons, lats, bmp = self.get_data()
112+
assert not lons.flags['C_CONTIGUOUS']
113+
assert isinstance(lons, np.ndarray)
114+
assert isinstance(bmp, Basemap)
115+
116+
xx1, yy1 = bmp(lons, lats)
117+
118+
119+
def test_results_should_be_same_for_c_and_f_order_arrays(self):
120+
121+
lons, lats, bmp = self.get_data()
122+
123+
xx1, yy1 = bmp(lons.copy(order="C"), lats.copy(order="C"))
124+
xx2, yy2 = bmp(lons.copy(order="F"), lats.copy(order="F"))
125+
126+
assert_almost_equal(xx1, xx2)
127+
assert_almost_equal(yy1, yy2)
128+
129+
130+
131+
132+
133+
99134
def test():
100135
"""
101136
Run some tests.

0 commit comments

Comments
 (0)