Python EnumSerializer raises AttributeError on NDArray of Record types containing enum fields
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 35
- Forks
- 14
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 1
Description
Writing an NDArray whose elements are records containing enum fields raises:
AttributeError: 'numpy.uint64' object has no attribute 'value'
This affects any field of type T[] where T is a record with at least one enum field.
Call path
NDArraySerializerBase._write_dataiterates over the flat structured array and callselement_serializer.write_numpy(stream, element)whereelementis anp.voidscalar.- The generated
RecordSerializer.write_numpyextracts each field withvalue['fieldname']— yielding bare numpy scalars (e.g.np.uint64for a flag field). - It passes them to
RecordSerializer._write, which callsfield_serializer.write(stream, scalar)for each field. EnumSerializer.writedoesself._integer_serializer.write(stream, value.value)— but anp.uint64scalar has no.valueattribute.
Minimal reproducer
Tested with mrd-python v2.2.1, Python 3.13, numpy 2.4.3.
import io
import numpy as np
import mrd
from mrd.binary import AcquisitionHeaderSerializer
from mrd._binary import NDArraySerializer, CodedOutputStream
hdr_ser = AcquisitionHeaderSerializer()
arr = np.zeros((1,), dtype=hdr_ser.overall_dtype()) # structured array of AcquisitionHeader
arr_ser = NDArraySerializer(hdr_ser, 1)
arr_ser.write(CodedOutputStream(io.BytesIO()), arr)
# AttributeError: 'numpy.uint64' object has no attribute 'value'
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at NDArraySerializerBase._write_data and follow the mentioned generated RecordSerializer.write_numpy, RecordSerializer._write, and EnumSerializer.write call path. Reproduce the failure with the minimal NDArray example in the issue, then verify that an NDArray of records containing enum fields serializes without AttributeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100