Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

_is_float should return false rather than an error when types are incompatible #475

Merged
merged 1 commit into from
Aug 15, 2017

Conversation

BenHewins
Copy link
Contributor

Currently a pandas Datetime column can cause an error to be thrown unnecessarily

@sebito91
Copy link
Contributor

sebito91 commented Jul 6, 2017

This is indeed a good catch, the helper function is somewhat helpful but not enough so! I would prefer we catch the types of errors more gracefully. The code should be made more robust so we capture each of these types as they come up instead of just silently ignore.

Could you please amend this to do something like:

In [19]: def _is_float(value):
       :     try:
       :         float(value)
       :     except (TypeError, ValueError):
       :         return False
       :     return True
       :

@sebito91
Copy link
Contributor

sebito91 commented Jul 6, 2017

@aviau UPDATE REQUESTED

@BenHewins
Copy link
Contributor Author

@sebito91 I've made the changes you suggested. I'm not quite sure when an exception rather than returning false would be the expected behaviour, but I suppose it's good practice.

@sebito91
Copy link
Contributor

Excellent, this looks good! Thanks @BenHewins!

@aviau this is ready to merge!

@sebito91
Copy link
Contributor

@BenHewins can you please try to squash into one commit? Thanks!

…eing tested is not a valid param for float()
@aviau aviau merged commit 758663a into influxdata:master Aug 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants