Skip to content

Commit 21ae147

Browse files
committed
FIX: revert change to lib.pyx
1 parent 3f52a44 commit 21ae147

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

pandas/_libs/lib.pyx

+10-16
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,8 @@ def memory_usage_of_objects(ndarray[object, ndim=1] arr):
5959
cdef Py_ssize_t i, n
6060
cdef int64_t s = 0
6161

62-
# The problem here is that...
63-
# A SparseArray of size 1 that has fill_value = the only value
64-
# will cause this
65-
66-
# n = 1
67-
#
6862
n = len(arr)
69-
for i in range(n):
63+
for i from 0 <= i < n:
7064
s += arr[i].__sizeof__()
7165
return s
7266

@@ -137,10 +131,10 @@ def fast_unique_multiple(list arrays):
137131
dict table = {}
138132
object val, stub = 0
139133

140-
for i in range(k):
134+
for i from 0 <= i < k:
141135
buf = arrays[i]
142136
n = len(buf)
143-
for j in range(n):
137+
for j from 0 <= j < n:
144138
val = buf[j]
145139
if val not in table:
146140
table[val] = stub
@@ -164,10 +158,10 @@ def fast_unique_multiple_list(list lists):
164158
dict table = {}
165159
object val, stub = 0
166160

167-
for i in range(k):
161+
for i from 0 <= i < k:
168162
buf = lists[i]
169163
n = len(buf)
170-
for j in range(n):
164+
for j from 0 <= j < n:
171165
val = buf[j]
172166
if val not in table:
173167
table[val] = stub
@@ -206,7 +200,7 @@ def fast_unique_multiple_list_gen(object gen, bint sort=True):
206200

207201
for buf in gen:
208202
n = len(buf)
209-
for j in range(n):
203+
for j from 0 <= j < n:
210204
val = buf[j]
211205
if val not in table:
212206
table[val] = stub
@@ -836,15 +830,15 @@ def count_level_2d(ndarray[uint8_t, ndim=2, cast=True] mask,
836830
if axis == 0:
837831
counts = np.zeros((max_bin, k), dtype='i8')
838832
with nogil:
839-
for i in range(n):
840-
for j in range(n):
833+
for i from 0 <= i < n:
834+
for j from 0 <= j < k:
841835
counts[labels[i], j] += mask[i, j]
842836

843837
else: # axis == 1
844838
counts = np.zeros((n, max_bin), dtype='i8')
845839
with nogil:
846-
for i in range(n):
847-
for j in range(k):
840+
for i from 0 <= i < n:
841+
for j from 0 <= j < k:
848842
counts[i, labels[j]] += mask[i, j]
849843

850844
return counts

0 commit comments

Comments
 (0)