Skip to content

Commit

Permalink
Fix warnings associated with NumPy deprecations. (#226)
Browse files Browse the repository at this point in the history
* Fix warnings associated wtih NumPy deprecations.

* NumPy deprecation fixes (numpy.object -> object)
  • Loading branch information
douglasdavis authored Dec 12, 2020
1 parent 6126798 commit 9092a40
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions uproot/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def isint(x):
including bool).
"""
return isinstance(x, (int, numbers.Integral, numpy.integer)) and not isinstance(
x, (numpy.bool, numpy.bool_)
x, (bool, numpy.bool_)
)


Expand All @@ -57,7 +57,7 @@ def isnum(x):
including bool).
"""
return isinstance(x, (int, float, numbers.Real, numpy.number)) and not isinstance(
x, (numpy.bool, numpy.bool_)
x, (bool, numpy.bool_)
)


Expand Down Expand Up @@ -390,7 +390,7 @@ def awkward_form(
model = model.newbyteorder("=")

if model not in _primitive_awkward_form:
if model == numpy.dtype(numpy.bool_) or model == numpy.dtype(numpy.bool):
if model == numpy.dtype(numpy.bool_) or model == numpy.dtype(bool):
_primitive_awkward_form[model] = awkward.forms.Form.fromjson('"bool"')
elif model == numpy.dtype(numpy.int8):
_primitive_awkward_form[model] = awkward.forms.Form.fromjson('"int8"')
Expand Down
6 changes: 3 additions & 3 deletions uproot/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


_stl_container_size = struct.Struct(">I")
_stl_object_type = numpy.dtype(numpy.object)
_stl_object_type = numpy.dtype(object)


def _content_typename(content):
Expand Down Expand Up @@ -695,7 +695,7 @@ def read(self, chunk, cursor, context, file, selffile, parent, header=True):
context,
file.file_path,
)
return numpy.array(out, dtype=numpy.dtype(numpy.object))
return numpy.array(out, dtype=numpy.dtype(object))

else:
if self._speedbump:
Expand All @@ -713,7 +713,7 @@ def read(self, chunk, cursor, context, file, selffile, parent, header=True):
chunk, cursor, context, file, selffile, parent
)
)
return numpy.array(out, dtype=numpy.dtype(numpy.object))
return numpy.array(out, dtype=numpy.dtype(object))


class AsVector(AsContainer):
Expand Down
2 changes: 1 addition & 1 deletion uproot/interpretation/jagged.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __eq__(self, other):

@property
def numpy_dtype(self):
return numpy.dtype(numpy.object)
return numpy.dtype(object)

def awkward_form(
self,
Expand Down
8 changes: 4 additions & 4 deletions uproot/interpretation/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ def finalize(self, array, branch, interpretation, entry_start, entry_stop):
if isinstance(array, uproot.interpretation.jagged.JaggedArray) and isinstance(
array.content, uproot.interpretation.objects.StridedObjectArray,
):
out = numpy.zeros(len(array), dtype=numpy.object)
out = numpy.zeros(len(array), dtype=object)
for i, x in enumerate(array):
out[i] = numpy.zeros(len(x), dtype=numpy.object)
out[i] = numpy.zeros(len(x), dtype=object)
for j, y in enumerate(x):
out[i][j] = y
return out
Expand All @@ -221,7 +221,7 @@ def finalize(self, array, branch, interpretation, entry_start, entry_stop):
uproot.interpretation.objects.StridedObjectArray,
),
):
out = numpy.zeros(len(array), dtype=numpy.object)
out = numpy.zeros(len(array), dtype=object)
for i, x in enumerate(array):
out[i] = x
return out
Expand Down Expand Up @@ -849,7 +849,7 @@ def finalize(self, array, branch, interpretation, entry_start, entry_stop):
uproot.interpretation.objects.ObjectArray,
),
):
out = numpy.zeros(len(array), dtype=numpy.object)
out = numpy.zeros(len(array), dtype=object)
for i, x in enumerate(array):
out[i] = x
index = _pandas_basic_index(pandas, entry_start, entry_stop)
Expand Down
6 changes: 3 additions & 3 deletions uproot/interpretation/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __eq__(self, other):

@property
def numpy_dtype(self):
return numpy.dtype(numpy.object)
return numpy.dtype(object)

@property
def cache_key(self):
Expand Down Expand Up @@ -419,7 +419,7 @@ def __eq__(self, other):

@property
def numpy_dtype(self):
return numpy.dtype(numpy.object)
return numpy.dtype(object)

def awkward_form(
self,
Expand Down Expand Up @@ -572,7 +572,7 @@ def to_numpy(self):
"""
Convert this ObjectArray into a NumPy ``dtype="O"`` (object) array.
"""
output = numpy.empty(len(self), dtype=numpy.dtype(numpy.object))
output = numpy.empty(len(self), dtype=numpy.dtype(object))
for i in range(len(self)):
output[i] = self[i]
return output
Expand Down
2 changes: 1 addition & 1 deletion uproot/interpretation/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def typename(self):

@property
def numpy_dtype(self):
return numpy.dtype(numpy.object)
return numpy.dtype(object)

def awkward_form(
self,
Expand Down
2 changes: 1 addition & 1 deletion uproot/streamers.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ def read_members(self, chunk, cursor, context, file):
uproot.const.kULong,
uproot.const.kLong,
):
self._bases[0]._members["fSize"] = numpy.dtype(numpy.long).itemsize
self._bases[0]._members["fSize"] = numpy.dtype(numpy.compat.long).itemsize

elif self._bases[0]._members["fType"] in (
uproot.const.kULong64,
Expand Down

0 comments on commit 9092a40

Please sign in to comment.