Commit d28b636c authored by Médéric Boquien's avatar Médéric Boquien

Implement blocks of models when using the parameters_file option too.

parent 0f472264
...@@ -184,6 +184,8 @@ class ParametersManagerFile(object): ...@@ -184,6 +184,8 @@ class ParametersManagerFile(object):
module = colname.split('.', 1)[0] module = colname.split('.', 1)[0]
if module not in self.modules: if module not in self.modules:
self.modules.append(module) self.modules.append(module)
self.blocks = self._split(range(self.size),
conf['analysis_params']['blocks'])
# The parameters file is read using astropy.Table. Unfortunately, it # The parameters file is read using astropy.Table. Unfortunately, it
# stores strings as np.str_, which is not marshalable, which means we # stores strings as np.str_, which is not marshalable, which means we
...@@ -207,6 +209,26 @@ class ParametersManagerFile(object): ...@@ -207,6 +209,26 @@ class ParametersManagerFile(object):
del table del table
@staticmethod
def _split(l, nb):
"""Split a list l into nb blocks.
Parameters
----------
l: list
List to split.
nb: int
Number of blocks.
"""
step = len(l) // nb
if step > 0:
return [l[i * step: (i+1) * step] for i in range(nb)]
raise ValueError("The number of blocks must be no more than the number"
"of models.")
def from_index(self, index): def from_index(self, index):
"""Provides the parameters of a model given an index. """Provides the parameters of a model given an index.
......
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