Code Monkey home page Code Monkey logo

Comments (6)

aleksandra-kim avatar aleksandra-kim commented on September 26, 2024

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


This is partially fixed in ffd2e6c, which splits nuncertainty into three tested strategies:

  • remove_uncertainty_from_negative_loss_exchanges
  • fix_unreasonably_high_lognormal_uncertainties
  • set_lognormal_loc_value

You can override the default cutoff and replacement values in fix_unreasonably_high_lognormal_uncertainties.

strategies is just a list; you can delete strategies you don't want easily, e.g.

#!python

from brightway2 import *
from bw2io.strategies.ecospold2 import *
ei = SingleOutputEcospold2Importer("something", "something")
del ei.strategies[ei.strategies.index(set_lognormal_loc_value)]

If you think there needs to be a better interface, please suggest something 😄

from brightway2-io.

aleksandra-kim avatar aleksandra-kim commented on September 26, 2024

Original comment by Pascal Lesage (Bitbucket: MPa, ).


To the solution proposed: Thanks for breaking up the strategy. I am unable to access (and hence delete) the strategy, however:

#!python

>>> ei32cutoff_no_cap = SingleOutputEcospold2Importer(myDir, 'ecoinvent 3.2 cutoff - no uncertainty cap')  
>>> ei32cutoff_no_cap.strategies
[<function bw2io.strategies.generic.normalize_units>,
 <function bw2io.strategies.ecospold2.remove_zero_amount_coproducts>,
 <function bw2io.strategies.ecospold2.remove_zero_amount_inputs_with_no_activity>,
 <function bw2io.strategies.ecospold2.remove_unnamed_parameters>,
 <function bw2io.strategies.ecospold2.es2_assign_only_product_with_amount_as_reference_product>,
 <function bw2io.strategies.ecospold2.assign_single_product_as_activity>,
 <function bw2io.strategies.ecospold2.create_composite_code>,
 <function bw2io.strategies.biosphere.drop_unspecified_subcategories>,
 <function bw2io.strategies.ecospold2.link_biosphere_by_flow_uuid>,
 <function bw2io.strategies.ecospold2.link_internal_technosphere_by_composite_code>,
 <function bw2io.strategies.ecospold2.delete_exchanges_missing_activity>,
 <function bw2io.strategies.ecospold2.delete_ghost_exchanges>,
 <function bw2io.strategies.ecospold2.remove_uncertainty_from_negative_loss_exchanges>,
 <function bw2io.strategies.ecospold2.fix_unreasonably_high_lognormal_uncertainties>,
 <function bw2io.strategies.ecospold2.set_lognormal_loc_value>]

>>> ei32cutoff_no_cap.strategies.index(set_lognormal_loc_value)
`NameError: name 'set_lognormal_loc_value' is not defined

As to proposing a better interface: I don't have a good enough understanding of the use of strategies to actually submit code (not now, anyways), but would offhandedly propose that assigning strategies be done in a way that all strategies are passed by default (ei.apply_strategy(set_lognormal_loc_value=True) but can be turned off, i.e. ei.apply_strategy(set_lognormal_loc_value=False)

from brightway2-io.

aleksandra-kim avatar aleksandra-kim commented on September 26, 2024

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


You are missing the import of the functions:

#!python

from bw2io.strategies.ecospold2 import *

It might be easy to accept **kwargs in apply_strategies(), I will think about it.

from brightway2-io.

aleksandra-kim avatar aleksandra-kim commented on September 26, 2024

Original comment by Pascal Lesage (Bitbucket: MPa, ).


Worked wonders.
Note that is seems that the capping of uncertainties is included outside the strategies per se (in the extractor), though with a cap that is much greater:

#!python

if data["scale"] <= 0 or data["scale"] > 25:
    cls.abort_exchange(data)

from brightway2-io.

aleksandra-kim avatar aleksandra-kim commented on September 26, 2024

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


Added more explicit comments to the extractor in ba745c5. Note that, at least for 3.3, this only changes exchanges where the variance is zero; I don't know how other software would handle those distributions.

from brightway2-io.

aleksandra-kim avatar aleksandra-kim commented on September 26, 2024

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


Considering this fixed for now. See also #38.

from brightway2-io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.