Skip to content

Commit

Permalink
Finish swapping np.float{,_} -> float; ma -> np.ma
Browse files Browse the repository at this point in the history
plus other comments on the PR.
  • Loading branch information
anntzer committed Jun 13, 2016
1 parent 71d9386 commit a101a9b
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 164 deletions.
3 changes: 1 addition & 2 deletions examples/misc/rec_join_demo.py
Expand Up @@ -11,8 +11,7 @@
r1 = r[-10:]

# Create a new array
r2 = np.empty(12, dtype=[('date', '|O4'), ('high', np.float),
('marker', np.float)])
r2 = np.empty(12, dtype=[('date', '|O4'), ('high', float), ('marker', float)])
r2 = r2.view(np.recarray)
r2.date = r.date[-17:-5]
r2.high = r.high[-17:-5]
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/demo_ribbon_box.py
Expand Up @@ -121,7 +121,7 @@ def draw(self, renderer, *args, **kwargs):
interpolation="bicubic",
zorder=0.1,
)
gradient = np.zeros((2, 2, 4), dtype=np.float)
gradient = np.zeros((2, 2, 4), dtype=float)
gradient[:, :, :3] = [1, 1, 0.]
gradient[:, :, 3] = [[0.1, 0.3], [0.3, 0.5]] # alpha channel
patch_gradient.set_array(gradient)
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/dolphin.py
Expand Up @@ -74,7 +74,7 @@
vertices.extend([[float(x) for x in y.split(',')] for y in
parts[i + 1:i + npoints + 1]])
i += npoints + 1
vertices = np.array(vertices, np.float)
vertices = np.array(vertices, float)
vertices[:, 1] -= 160

dolphin_path = Path(vertices, codes)
Expand Down
2 changes: 1 addition & 1 deletion examples/units/units_scatter.py
Expand Up @@ -15,7 +15,7 @@
# create masked array


xsecs = secs*np.ma.MaskedArray((1, 2, 3, 4, 5, 6, 7, 8), (1, 0, 1, 0, 0, 0, 1, 0), np.float)
xsecs = secs*np.ma.MaskedArray((1, 2, 3, 4, 5, 6, 7, 8), (1, 0, 1, 0, 0, 0, 1, 0), float)
#xsecs = secs*np.arange(1,10.)

fig = figure()
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/__init__.py
Expand Up @@ -126,7 +126,6 @@
cycler)

import numpy
import numpy.ma
from matplotlib.externals.six.moves.urllib.request import urlopen
from matplotlib.externals.six.moves import reload_module as reload

Expand Down
14 changes: 7 additions & 7 deletions lib/matplotlib/axes/_axes.py
Expand Up @@ -2357,7 +2357,7 @@ def stem(self, *args, **kwargs):

# Try a second one
try:
second = np.asarray(args[0], dtype=np.float)
second = np.asarray(args[0], dtype=float)
x, y = y, second
args = args[1:]
except (IndexError, ValueError):
Expand Down Expand Up @@ -4739,7 +4739,7 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
continue

N = len(xslice)
X = np.zeros((2 * N + 2, 2), np.float)
X = np.zeros((2 * N + 2, 2), float)

if interpolate:
def get_interp_point(ind):
Expand Down Expand Up @@ -4889,7 +4889,7 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
continue

N = len(yslice)
Y = np.zeros((2 * N + 2, 2), np.float)
Y = np.zeros((2 * N + 2, 2), float)

# the purpose of the next two lines is for when x2 is a
# scalar like 0 and we want the fill to go all the way
Expand Down Expand Up @@ -6203,7 +6203,7 @@ def _normalize_input(inp, ename='input'):

for m, c in zip(n, color):
if bottom is None:
bottom = np.zeros(len(m), np.float)
bottom = np.zeros(len(m), float)
if stacked:
height = m - bottom
else:
Expand All @@ -6222,14 +6222,14 @@ def _normalize_input(inp, ename='input'):

elif histtype.startswith('step'):
# these define the perimeter of the polygon
x = np.zeros(4 * len(bins) - 3, np.float)
y = np.zeros(4 * len(bins) - 3, np.float)
x = np.zeros(4 * len(bins) - 3, float)
y = np.zeros(4 * len(bins) - 3, float)

x[0:2*len(bins)-1:2], x[1:2*len(bins)-1:2] = bins, bins[:-1]
x[2*len(bins)-1:] = x[1:2*len(bins)-1][::-1]

if bottom is None:
bottom = np.zeros(len(bins)-1, np.float)
bottom = np.zeros(len(bins)-1, float)

y[1:2*len(bins)-1:2], y[2:2*len(bins):2] = bottom, bottom
y[2*len(bins)-1:] = y[1:2*len(bins)-1][::-1]
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backend_bases.py
Expand Up @@ -327,7 +327,7 @@ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,

if edgecolors is None:
edgecolors = facecolors
linewidths = np.array([gc.get_linewidth()], np.float_)
linewidths = np.array([gc.get_linewidth()], float)

