OSeMOSYS / otoole

OSeMOSYS Tools for Energy
https://otoole.readthedocs.io
MIT License
25 stars 18 forks source link

Updates dtype casting when reading in data #168

Closed trevorb1 closed 1 year ago

trevorb1 commented 1 year ago

Description

Adds a try except block to check for the exception ValueError: invalid literal for int() with base 10: when type casting the set indices upon reading in data. This error is raised when trying to cast a column from a float to an int. If the error is raised, the entire column is first cast as a float, then in turn cast as an int. This seems to be the normal way to deal with this error according to stack overflow.

Tests for the ReadStrategy._check_index_dtypes(..) have been expanded to check for more datatypes as well. Previously they only tested for string->X type casting. (My bad for that 😅)

I would not exactly call this an elegant solution, since each column needs to be cast one by one if the except logic is entered. But this is a bit of an edge case, so I think it is probably okay for the time being.

Issue Ticket Number

Closes #167

Documentation

na