Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting exception when adding two discrete MISO transfer functions #68

Closed
twmacro opened this issue Nov 3, 2020 · 6 comments · Fixed by #83
Closed

Getting exception when adding two discrete MISO transfer functions #68

twmacro opened this issue Nov 3, 2020 · 6 comments · Fixed by #83
Labels
Milestone

Comments

@twmacro
Copy link

twmacro commented Nov 3, 2020

Hi again! :-)

I think the following code should work, but I'm getting an exception:

import harold
print(harold.__version__)
tf = (harold.Transfer([[[0.0], [1.0]]], [[[1.0], [1.0]]], 0.02)
    + harold.Transfer([[[1.0], [0.5]]], [[[1.0], [1.0]]], 0.02))
print(tf.polynomials)

Here is the output:

1.0.2.dev0+90a785b
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~/anaconda3/envs/py38/lib/python3.8/site-packages/harold-1.0.2.dev0+90a785b-py3.8.egg/harold/_classes.py in __add__(self, other)
    404                 try:
--> 405                     return Transfer(self.to_array() + other.to_array(),
    406                                     dt=self._dt)

~/anaconda3/envs/py38/lib/python3.8/site-packages/harold-1.0.2.dev0+90a785b-py3.8.egg/harold/_classes.py in __init__(self, num, den, dt)
     64         (self._num, self._den,
---> 65          self._shape, self._isgain) = self.validate_arguments(num, den)
     66         self._p, self._m = self._shape

~/anaconda3/envs/py38/lib/python3.8/site-packages/harold-1.0.2.dev0+90a785b-py3.8.egg/harold/_classes.py in validate_arguments(num, den, verbose)
   1504             if returned_numden_list[0].size > returned_numden_list[1].size:
-> 1505                 raise ValueError('Noncausal transfer functions are not '
   1506                                  'allowed.')

ValueError: Noncausal transfer functions are not allowed.

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-1-fe5c19b20276> in <module>
      1 import harold
      2 print(harold.__version__)
----> 3 tf = (harold.Transfer([[[0.0], [1.0]]], [[[1.0], [1.0]]], 0.02)
      4     + harold.Transfer([[[1.0], [0.5]]], [[[1.0], [1.0]]], 0.02))
      5 print(tf.polynomials)

~/anaconda3/envs/py38/lib/python3.8/site-packages/harold-1.0.2.dev0+90a785b-py3.8.egg/harold/_classes.py in __add__(self, other)
    406                                     dt=self._dt)
    407                 except ValueError:
--> 408                     raise ValueError('Shapes are not compatible for '
    409                                      'addition. Model shapes are {0} and'
    410                                      ' {1}'.format(self._shape, other.shape))

ValueError: Shapes are not compatible for addition. Model shapes are (1, 2) and (1, 2)
@ilayn
Copy link
Owner

ilayn commented Nov 3, 2020

Yeah probably again some static gain detection failure. Let me check quickly

@ilayn ilayn added the bug label Nov 3, 2020
@ilayn ilayn added this to the v1.0.2 milestone Nov 3, 2020
@ilayn
Copy link
Owner

ilayn commented Nov 3, 2020

By the way you can directly create static gains like the following

F = harold.Transfer([[1, 0.5]], 0.02)

@twmacro
Copy link
Author

twmacro commented Nov 3, 2020

Yep! That worked like a charm:

In [3]: harold.Transfer([[1, 0.5]], 0.02).polynomials
Out[3]: ([[array([[1.]]), array([[0.5]])]], [[array([[0.02]]), array([[0.02]])]])

@ilayn
Copy link
Owner

ilayn commented Nov 7, 2020

Hi Tim, this revealed yet another symptom of #30 so it will take a bit longer for me to revamp the Transfer class. So to let you know :)

@twmacro
Copy link
Author

twmacro commented Nov 8, 2020

Understood. Thanks @ilayn! :)

@ilayn
Copy link
Owner

ilayn commented Apr 14, 2022

Well at least I wasn't lying about the time needed 😃 Sincere apologies for the ridiculous delay.

@ilayn ilayn closed this as completed in #83 Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants