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

Implement blocks of models when using the parameters_file option too.

parent 0f472264
......@@ -184,6 +184,8 @@ class ParametersManagerFile(object):
module = colname.split('.', 1)[0]
if module not in self.modules:
self.blocks = self._split(range(self.size),
# The parameters file is read using astropy.Table. Unfortunately, it
# stores strings as np.str_, which is not marshalable, which means we
......@@ -207,6 +209,26 @@ class ParametersManagerFile(object):
del table
def _split(l, nb):
"""Split a list l into nb blocks.
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):
"""Provides the parameters of a model given an index.
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