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

No good way to get PresamplePackages in correct order from Campaign #43

Open PascalLesage opened 6 years ago

PascalLesage commented 6 years ago

Multiple presample packages can be passed to e.g. MonteCarloLCA If an element (a parameter, a matrix index) is part of more than one package, the value in the package that is later in the list is the one that is used. Knowing this, there should be a way to generate a list of presample resources from campaign that is ordered thus:

Currently, Campaign.ancestors will list ancestors in the reverse of the desired order (from direct parent to furthest ancestor). It also does not list presample resources, just campaigns.

The solution should be a class method that looks something like this:

def get_all_resources_in_proper_order(self):    
    ancestors = list(self.ancestors)
    ancestors.reverse()
    resources = [p.path for ancestor in ancestors for p in ancestor.packages]
    try:
        resources.append(*[p.path for p in self.packages])
    except:
        pass
    return resources

@cmutel I tag you in case this is already implemented somewhere and I just can't find it.

cmutel commented 6 years ago

Just to clarify - you would want the list of resources, but are not asking for us to determine which resources could (potentially) overwrite previous ones, right?

Also, I think you want extend instead of append :)

PascalLesage commented 6 years ago

Just to clarify - you would want the list of resources, but are not asking for us to determine which resources could (potentially) overwrite previous ones, right?

Indeed. The idea is to pass the list of presamples filepaths in the correct order to e.g. MonteCarloLCA instantiation.