(related to #22884)
There is an issue in the linting of the benchmarks, caused by how asv manages reusing a setup function. See:
(pandas-dev) [mgarcia@xps asv_bench]$ flake8 --config=none benchmarks/categoricals.py
benchmarks/categoricals.py:21:5: F811 redefinition of unused 'setup' from line 14
The problem is that to make asv reuse a common setup function for all the benchmarks in a file, it is expected to have it defined in the top-level namespace. Then every benchmark class in the file can specify a setup method that will be executed after the common one. See this sample code:
from .pandas_vb_common import setup
class MyBenchmark:
def setup(self):
pass
Regardless if this is a good approach by asv, the problem is that the previous code causes linting problems (the error shown before). In this case, the setup defined in pandas_vb_common.py simply defines the seed, np.random.seed(1234).
It's not a great option, but we could move the import of setup at the end of the file (so, the methods are not seen as redefinitions), and flag it to ignore the validation of not being used: from .pandas_vb_common import setup # noqa: F401. But I find this one trickier, as it's difficult to see that there is a common setup being executed, unless you go at the end of the file.
Those are the affected files:
benchmarks/ctors.py
benchmarks/series_methods.py
benchmarks/panel_methods.py
benchmarks/inference.py
benchmarks/replace.py
benchmarks/groupby.py
benchmarks/algorithms.py
benchmarks/timeseries.py
benchmarks/binary_ops.py
benchmarks/stat_ops.py
benchmarks/index_object.py
benchmarks/frame_methods.py
benchmarks/panel_ctor.py
benchmarks/eval.py
benchmarks/reshape.py
benchmarks/categoricals.py
benchmarks/rolling.py
benchmarks/gil.py
benchmarks/indexing.py
benchmarks/multiindex_object.py
benchmarks/sparse.py
benchmarks/frame_ctor.py
benchmarks/plotting.py
benchmarks/join_merge.py
benchmarks/attrs_caching.py
benchmarks/reindex.py
benchmarks/io/stata.py
benchmarks/io/csv.py
benchmarks/io/sql.py
benchmarks/io/json.py
benchmarks/io/msgpack.py
benchmarks/io/hdf.py
benchmarks/io/excel.py
benchmarks/io/pickle.py
(related to #22884)
There is an issue in the linting of the benchmarks, caused by how
asvmanages reusing asetupfunction. See:The problem is that to make
asvreuse a commonsetupfunction for all the benchmarks in a file, it is expected to have it defined in the top-level namespace. Then every benchmark class in the file can specify asetupmethod that will be executed after the common one. See this sample code:Regardless if this is a good approach by
asv, the problem is that the previous code causes linting problems (the error shown before). In this case, thesetupdefined inpandas_vb_common.pysimply defines the seed,np.random.seed(1234).It's not a great option, but we could move the import of
setupat the end of the file (so, the methods are not seen as redefinitions), and flag it to ignore the validation of not being used:from .pandas_vb_common import setup # noqa: F401. But I find this one trickier, as it's difficult to see that there is a common setup being executed, unless you go at the end of the file.Those are the affected files: