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

Unused code/syntax error in matexpr #22115

Open
oscargus opened this issue Sep 18, 2021 · 1 comment
Open

Unused code/syntax error in matexpr #22115

oscargus opened this issue Sep 18, 2021 · 1 comment

Comments

@oscargus
Copy link
Contributor

It seems like the following code will not work (and therefore is probably not tested). Subject to something really clever that I cannot figure out:

if _get_shape(self.first)[1] != _get_shape(self.second)[1]:
# Remove one-dimensional identity matrices:
# (this is needed by `a.diff(a)` where `a` is a vector)
if _get_shape(self.second) == (1, 1):
return self.first*self.second[0, 0]
if _get_shape(self.first) == (1, 1):
return self.first[1, 1]*self.second.T
raise ValueError("incompatible shapes")
if self.first != 1:
return self.first*self.second.T
else:
return self.higher

Especially, self.first and self.second is not defined. Should it be self.first_pointer and self.second_pointer?

@Upabjojr

@Upabjojr
Copy link
Contributor

That is part of the matrix derivation algorithm. It might be that it's a bit defective. I plan to eventually replace it with a new algorithm in the module sympy.tensor.array.expressions, which as of now is not complete. As soon as the new module is finished, most stuff related to matrix derivations in sympy.matrices.expressions will be removed (like the _LeftRightArgs class).

I wouldn't concentrate on fixing the _LeftRightArgs class, as it will hopefully be fully removed in the future.

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

No branches or pull requests

2 participants