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

FIX: sympify unevaluated_expression instance attributes #374

Merged
merged 5 commits into from
Dec 18, 2023

Conversation

redeboer
Copy link
Member

Classes with attributes that are not of type sp.Basic would previously crash. For instance:

import sympy as sp
from ampform.sympy import unevaluated_expression
from typing import Any

@unevaluated_expression
class MyExpr(sp.Expr):
    x: Any
    m: Any

    def evaluate(self) -> sp.Expr:
        return self.x**self.m

expr = MyExpr(4, m=2)
assert expr.doit() == 16

would previously crash, because the value given to x is of type int and was not sympified to sp.Integer.

@redeboer redeboer added the 🐛 Bug Something isn't working label Dec 18, 2023
@redeboer redeboer self-assigned this Dec 18, 2023
@redeboer redeboer marked this pull request as ready for review December 18, 2023 12:47
@redeboer redeboer enabled auto-merge (squash) December 18, 2023 12:48
@redeboer redeboer merged commit 121844a into main Dec 18, 2023
23 checks passed
@redeboer redeboer deleted the fix-sympification branch December 18, 2023 12:50
redeboer added a commit that referenced this pull request Dec 22, 2023
* ENH: switch to tuples and improve signatures
* ENH: test sympification of `@unevaluated_expression()` attributes
* MAINT: remove redundant docstring in tests
* MAINT: sort test functions
@redeboer redeboer added this to the 0.14.8 milestone Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant