<commit_before># -*- coding: utf-8 -*-

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np
from . import basex
from . import hansenlaw
from . import onion_peeling
from . import dasch_onion_peeling
from . import direct
from . import three_point
from . import tools

class AbelTiming(object):
    def __init__(self, n=[301, 501], n_max_bs=700, n_max_slow=700, transform_repeat=1):
        """
        Benchmark performance of different iAbel/fAbel implementations.

        Parameters
        ----------
        n: integer
            a list of arrays sizes for the benchmark (assuming 2D square arrays (n,n))
        n_max_bs: integer
            since the basis sets generation takes a long time,
            do not run this benchmark for implementations that use basis sets
            for n > n_max_bs
        n_max_slow: integer
            maximum n run for the "slow" transform methods, so far including only
            the "direct_python" implementation.
        """
        from timeit import Timer
        import time

        self.n = n

        res_fabel = {'hansenlaw':      [],
                     'direct_python':  [] }
        res_iabel = {'basex':          [],
                     'basex_bs':       [],
                     'three_point':    [],
                     'three_point_bs': [],
                     'hansenlaw':      [],
                     'onion_peeling':  [],
                     'dasch_onion_peeling': [],
                     'direct_python' : [] }
                     
        if direct.cython_ext:
            res_fabel['direct_C'] = []
            res_iabel['direct_C'] = []
            
        for ni in n:
            x = np.random.randn(ni, ni)
            
            if ni <= n_max_bs:
                # evaluate basis sets, saved for later re-use
                t = time.time()
                bs = basex.get_bs_basex_cached(ni, ni, basis_dir=None)
                res_iabel['basex_bs'].append((time.time()-t)*1000)
                
                t = time.time()
                tbs = three_point.get_bs_three_point_cached(ni, basis_dir=None)
                res_iabel['three_point_bs'].append((time.time()-t)*1000)
               
                res_iabel['basex'   ].append(Timer(
                    lambda: basex.basex_core_transform(x, *bs)).timeit(number=transform_repeat)*1000/transform_repeat)
                res_iabel['three_point'].append(Timer(
                    lambda: three_point.three_point_core_transform(x, tbs)).timeit(number=transform_repeat)*1000/transform_repeat)
            else:
                res_iabel['basex_bs'].append(np.nan)
                res_iabel['basex'   ].append(np.nan)
                res_iabel['three_point_bs'].append(np.nan)
                res_iabel['three_point'   ].append(np.nan)
            
            if ni <= n_max_slow:
                res_iabel['direct_python'].append(Timer(
                    lambda: direct.direct_transform(x, backend='Python', direction='inverse')).timeit(number=transform_repeat)*1000/transform_repeat)
                      
                res_fabel['direct_python'].append(Timer(
                    lambda: direct.direct_transform(x, backend='Python', direction='forward')).timeit(number=transform_repeat)*1000/transform_repeat)
            
            else:
                res_iabel['direct_python'].append(np.nan)
                res_fabel['direct_python'].append(np.nan)
                
            res_fabel['hansenlaw'].append(Timer(
            lambda: hansenlaw.hansenlaw_transform(x, direction='forward')).timeit(number=transform_repeat)*1000/transform_repeat)
                      
            res_iabel['hansenlaw'].append(Timer(
                lambda: hansenlaw.hansenlaw_transform(x, direction='inverse')).timeit(number=transform_repeat)*1000/transform_repeat)

            res_iabel['onion_peeling'].append(Timer(
                lambda: onion_peeling.onion_peeling_transform(x, direction='inverse')).timeit(number=transform_repeat)*1000/transform_repeat)
                      
                      
            if direct.cython_ext:
                res_iabel['direct_C'].append(Timer(
                    lambda: direct.direct_transform(x, backend='C', direction='inverse')).timeit(number=transform_repeat)*1000/transform_repeat)
                        
                res_fabel['direct_C'].append(Timer(
                    lambda: direct.direct_transform(x, backend='C', direction='forward')).timeit(number=transform_repeat)*1000/transform_repeat)

        self.fabel = res_fabel
        self.iabel = res_iabel

    def __repr__(self):<commit_msg>benchmark for dasch_onion_peeling<commit_after># -*- coding: utf-8 -*-

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np
from . import basex
from . import hansenlaw
from . import onion_peeling
from . import dasch_onion_peeling
from . import direct
from . import three_point
from . import tools

class AbelTiming(object):
    def __init__(self, n=[301, 501], n_max_bs=700, n_max_slow=700, transform_repeat=1):
        """
        Benchmark performance of different iAbel/fAbel implementations.

        Parameters
        ----------
        n: integer
            a list of arrays sizes for the benchmark (assuming 2D square arrays (n,n))
        n_max_bs: integer
            since the basis sets generation takes a long time,
            do not run this benchmark for implementations that use basis sets
            for n > n_max_bs
        n_max_slow: integer
            maximum n run for the "slow" transform methods, so far including only
            the "direct_python" implementation.
        """
        from timeit import Timer
        import time

        self.n = n

        res_fabel = {'hansenlaw':      [],
                     'direct_python':  [] }
        res_iabel = {'basex':          [],
                     'basex_bs':       [],
                     'three_point':    [],
                     'three_point_bs': [],
                     'hansenlaw':      [],
                     'onion_peeling':  [],
                     'dasch_onion_peeling': [],
                     'direct_python' : [] }
                     
        if direct.cython_ext:
            res_fabel['direct_C'] = []
            res_iabel['direct_C'] = []
            
        for ni in n:
            x = np.random.randn(ni, ni)
            
            if ni <= n_max_bs:
                # evaluate basis sets, saved for later re-use
                t = time.time()
                bs = basex.get_bs_basex_cached(ni, ni, basis_dir=None)
                res_iabel['basex_bs'].append((time.time()-t)*1000)
                
                t = time.time()
                tbs = three_point.get_bs_three_point_cached(ni, basis_dir=None)
                res_iabel['three_point_bs'].append((time.time()-t)*1000)
               
                res_iabel['basex'   ].append(Timer(
                    lambda: basex.basex_core_transform(x, *bs)).timeit(number=transform_repeat)*1000/transform_repeat)
                res_iabel['three_point'].append(Timer(
                    lambda: three_point.three_point_core_transform(x, tbs)).timeit(number=transform_repeat)*1000/transform_repeat)
            else:
                res_iabel['basex_bs'].append(np.nan)
                res_iabel['basex'   ].append(np.nan)
                res_iabel['three_point_bs'].append(np.nan)
                res_iabel['three_point'   ].append(np.nan)
            
            if ni <= n_max_slow:
                res_iabel['direct_python'].append(Timer(
                    lambda: direct.direct_transform(x, backend='Python', direction='inverse')).timeit(number=transform_repeat)*1000/transform_repeat)
                      
                res_fabel['direct_python'].append(Timer(
                    lambda: direct.direct_transform(x, backend='Python', direction='forward')).timeit(number=transform_repeat)*1000/transform_repeat)
            
            else:
                res_iabel['direct_python'].append(np.nan)
                res_fabel['direct_python'].append(np.nan)
                
            res_fabel['hansenlaw'].append(Timer(
            lambda: hansenlaw.hansenlaw_transform(x, direction='forward')).timeit(number=transform_repeat)*1000/transform_repeat)
                      
            res_iabel['hansenlaw'].append(Timer(
                lambda: hansenlaw.hansenlaw_transform(x, direction='inverse')).timeit(number=transform_repeat)*1000/transform_repeat)

            res_iabel['dash_onion_peeling'].append(Timer(
                lambda: dash_onion_peeling.dash_onion_peeling_transform(x, direction='inverse')).timeit(number=transform_repeat)*1000/transform_repeat)
                      
            res_iabel['onion_peeling'].append(Timer(
                lambda: onion_peeling.onion_peeling_transform(x, direction='inverse')).timeit(number=transform_repeat)*1000/transform_repeat)
                      
                      
            if direct.cython_ext:
                res_iabel['direct_C'].append(Timer(
                    lambda: direct.direct_transform(x, backend='C', direction='inverse')).timeit(number=transform_repeat)*1000/transform_repeat)
                        
                res_fabel['direct_C'].append(Timer(
                    lambda: direct.direct_transform(x, backend='C', direction='forward')).timeit(number=transform_repeat)*1000/transform_repeat)

        self.fabel = res_fabel
        self.iabel = res_iabel

    def __repr__(self):
{'fraction_non_alphanumeric': 0.10417310664605874, 'fraction_numerical': 0.012570839773312725, 'mean_word_length': 1.9112177564487103, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1020764', 'n_tokens_mistral': 2843, 'n_tokens_neox': 2631, 'n_words': 471}