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

Presamples CF package fails if biosphere flows not used in database #49

Open cmutel opened 5 years ago

cmutel commented 5 years ago

It is difficult to impossible to tell ahead of time which flows a given database will use, so instead of raising a mysterious error, we need to just ignore these flows. The error I get now is:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-87-59955be80c45> in <module>()
      1 mc_with = bw.MonteCarloLCA(fu, lcia_method, presamples=[path])
----> 2 mc_with_results = np.array([next(mc_with) for _ in range(250)])

...

~/miniconda3/envs/regional/lib/python3.6/site-packages/scipy/sparse/compressed.py in check_bounds(indices, bound)
    700             if idx >= bound:
    701                 raise IndexError('index (%d) out of range (>= %d)' %
--> 702                                  (idx, bound))
    703             idx = indices.min()
    704             if idx < -bound:

IndexError: index (4294967295) out of range (>= 2077)
PascalLesage commented 5 years ago

Indeed. This is not limited to biosphere exchanges. Presamples generated in one project and reuse in another will almost inevitably lead to this error. I've dealt with this by regenerating presamples for new projects, which was a very temporary solution. I am against a short-term plug that simply ignores these errors, because users may think their exchanges are being overwritten by presamples, and would be hard-pressed to know they weren't until they analysed their results. At a strict minimum, if we do this, we should provide a list of unmapped exchanges. Other options I've considered are: