Advertisement
jensyao

fails to import calc operators, gaussian example

Feb 9th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 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.  
  22. calc.print_oper()
  23. while True:
  24.     user = input("")
  25.     if user == 'q':
  26.         break
  27.     try:
  28.         calc.addto_q(user)
  29.     except calcerr as Error:
  30.         print('error', Error)
  31.     calc.print_q()
  32.  
  33.  
  34. calc
  35. ---------------------------------------------------------------------------
  36. TypeError                                 Traceback (most recent call last)
  37. <ipython-input-39-51b0c57e7b82> 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'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement