`NTEnum` doesn't use passed in `extra` on init
Currently, both NTScalar and NTEnum allow for extra to be passed in on initialisation, which means additional fields can be passed in on init. These fields can be used in NTScalar, but not on NTEnum:
NTScalar
A record with type
some_scalar_t = NTScalar("b", extra=[("description", "s")]
Allows for wrapping and unwrapping with a description:
some_scalar = some_scalar_t.wrap({
"value": False,
"description": "haha"
})
and
[:)] pvget -v DEVICE:Child:E
DEVICE:Child:E epics:nt/NTScalar:1.0
byte value 0
time_t timeStamp 2025-02-05 09:10:21.911
long secondsPastEpoch 1738746621
int nanoseconds 911180973
string description haha
Extra is passed in:
https://github.com/epics-base/p4p/blob/9040d4bb56d58b674de1475dbb62444a056f6729/src/p4p/nt/scalar.py#L199
On wrap the type of the value is used:
https://github.com/epics-base/p4p/blob/9040d4bb56d58b674de1475dbb62444a056f6729/src/p4p/nt/scalar.py#L235-L236
NTEnum - fixed by #154
NTEnum also takes extra, and builds its type with it:
https://github.com/epics-base/p4p/blob/9040d4bb56d58b674de1475dbb62444a056f6729/src/p4p/nt/enum.py#L42
However, wrap fails to take the extra fields:
https://github.com/epics-base/p4p/blob/9040d4bb56d58b674de1475dbb62444a056f6729/src/p4p/nt/enum.py#L62-L76
EDIT
NTNDArray also has this problem. buildType will extend with extra:
https://github.com/epics-base/p4p/blob/9040d4bb56d58b674de1475dbb62444a056f6729/src/p4p/nt/ndarray.py#L91
But wrap won't add extra fields:
https://github.com/epics-base/p4p/blob/9040d4bb56d58b674de1475dbb62444a056f6729/src/p4p/nt/ndarray.py#L171-L180
I'm also struggling to get NTEnuma().wrap # No extra= to work with any input, either
wrap(some_index, choices=["A", "B"])
or
wrap({"choices": ["A", "B"], "index": some_index})
I believe https://github.com/epics-base/p4p/pull/154 fixes this issue, but only for NTEnum types.
Yes, looks like it fixes the enum part.