python-matplotlib/97e170d2fc2c_Pass-integers-to-np_linspace.patch

71 lines
2.9 KiB
Diff

From 97e170d2fc2c2e8771148ea031bf39cdce3a014d Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Wed, 7 Dec 2016 00:14:07 -0500
Subject: [PATCH] Pass integers to np.linspace/np.logspace's count.
This fixes "DeprecationWarning: object of type <class 'float'> cannot
be safely interpreted as an integer." raised by latest NumPy.
---
examples/api/custom_projection_example.py | 4 ++--
lib/matplotlib/projections/geo.py | 4 ++--
lib/matplotlib/tests/test_path.py | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/examples/api/custom_projection_example.py b/examples/api/custom_projection_example.py
index 7dc0ca2b1e4..b8c13eff733 100644
--- a/examples/api/custom_projection_example.py
+++ b/examples/api/custom_projection_example.py
@@ -298,7 +298,7 @@ def set_longitude_grid(self, degrees):
class -- it provides a more convenient interface to set the
ticking than set_xticks would.
"""
- number = (360.0 / degrees) + 1
+ number = int(360 / degrees) + 1
self.xaxis.set_major_locator(
FixedLocator(
np.linspace(-np.pi, np.pi, number, True)[1:-1]))
@@ -312,7 +312,7 @@ def set_latitude_grid(self, degrees):
class -- it provides a more convenient interface than
set_yticks would.
"""
- number = (180.0 / degrees) + 1
+ number = int(180 / degrees) + 1
self.yaxis.set_major_locator(
FixedLocator(
np.linspace(-np.pi / 2.0, np.pi / 2.0, number, True)[1:-1]))
diff --git a/lib/matplotlib/projections/geo.py b/lib/matplotlib/projections/geo.py
index a428b1380cb..e834f008795 100644
--- a/lib/matplotlib/projections/geo.py
+++ b/lib/matplotlib/projections/geo.py
@@ -190,7 +190,7 @@ def set_longitude_grid(self, degrees):
"""
Set the number of degrees between each longitude grid.
"""
- number = (360.0 / degrees) + 1
+ number = int(360 / degrees) + 1
self.xaxis.set_major_locator(
FixedLocator(
np.linspace(-np.pi, np.pi, number, True)[1:-1]))
@@ -201,7 +201,7 @@ def set_latitude_grid(self, degrees):
"""
Set the number of degrees between each longitude grid.
"""
- number = (180.0 / degrees) + 1
+ number = int(180 / degrees) + 1
self.yaxis.set_major_locator(
FixedLocator(
np.linspace(-np.pi / 2.0, np.pi / 2.0, number, True)[1:-1]))
diff --git a/lib/matplotlib/tests/test_path.py b/lib/matplotlib/tests/test_path.py
index c29289ae81f..71fcb7c89bc 100644
--- a/lib/matplotlib/tests/test_path.py
+++ b/lib/matplotlib/tests/test_path.py
@@ -97,7 +97,7 @@ def test_make_compound_path_empty():
def test_xkcd():
np.random.seed(0)
- x = np.linspace(0, 2.0 * np.pi, 100.0)
+ x = np.linspace(0, 2 * np.pi, 100)
y = np.sin(x)
with plt.xkcd():