Skip to content

compose datashapes for view casting #366

Open

Description

@jreback

This works great.

In [11]: arr = nd.array([1.5,2,3],dtype='?float64')

In [12]: arr
Out[12]: 
nd.array([1.5,   2,   3],
         type="3 * ?float64")

In [13]: nd.view(arr,ndt.type('3 * float64'))
Out[13]: 
nd.array([1.5,   2,   3],
         type="3 * float64")

however, say I want to cast to float32. I need to compose 3 * float32). Is their a way in ndt to do this generally?

It can be done by string substituteion with this, but not that elegant

In [16]: nd.dshape_of(arr)
Out[16]: '3 * ?float64'

Activity

  1. mwiebe commented on Sep 21, 2015

    @mwiebe
    Member

    One idea is to add a search/replace pattern matching method on the ndt.type. Like tp.replace("Scalar", "float32") to substitute the dtype.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions