Example #1
0
 def __init__(self, phrase, var_values = None, variables = None,\
 cpx = True, constants = {'e':e, 'pi':pi, 'I':1j, \
 'π':pi, 'inf':'inf', 'oo':'inf'}, asimp = True):
     """makes a Function given a string phrase and isolates its variables"""
     self.complex = cpx
     self.phrase = phrase
     self.phrase = eqn_helper.make_friendly(\
     self.phrase, constants.keys(), self.complex)
     if constants != None:
         for name in constants:
             self.phrase = eqn_helper.replace_constants(\
             self.phrase, constants[name], name)
         self.phrase = eqn_helper.make_friendly(\
         self.phrase, constants.keys(), self.complex)
     else:
         self.constants = dict('')
     self.constants = constants
     #autosimplify
     self.asimp = asimp
     self.var_names = eqn_helper.get_variables(self.phrase, self.complex)
     if variables == None:
         #default list of variables for testing purposes
         if var_values == None:
             self.var_values = [i+1 for i in range(len(self.var_names))]
         else:
             self.var_values = var_values
         #the order of variable assignment and dictionary creation allows
         #the variables in a Function to simply be assigned left to right
         self.variables = dict(zip(self.var_names, self.var_values))
     else:
         self.set_variables(variables)
     self.terms = self.init_terms()
     self.degrees = self.init_degrees()
Example #2
0
 def __init__(self, phrase, cpx = False, constants = {'e':e, 'pi':pi,\
 'I':1j, 'π':pi, 'inf':'inf', 'oo':'inf'}):
     """makes a Function given a string phrase and isolates its variables"""
     self.complex = cpx
     self.phrase = phrase
     self.phrase = make_friendly(\
     self.phrase, constants.keys(), self.complex)
     if constants != None:
         for name in constants:
             self.phrase = replace_constants(\
             self.phrase, constants[name], name)
         self.phrase = make_friendly(\
         self.phrase, constants.keys(), self.complex)
     else:
         self.constants = dict('')
     self.constants = constants
     self.var_names = get_variables(self.phrase, self.complex)
     self.imd = RawEvaluator(self.phrase)