Skip to content

fix(hashing): ignore casting to float#84

Closed
abduhbm wants to merge 1 commit intodocarray:mainfrom
abduhbm:fix-hashing
Closed

fix(hashing): ignore casting to float#84
abduhbm wants to merge 1 commit intodocarray:mainfrom
abduhbm:fix-hashing

Conversation

@abduhbm
Copy link
Copy Markdown
Contributor

@abduhbm abduhbm commented Jan 26, 2022

Fixes #83

>>> x = Document(text="float test 2.56")
>>> x.get_vocabulary()
Counter({'float': 1, 'test': 1, '2': 1, '56': 1})

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 26, 2022

Codecov Report

Merging #84 (645b1df) into main (1ed4ddd) will decrease coverage by 0.01%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #84      +/-   ##
==========================================
- Coverage   82.98%   82.97%   -0.02%     
==========================================
  Files          87       87              
  Lines        3814     3811       -3     
==========================================
- Hits         3165     3162       -3     
  Misses        649      649              
Flag Coverage Δ
docarray 82.97% <66.66%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
docarray/document/mixins/featurehash.py 87.75% <66.66%> (-0.71%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1ed4ddd...645b1df. Read the comment docs.

return int(v) # parse int parameter
except ValueError:
try:
return float(v) # parse float parameter
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can also check the parsed value, and raise exception then

v = float(v)
if math.isnan(v) or math.isinf(v):
    raise ValueError

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature hashing fails with float strings inf and nan

2 participants