How to add entry to Spectrum metadata #107
-
How to update the metadata of a spectrum instance ? @georgievgeorgi
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Spectrum.meta
is a getter forSpectrum._metadata
which is an instance ofSpeMetadataModel
which does not provide a setter. By design Spectrum for the most part should be immutable. By altering the metadata dictionary you will be violating this concept. Withspe.meta = new_meta
you may change the metadata with new dictionary which will be validated toSpeMetadataModel
.If for a reason you need to modify it in-place, you can do so with
spe.meta.__root__['new_key'] = 'new_val'
You may define also a setter in
SpeMetadataModel
, which i discourage, as it makes it easy for the end user to alter the metadata and again brakes the concept of immutability of the Spectrum instances.