-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a calculation function that works generically for all trips (…
…#184) * add a calculation function that works generically for all trips * add settings.json to vscode * add tests * remove leftover business trip function * bump version
- Loading branch information
1 parent
ebf4dbb
commit 7b0cba7
Showing
6 changed files
with
121 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ __pycache__/ | |
# C extensions | ||
*.so | ||
|
||
#.vscode | ||
settings.json | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Generic collection of util functions and maps.""" | ||
|
||
from co2calculator.constants import TransportationMode | ||
from co2calculator.mobility.calculate_mobility import ( | ||
calc_co2_bicycle, | ||
calc_co2_bus, | ||
calc_co2_car, | ||
calc_co2_ferry, | ||
calc_co2_motorbike, | ||
calc_co2_pedelec, | ||
calc_co2_train, | ||
calc_co2_tram, | ||
) | ||
|
||
|
||
def get_calc_function_from_transport_mode( | ||
transport_mode: TransportationMode, | ||
) -> callable: | ||
transportation_mode_calc_function_map = { | ||
TransportationMode.CAR: calc_co2_car, | ||
TransportationMode.MOTORBIKE: calc_co2_motorbike, | ||
TransportationMode.BUS: calc_co2_bus, | ||
TransportationMode.TRAIN: calc_co2_train, | ||
TransportationMode.BICYCLE: calc_co2_bicycle, | ||
TransportationMode.TRAM: calc_co2_tram, | ||
TransportationMode.FERRY: calc_co2_ferry, | ||
TransportationMode.PEDELEC: calc_co2_pedelec, | ||
} | ||
return transportation_mode_calc_function_map[transport_mode] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.