Skip to content

Commit d5de0e2

Browse files
Revert "Replaces math.isnan with simple None comparisons."
This reverts commit ebbb442. And this fixes the broken test introduced in the previous commit.
1 parent 4b4a4ac commit d5de0e2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

django_pandas/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# coding: utf-8
22

3+
from math import isnan
34
from django.core.cache import cache
45
from django.utils.encoding import force_text
56

@@ -31,7 +32,7 @@ def replace_pk(model):
3132
base_cache_key = get_base_cache_key(model)
3233

3334
def inner(pk_list):
34-
cache_keys = [None if pk is None else base_cache_key % pk
35+
cache_keys = [None if isnan(pk) else base_cache_key % pk
3536
for pk in pk_list]
3637
out_dict = cache.get_many(frozenset(cache_keys))
3738
try:
@@ -41,7 +42,7 @@ def inner(pk_list):
4142
out_dict = {
4243
base_cache_key % obj.pk: force_text(obj)
4344
for obj in model.objects.filter(pk__in={pk for pk in pk_list
44-
if pk is not None})}
45+
if not isnan(pk)})}
4546
cache.set_many(out_dict)
4647
out_list = list(map(out_dict.get, cache_keys))
4748
return out_list

0 commit comments

Comments
 (0)