Open PascalLesage opened 4 years ago
The simple fix above has tests failing in bw.LCA.
Tests in LCA show that the expected behaviour is not what would be allowed by the change described above.
Indeed, the expected behaviour is that:
presamples
have not had their matrices updated via lca.presamples.update_matrices
will use the values in the first column (this is also how things work with the change above). This is good, because LCA will often use presamples with a single column (scenario)update_matrices
moves the index from 0 to 1. This is because the indexer.count
is 1 when loaded. In the suggestion above, the indexer.count
is reset to 0, so the first call of update_matrices
actually moves the indexer.count
to 1 but the index itself remains at 0.So the expected usage is sequentially seeded presample packages in LCA would be something like this:
>>> lca = bw.LCA({some_act:1}, presamples=[pp_dirpath])
>>> print("iteration\tindex")
>>> for i in range(5):
... if i != 0:
... lca.presamples.update_matrices()
... lca.lci()
... print(i, "\t", lca.presamples.matrix_indexer[0].index)
iteration index
0 0
1 1
2 2
3 3
4 4
The if
clause is a bit annoying, so we need to decide what approach is better:
update_indices
for the first time (suggestion above); orupdate_indices
on runs beyond the first. @cmutel any preference?
Suppose a presamples package containing matrix data with the following properties:
pp_dirpath
.If used in
MonteCarloLCA
, the indices start at 0 (thanks to the reset of the indexers here). For each iteration (i.e. each timenext(mc_object)
is called), the matrix data indexer goes up by 1. All this is sane and easy to use.For
LCA
, however, things are more complicated.Suppose the data in the presamples package is some time series, and we want to generate LCA results for each time step by calling LCA n times. If we just use the
LCA.lci()
method, things don't work:We need to actively update indices to get the indices moving up. If we naively use
update_matrices
, we don't get the first column.Resetting sequential indices, like for
MonteCarloLCA
, gives the expected behaviour to the problem described above:This resetting could simply be added here Tried it, no presamples tests fail.
We may want to consider moving indices directly when the
lci
method is invoked.