Skip to content

Projecting issue209 #212

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

Merged
merged 4 commits into from
Oct 26, 2015
Merged
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
3 changes: 2 additions & 1 deletion lib/mpl_toolkits/basemap/pyproj.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ def _copytobuffer(x):
# (this makes a copy - which is crucial
# since buffer is modified in place)
x.dtype.char
inx = x.astype('d')
inx = x.astype('d', order="C")

# inx,isfloat,islist,istuple
return inx,False,False,False
except:
Expand Down
35 changes: 35 additions & 0 deletions lib/mpl_toolkits/basemap/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,41 @@ def test_no_cyc2(self):
assert (grid==gridout).all()


class TestProjectCoords(TestCase):
def get_data(self):
lons, lats = np.arange(-180, 180, 20), np.arange(-90, 90, 10)
lats, lons = np.meshgrid(lats, lons)
lons, lats = lons.copy(order="F"), lats.copy(order="F")
return lons, lats, Basemap(projection="sinu", lon_0=0)


def test_convert(self):
"""
Should not fail on C non-contiguous arrays
"""
lons, lats, bmp = self.get_data()
assert not lons.flags['C_CONTIGUOUS']
assert isinstance(lons, np.ndarray)
assert isinstance(bmp, Basemap)

xx1, yy1 = bmp(lons, lats)


def test_results_should_be_same_for_c_and_f_order_arrays(self):

lons, lats, bmp = self.get_data()

xx1, yy1 = bmp(lons.copy(order="C"), lats.copy(order="C"))
xx2, yy2 = bmp(lons.copy(order="F"), lats.copy(order="F"))

assert_almost_equal(xx1, xx2)
assert_almost_equal(yy1, yy2)






def test():
"""
Run some tests.
Expand Down