PascalLesage / presamples

Package to write, load, manage and verify numerical arrays, called presamples.
BSD 3-Clause "New" or "Revised" License
14 stars 11 forks source link

Missing consolidated parameter samples #56

Closed PascalLesage closed 5 years ago

PascalLesage commented 5 years ago

The PackagesDataLoader will load all data from an iterable of presample package dirpaths.

When multiple presample package dirpaths contain data for the same matrix elements, only the last data will be used. This allows a baseline model to be updated with new values by passing the baseline presample package first and the new values presamples package after in the list of dirpaths. This is expected behaviour and one of the strengths of presamples.

HOWEVER, for parameter data, there is no "consolidation" of parameter data. Parameter data from different packages are all accessible through their own IndexedParametersMapping object. Parameters in different IndexedParametersMapping objects with the same names coexist and do not influence each other.

What is missing is:

To illustrate simply, let's say we wanted to return a dict with {param_name: sample}. This simple dict comprehension would do the trick (self refers to a  PackagesDataLoader object:

{
    name:sample 
        for i in range(len(self.parameters)) # ensures order
        for name, sample in self.parameters[i].items()
} 

Perhaps the best place for this would be in the parameters property (in which case what is presently stored in the parameters property would need to be renamed to e.g. index_parameter_mappings).

However, we should think about whether we want to make this richer:

cmutel commented 5 years ago

Seems reasonable. We didn't do this before specifically because we didn't want parameter names to be overridden, but if there is a use case, then that is fine.

Hard to tell about the right architecture without coding something up and seeing how easy it is to write tests, but I think this should be optional behaviour, which means either new functions or classes. The metadata mentioned will be generated on demand, as it seems to me that this is a corner case (much more useful is the consolidated dictionary).