Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 85853da

Browse filesBrowse files
committed
PRF: Don't use MaskedArray in Aitoff transform.
It's just a slight bit slower than plain indexing.
1 parent c91c8ad commit 85853da
Copy full SHA for 85853da

File tree

Expand file treeCollapse file tree

1 file changed

+9
-10
lines changed
Filter options
  • lib/matplotlib/projections
Expand file treeCollapse file tree

1 file changed

+9
-10
lines changed

‎lib/matplotlib/projections/geo.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/geo.py
+9-10Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,24 +269,23 @@ def __init__(self, resolution):
269269
self._resolution = resolution
270270

271271
def transform_non_affine(self, ll):
272-
longitude = ll[:, 0:1]
273-
latitude = ll[:, 1:2]
272+
longitude = ll[:, 0]
273+
latitude = ll[:, 1]
274274

275275
# Pre-compute some values
276276
half_long = longitude / 2.0
277277
cos_latitude = np.cos(latitude)
278278

279279
alpha = np.arccos(cos_latitude * np.cos(half_long))
280-
# Mask this array or we'll get divide-by-zero errors
281-
alpha = ma.masked_where(alpha == 0.0, alpha)
282-
# The numerators also need to be masked so that masked
283-
# division will be invoked.
280+
# Avoid divide-by-zero errors using same method as NumPy.
281+
alpha[alpha == 0.0] = 1e-20
284282
# We want unnormalized sinc. numpy.sinc gives us normalized
285-
sinc_alpha = ma.sin(alpha) / alpha
283+
sinc_alpha = np.sin(alpha) / alpha
286284

287-
x = (cos_latitude * ma.sin(half_long)) / sinc_alpha
288-
y = (ma.sin(latitude) / sinc_alpha)
289-
return np.concatenate((x.filled(0), y.filled(0)), 1)
285+
xy = np.empty_like(ll, float)
286+
xy[:, 0] = (cos_latitude * np.sin(half_long)) / sinc_alpha
287+
xy[:, 1] = np.sin(latitude) / sinc_alpha
288+
return xy
290289
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
291290

292291
def transform_path_non_affine(self, path):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.