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

Subclassed Symbols that define __getitem__ break DenseMatrix #485

Open
bocklund opened this issue Jul 22, 2024 · 2 comments
Open

Subclassed Symbols that define __getitem__ break DenseMatrix #485

bocklund opened this issue Jul 22, 2024 · 2 comments

Comments

@bocklund
Copy link

bocklund commented Jul 22, 2024

Here's a self-contained test

from symengine import Symbol, DenseMatrix
class MySymbol(Symbol):
    def __getitem__(self, x):
        pass
x = Symbol("x")
y = MySymbol("y")
DenseMatrix([x])  # works fine
DenseMatrix([y])  # SIGSEGV

In PyCalphad (pycalphad/pycalphad#547), we have something where __getitem__ returns, effectively, a new MySymbol, and think ends up in some loop where MySymbol keeps getting created and eats all the system memory.

@isuruf
Copy link
Member

isuruf commented Jul 22, 2024

You'll have to do DenseMatrix([[y]]) as a workaround.

@bocklund
Copy link
Author

Thank you, I think this is working for my immediate need

bocklund added a commit to PhasesResearchLab/ESPEI that referenced this issue Aug 9, 2024
- Add support for breaking changes in the upcoming PyCalphad 0.11 release:
    - Migrate almost all residual function implementations to PyCalphad `Workspace`. This allowed us to remove several `espei.shadow_functions` that are no longer necessary.
    - With `Workspace`, ESPEI no longer needs to use a heuristic and hack the solver to prevent adding composition sets for constrained equilibria in ZPF data because this functionality is replaced by `IsolatedPhase`. This should resolve several bugs where the heurisitic for choosing points was too narrow (not allowing any points to be selected) or too broad (with bad starting points selected that could give metastable equilibria).
    - Update data structures to reflect the change in PyCalphad to `PhaseRecordFactory` objects
    - Fix compatibilitiy with `unpack_components` -> `unpack_species`
    - Fix `ImmutableDenseMatrix` of symbolic coefficients in parameter selection now that PyCalphad `Symbol` objects define a `__getitem__` method. See symengine/symengine.py#485 for more details.
    - Fix need to pad `points` matricies in `plot_endmember` and `plot_interaction` (`_compare_data_to_parameters` is getting removed as deprecated in a future PR)
- Drop Python 3.8 support (NEP-29)
- Remove dead code and dead imports
- Add timings to individual likelihood calls in trace output
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