return self.draw_path_collection(
gc, master_transform, paths, [], offsets, offsetTrans, facecolors,
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/cbook.py
Expand Up @@ -2303,7 +2303,7 @@ def pts_to_prestep(x, *args):
# do normalization
vertices = _step_validation(x, *args)
# create the output array
steps = np.zeros((vertices.shape[0], 2 * len(x) - 1), np.float)
steps = np.zeros((vertices.shape[0], 2 * len(x) - 1), float)
# do the to step conversion logic
steps[0, 0::2], steps[0, 1::2] = vertices[0, :], vertices[0, :-1]
steps[1:, 0::2], steps[1:, 1:-1:2] = vertices[1:, :], vertices[1:, 1:]
Expand Down Expand Up @@ -2343,7 +2343,7 @@ def pts_to_poststep(x, *args):
# do normalization
vertices = _step_validation(x, *args)
# create the output array
steps = np.zeros((vertices.shape[0], 2 * len(x) - 1), np.float)
steps = np.zeros((vertices.shape[0], 2 * len(x) - 1), float)
# do the to step conversion logic
steps[0, ::2], steps[0, 1:-1:2] = vertices[0, :], vertices[0, 1:]
steps[1:, 0::2], steps[1:, 1::2] = vertices[1:, :], vertices[1:, :-1]
Expand Down Expand Up @@ -2384,7 +2384,7 @@ def pts_to_midstep(x, *args):
# do normalization
vertices = _step_validation(x, *args)
# create the output array
steps = np.zeros((vertices.shape[0], 2 * len(x)), np.float)
steps = np.zeros((vertices.shape[0], 2 * len(x)), float)
steps[0, 1:-1:2] = 0.5 * (vertices[0, :-1] + vertices[0, 1:])
steps[0, 2::2] = 0.5 * (vertices[0, :-1] + vertices[0, 1:])
steps[0, 0] = vertices[0, 0]
Expand Down
16 changes: 8 additions & 8 deletions lib/matplotlib/collections.py
Expand Up @@ -76,7 +76,7 @@ class Collection(artist.Artist, cm.ScalarMappable):
(i.e., a call to set_array has been made), at draw time a call to
scalar mappable will be made to set the face colors.
"""
_offsets = np.array([], np.float_)
_offsets = np.array([], float)
# _offsets must be a Nx2 array!
_offsets.shape = (0, 2)
_transOffset = transforms.IdentityTransform()
Expand Down Expand Up @@ -129,7 +129,7 @@ def __init__(self,
self.set_zorder(zorder)

self._uniform_offsets = None
self._offsets = np.array([[0, 0]], np.float_)
self._offsets = np.array([[0, 0]], float)
if offsets is not None:
offsets = np.asanyarray(offsets)
offsets.shape = (-1, 2) # Make it Nx2
Expand Down Expand Up @@ -197,7 +197,7 @@ def get_datalim(self, transData):
offsets = transOffset.transform_non_affine(offsets)
transOffset = transOffset.get_affine()

offsets = np.asanyarray(offsets, np.float_)
offsets = np.asanyarray(offsets, float)
if isinstance(offsets, np.ma.MaskedArray):
offsets = offsets.filled(np.nan)
# get_path_collection_extents handles nan but not masked arrays
Expand Down Expand Up @@ -239,7 +239,7 @@ def _prepare_points(self):
ys = self.convert_yunits(offsets[:, 1])
offsets = list(zip(xs, ys))

offsets = np.asanyarray(offsets, np.float_)
offsets = np.asanyarray(offsets, float)
offsets.shape = (-1, 2) # Make it Nx2

if not transform.is_affine:
Expand Down Expand Up @@ -428,7 +428,7 @@ def set_offsets(self, offsets):
ACCEPTS: float or sequence of floats
"""
offsets = np.asanyarray(offsets, np.float_)
offsets = np.asanyarray(offsets, float)
offsets.shape = (-1, 2) # Make it Nx2
#This decision is based on how they are initialized above
if self._uniform_offsets is None:
Expand Down Expand Up @@ -1162,7 +1162,7 @@ def set_segments(self, segments):

for seg in segments:
if not isinstance(seg, np.ma.MaskedArray):
seg = np.asarray(seg, np.float_)
seg = np.asarray(seg, float)
_segments.append(seg)

if self._uniform_offsets is not None:
Expand Down Expand Up @@ -1752,7 +1752,7 @@ def __init__(self, meshWidth, meshHeight, coordinates,
# By converting to floats now, we can avoid that on every draw.
self._coordinates = self._coordinates.reshape(
(meshHeight + 1, meshWidth + 1, 2))
self._coordinates = np.array(self._coordinates, np.float_)
self._coordinates = np.array(self._coordinates, float)

def get_paths(self):
if self._paths is None:
Expand Down Expand Up @@ -1850,7 +1850,7 @@ def draw(self, renderer):
ys = self.convert_yunits(self._offsets[:, 1])
offsets = list(zip(xs, ys))

offsets = np.asarray(offsets, np.float_)
offsets = np.asarray(offsets, float)
offsets.shape = (-1, 2) # Make it Nx2

self.update_scalarmappable()
Expand Down

0 comments on commit a101a9b

Please sign in to comment.