Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upadded message when key_on not found in geojson #1144
Conversation
| @@ -1095,6 +1095,9 @@ def get_by_key(obj, key): | |||
|
|
|||
| def color_scale_fun(x): | |||
| key_of_x = get_by_key(x, key_on) | |||
| if not key_of_x: | |||
| if len(key_on) > 0: | |||
Conengmo
May 8, 2019
Collaborator
In what case will key_on be an empty string? And why don't we want to raise an error in that case? If key_on is indeed an empty string it will still fail, so good to raise an error I would say.
In what case will key_on be an empty string? And why don't we want to raise an error in that case? If key_on is indeed an empty string it will still fail, so good to raise an error I would say.
| @@ -1095,6 +1095,9 @@ def get_by_key(obj, key): | |||
|
|
|||
| def color_scale_fun(x): | |||
| key_of_x = get_by_key(x, key_on) | |||
| if not key_of_x: | |||
| if len(key_on) > 0: | |||
| raise("key_on value not found in geojson") | |||
Conengmo
May 8, 2019
Collaborator
I don't know if this is the right syntax. I would suggest to raise it with raise ValueError('my message'). A value error, because the type of key_on is right (it's a string), but its value is wrong.
I don't know if this is the right syntax. I would suggest to raise it with raise ValueError('my message'). A value error, because the type of key_on is right (it's a string), but its value is wrong.
| @@ -1095,6 +1095,9 @@ def get_by_key(obj, key): | |||
|
|
|||
| def color_scale_fun(x): | |||
| key_of_x = get_by_key(x, key_on) | |||
| if not key_of_x: | |||
| if len(key_on) > 0: | |||
| raise("key_on value not found in geojson") | |||
Conengmo
May 8, 2019
Collaborator
Would be really helpful if we could include some information in the error message on what's wrong with the data. You could for example show the key_on value in the error message. Something like 'wrong value: {}'.format(value).
Would be really helpful if we could include some information in the error message on what's wrong with the data. You could for example show the key_on value in the error message. Something like 'wrong value: {}'.format(value).
|
@Conengmo can you take a second look at this? |
|
This looks good! I'll merge it. |
|
Thanks @evwhiz! Sorry it took me a while to get back to this. |
This address #918 and raises a TypeError "key_on value not found in geojson" when key_on is given, but not found in the geojson file.