Skip to content

Commit

Permalink
BENCH: fix issues with Methods0D benchmarks in bench_ufunc.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rgommers committed Aug 27, 2023
1 parent 8a730be commit 59ccb8c
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions benchmarks/benchmarks/bench_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,54 @@ def time_ndarray_meth(self, methname, npdtypes):
getattr(operator, methname)(*[self.vals, 2])


class Methods0D(Benchmark):
class Methods0DBoolComplex(Benchmark):
"""Zero dimension array methods
"""
params = [['__bool__', '__complex__', '__invert__',
'__float__', '__int__'], TYPES1]
params = [['__bool__', '__complex__'],
TYPES1]
param_names = ['methods', 'npdtypes']
timeout = 10

def setup(self, methname, npdtypes):
self.xarg = np.array(3, dtype=npdtypes)
if (npdtypes.startswith('complex') and
methname in ['__float__', '__int__']) or \
(npdtypes.startswith('int') and methname == '__invert__'):
# Skip
raise NotImplementedError

def time_ndarray__0d__(self, methname, npdtypes):
meth = getattr(self.xarg, methname)
meth()


class Methods0DFloatInt(Benchmark):
"""Zero dimension array methods
"""
params = [['__int__', '__float__'],
[dt for dt in TYPES1 if not dt.startswith('complex')]
]
param_names = ['methods', 'npdtypes']
timeout = 10

def setup(self, methname, npdtypes):
self.xarg = np.array(3, dtype=npdtypes)

def time_ndarray__0d__(self, methname, npdtypes):
meth = getattr(self.xarg, methname)
meth()



class Methods0DInvert(Benchmark):
"""Zero dimension array methods
"""
params = ['int16', 'int32', 'int64']
param_names = ['npdtypes']
timeout = 10

def setup(self, npdtypes):
self.xarg = np.array(3, dtype=npdtypes)

def time_ndarray__0d__(self, npdtypes):
self.xarg.__invert__()


class MethodsV1(Benchmark):
""" Benchmark for the methods which take an argument
"""
Expand Down

0 comments on commit 59ccb8c

Please sign in to comment.