Skip to content

Commit 1b41e14

Browse files
committed
ENH: match numpy for tnp.dtype(...).kind
1 parent 89a8d54 commit 1b41e14

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

torch_np/_dtypes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class bool_(generic):
197197
_typecodes = {st.typecode: st for cat in sctypes for st in sctypes[cat]}
198198
_torch_dtypes = {st.torch_dtype: st for cat in sctypes for st in sctypes[cat]}
199199

200+
200201
_aliases = {
201202
"u1": uint8,
202203
"i1": int8,
@@ -287,7 +288,8 @@ def type(self):
287288

288289
@property
289290
def kind(self):
290-
raise NotImplementedError
291+
# https://numpy.org/doc/stable/reference/generated/numpy.dtype.kind.html
292+
return _torch_dtypes[self.torch_dtype].name[0]
291293

292294
@property
293295
def typecode(self):

0 commit comments

Comments
 (0)