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 527faa4

Browse filesBrowse files
committed
Small improvements to aitoff projection.
- Use np.sinc instead of rewriting it ourselves. (This way, if numpy ever switches sinc to C, we get the speedup too.) - Make InvertedAitoff return nan (which is clearly suggests "we can't compute this") instead of being a noop (which makes it return nonsensical data with no user warning). AFAICT this is only used to print mouseover coordinates. See e.g. `subplots_axes_and_figures/geo_demo.py` where the mouseover coordinates for aitoff were just completely wrong.
1 parent ff15ca9 commit 527faa4
Copy full SHA for 527faa4

File tree

Expand file treeCollapse file tree

1 file changed

+2
-5
lines changed
Filter options
  • lib/matplotlib/projections
Expand file treeCollapse file tree

1 file changed

+2
-5
lines changed

‎lib/matplotlib/projections/geo.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/geo.py
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,7 @@ def transform_non_affine(self, ll):
264264
cos_latitude = np.cos(latitude)
265265

266266
alpha = np.arccos(cos_latitude * np.cos(half_long))
267-
# Avoid divide-by-zero errors using same method as NumPy.
268-
alpha[alpha == 0.0] = 1e-20
269-
# We want unnormalized sinc. numpy.sinc gives us normalized
270-
sinc_alpha = np.sin(alpha) / alpha
267+
sinc_alpha = np.sinc(alpha / np.pi) # np.sinc is sin(pi*x)/(pi*x).
271268

272269
x = (cos_latitude * np.sin(half_long)) / sinc_alpha
273270
y = np.sin(latitude) / sinc_alpha
@@ -282,7 +279,7 @@ class InvertedAitoffTransform(_GeoTransform):
282279
def transform_non_affine(self, xy):
283280
# docstring inherited
284281
# MGDTODO: Math is hard ;(
285-
return xy
282+
return np.full_like(xy, np.nan)
286283

287284
def inverted(self):
288285
# docstring inherited

0 commit comments

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