From 7edfdf55e495f9a78a20d2280919d8a78d3fc1e2 Mon Sep 17 00:00:00 2001 From: Ansgar Wehrhahn <31626864+AWehrhahn@users.noreply.github.com> Date: Wed, 9 Jun 2021 15:48:20 +0200 Subject: [PATCH] skip a copy of the abundances array --- src/pysme/abund.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pysme/abund.py b/src/pysme/abund.py index 6f328f82..6333532d 100644 --- a/src/pysme/abund.py +++ b/src/pysme/abund.py @@ -235,7 +235,7 @@ def __call__(self, type="H=12", raw=False): pattern = np.copy(self._pattern) if self.monh is not None: pattern[2:] += self.monh - return self.totype(pattern, type, raw=raw) + return self.totype(pattern, type, raw=raw, copy=False) def __getitem__(self, elem): return self.get_element(elem) @@ -352,7 +352,7 @@ def fromtype(pattern, fromtype, raw=False): return {el: abund[elements_dict[el]] for el in elements} @staticmethod - def totype(pattern, totype, raw=False): + def totype(pattern, totype, raw=False, copy=True): """Return a copy of the input abundance pattern, transformed from the 'H=12' type to the output type. Valid abundance pattern types are 'sme', 'n/nTot', 'n/nH', and 'H=12'. @@ -360,8 +360,10 @@ def totype(pattern, totype, raw=False): if isinstance(pattern, dict): abund = [pattern[el] if el in pattern.keys() else np.nan for el in elements] abund = np.array(abund) - else: + elif copy: abund = np.copy(pattern) + else: + abund = pattern type = totype.lower()