You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scadnano supports the notion of a label attached to a strand, domain, loopout, or extension.
Currently, the type of label is an arbitrary JSON-serializable object. However, this makes type checking awkward, and since such objects can be mutable, the web interface (which relies on immutable state date) might have unforeseen problems due to this.
It would be simpler to simply say the type of label is a string. If a user wants more structured data, they can do the JSON serialization and deserialization themselves. Note that this will be a breaking change.
Changed the type of label field in Strand, Domain, Loopout, and Extension to str instead of an arbitrary object.
This is a breaking change because existing code using non-string labels will have to be altered to change the data to a string before storing and change it back to structured data when reading.
Users can serialize to a string and deserialize back to structured data manually using the json package.
Before, this was possible:
fromtypingimportList# previously was possible, now is not supportednums= [1, 2, 3]
strand.label=nums# stores strand.label as the list [1, 2, 3]; would be a mypy type error now# and to get the structured data back out:nums: List[int] =strand.label# would be a mypy type error now
Now this is necessary to store a list of int's in the label:
importjsonfromtypingimportListnums= [1, 2, 3]
strand.label=json.dumps(nums) # stores strand.label as the string '[1, 2, 3]'# and to get the structured data back out:nums: List[int] =json.loads(strand.label) # nums is now the list [1, 2, 3]
Scadnano supports the notion of a
label
attached to a strand, domain, loopout, or extension.Currently, the type of
label
is an arbitrary JSON-serializable object. However, this makes type checking awkward, and since such objects can be mutable, the web interface (which relies on immutable state date) might have unforeseen problems due to this.It would be simpler to simply say the type of
label
is a string. If a user wants more structured data, they can do the JSON serialization and deserialization themselves. Note that this will be a breaking change.See UC-Davis-molecular-computing/scadnano#878
The text was updated successfully, but these errors were encountered: