<commit_before>
from sympy.core.basic import Basic, S, cache_it, cache_it_immutable
from sympy.core.function import Lambda, SingleValuedFunction

###############################################################################
############################# SQUARE ROOT FUNCTION ############################
###############################################################################

class sqrt(SingleValuedFunction):

    nofargs = 1

    def fdiff(self, argindex=1):
        if argindex == 1:
            s = Basic.Symbol('x',dummy=True)
            return Lambda(S.Half * s**(-S.Half),s)
        else:
            raise ArgumentIndexError(self, argindex)

    def inverse(self, argindex=1):
        s = Basic.Symbol('x', dummy=True)
        return Lambda(s**2, s)

    def tostr(self, p=None):
        return "sqrt(%s)" % self[0]

    @classmethod
    def _eval_apply(self, arg):
        arg = Basic.sympify(arg)

        if isinstance(arg, Basic.Number):
            if isinstance(arg, Basic.NaN):
                return S.NaN
            if isinstance(arg, Basic.Infinity):
                return S.Infinity
            if isinstance(arg, Basic.NegativeInfinity):
                return S.ImaginaryUnit * S.Infinity
            if isinstance(arg, Basic.Rational):
                factors = arg.factors()
                sqrt_factors = {}
                eval_factors = {}
                n = Basic.Integer(1)
                for k,v in factors.items():
                    n *= Basic.Integer(k) ** (v//2)
                    if v % 2:
                        n *= Basic.Integer(k) ** S.Half
                return n<commit_msg>documenting the problem in sqrt()<commit_after>
from sympy.core.basic import Basic, S, cache_it, cache_it_immutable
from sympy.core.function import Lambda, SingleValuedFunction

###############################################################################
############################# SQUARE ROOT FUNCTION ############################
###############################################################################

class sqrt(SingleValuedFunction):

    nofargs = 1

    def fdiff(self, argindex=1):
        if argindex == 1:
            s = Basic.Symbol('x',dummy=True)
            return Lambda(S.Half * s**(-S.Half),s)
        else:
            raise ArgumentIndexError(self, argindex)

    def inverse(self, argindex=1):
        s = Basic.Symbol('x', dummy=True)
        return Lambda(s**2, s)

    def tostr(self, p=None):
        return "sqrt(%s)" % self[0]

    @classmethod
    def _eval_apply(self, arg):
        #XXX this doesn't work, but it should (see #390):
        #return arg**S.Half
        arg = Basic.sympify(arg)

        if isinstance(arg, Basic.Number):
            if isinstance(arg, Basic.NaN):
                return S.NaN
            if isinstance(arg, Basic.Infinity):
                return S.Infinity
            if isinstance(arg, Basic.NegativeInfinity):
                return S.ImaginaryUnit * S.Infinity
            if isinstance(arg, Basic.Rational):
                factors = arg.factors()
                sqrt_factors = {}
                eval_factors = {}
                n = Basic.Integer(1)
                for k,v in factors.items():
                    n *= Basic.Integer(k) ** (v//2)
                    if v % 2:
                        n *= Basic.Integer(k) ** S.Half
                return n
{'fraction_non_alphanumeric': 0.22363744075829384, 'fraction_numerical': 0.006220379146919431, 'mean_word_length': 2.101010101010101, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2548145', 'n_tokens_mistral': 957, 'n_tokens_neox': 880, 'n_words': 212}