Closed genius487 closed 1 year ago
@willu47 Thanks so much for the feedback. I amended the workflow by using the python package you suggested. Also, this is now a partial solution of the region hard coding as the iso2 or iso3 codes can be located anywhere in the technology or fuel name and converted to the full name of the country. Kindly inform if this is satisfactory.
@willu47 Thanks so much for the feedback. I amended the workflow by using the Python package you suggested. Also, this is now a partial solution of the region hard coding as the iso2 or iso3 codes can be located anywhere in the technology or fuel name and converted to the full name of the country. Kindly inform if this is satisfactory.
This looks good.
I think you should add some tests for the iso2country method. Take a look in the tests/
folder and create a new test function in test_resultify.py
.
I would be interested in a few corner cases such as:
NGNGA2 - natural gas technology in Nigeria (iso2) DENGA2 - natural gas technology in Germany NGKENGX - export of natural gas from Nigeria to Kenya NGANGA - natural gas technology in Nigeria (iso3) ZXNGA - country code does not exist natural gas technology 'strat', 'ned' - misspelt arguments should raise a ValueError() -1, 22 - position number negative or larger than string should raise a ValueError()
You can run the tests with pytest
@willu47 I've added some tests, and renamed the function to iso_to_country for deeper clarity. A position larger than the string's length isn't intended to raise an error in order to accommodate a list of name with varying name length. Instead, an empty string is returned and a message notifying the failure to find the code is displayed for the user.
Good day. Here is a summary of my changes.
removed the need for openentrance package (closes #24)
changed read_file function to be able to read results generated from KTH's interface
from-file
uses the region in the CSV.from-tech-name
uses the region from the ISO codes at the beginning of technology and fuel names (for OSeMBE purposes mainly). Otherwise, whatever country name is written in the config file is forced as the region.My config that I used testing is here