jensyao

fails to import calc operators, gaussian example + R func

Feb 9th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. from __future__ import print_function
  2. from calc import calc
  3. from calc import oper2
  4. from calc import calcerr
  5.  
  6. class notebook(calc):
  7.     def add_cust_func(self, func, key, num_args=1):
  8.         self.operations_list[key]=operator(func,num_args=numargs)
  9. def power(arg1,arg2):
  10.     return arg2**arg1
  11. def gaussian(x,u=0.0,std=1.0):
  12.     import math
  13.     return math.exp((x-u)/(2*std**2))/math.sqrt(2*math.pi*std**2)
  14.  
  15.  
  16. print("calc")
  17. calc1 =notebook()
  18. calc.add_custom("operators.json")
  19. calc.add_cust_func(power, '**',num_args=2)
  20. calc.add_cust_func(gaussian, 'gauss',num_args=3)
  21. calc.add_cust_func(r_func,'4th',num_args=1)
  22.  
  23. calc.print_oper()
  24. while True:
  25.     user = input("")
  26.     if user == 'q':
  27.         break
  28.     try:
  29.         calc.addto_q(user)
  30.     except calcerr as Error:
  31.         print('error', Error)
  32.     calc.print_q()
  33.  
  34. calc
  35. ---------------------------------------------------------------------------
  36. TypeError                                 Traceback (most recent call last)
  37. <ipython-input-46-21026436a7f6> in <module>()
  38.      16 print("calc")
  39.      17 calc1 =notebook()
  40. ---> 18 calc.add_custom("operators.json")
  41.      19 calc.add_cust_func(power, '**',num_args=2)
  42.      20 calc.add_cust_func(gaussian, 'gauss',num_args=3)
  43.  
  44. TypeError: add_custom() missing 1 required positional argument: 'filename'
Add Comment
Please, Sign In to add comment