Skip to content

Commit

Permalink
skip a copy of the abundances array
Browse files Browse the repository at this point in the history
  • Loading branch information
AWehrhahn committed Jun 9, 2021
1 parent 7e4f740 commit 7edfdf5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pysme/abund.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -352,16 +352,18 @@ 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'.
"""
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()

Expand Down

0 comments on commit 7edfdf5

Please sign in to comment.