<commit_before>import sympy as sp, numpy as np
from numpy.core.numeric import isscalar
from sympy.utilities.lambdify import implemented_function
from scipy import interpolate
from sympy.physics.mechanics import dynamicsymbols
#from .Systems

sinc = implemented_function(sp.Function('sinc'), lambda x: np.sinc(x/np.pi) )
step = implemented_function(sp.Function('step'), lambda x: 1.0*(x>=0))

def process_vector_args(args):
    # TODO: any combination of vectors for each arg should be allowed
    # TODO: be more vectorizable? allow vectors for each arg
    # TODO: create wrapper of this?
    new_args = []
    for arg in args:
        if isinstance(arg,(sp.Matrix,np.ndarray)):
            shape = arg.shape
            if (min(shape) != 1 and len(shape) == 2) or len(shape) > 2:
                raise AttributeError("Arguments should only contain vectors")
            for i in range(max(shape)):
                if len(shape) == 1:
                    new_args.append(arg[i])
                elif shape[0] == 1:
                    new_args.append(arg[0,i])
                elif shape[1] == 1: 
                    new_args.append(arg[i,0])
        elif isinstance(arg,(list,tuple)):
            for element in arg:
                if isinstance(element,(list,tuple)):
                    raise AttributeError("Arguments should not be nested lists/tuples")
                new_args.append(element)
        else: # hope it's atomic!
            new_args.append(arg)

    return tuple(new_args)
    
def lambdify_with_vector_args(args, expr, modules=({'ImmutableMatrix': np.matrix}, "numpy", {"Mod": np.mod})):
    new_args = process_vector_args(args)
    
    # TODO: check what later verisons of SymPy need for modules/handling Mod  
    # TODO: apparently lambdify can't be trusted?? Eventually move to <commit_msg>get ready to prefer n-dim array<commit_after>import sympy as sp, numpy as np
from numpy.core.numeric import isscalar
from sympy.utilities.lambdify import implemented_function
from scipy import interpolate
from sympy.physics.mechanics import dynamicsymbols
#from .Systems

sinc = implemented_function(sp.Function('sinc'), lambda x: np.sinc(x/np.pi) )
step = implemented_function(sp.Function('step'), lambda x: 1.0*(x>=0))

def process_vector_args(args):
    # TODO: any combination of vectors for each arg should be allowed
    # TODO: be more vectorizable? allow vectors for each arg
    # TODO: create wrapper of this?
    new_args = []
    for arg in args:
        if hasattr(arg, 'shape'):
            shape = arg.shape
            if (min(shape) != 1 and len(shape) == 2) or len(shape) > 2:
                raise AttributeError("Arguments should only contain vectors")
            for i in range(max(shape)):
                if len(shape) == 1:
                    new_args.append(arg[i])
                elif shape[0] == 1:
                    new_args.append(arg[0,i])
                elif shape[1] == 1: 
                    new_args.append(arg[i,0])
        elif isinstance(arg,(list,tuple)):
            for element in arg:
                if isinstance(element,(list,tuple)):
                    raise AttributeError("Arguments should not be nested lists/tuples")
                new_args.append(element)
        else: # hope it's atomic!
            new_args.append(arg)

    return tuple(new_args)
    
def lambdify_with_vector_args(args, expr, modules=({'ImmutableMatrix': np.matrix}, "numpy", {"Mod": np.mod})):
    new_args = process_vector_args(args)
    
    # TODO: check what later verisons of SymPy need for modules/handling Mod  
    # TODO: apparently lambdify can't be trusted?? Eventually move to 
{'fraction_non_alphanumeric': 0.10436693216149409, 'fraction_numerical': 0.007140895358418017, 'mean_word_length': 2.5428015564202333, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, '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': '1303919', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1027, 'n_words': 316}