Commit e3a55ce1 authored by Yannick Roehlly's avatar Yannick Roehlly
Browse files

Use a set for mass_proportional_info

Using a list to keep the information keys that are proportional to the
mass leads to problems when forcing the update of a proportional
information: the key name appears then twice (or more) in the list and
the information is multiplied twice (or more) by the mass.
parent 0aebb666
...@@ -25,7 +25,7 @@ Such SED is characterised by: ...@@ -25,7 +25,7 @@ Such SED is characterised by:
- info: a dictionary containing various information about the SED. - info: a dictionary containing various information about the SED.
- mass_proportional_info: the list of keys in the info dictionary whose value - mass_proportional_info: the set of keys in the info dictionary whose value
is proportional to the galaxy mass. is proportional to the galaxy mass.
""" """
...@@ -66,7 +66,7 @@ class SED(object): ...@@ -66,7 +66,7 @@ class SED(object):
self.luminosity = None self.luminosity = None
self.luminosities = None self.luminosities = None
self.info = OrderedDict() self.info = OrderedDict()
self.mass_proportional_info = [] self.mass_proportional_info = set()
self.cache_filters = {} self.cache_filters = {}
@property @property
...@@ -134,7 +134,7 @@ class SED(object): ...@@ -134,7 +134,7 @@ class SED(object):
if (key not in self.info) or force: if (key not in self.info) or force:
self.info[key] = value self.info[key] = value
if mass_proportional: if mass_proportional:
self.mass_proportional_info.append(key) self.mass_proportional_info.add(key)
else: else:
raise KeyError("The information %s is already present " raise KeyError("The information %s is already present "
"in the SED. " % key) "in the SED. " % key)
...@@ -345,7 +345,7 @@ class SED(object): ...@@ -345,7 +345,7 @@ class SED(object):
sed.luminosities = None sed.luminosities = None
sed.contribution_names = self.contribution_names[:] sed.contribution_names = self.contribution_names[:]
sed.info = self.info.copy() sed.info = self.info.copy()
sed.mass_proportional_info = self.mass_proportional_info[:] sed.mass_proportional_info = self.mass_proportional_info.copy()
sed.cache_filters = self.cache_filters sed.cache_filters = self.cache_filters
return sed return sed
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment