ClimateImpactLab / metacsv

Tools for documentation-aware data reading, writing, and analysis

Home Page:https://metacsv.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The `copy` method on `Variables` does not work as expected

jrising opened this issue · comments

MetaCSV objects support a copy method, which applies copy to all the contained information, including the variables, going so far as to create a new Variables object in the new MetaCSV object. But changing the newly copied object changes the original. This is because the final copy is not a deep-copy, and all content, like units and descriptions, are a second level deep.

I currently work around this by saying:

newcsv['variables']._data = copy.deepcopy(newcsv['variables']._data)

before updating information in the variables.