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

added message when key_on not found in geojson #1144

Merged
merged 2 commits into from
May 27, 2019

Conversation

evwhiz
Copy link
Contributor

@evwhiz evwhiz commented May 4, 2019

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.

@ocefpaf
Copy link
Member

ocefpaf commented May 5, 2019

@evwhiz this looks good. Thanks! I'll leave this for @Conengmo to take a look at but I'm planning on merging it during the rest of the sprints.

@ocefpaf ocefpaf mentioned this pull request May 5, 2019
Copy link
Member

@Conengmo Conengmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @evwhiz for making this PR! I added some comments, hope you can have a look. Let us know if you have questions or if we can help.

folium/features.py Show resolved Hide resolved
@@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@ocefpaf
Copy link
Member

ocefpaf commented May 26, 2019

@Conengmo can you take a second look at this?

Copy link
Member

@Conengmo Conengmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! I'll merge it.

@Conengmo Conengmo merged commit f05f3ce into python-visualization:master May 27, 2019
@ocefpaf
Copy link
Member

ocefpaf commented May 27, 2019

Thanks @evwhiz! Sorry it took me a while to get back to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants