Skip to content

[WIP] Make Basic.has behave more like SymPy, use new visitor #521

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bjodah
Copy link
Contributor

@bjodah bjodah commented Jul 29, 2025

This would require symengine/symengine#2120
This supersedes gh-515

@@ -19,7 +19,7 @@
Max, Min, DenseMatrix, Matrix,
ImmutableMatrix, ImmutableDenseMatrix, MutableDenseMatrix,
MatrixBase, Basic, DictBasic, symarray, series, diff, zeros,
eye, diag, ones, Derivative, Subs, expand, has_symbol,
eye, diag, ones, Derivative, Subs, expand, has_basic, has_symbol,
Copy link
Member

Choose a reason for hiding this comment

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

Let's not export has_basic and use .has

def has(self, *symbols):
return any([has_symbol(self, symbol) for symbol in symbols])
def has(self, *args):
for arg in args:
Copy link
Contributor Author

@bjodah bjodah Jul 29, 2025

Choose a reason for hiding this comment

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

The loop here begs the question:
Should HasBasicVisitor's looking_for_ rather be a vec_basic instead of a simple rcp_basic? If it's common to query with multiple arguments, then a vec_basic would avoid traversing the (possibly large) syntax tree multiple times, but if the majority of use cases only matches against a single argument, that would be a pessimisation, what do you think?

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

Successfully merging this pull request may close these issues.

2 participants