Skip to content

Commit fa44c87

Browse files
authored
Merge pull request #9862 from QuLogic/Axes-micro-opt
PRF: Don't used MaskedArray in Aitoff transform.
2 parents 124bbf2 + 85853da commit fa44c87

File tree

1 file changed

+9
-10
lines changed
  • lib/matplotlib/projections

1 file changed

+9
-10
lines changed

lib/matplotlib/projections/geo.py

+9-10
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)