Skip to content

Commit bea1781

Browse files
committed
apply suggestions from code review.
1 parent fd24525 commit bea1781

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

datajoint/blob.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ def read_blob(self, n_bytes=None):
163163
"F": self.read_recarray, # numpy array with fields, including recarrays
164164
"d": self.read_decimal, # a decimal
165165
"t": self.read_datetime, # date, time, or datetime
166-
"T": self.read_int64_datetime, # np.datetime64
167166
"u": self.read_uuid, # UUID
168167
}[data_structure_code]
169168
except KeyError:
@@ -199,15 +198,13 @@ def pack_blob(self, obj):
199198
return self.pack_float(obj)
200199
if isinstance(obj, np.ndarray) and obj.dtype.fields:
201200
return self.pack_recarray(np.array(obj))
202-
if isinstance(obj, np.number):
201+
if isinstance(obj, (np.number, np.datetime64)):
203202
return self.pack_array(np.array(obj))
204203
if isinstance(obj, (bool, np.bool_)):
205204
return self.pack_array(np.array(obj))
206205
if isinstance(obj, (float, int, complex)):
207206
return self.pack_array(np.array(obj))
208-
if isinstance(
209-
obj, (datetime.datetime, datetime.date, datetime.time, np.datetime64)
210-
):
207+
if isinstance(obj, (datetime.datetime, datetime.date, datetime.time)):
211208
return self.pack_datetime(obj)
212209
if isinstance(obj, Decimal):
213210
return self.pack_decimal(obj)
@@ -538,18 +535,12 @@ def read_datetime(self):
538535
)
539536
return time and date and datetime.datetime.combine(date, time) or time or date
540537

541-
def read_int64_datetime(self):
542-
data = self.read_value()
543-
return data.astype("datetime64[us]")
544-
545538
@staticmethod
546539
def pack_datetime(d):
547540
if isinstance(d, datetime.datetime):
548541
date, time = d.date(), d.time()
549542
elif isinstance(d, datetime.date):
550543
date, time = d, None
551-
elif isinstance(d, np.datetime64):
552-
return b"T" + (d.astype("datetime64[us]")).tobytes()
553544
else:
554545
date, time = None, d
555546
return b"t" + (

0 commit comments

Comments
 (0)