Open jeffwack111 opened 2 months ago
You need to add more of a stack trace. just quoting TypeError: len() of unsized object
is not enough to know what is causing the problem. Can you create a test case and attempt to fix this?
Here's the stack trace:
TypeError Traceback (most recent call last)
Cell In[2], [line 10](vscode-notebook-cell:?execution_count=2&line=10)
[6](vscode-notebook-cell:?execution_count=2&line=6) f_Hz = np.geomspace(1000,1,500)
[8](vscode-notebook-cell:?execution_count=2&line=8) originalresponse = P.fresponse(f = f_Hz)
---> [10](vscode-notebook-cell:?execution_count=2&line=10) bary = AAA.tfAAA(F_Hz=f_Hz,xfer=originalresponse.tf)
[11](vscode-notebook-cell:?execution_count=2&line=11) newresponse = SISO.zpk(bary.zpk).fresponse(f=f_Hz)
[13](vscode-notebook-cell:?execution_count=2&line=13) plt.loglog(f_Hz,originalresponse.mag,label = "original")
File ~\code\wield-environment\wield-control\src\wield\control\AAA\AAA.py:332, in tfAAA(F_Hz, xfer, exact, res_tol, s_tol, w, w_res, degree_max, nconv, nrel, rtype, lf_eager, supports, minreal_cutoff, all_real, all_pos)
[329](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/Jeff/code/wield-environment/scripts/~/code/wield-environment/wield-control/src/wield/control/AAA/AAA.py:329) w_res = w
[330](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/Jeff/code/wield-environment/scripts/~/code/wield-environment/wield-control/src/wield/control/AAA/AAA.py:330) w_res = np.asarray(w_res)
--> [332](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/Jeff/code/wield-environment/scripts/~/code/wield-environment/wield-control/src/wield/control/AAA/AAA.py:332) F_Hz, xfer, w, w_res = domain_sort(F_Hz, xfer, w, w_res)
[334](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/Jeff/code/wield-environment/scripts/~/code/wield-environment/wield-control/src/wield/control/AAA/AAA.py:334) sF_Hz = 1j * F_Hz
[336](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/Jeff/code/wield-environment/scripts/~/code/wield-environment/wield-control/src/wield/control/AAA/AAA.py:336) fit_list = []
File ~\code\wield-environment\wield-control\src\wield\control\AAA\AAA.py:684, in domain_sort(X, *Y)
[682](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/Jeff/code/wield-environment/scripts/~/code/wield-environment/wield-control/src/wield/control/AAA/AAA.py:682) else:
[683](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/Jeff/code/wield-environment/scripts/~/code/wield-environment/wield-control/src/wield/control/AAA/AAA.py:683) y = np.asarray(y)
--> [684](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/Jeff/code/wield-environment/scripts/~/code/wield-environment/wield-control/src/wield/control/AAA/AAA.py:684) if len(y) == 1:
[685](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/Jeff/code/wield-environment/scripts/~/code/wield-environment/wield-control/src/wield/control/AAA/AAA.py:685) output.append(y)
[686](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/Jeff/code/wield-environment/scripts/~/code/wield-environment/wield-control/src/wield/control/AAA/AAA.py:686) else:
TypeError: len() of unsized object
The error occurs inside domain_sort() when the elements of Y are checked to see if they are vectors or scalars. By default, w and w_res are equal to "np.asarray(1)".
This object apparently does not have a len()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[3], [line 1](vscode-notebook-cell:?execution_count=3&line=1)
----> [1](vscode-notebook-cell:?execution_count=3&line=1) len(np.asarray(1))
TypeError: len() of unsized object
But it does have np.size()
np.size(np.asarray(1)) == 1
returns true
I've changed len() to np.shape() in the fork I have open
The following short script creates a simple SISO system, calculates a frequency response, then asks tfAAA to do its thing.
this throws the error:
Given that frequency response data coming from instruments could be in either orientation (low->high or high->low) it would be nice to have tfAAA support both. If not, there could be a helpful error message instructing the user to flip their stuff before calling tfAAA