Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi params together with 'axis' #52

Open
felixpollet opened this issue May 16, 2024 · 4 comments
Open

Multi params together with 'axis' #52

felixpollet opened this issue May 16, 2024 · 4 comments

Comments

@felixpollet
Copy link
Contributor

Hi,

In previous versions of lca_algebraic, the extract_activities option of multiLCAAlgebric allowed the contribution of a subset of activities to be calculated. It has been replaced by the axis option in v1.1. However, axis is only compatible for a single set of parameter values. Are there any intentions to enable this feature when a list of parameter values is provided?

I used to calculate the contributions of each activity in the following way:

for act in activities:
       res = agb.multiLCAAlgebric(
                    model,
                    impacts,
                    extract_activities=[act],
                    **parameters
        )

Any idea on how to do this in v1.1? Apart from calling compute_impacts() for each parameter value in a loop.

Thanks for this wonderful library :-)

@raphaeljolivet
Copy link
Contributor

Hi,

I've removed the support of extract_activities indeed.
Axis is the correct way to replace this feature indeed.

It is compatible with multiple value as long as you don't use several impacts :
In which case we would have to fit 3 dimensional matrices into a Dataframe.

I recommand that you do a "for loop" over your list of impact methods, which I suppose may not be too numerous.

Alternatively, there is a on going pull request to provide a "raw" interface to compute_impacts, using Xarray (matrices of arbitrary dimensions) before transforming it to Dataframe.

But I didn't have time to look at it / test it yet.

@felixpollet
Copy link
Contributor Author

Thank you for the feedback. I will implement your recommendation on the "for loop" and have a look at the ongoing pull request.

@felixpollet
Copy link
Contributor Author

Apologies, but actually it doesn't seem that postMultiLCAAlgebric() with axis can handle multiple values, even with a single impact method:

if lambdas[0].has_axis:
        if param_length > 1:
            raise Exception("Multi params cannot be used together with 'axis'")
        param_length = len(lambdas[0].axis_keys)

Are you referring to a dev version of lca-algebraic?

@raphaeljolivet
Copy link
Contributor

raphaeljolivet commented Jun 18, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants