FIX: numpy floats parsed incorrectly#955
Conversation
|
Thanks @juhi24. The CI looks like it is failing on unrelated issues. It looks like this line was originally It would be good to add a test with a high precision bbox values to check if Also linking to a related issue #878. |
|
Hi, @geographika. I cannot reproduce the difference in precision in the earliest and latest supported Python versions 3.10 or 3.13, nor in legacy 3.6. All give: >>> f = 123.4567890123456789
>>> str(f)
'123.45678901234568'
>>> repr(f)
'123.45678901234568'I think this was a Python 2 issue: >>> f = 123.4567890123456789
>>> str(f)
'123.456789012'
>>> repr(f)
'123.45678901234568'The c9e2ddb was committed in 2011. |
|
@juhi24 - thanks for checking this, I'm +1 on merging. It would be good to add in a test just confirming the precision for a bbox is retained. I think adding a simple unit test for |
|
@geographika, test added and passing. |
|
Just for future reference a float is truncated when converting with >>> f = 123.4567890123456789
>>> str(f)
'123.45678901234568'
>>> repr(f)
'123.45678901234568'
# to have higher precision use decimals - str converts correctly
>>> str(d)
'123.4567890123456805895330035127699375152587890625'
>>> repr(d)
"Decimal('123.4567890123456805895330035127699375152587890625')"
# this would fail to create a bboxThanks for the test and fix @juhi24. |
Referring to SciTools/cartopy#2472 (comment)
Currently
owslibcannot handle bbox defined asnumpy.float64. This PR fixes the referred issue by usingstrinstead ofrepr.