Skip to content

Commit

Permalink
fix all the memory leaks in test_omnisci_array_operators.py
Browse files Browse the repository at this point in the history
  • Loading branch information
antocuni committed Feb 7, 2022
1 parent 321d18e commit a943884
Showing 1 changed file with 46 additions and 31 deletions.
77 changes: 46 additions & 31 deletions rbc/tests/test_omnisci_array_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def operator_add(size):
b[i] = nb_types.int32(size-i-1)
res = operator.add(a, b)
a.free()
b.free()
return res

@omnisci('int32[](int64)')
Expand All @@ -103,6 +104,7 @@ def operator_and_bw(size):
b[i] = nb_types.int32(size-i-1)
res = operator.and_(a, b)
a.free()
b.free()
return res

@omnisci('int64(int64, int64, int64)')
Expand All @@ -119,7 +121,7 @@ def operator_eq(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a == v
res = (a == v)
a.free()
return res

Expand All @@ -128,7 +130,7 @@ def operator_eq_array(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a == a
res = (a == a)
a.free()
return res

Expand All @@ -141,6 +143,7 @@ def operator_floordiv(size):
b[i] = nb_types.int32(i+3)
res = operator.floordiv(a, b)
a.free()
b.free()
return res

@omnisci('double[](int64)')
Expand All @@ -152,14 +155,15 @@ def operator_floordiv2(size):
b[i] = nb_types.double(i+3)
res = operator.floordiv(a, b)
a.free()
b.free()
return res

@omnisci('int8[](int64, int32)')
def operator_ge(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a >= v
res = (a >= v)
a.free()
return res

Expand All @@ -168,7 +172,7 @@ def operator_ge_array(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a >= a
res = (a >= a)
a.free()
return res

Expand All @@ -177,7 +181,7 @@ def operator_gt(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a > v
res = (a > v)
a.free()
return res

Expand All @@ -186,11 +190,11 @@ def operator_gt_array(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a > a
res = (a > a)
a.free()
return res

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_iadd(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -201,7 +205,7 @@ def operator_iadd(size):
b.free()
return a

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_iand(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -212,7 +216,7 @@ def operator_iand(size):
b.free()
return a

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_ifloordiv(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -223,7 +227,7 @@ def operator_ifloordiv(size):
b.free()
return a

@omnisci('double[](int64)', on_missing_free='ignore')
@omnisci('double[](int64)')
def operator_ifloordiv2(size):
a = Array(size, 'double')
b = Array(size, 'double')
Expand All @@ -234,7 +238,7 @@ def operator_ifloordiv2(size):
b.free()
return a

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_ilshift(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -245,7 +249,7 @@ def operator_ilshift(size):
b.free()
return a

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_imul(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -256,7 +260,7 @@ def operator_imul(size):
b.free()
return a

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_ior(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -267,7 +271,7 @@ def operator_ior(size):
b.free()
return a

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_isub(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -278,7 +282,7 @@ def operator_isub(size):
b.free()
return a

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_ipow(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -289,7 +293,7 @@ def operator_ipow(size):
b.free()
return a

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_irshift(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -300,7 +304,7 @@ def operator_irshift(size):
b.free()
return a

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_itruediv(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -311,7 +315,7 @@ def operator_itruediv(size):
b.free()
return a

@omnisci('double[](int64)', on_missing_free='ignore')
@omnisci('double[](int64)')
def operator_itruediv2(size):
a = Array(size, 'double')
b = Array(size, 'double')
Expand All @@ -322,7 +326,7 @@ def operator_itruediv2(size):
b.free()
return a

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_imod(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -333,7 +337,7 @@ def operator_imod(size):
b.free()
return a

@omnisci('int32[](int64)', on_missing_free='ignore')
@omnisci('int32[](int64)')
def operator_ixor(size):
a = Array(size, 'int32')
b = Array(size, 'int32')
Expand All @@ -349,23 +353,23 @@ def operator_in(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = v in a
res = (v in a)
a.free()
return res

@omnisci('int8(int64, int32)')
def operator_is(size, v):
a = Array(size, 'int32')
a.fill(v)
res = a is a
res = (a is a)
a.free()
return res

@omnisci('int8(int64, int32)')
def operator_is_not(size, v):
a = Array(size, 'int32')
a.fill(v)
res = a is not a
res = (a is not a)
a.free()
return res

Expand All @@ -375,16 +379,17 @@ def operator_is_not2(size, v):
a.fill(v)
b = Array(size, 'int32')
b.fill(v)
res = a is not b
res = (a is not b)
a.free()
b.free()
return res

@omnisci('int8[](int64, int32)')
def operator_le(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a <= v
res = (a <= v)
a.free()
return res

Expand All @@ -393,7 +398,7 @@ def operator_le_array(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a <= a
res = (a <= a)
a.free()
return res

Expand All @@ -406,14 +411,15 @@ def operator_lshift(size):
b[i] = nb_types.int32(size-i-1)
res = operator.lshift(a, b)
a.free()
b.free()
return res

@omnisci('int8[](int64, int32)')
def operator_lt(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a < v
res = (a < v)
a.free()
return res

Expand All @@ -422,7 +428,7 @@ def operator_lt_array(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a < a
res = (a < a)
a.free()
return res

Expand All @@ -435,6 +441,7 @@ def operator_mul(size):
b[i] = nb_types.int32(size-i-1)
res = operator.mul(a, b)
a.free()
b.free()
return res

@omnisci('int32[](int64)')
Expand All @@ -446,14 +453,15 @@ def operator_mod(size):
b[i] = nb_types.int32(7)
res = operator.mod(a, b)
a.free()
b.free()
return res

@omnisci('int8[](int64, int32)')
def operator_ne(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a != v
res = (a != v)
a.free()
return res

Expand All @@ -462,7 +470,7 @@ def operator_ne_array(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = a != a
res = (a != a)
a.free()
return res

Expand All @@ -480,7 +488,7 @@ def operator_not_in(size, v):
a = Array(size, 'int32')
for i in range(size):
a[i] = nb_types.int32(i)
res = v not in a
res = (v not in a)
a.free()
return res

Expand All @@ -493,6 +501,7 @@ def operator_or_bw(size):
b[i] = nb_types.int32(size-i-1)
res = operator.or_(a, b)
a.free()
b.free()
return res

@omnisci('int32[](int64)')
Expand All @@ -513,6 +522,7 @@ def operator_pow(size):
b[i] = nb_types.int32(size-i)
res = operator.pow(a, b)
a.free()
b.free()
return res

@omnisci('int32[](int64)')
Expand All @@ -524,6 +534,7 @@ def operator_rshift(size):
b[i] = nb_types.int32(size-i-1)
res = operator.rshift(a, b)
a.free()
b.free()
return res

@omnisci('int32[](int64)')
Expand All @@ -535,6 +546,7 @@ def operator_sub(size):
b[i] = nb_types.int32(size-i-1)
res = operator.sub(a, b)
a.free()
b.free()
return res

@omnisci('int32[](int64)')
Expand All @@ -546,6 +558,7 @@ def operator_truediv(size):
b[i] = nb_types.int32(i+3)
res = operator.truediv(a, b)
a.free()
b.free()
return res

@omnisci('double[](int64)')
Expand All @@ -557,6 +570,7 @@ def operator_truediv2(size):
b[i] = nb_types.double(i+3)
res = operator.truediv(a, b)
a.free()
b.free()
return res

@omnisci('int32[](int64)')
Expand All @@ -568,6 +582,7 @@ def operator_xor(size):
b[i] = nb_types.int32(size-i-1)
res = operator.xor(a, b)
a.free()
b.free()
return res


Expand Down

0 comments on commit a943884

Please sign in to comment.