-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Description
On a 32-bit Intel machine I get:
=================================== FAILURES ===================================
________________________ TestRedisCommands.test_geopos _________________________
self = <tests.test_commands.TestRedisCommands object at 0xf5eb1fac>
r = Redis<ConnectionPool<Connection<host=localhost,port=6379,db=9>>>
@skip_if_server_version_lt('3.2.0')
def test_geopos(self, r):
values = (2.1909389952632, 41.433791470673, 'place1') +\
(2.1873744593677, 41.406342043777, 'place2')
r.geoadd('barcelona', *values)
# redis uses 52 bits precision, hereby small errors may be introduced.
> assert r.geopos('barcelona', 'place1', 'place2') ==\
[(2.19093829393386841, 41.43379028184083523),
(2.18737632036209106, 41.40634178640635099)]
E assert [(2.190938293...634178640635)] == [(2.1909382939...634178640635)]
E At index 0 diff: (2.1909382939338684, 41.43379028184083) != (2.1909382939338684, 41.433790281840835)
E Use -v to get the full diff
tests/test_commands.py:1460: AssertionError
____________________ TestRedisCommands.test_georadius_with _____________________
self = <tests.test_commands.TestRedisCommands object at 0xf6125d8c>
r = Redis<ConnectionPool<Connection<host=localhost,port=6379,db=9>>>
@skip_if_server_version_lt('3.2.0')
def test_georadius_with(self, r):
values = (2.1909389952632, 41.433791470673, 'place1') +\
(2.1873744593677, 41.406342043777, 'place2')
r.geoadd('barcelona', *values)
# test a bunch of combinations to test the parse response
# function.
> assert r.georadius('barcelona', 2.191, 41.433, 1, unit='km',
withdist=True, withcoord=True, withhash=True) ==\
[['place1', 0.0881, 3471609698139488,
(2.19093829393386841, 41.43379028184083523)]]
E AssertionError: assert [['place1', 0...79028184083)]] == [['place1', 0....90281840835)]]
E At index 0 diff: ['place1', 0.0881, 3471609698139488, (2.1909382939338684, 41.43379028184083)] != ['place1', 0.0881, 3471609698139488, (2.1909382939338684, 41.433790281840835)]
E Use -v to get the full diff
tests/test_commands.py:1507: AssertionError
_________________ TestRedisCommands.test_georadius_store_dist __________________
self = <tests.test_commands.TestRedisCommands object at 0xf625a5ec>
r = Redis<ConnectionPool<Connection<host=localhost,port=6379,db=9>>>
@skip_if_server_version_lt('3.2.0')
def test_georadius_store_dist(self, r):
values = (2.1909389952632, 41.433791470673, 'place1') +\
(2.1873744593677, 41.406342043777, 'place2')
r.geoadd('barcelona', *values)
r.georadius('barcelona', 2.191, 41.433, 1000,
store_dist='places_barcelona')
# instead of save the geo score, the distance is saved.
> assert r.zscore('places_barcelona', 'place1') == 88.05060698409301
E AssertionError: assert 88.05060698268038 == 88.05060698409301
E + where 88.05060698268038 = <bound method StrictRedis.zscore of Redis<ConnectionPool<Connection<host=localhost,port=6379,db=9>>>>('places_barcelona', 'place1')
E + where <bound method StrictRedis.zscore of Redis<ConnectionPool<Connection<host=localhost,port=6379,db=9>>>> = Redis<ConnectionPool<Connection<host=localhost,port=6379,db=9>>>.zscore
tests/test_commands.py:1564: AssertionError
____________________ TestRedisCommands.test_georadiusmember ____________________
self = <tests.test_commands.TestRedisCommands object at 0xf5f94a4c>
r = Redis<ConnectionPool<Connection<host=localhost,port=6379,db=9>>>
@skip_if_server_version_lt('3.2.0')
def test_georadiusmember(self, r):
values = (2.1909389952632, 41.433791470673, 'place1') +\
(2.1873744593677, 41.406342043777, 'place2')
r.geoadd('barcelona', *values)
assert r.georadiusbymember('barcelona', 'place1', 4000) ==\
['place2', 'place1']
assert r.georadiusbymember('barcelona', 'place1', 10) == ['place1']
> assert r.georadiusbymember('barcelona', 'place1', 4000,
withdist=True, withcoord=True,
withhash=True) ==\
[['place2', 3067.4157, 3471609625421029,
(2.187376320362091, 41.40634178640635)],
['place1', 0.0, 3471609698139488,
(2.1909382939338684, 41.433790281840835)]]
E AssertionError: assert [['place2', 3...79028184083)]] == [['place2', 30...90281840835)]]
E At index 1 diff: ['place1', 0.0, 3471609698139488, (2.1909382939338684, 41.43379028184083)] != ['place1', 0.0, 3471609698139488, (2.1909382939338684, 41.433790281840835)]
E Use -v to get the full diff
tests/test_commands.py:1576: AssertionError
=============== 4 failed, 351 passed, 1 skipped in 9.71 seconds ================
See http://floating-point-gui.de/errors/comparison/. In the ideal case there is a function in your
unit testing framework which can do proper float/double comparisions.
The same problem could arise on ARM or on every other architecture with a slightly different
precision for floats.
Metadata
Metadata
Assignees
Labels
No labels