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

isequal: failing with error: cell2mat: C must be a cell array #1221

Closed
cbm755 opened this issue Sep 2, 2022 · 7 comments
Closed

isequal: failing with error: cell2mat: C must be a cell array #1221

cbm755 opened this issue Sep 2, 2022 · 7 comments

Comments

@cbm755
Copy link
Collaborator

cbm755 commented Sep 2, 2022

This is based on a test from @sym/and, on the Array_not_Matrix branch:

>> t = sym(true); f = sym(false);
>> w = [t t; f f]; z = [t f; t f];
>> A = w & z
pydebug: elementwise_op: returning an Array not a Matrix
pydebug: I am here with an array with shape (2, 2)
A = (sym 2×2 matrix)
  ⎡True   False⎤
  ⎢            ⎥
  ⎣False  False⎦

>> isequal (A, [t f; f f])
error: cell2mat: C must be a cell array
error: called from
    cell2mat at line 47 column 7
    uniop_bool_helper at line 62 column 11
    isnan at line 51 column 5
    isequal at line 62 column 3

Note:

>> sympy(w)
ans = MutableDenseMatrix([[true, true], [false, false]])
>> sympy(A)
ans = ImmutableDenseNDimArray(Tuple(true, false, false, false), Tuple(Integer(2), Integer(2)))

Looks like even after #1216, we're still getting Matrix from concatenate ops:

>> sympy(horzcat(t, t))
ans = MutableDenseMatrix([[true, true]])
@cbm755
Copy link
Collaborator Author

cbm755 commented Sep 2, 2022

Oh perhaps I misunderstand dbg_no_array as it seems nothing was making Arrays... This issue may not be valid

@cbm755
Copy link
Collaborator Author

cbm755 commented Sep 2, 2022

Simpler way to hit this:

>> t = sym(true)
>> w = [t t]
pydebug: make_matrix_or_array: making 2D Array...
pydebug: I am here with an array with shape (2, 1)
pydebug: make_matrix_or_array: making 2D Array...
pydebug: I am here with an array with shape (1, 2)
w = (sym) [[True  True]]  (1×2 matrix)

>> sympy(w)
ans = ImmutableDenseNDimArray(Tuple(true, true), Tuple(Integer(1), Integer(2)))

>> isequal(w, w)
error: cell2mat: C must be a cell array
error: called from
    cell2mat at line 47 column 7
    uniop_bool_helper at line 62 column 11
    isnan at line 51 column 5
    isequal at line 62 column 3

>> isequal(t, t)
ans = 1

@cbm755
Copy link
Collaborator Author

cbm755 commented Sep 2, 2022

In uniop_bool_helper:

              'if x is not None and x.is_Matrix:'
              '    # bool will map None to False'
              '    return [bool(sf(a, *pp)) for a in x.T],'

Maybe this should be if x is not None and isinstance(A, (MatrixBase, NDimArray)):.

Or maybe just if isinstance(A, (MatrixBase, NDimArray):. I remember some subtly about is_Matrix versus isinstance() but maybe it was just this explicit None handling...

@cbm755
Copy link
Collaborator Author

cbm755 commented Sep 2, 2022

This function also uses linear indexing, similar to #1222.

cbm755 added a commit that referenced this issue Sep 2, 2022
This routine is supposed to return a logical Octave array.  Do linear
indexing on the flattened tolist output which will work on both Array
and Matrix.  Fixes #1221.
@alexvong243f
Copy link
Collaborator

alexvong243f commented Sep 5, 2022 via email

@alexvong243f
Copy link
Collaborator

Fixed by #1224

@alexvong243f
Copy link
Collaborator

alexvong243f commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants