wtclarke / pymapvbvd

Python port of mapVBVD
MIT License
40 stars 25 forks source link

Mutable default values #21

Closed DimitriPapadopoulos closed 1 year ago

DimitriPapadopoulos commented 1 year ago

Python 3.11 reports this bug related to the use of dataclasses:

ValueError: mutable default <class 'numpy.ndarray'> for field sz is not allowed: use default_factory

Need to use default factory functions to avoid mutable default values (np.array): https://github.com/wtclarke/pymapvbvd/blob/26471620a77c7d2766d816e784b0600ea508fc7e/mapvbvd/twix_map_obj.py#L197-L204

See also https://github.com/wtclarke/spec2nii/pull/55.