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

elementwise_op: use 2d loop for Array #1223

Merged
merged 2 commits into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions inst/@sym/private/elementwise_op.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@
% at least one input was a matrix:
'# dbout(f"at least one matrix param, shape={q.shape}")'
'elements = []'
'for i in range(0, len(q)):'
' elements.append(_op(*[k[i] if isinstance(k, MatrixBase) else k for k in _ins]))'
'assert len(q.shape) == 2, "non-2D arrays/tensors not yet supported"'
'for i in range(0, q.shape[0]):'
' for j in range(0, q.shape[1]):'
' elements.append(_op(*[k[i, j] if isinstance(k, (MatrixBase, NDimArray)) else k for k in _ins]))'
'if all(isinstance(x, Expr) for x in elements):'
' return Matrix(*q.shape, elements)'
'dbout(f"elementwise_op: returning an Array not a Matrix")'
Expand Down
2 changes: 1 addition & 1 deletion inst/private/python_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def octoutput(x, et):


try:
def make_matrix_or_array(ls_of_ls, dbg_no_array=True):
def make_matrix_or_array(ls_of_ls, dbg_no_array=False):
# should be kept in sync with the same function
# defined in inst/private/python_ipc_native.m
Comment on lines -244 to 246
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also change dbg_no_array from True to False in inst/private/python_ipc_native.m.

LGTM otherwise as this test (for @sym/and)

%!test
%! % array
%! w = [t t f f];
%! z = [t f t f];
%! assert (isequal (w & z, [t f f f]))

now passes!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in 37724d6

# FIXME: dbg_no_array is currently used for debugging,
Expand Down