You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to create a nengo.Connection(..., function=function) where function returns an array with more than one axes (e.g., a matrix), and it can make it past validation as long as the total size of the array matches the expected dimensionality. Rather than failing fast it will fail later during build with a less clear error.
"Node output must be a vector (got shape %s)"% (result.shape,),
attr=self.name,
obj=node,
)
By the way, superfluous axes seem to work as long as they are on the outermost dimensions (but not the innermost). That is, function=lambda x: np.ones(9)[None, :] works but function=lambda x: np.ones(9)[:, None] does not:
ValueError: could not broadcast input array from shape (9,1) into shape (9)
(And so there may be some models out there right now that work but accidentally rely on this being able to get past validation.)
The text was updated successfully, but these errors were encountered:
Describe the bug
It is possible to create a
nengo.Connection(..., function=function)
wherefunction
returns an array with more than one axes (e.g., a matrix), and it can make it past validation as long as the total size of the array matches the expected dimensionality. Rather than failing fast it will fail later during build with a less clear error.To reproduce
Expected behavior
Expected to see a validation error when the connection is created, similar to what you would see if for example
function=lambda x: np.ones(8)
:Error message and logs
Instead of a validation error, a less clear exception occurs while building:
Versions
Additional Context
It sneaks past validation because of this line:
nengo/nengo/connection.py
Line 252 in 3ac49d6
A solution could be to make sure that the array has at most one axis, as is done when checking the function on a node:
nengo/nengo/node.py
Lines 102 to 109 in 3ac49d6
By the way, superfluous axes seem to work as long as they are on the outermost dimensions (but not the innermost). That is,
function=lambda x: np.ones(9)[None, :]
works butfunction=lambda x: np.ones(9)[:, None]
does not:(And so there may be some models out there right now that work but accidentally rely on this being able to get past validation.)
The text was updated successfully, but these errors were encountered: