pledge4future / co2calculator

Python package to calculate work related CO2 emissions from heating and electricity consumption as well as business trips and commuting.
https://pledge4future.github.io/co2calculator/
GNU General Public License v3.0
12 stars 5 forks source link

Overwriting non existing parameter values #138

Open redfrexx opened 1 year ago

redfrexx commented 1 year ago

The following tests are run with parameters combinations that are not present in the emission factors. Instead the provided parameters are overwritten with default values (e.g. size=average is used when size=small is not there for the last one ). I think in the future it would be better to return an error indicating that this parameter does not exist or have a method that tells the users which options are valid (see #137). What do you think?

test_calculate.py:131 (test_calc_co2_bus[size: 'small', fuel_type: `diesel`, vehicle_range: 'long-distance'])
distance = 10, size = 'small', fuel_type = 'diesel', occupancy = None
vehicle_range = 'long-distance', expected_emissions = 0.39

test_calculate.py:131 (test_calc_co2_bus[fuel_type: `cng` and size])
distance = 10, size = 'medium', fuel_type = 'cng', occupancy = None
vehicle_range = 'long-distance', expected_emissions = 0.62

test_calculate.py:131 (test_calc_co2_bus[fuel_type: `hydrogen` and size])
distance = 10, size = 'small', fuel_type = 'hydrogen', occupancy = None
vehicle_range = 'local', expected_emissions = 0.25
veitu commented 1 year ago

Yes, that's a good idea. In the example, I would still do the calculation with size=average, but give a message to the user saying that average is used because size=small does not exist and to give a list of parameters that do exist