Guest User

Untitled

a guest
Jan 17th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. #--- shell (Ubuntu 17.10, Octave 4.2.1, Python 3.6.4)
  2. pip install oct2py==4.0.6
  3.  
  4. #--- Python
  5. x=[0.,0,0,0,0,1,1,1,1,0,0,0,0,0]
  6.  
  7. from oct2py import Oct2Py
  8. with Oct2Py() as oc:
  9. oc.eval('pkg load signal')
  10. y = oc.sgolayfilt(x,3,5)
  11.  
  12. #--- stderr
  13. Traceback (most recent call last):
  14. File "<stdin>", line 1, in <module>
  15. File "~/miniconda3/lib/python3.6/site-packages/oct2py/dynamic.py", line 96, in __call__
  16. return self._ref().feval(self.name, *inputs, **kwargs)
  17. File "~/miniconda3/lib/python3.6/site-packages/oct2py/core.py", line 369, in feval
  18. store_as=store_as, plot_dir=plot_dir)
  19. File "~/miniconda3/lib/python3.6/site-packages/oct2py/core.py", line 568, in _feval
  20. raise Oct2PyError(msg)
  21. oct2py.utils.Oct2PyError: Octave evaluation error:
  22. error: =: nonconformant arguments (op1 is 1x5, op2 is 3x5)
  23.  
  24.  
  25. #--- work in plain Octave 4.2.1
  26. x=[0.,0,0,0,0,1,1,1,1,0,0,0,0,0];
  27. pkg load signal
  28. y = sgolayfilt(x,3,5);
  29.  
  30. type y
  31. y is a variable
  32. Columns 1 through 5:
  33.  
  34. 0.00000 0.00000 0.00000 -0.08571 0.25714
  35.  
  36. Columns 6 through 10:
  37.  
  38. 0.74286 1.08571 1.08571 0.74286 0.25714
  39.  
  40. Columns 11 through 14:
  41.  
  42. -0.08571 0.00000 0.00000 0.00000
  43.  
  44. # --- omitting all but first argument works from Python
  45. sgolayfilt(x) == sgolayfilt(x,3,5) since those are the default parameters.
  46.  
  47. y = oc.sgolayfilt(x)
  48. >>> y
  49. array([[ 0. , 0. , 0. , -0.08571429, 0.25714286,
  50. 0.74285714, 1.08571429, 1.08571429, 0.74285714, 0.25714286,
  51. -0.08571429, 0. , 0. , 0. ]])
Add Comment
Please, Sign In to add comment