Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

view_scalars no longer works with type objects #575

Open
jcrist opened this issue Feb 4, 2016 · 2 comments
Open

view_scalars no longer works with type objects #575

jcrist opened this issue Feb 4, 2016 · 2 comments

Comments

@jcrist
Copy link

jcrist commented Feb 4, 2016

This used to work in dynd 0.7.0, but doesn't work in the new release:

In [1]: from dynd import nd

In [2]: a = nd.array([1, 2, None])

In [3]: a.dtype.value_type
Out[3]:
nd.array(int32,
         type="type")

In [4]: a.view_scalars(a.dtype.value_type)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-8ec4eaa0d375> in <module>()
----> 1 a.view_scalars(a.dtype.value_type)

dynd/nd/array.pyx in dynd.nd.array.array.view_scalars (/Users/travis/build/libdynd/dynd-python/build/temp.macosx-10.5-x86_64-3.5/dynd/nd/array.cxx:5615)()

dynd/ndt/type.pyx in dynd.ndt.type.type.__init__ (/Users/travis/build/libdynd/dynd-python/build/temp.macosx-10.5-x86_64-3.5/dynd/ndt/type.cxx:1625)()

dynd/ndt/type.pyx in dynd.ndt.type.as_cpp_type (/Users/travis/build/libdynd/dynd-python/build/temp.macosx-10.5-x86_64-3.5/dynd/ndt/type.cxx:4819)()

TypeError: issubclass() arg 1 must be a class

In [5]: import dynd

In [6]: dynd.__version__
Out[6]: "b'f641248'"

It does work with strings though:

In [7]: a.view_scalars('int32')
Out[7]:
nd.array([          1,           2, -2147483648],
         type="3 * int32")
@jcrist jcrist changed the title view_scalars no longer works view_scalars no longer works with type objects Feb 4, 2016
@jcrist
Copy link
Author

jcrist commented Feb 4, 2016

Ah, it's because type.value_type is now an instance of nd.array. I can't seem to get the type out though.

In [49]: t = a.dtype.value_type

In [50]: t
Out[50]:
nd.array(int32,
         type="type")

In [51]: t[0]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-51-d0a24a012877> in <module>()
----> 1 t[0]

dynd/nd/array.pyx in dynd.nd.array.array.__getitem__ (/Users/travis/build/libdynd/dynd-python/build/temp.macosx-10.5-x86_64-3.5/dynd/nd/array.cxx:3253)()

IndexError: provided 1 indices to dynd type type, but only 0 dimensions available

In [52]: t.to(ndt.type)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-52-055b254edf25> in <module>()
----> 1 t.to(ndt.type)

dynd/nd/array.pyx in dynd.nd.array.array.to (/Users/travis/build/libdynd/dynd-python/build/temp.macosx-10.5-x86_64-3.5/dynd/nd/array.cxx:2196)()

TypeError: Can't convert 'type' object to str implicitly

In [53]: ndt.type(t)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-53-55abca7be71c> in <module>()
----> 1 ndt.type(t)

dynd/ndt/type.pyx in dynd.ndt.type.type.__init__ (/Users/travis/build/libdynd/dynd-python/build/temp.macosx-10.5-x86_64-3.5/dynd/ndt/type.cxx:1625)()

dynd/ndt/type.pyx in dynd.ndt.type.as_cpp_type (/Users/travis/build/libdynd/dynd-python/build/temp.macosx-10.5-x86_64-3.5/dynd/ndt/type.cxx:4819)()

TypeError: issubclass() arg 1 must be a class

In [54]: str(t)
Out[54]: 'nd.array(int32,\n         type="type")'

@izaid
Copy link
Member

izaid commented Feb 4, 2016

That's a bug (and easy to fix), will do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants