Skip to content

Commit e12e014

Browse files
committed
Adds option to have references instead of deep copies of members
1 parent 7e53650 commit e12e014

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

climada/trajectories/snapshot.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class Snapshot:
5252
The date of the Snapshot, it can be an integer representing a year,
5353
a datetime object or a string representation of a datetime object
5454
with format "YYYY-MM-DD".
55+
ref_only : bool, default False
56+
Should the `Snapshot` contain deep copies of the Exposures, Hazard and Impfset (False)
57+
or references only (True).
5558
5659
Attributes
5760
----------
@@ -80,10 +83,11 @@ def __init__(
8083
hazard: Hazard,
8184
impfset: ImpactFuncSet,
8285
date: int | datetime.date | str,
86+
ref_only: bool = False,
8387
) -> None:
84-
self._exposure = copy.deepcopy(exposure)
85-
self._hazard = copy.deepcopy(hazard)
86-
self._impfset = copy.deepcopy(impfset)
88+
self._exposure = exposure if ref_only else copy.deepcopy(exposure)
89+
self._hazard = hazard if ref_only else copy.deepcopy(hazard)
90+
self._impfset = impfset if ref_only else copy.deepcopy(impfset)
8791
self._measure = None
8892
self._date = self._convert_to_date(date)
8993

0 commit comments

Comments
 (0)