-
Notifications
You must be signed in to change notification settings - Fork 32
separate out importer code #3023
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e21878c
move files & refactor
FFroehlich 8e40879
fixups
FFroehlich fc0b257
conditional import guards
FFroehlich 6b64d7b
fixup actions
FFroehlich 86f5de0
remove unified import interface
FFroehlich 2c80c59
Merge branch 'main' into importer_reorg
FFroehlich 3204bec
fixups
FFroehlich 8a3d0d0
fixup
FFroehlich 149e5cb
fixup
FFroehlich 3440858
fixup
FFroehlich 66037bf
Update ExampleSplinesSwameye2003.ipynb
FFroehlich 4918ed7
fix doc
FFroehlich a734905
Merge branch 'main' into importer_reorg
FFroehlich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
| from sympy.utilities.iterables import numbered_symbols | ||
| from toposort import toposort | ||
|
|
||
| from ...import_utils import symbol_with_assumptions | ||
| from amici.importers.utils import symbol_with_assumptions | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above, amici.exporters should not import anything from amici.importers, only from the symbolic middle layer. |
||
|
|
||
|
|
||
| class AmiciCxxCodePrinter(CXX11CodePrinter): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| """Unified model import interface for AMICI. | ||
| This subpackage aggregates functionality for importing models from various | ||
| formats into AMICI. | ||
| Re-exported symbols (imported conditionally where dependencies are optional): | ||
FFroehlich marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - SBML: `SbmlImporter` (requires `libsbml` and related deps) | ||
| - PySB: `pysb2amici`, `pysb2jax`, `ode_model_from_pysb_importer` (requires `pysb`) | ||
| - Antimony:`antimony2sbml`, `antimony2amici` (requires `antimony` Python package) | ||
| - Utils: `MeasurementChannel`, noise helpers, `RESERVED_SYMBOLS`, | ||
| `ObservableTransformation` | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| # Utils are internal and safe to import unconditionally | ||
| from .utils import ( | ||
| RESERVED_SYMBOLS, | ||
| MeasurementChannel, | ||
| ObservableTransformation, | ||
| noise_distribution_to_cost_function, | ||
| noise_distribution_to_observable_transformation, | ||
| ) | ||
|
|
||
| __all__: list[str] = [ | ||
| # Utils | ||
| "MeasurementChannel", | ||
| "noise_distribution_to_cost_function", | ||
| "noise_distribution_to_observable_transformation", | ||
| "RESERVED_SYMBOLS", | ||
| "ObservableTransformation", | ||
| ] | ||
|
|
||
| # SBML importer (optional) | ||
| try: | ||
| from .sbml import ( | ||
| SbmlImporter, # noqa: E402,F401 | ||
| sbml2jax, # noqa: E402,F401 | ||
| smbl2amici, # noqa: E402,F401 | ||
| ) | ||
|
|
||
| __all__ += [ | ||
| "sbml2amici", | ||
| "sbml2jax", | ||
| "SbmlImporter", | ||
| ] | ||
| except Exception: | ||
| # Leave unavailable if optional dependency is missing | ||
| pass | ||
|
|
||
| # PySB importer (optional) | ||
| try: | ||
| from .pysb import ( | ||
| ode_model_from_pysb_importer, # noqa: E402,F401 | ||
| pysb2amici, # noqa: E402,F401 | ||
| pysb2jax, # noqa: E402,F401 | ||
| ) | ||
|
|
||
| __all__ += [ | ||
| "pysb2amici", | ||
| "pysb2jax", | ||
| "ode_model_from_pysb_importer", | ||
| ] | ||
| except Exception: | ||
| pass | ||
|
|
||
| # Antimony importer (optional) | ||
| try: | ||
| from .antimony import antimony2amici, antimony2sbml # noqa: E402,F401 | ||
|
|
||
| __all__ += ["antimony2sbml", "antimony2amici"] | ||
| except Exception: | ||
| pass | ||
|
|
||
| # BNGL importer (optional) | ||
| try: | ||
| from .bngl import bngl2amici # noqa: E402,F401 | ||
|
|
||
| __all__.append("bngl2amici") | ||
| except Exception: | ||
| pass | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay for now, but I'd say we should make the core symbolic code not import anything from amici.importers, only vice verse. Can be addressed when moving de_model.py.