Skip to content

Refactor is_linear_expression() in expr/expr.py#187

Merged
yguclu merged 11 commits into
masterfrom
fix_check_linearity
Jul 17, 2026
Merged

Refactor is_linear_expression() in expr/expr.py#187
yguclu merged 11 commits into
masterfrom
fix_check_linearity

Conversation

@alisa-kirkinskaia

@alisa-kirkinskaia alisa-kirkinskaia commented May 3, 2026

Copy link
Copy Markdown
Contributor

1. Fix #121:

Fix a bug in is_linear_expression related to expand() being very slow for some expressions. The bug is caused by the following line:

if not( (a-b).expand() == 0 or a.expand() == b.expand()):

In the fix we avoid comparing the values of a.expand() and b.expand() if (a-b).expand() is 0, as it already means the expression is linear.

2. Refactor is_linear_expression for better readability:

  • Remove unused argument integral
  • Rename variables
  • Add docstring

3. Update library patch version to 0.19.3

@alisa-kirkinskaia
alisa-kirkinskaia requested a review from a team May 22, 2026 07:15

@yguclu yguclu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you please update the library version to 0.19.3 in the file sympde/pyproject.toml?

@yguclu yguclu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good job @alisa-kirkinskaia! I have a couple of minor comments, mostly about formatting.

Comment thread sympde/expr/expr.py Outdated
Comment thread sympde/expr/expr.py Outdated
Comment thread sympde/expr/expr.py Outdated
Comment thread sympde/expr/expr.py Outdated
Comment thread sympde/expr/expr.py Outdated
Comment thread sympde/expr/expr.py
@yguclu

yguclu commented Jul 14, 2026

Copy link
Copy Markdown
Member

Can you please update the library version to 0.19.3 in the file sympde/pyproject.toml?

Thanks for commit 85fba96!

Alisa Kirkinskaia and others added 4 commits July 16, 2026 18:00
Co-authored-by: Yaman Güçlü <yaman.guclu@gmail.com>
@alisa-kirkinskaia
alisa-kirkinskaia requested a review from yguclu July 16, 2026 18:03
Comment thread sympde/expr/expr.py Outdated
Comment thread sympde/expr/expr.py
Comment thread sympde/expr/expr.py Outdated
Alisa Kirkinskaia and others added 3 commits July 17, 2026 14:05
Co-authored-by: Yaman Güçlü <yaman.guclu@gmail.com>

@yguclu yguclu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me!

@yguclu yguclu changed the title Refactor is_linear_expression function of expr.py Refactor is_linear_expression() in expr/expr.py Jul 17, 2026
@yguclu
yguclu merged commit b251453 into master Jul 17, 2026
11 checks passed
@yguclu
yguclu deleted the fix_check_linearity branch July 17, 2026 12:51
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.

Stuck or very Slow check is_linear_expression in LinearForm and BilinearForm

2 participants