Skip to content

Commit

Permalink
Add hack (possibly temporary) to support bfloat16.
Browse files Browse the repository at this point in the history
  • Loading branch information
skrah committed Apr 10, 2018
1 parent b6a7a67 commit d516021
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/xnd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ class xnd(Xnd):
xnd([49, 50, 51], type="3 * uint8")
"""

def __new__(cls, value, *, type=None, dtype=None, levels=None, typedef=None):
if (type, dtype, levels, typedef).count(None) < 2:
def __new__(cls, value, *, type=None, dtype=None, levels=None,
typedef=None, dtypedef=None):
if (type, dtype, levels, typedef, dtypedef).count(None) < 2:
raise TypeError(
"the 'type', 'dtype', 'levels' and 'typedef' arguments are "
"mutually exclusive")
Expand All @@ -118,6 +119,9 @@ def __new__(cls, value, *, type=None, dtype=None, levels=None, typedef=None):
dtype = type.hidden_dtype
t = typeof(value, dtype=dtype)
type = instantiate(typedef, t)
elif dtypedef is not None:
dtype = ndt(dtypedef)
type = typeof(value, dtype=dtype)
else:
type = typeof(value)
return super().__new__(cls, type=type, value=value)
Expand Down

0 comments on commit d516021

Please sign in to comment.