Ticket #302 (new defect)

Opened 5 years ago

Last modified 21 months ago

Usability problem: Cannot access .shape member of numpy.ndarray as tuple

Reported by: NNemec Owned by: somebody
Priority: major Milestone: wishlist
Component: Parsing Keywords: numerics
Cc:

Description

On typed variable of type numpy.ndarray, the .shape member does not work


cdef numpy.ndarray var = numpy.zeros((3,)) print var.shape


gives the cython compiler error "Cannot convert 'numpy.npy_intp *' to Python object"

===================

Comment by dagss (mailing list):


This is mostly a question of semantics. shape is defined to be a C integer array for speed of var.shape[0]. How can we define a generic rule in Cython which makes both possible?

Should the behaviour of "var.shape" e.g. depend on the requested return value? This means overloading on return value which is a non-trivial language change, though perhaps appropriate here.

Thoughts welcome!

Change History

Changed 5 years ago by NNemec

  • owner somebody deleted
  • component changed from Build System to Invalid

Changed 5 years ago by NNemec

  • keywords numerics added

Changed 5 years ago by dagss

  • owner set to somebody
  • summary changed from .shape member of numpy.ndarray broken to Usability problem: Cannot access .shape member of numpy.ndarray as tuple
  • component changed from Invalid to Parsing
  • milestone set to wishlist

Changed 21 months ago by bfroehle

Not very satisfying, but of course the following will work:

cdef np.ndarray var = np.zeros((3,))
print (<object> var).shape
Note: See TracTickets for help on using tickets.