Skip to content

Commit

Permalink
Fixed float parsing in clean_osm_data.py (#1089)
Browse files Browse the repository at this point in the history
* Fixed float parsing in clean_osm_data.py

* Update release_notes.rst to account for float parsing fix

* Add link to PR

---------

Co-authored-by: Ryan Sparks <>
Co-authored-by: Davide Fioriti <67809479+davide-f@users.noreply.github.com>
  • Loading branch information
rsparks3 and davide-f authored Sep 6, 2024
1 parent 1bd7f84 commit 182f7dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ E.g. if a new rule becomes available describe how to use it `snakemake -j1 run_t
**Minor Changes and bug-fixing**

* Remove unused `countries_codes` argument from `load_GDP` function in `build_shapes.py` script, which was not being called as intended with positional arguments `PR #1069 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/1069>`__
* Fixed problematic float parsing (`_parse_float`) in `clean_osm_data.py` to make sure all OSM lines are correctly accounted for `PR #1089 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/1089>`__


PyPSA-Earth 0.4.0
Expand Down
8 changes: 3 additions & 5 deletions scripts/clean_osm_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,10 @@ def _get_circuits_status(df):
return len_f, len_c, isna_c, len_cab, isna_cab

def _parse_float(x, ret_def=0.0):
if isinstance(x, (int, float)):
try:
return float(x)
str_x = str(x)
if str_x.isnumeric():
return float(str_x)
return ret_def
except:
return ret_def

# cables requirement for circuits calculation
cables_req = {
Expand Down

0 comments on commit 182f7dd

Please sign in to comment.