rtviii / riboxyz

htpps://ribosome.xyz
0 stars 0 forks source link

`enum_union` #31

Open rtviii opened 10 months ago

rtviii commented 10 months ago

This gives me a lot of headaches with serialization (value != name of the enum members), but is a really good sell in organizing the PolymerTypes. What is the essential functionality of it over the vanilla python Enum? Can is be replaced? Trying with pydantic.Enum.

rtviii commented 10 months ago
members=  [*map( lambda x: x.value, [*Polynucleotide] )]
print(members)
x = "5SrRNA" in members
print(x)
['mt12SrRNA', 'mt16SrRNA', '5SrRNA', '16SrRNA']
True
rtviii commented 10 months ago

TODO : Investigate whether enum_union can be rewritten in terms of pydantic.RootModel

rtviii commented 10 months ago

the serialiazation solution for now is

    @field_serializer('nomenclature')
    def serialize_dt(self, nomenclature:list[PolymerClass], _info):
        return [x.name for x in nomenclature]
rtviii commented 4 months ago

It's been a good run of reckless arrogance and folly, but enum.StrEnum ships with python3.11 so there is no reason to indulge in this masochism any further

rtviii commented 4 months ago