UC-Davis-molecular-computing / scadnano-python-package

Python scripting library for generating designs readable by scadnano.
https://scadnano.org
MIT License
13 stars 7 forks source link

closes #261: change `label` type to `str` #262

Closed dave-doty closed 1 year ago

dave-doty commented 1 year ago

Description

Changed the type of label field in Strand, Domain, Loopout, and Extension to str instead of an arbitrary object.

Related Issue

261

Motivation and Context

Supporting arbitrary data is more complex, both for the type checking (requiring some ugly Generic declarations), and for trying to serialize and deserialize automatically. Instead users can serialize and deserialize manually using the json package:

import json

nums = [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 = json.loads(strand.label)  # nums is now the list [1, 2, 3]

How Has This Been Tested?

Mostly just changed type hints, so checked that there are no mypy errors.

Screenshots (if appropriate):