[Numpy-discussion] Structured array with no fields - possible?

Matthew Brett matthew.brett@gmail....
Tue May 5 11:33:53 CDT 2009


>> I'm afraid what I need is some way of representing the fact that I
>> have read, from matlab, a structure with no fields (and therefore no
>> data) that can be - say - shape (10,2) - or any other.
> how about:
>  >>> a = np.empty(size, dtype=np.object)
>  >>>
>  >>> a
> array([[None, None, None, None],
>        [None, None, None, None],
>        [None, None, None, None]], dtype=object)

Yes, that's the solution I came to in the end, the problem being that
it is hard for the roundtrip (matlab->python->matlab) to tell that
this Python thing should be converted to an empty struct;  normally
structs are numpy structured arrays, and I used object arrays for
matlab cell arrays.   Your empty class idea is good, and more
obviously identifiable, at least to the code.

But thanks for the thoughts, it's helpful to try and think it through,


More information about the Numpy-discussion mailing list