Commit 5358690c authored by Médéric Boquien's avatar Médéric Boquien

Eliminate remnants of the previous SED cache system now that are not needed anymore.

parent fe9ea2dc
......@@ -26,13 +26,12 @@ def init_sed(models, counter):
Counter for the number of models computed
"""
global gbl_previous_idx, gbl_warehouse, gbl_models, gbl_counter
global gbl_warehouse, gbl_models, gbl_counter
# Limit the number of threads to 1 if we use MKL in order to limit the
# oversubscription of the CPU/RAM.
nothread()
gbl_previous_idx = -1
gbl_warehouse = SedWarehouse()
gbl_models = models
......@@ -77,10 +76,9 @@ def init_bestfit(conf, params, observations, results, counter):
Counter for the number of objects analysed
"""
global gbl_previous_idx, gbl_warehouse, gbl_conf, gbl_params, gbl_obs
global gbl_warehouse, gbl_conf, gbl_params, gbl_obs
global gbl_results, gbl_counter
gbl_previous_idx = -1
gbl_warehouse = SedWarehouse()
gbl_conf = conf
......
......@@ -24,15 +24,12 @@ def init_fluxes(models, counter):
Counter for the number of models computed
"""
global gbl_previous_idx, gbl_warehouse, gbl_models, gbl_obs, gbl_save
global gbl_counter
global gbl_warehouse, gbl_models, gbl_obs, gbl_save, gbl_counter
# Limit the number of threads to 1 if we use MKL in order to limit the
# oversubscription of the CPU/RAM.
nothread()
gbl_previous_idx = -1
gbl_warehouse = SedWarehouse()
gbl_models = models
......
......@@ -138,29 +138,6 @@ class ParametersManagerGrid(object):
return params
def index_module_changed(self, idx1, idx2):
"""Find the index of the first module affected by a change of parameters.
Parameters
----------
idx1: int
First index
idx2: int
Second index
Returns
-------
module_idx: int
Index of the first module that has a different parameter
"""
indices = np.unravel_index((idx1, idx2), self.shape)
for module_idx, (i, j) in enumerate(indices):
if i != j:
return module_idx
return len(self.shape)
class ParametersManagerFile(object):
"""Class to generate a parameters manager for list of parameters given in an
......@@ -244,26 +221,3 @@ class ParametersManagerFile(object):
in enumerate(self.modules)]
return params
def index_module_changed(self, idx1, idx2):
"""Find the index of the first module affected by a change of parameters.
Parameters
----------
idx1: int
First index
idx2: int
Second index
Returns
-------
module_idx: int
Index of the first module that has a different parameter
"""
for module_idx, module in enumerate(self.parameters):
if any([param[idx1] != param[idx2] for param in module.values()]):
return module_idx
return len(self.parameters)
......@@ -67,28 +67,6 @@ class SedWarehouse(object):
return module
def partial_clear_cache(self, n_modules_max):
"""Clear the cache of SEDs that are not relevant anymore
To do partial clearing of the cache, we go through the entire cache
and delete the SEDs that have more than a given number of modules.
This is done by computing the index of the module that has a changed
parameter. This means that SEDs with this number of modules or more
are not needed anymore to compute new models and we can discard them.
Passing 0 as an argument empties the cache completely.
Parameters
----------
n_modules_max: int
Maximum number of modules. All SED with at least this number of
modules have to be discarded
"""
if n_modules_max > -1:
for k in list(self.sed_cache.keys()):
if len(k) > n_modules_max:
del self.sed_cache[k]
def get_sed(self, module_list, parameter_list):
"""Get the SED corresponding to the module and parameter lists
......
Markdown is supported
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