(args, expr_len, nb_of_free_symbols)
Checks the arguments and converts into tuples of the
    form (exprs, ranges)

    Examples
    ========

    >>> from sympy import plot, cos, sin, symbols
    >>> from sympy.plotting.plot import check_arguments
    >>> x = symbols('x')
    >>> check_arguments([cos(x), sin(x)], 2, 1)
        [(cos(x), sin(x), (x, -10, 10))]

    >>> check_arguments([x, x**2], 1, 1)
        [(x, (x, -10, 10)), (x**2, (x, -10, 10))]
Checks the arguments and converts into tuples of the
    form (exprs, ranges)
Checks the arguments and converts into tuples of the form ( exprs ranges )
def check_arguments(args, expr_len, nb_of_free_symbols):
    """
    Checks the arguments and converts into tuples of the
    form (exprs, ranges)

    Examples
    ========

    >>> from sympy import plot, cos, sin, symbols
    >>> from sympy.plotting.plot import check_arguments
    >>> x = symbols('x')
    >>> check_arguments([cos(x), sin(x)], 2, 1)
        [(cos(x), sin(x), (x, -10, 10))]

    >>> check_arguments([x, x**2], 1, 1)
        [(x, (x, -10, 10)), (x**2, (x, -10, 10))]
    """
    if expr_len > 1 and isinstance(args[0], Expr):
        # Multiple expressions same range.
        # The arguments are tuples when the expression length is
        # greater than 1.
        if len(args) < expr_len:
            raise ValueError("len(args) should not be less than expr_len")
        for i in range(len(args)):
            if isinstance(args[i], Tuple):
                break
        else:
            i = len(args) + 1

        exprs = Tuple(*args[:i])
        free_symbols = list(set.union(*[e.free_symbols for e in exprs]))
        if len(args) == expr_len + nb_of_free_symbols:
            #Ranges given
            plots = [exprs + Tuple(*args[expr_len:])]
        else:
            default_range = Tuple(-10, 10)
            ranges = []
            for symbol in free_symbols:
                ranges.append(Tuple(symbol) + default_range)

            for i in range(len(free_symbols) - nb_of_free_symbols):
                ranges.append(Tuple(Dummy()) + default_range)
            plots = [exprs + Tuple(*ranges)]
        return plots

    if isinstance(args[0], Expr) or (isinstance(args[0], Tuple) and
                                     len(args[0]) == expr_len and
                                     expr_len != 3):
        # Cannot handle expressions with number of expression = 3. It is
        # not possible to differentiate between expressions and ranges.
        #Series of plots with same range
        for i in range(len(args)):
            if isinstance(args[i], Tuple) and len(args[i]) != expr_len:
                break
            if not isinstance(args[i], Tuple):
                args[i] = Tuple(args[i])
        else:
            i = len(args) + 1

        exprs = args[:i]
        assert all(isinstance(e, Expr) for expr in exprs for e in expr)
        free_symbols = list(set.union(*[e.free_symbols for expr in exprs
                                        for e in expr]))

        if len(free_symbols) > nb_of_free_symbols:
            raise ValueError("The number of free_symbols in the expression "
                             "is greater than %d" % nb_of_free_symbols)
        if len(args) == i + nb_of_free_symbols and isinstance(args[i], Tuple):
            ranges = Tuple(*[range_expr for range_expr in args[
                           i:i + nb_of_free_symbols]])
            plots = [expr + ranges for expr in exprs]
            return plots
        else:
            #Use default ranges.
            default_range = Tuple(-10, 10)
            ranges = []
            for symbol in free_symbols:
                ranges.append(Tuple(symbol) + default_range)

            for i in range(len(free_symbols) - nb_of_free_symbols):
                ranges.append(Tuple(Dummy()) + default_range)
            ranges = Tuple(*ranges)
            plots = [expr + ranges for expr in exprs]
            return plots

    elif isinstance(args[0], Tuple) and len(args[0]) == expr_len + nb_of_free_symbols:
        #Multiple plots with different ranges.
        for arg in args:
            for i in range(expr_len):
                if not isinstance(arg[i], Expr):
                    raise ValueError("Expected an expression, given %s" %
                                     str(arg[i]))
            for i in range(nb_of_free_symbols):
                if not len(arg[i + expr_len]) == 3:
                    raise ValueError("The ranges should be a tuple of "
                                     "length 3, got %s" % str(arg[i + expr_len]))
        return args
