BioSTEAMDevelopmentGroup / biosteam

The Biorefinery Simulation and Techno-Economic Analysis Modules; Life Cycle Assessment; Chemical Process Simulation Under Uncertainty
Other
175 stars 35 forks source link

`Model.copy` #101

Closed yalinli2 closed 2 years ago

yalinli2 commented 2 years ago

@yoelcortes Just want you to have a look and see if this is a good fix, thank you!

https://github.com/BioSTEAMDevelopmentGroup/biosteam/blob/f58d6318df74992c719a88efbf2c43f3ad5f1c9f/biosteam/evaluation/_model.py#L75

yoelcortes commented 2 years ago

@yalinli2, that looks good, I think it should look something like this. We should also add "copy" to the tests (so I don't break it again jaja):

if self.table is None:
    copy._samples = copy.table = None
else:
    copy.table = self.table.copy()
    copy._samples = self._samples
    copy._index = self._index

Thanks!

yalinli2 commented 2 years ago

Looks good, thanks @yoelcortes ! We use the copy function in QSDsan's doc (that's how I found out about this) so it's already in tests!

yoelcortes commented 2 years ago

@yalinli2 OK! I'll go ahead and fix it up.