Hello all! I am a bit confused by the behaviour of mrecarray:
>>> import numpy.ma.mrecords >>> data = [(1, 'a'), (2, 'b')] >>> ra = numpy.rec.fromrecords(data) >>> mra = numpy.ma.mrecords.fromrecords(data) >>> ra rec.array([(1, 'a'), (2, 'b')], dtype=[('f0', '<i4'), ('f1', '|S1')]) >>> mra masked_records( f0 : [1 2] f1 : [a b] fill_value : (999999, 'N') ) >>> for a in [ra, mra]: ... for cname, cell in [('row first', a[0]['f1']), ('field first', a['f1'][0])]: ... print(type(a), cname, cell, type(cell), sep=', ') ... <class 'numpy.core.records.recarray'>, row first, a, <type 'numpy.string_'> <class 'numpy.core.records.recarray'>, field first, a, <type 'numpy.string_'> <class 'numpy.ma.mrecords.MaskedRecords'>, row first, a, <class 'numpy.ma.core.MaskedArray'> <class 'numpy.ma.mrecords.MaskedRecords'>, field first, a, <type 'numpy.string_'> Why when I index an mrecarray by offset before field do I get a zero-dimension MaskedArray instead of the object I get when indexing by field then offset? This seems strange behaviour. Is it documented? It doesn't seem to be tested; ma/tests/test_mrecords.py:79,87<https://github.com/numpy/numpy/blob/master/numpy/ma/tests/test_mrecords.py#L79>asserts equality of value but says nothing about the types that should be returned. Similarly: >>> mra['f1'][0] == mra[0]['f1'] masked_array(data = True, mask = False, fill_value = True) >>> type(mra['f1'][0]) == type(mra[0]['f1']) False I look forward to any explanation or clarification! Thanks, - Joel
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion