Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor change #21

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions zoomin/disaggregation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@
char_dict = {"NUTS3": 5, "NUTS2": 4, "NUTS1": 3, "NUTS0": 2}


def is_float(s):
try:
float(s)
return True
except ValueError:
return False


def solve_proxy_equation(equation: str, target_resolution):
# TODO: doctrings

# read in all the proxy data and normalise value column before performing arithmetic operations
operators = r"[\+\-\*\%\(\)\/\.\n]"
operators = r"[\+\-\*\%\(\)\/\n]"

# Splitting the string using the defined pattern
split_result = re.split(operators, equation)
Expand All @@ -21,7 +29,7 @@ def solve_proxy_equation(equation: str, target_resolution):
var_list = [
part.strip()
for part in split_result
if part.strip() and not part.strip().isdigit()
if part.strip() and not part.strip().isdigit() and not is_float(part.strip())
]

result = None
Expand Down
Loading