Commit e6def344 authored by Cecilia Nievas's avatar Cecilia Nievas
Browse files

Fixed bug in transform_dict_into_dataframe when sum in row is zero

parent 8fca4646
......@@ -784,7 +784,11 @@ def transform_dict_into_dataframe(dict_of_subclasses, bdg_classes):
elif sum_per_row[row] < 1E-5:
# If the row sums up to zero (because there are zero buildings in these admin units), replace the
# zeroes with a uniform distribution:
collect_values[row, :] = (1.0/float(len(unique_involved_ids))) * np.ones([len(unique_involved_ids)])
aux_ids = dict_of_subclasses[bdg_classes[row]]['Country_Admin_IDs'] # admin IDs for which this building class exists
uniform_proportion = 1.0/float(len(aux_ids))
for admin_id in aux_ids:
which_col = np.where(unique_involved_ids == admin_id)[0][0]
collect_values[row, which_col] = uniform_proportion
return bdg_classes, unique_involved_ids, collect_values, errors_found
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment