Repository navigation
Klong compatibility? #82
Replies: 2 comments
|
The two results look like a broadcasting-orientation difference, not an arithmetic error. The reshaped right-hand value is a 3 by 3 matrix. Klong produces: which is equivalent to adding the vector [1 2 3] as a column vector to every row. The NumPy backend produces: which is NumPy's default trailing-axis broadcasting: the vector is added across each row. That distinction matters for compatibility. In NumPy terms, the Klong result is closer to reshaping the vector to shape (3, 1) before adding it to a (3, 3) matrix, while the current backend uses shape (3,) and therefore broadcasts across columns. I would add this exact expression as a regression test and document which axis Klong uses when a rank-1 array is combined with a rank-2 array. The existing broadcasting tests cover scalars, vectors, and nested singleton shapes, but a mixed 1D/2D case like this is the missing boundary. If Klong semantics are the compatibility target, the backend should normalize the rank-1 operand or implement the operation in the Klong layer before delegating to NumPy. If NumPy behavior is intentional for KlongPy, the difference should be documented explicitly so users following the Klong book know when to reshape. Relevant test location: |
|
Hello, This has been addressed here: Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello, I'm a newcomer curious about array programming languages.
Thank you for implementing KlongPy.
I'm following the Klong book with KlongPy and it seems Klong and KlongPy evaluates certain expressions differently. I am curious if this is intentional. Is there a list of incompatibilities documented somewhere?
Thank you again for your work.
All reactions