Skip to content

Commit 02797ab

Browse files
committed
Replace use of numpy aliases of built-in types with built-in type
Numpy 1.20 deprecated the use of numpy aliases of built-in types. Replacing the aliases with the built-in types does not change behavior but will silence the deprecation warning. https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
1 parent 39598f6 commit 02797ab

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

datajoint/blob.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def pack_blob(self, obj):
164164
return self.pack_recarray(np.array(obj))
165165
if isinstance(obj, np.number):
166166
return self.pack_array(np.array(obj))
167-
if isinstance(obj, (np.bool, np.bool_)):
167+
if isinstance(obj, (bool, np.bool_)):
168168
return self.pack_array(np.array(obj))
169169
if isinstance(obj, (datetime.datetime, datetime.date, datetime.time)):
170170
return self.pack_datetime(obj)
@@ -365,7 +365,7 @@ def read_struct(self):
365365
raw_data = [
366366
tuple(self.read_blob(n_bytes=int(self.read_value('uint64'))) for _ in range(n_fields))
367367
for __ in range(n_elem)]
368-
data = np.array(raw_data, dtype=list(zip(field_names, repeat(np.object))))
368+
data = np.array(raw_data, dtype=list(zip(field_names, repeat(object))))
369369
return self.squeeze(data.reshape(shape, order="F"), convert_to_scalar=False).view(MatStruct)
370370

371371
def pack_struct(self, array):

datajoint/table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ def _update(self, attrname, value=None):
586586
value = blob.pack(value)
587587
placeholder = '%s'
588588
elif attr.numeric:
589-
if value is None or np.isnan(np.float(value)): # nans are turned into NULLs
589+
if value is None or np.isnan(float(value)): # nans are turned into NULLs
590590
placeholder = 'NULL'
591591
value = None
592592
else:
@@ -615,7 +615,7 @@ def __make_placeholder(self, name, value, ignore_extra_fields=False):
615615
attr = self.heading[name]
616616
if attr.adapter:
617617
value = attr.adapter.put(value)
618-
if value is None or (attr.numeric and (value == '' or np.isnan(np.float(value)))):
618+
if value is None or (attr.numeric and (value == '' or np.isnan(float(value)))):
619619
# set default value
620620
placeholder, value = 'DEFAULT', None
621621
else: # not NULL

0 commit comments

Comments
 (0)