def check_arguments ( args , expr_len , nb_of_free_symbols ) : if expr_len > 1 and isinstance ( args [ 0 ] , Expr ) : # Multiple expressions same range. # The arguments are tuples when the expression length is # greater than 1. if len ( args ) < expr_len : raise ValueError ( "len(args) should not be less than expr_len" ) for i in range ( len ( args ) ) : if isinstance ( args [ i ] , Tuple ) : break else : i = len ( args ) + 1 exprs = Tuple ( * args [ : i ] ) free_symbols = list ( set . union ( * [ e . free_symbols for e in exprs ] ) ) if len ( args ) == expr_len + nb_of_free_symbols : #Ranges given plots = [ exprs + Tuple ( * args [ expr_len : ] ) ] else : default_range = Tuple ( - 10 , 10 ) ranges = [ ] for symbol in free_symbols : ranges . append ( Tuple ( symbol ) + default_range ) for i in range ( len ( free_symbols ) - nb_of_free_symbols ) : ranges . append ( Tuple ( Dummy ( ) ) + default_range ) plots = [ exprs + Tuple ( * ranges ) ] return plots if isinstance ( args [ 0 ] , Expr ) or ( isinstance ( args [ 0 ] , Tuple ) and len ( args [ 0 ] ) == expr_len and expr_len != 3 ) : # Cannot handle expressions with number of expression = 3. It is # not possible to differentiate between expressions and ranges. #Series of plots with same range for i in range ( len ( args ) ) : if isinstance ( args [ i ] , Tuple ) and len ( args [ i ] ) != expr_len : break if not isinstance ( args [ i ] , Tuple ) : args [ i ] = Tuple ( args [ i ] ) else : i = len ( args ) + 1 exprs = args [ : i ] assert all ( isinstance ( e , Expr ) for expr in exprs for e in expr ) free_symbols = list ( set . union ( * [ e . free_symbols for expr in exprs for e in expr ] ) ) if len ( free_symbols ) > nb_of_free_symbols : raise ValueError ( "The number of free_symbols in the expression " "is greater than %d" % nb_of_free_symbols ) if len ( args ) == i + nb_of_free_symbols and isinstance ( args [ i ] , Tuple ) : ranges = Tuple ( * [ range_expr for range_expr in args [ i : i + nb_of_free_symbols ] ] ) plots = [ expr + ranges for expr in exprs ] return plots else : #Use default ranges. default_range = Tuple ( - 10 , 10 ) ranges = [ ] for symbol in free_symbols : ranges . append ( Tuple ( symbol ) + default_range ) for i in range ( len ( free_symbols ) - nb_of_free_symbols ) : ranges . append ( Tuple ( Dummy ( ) ) + default_range ) ranges = Tuple ( * ranges ) plots = [ expr + ranges for expr in exprs ] return plots elif isinstance ( args [ 0 ] , Tuple ) and len ( args [ 0 ] ) == expr_len + nb_of_free_symbols : #Multiple plots with different ranges. for arg in args : for i in range ( expr_len ) : if not isinstance ( arg [ i ] , Expr ) : raise ValueError ( "Expected an expression, given %s" % str ( arg [ i ] ) ) for i in range ( nb_of_free_symbols ) : if not len ( arg [ i + expr_len ] ) == 3 : raise ValueError ( "The ranges should be a tuple of " "length 3, got %s" % str ( arg [ i + expr_len ] ) ) return args