Skip to content

How to add entry to Spectrum metadata #107

Answered by georgievgeorgi
vedina asked this question in Q&A
Discussion options

You must be logged in to vote

Spectrum.meta is a getter for Spectrum._metadata which is an instance of SpeMetadataModel 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. With spe.meta = new_meta you may change the metadata with new dictionary which will be validated to SpeMetadataModel.
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.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by vedina
Comment options

vedina
Mar 13, 2024
Maintainer Author

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants