[feat] Integrate with brainunit to provide physical units and unit-aware mathematical handing #18
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.
This pull request introduces several modifications to the
catalaxpackage, focusing on integrating thebrainunitlibrary for handling quantities and units, and adding functionality to the model and plotting modules. The most important changes include updating the MCMC and model simulation functions to support quantities, enhancing the plotting functions to display units, and adding new methods for model configuration.Technical Compatibility Notes
Current implementation faces version dependency conflicts between Catalax and recent updates of Diffrax-related packages, which disrupt neural network functionalities. For unit-aware differential equation solving in BrainUnit integration, the workflow relies on diffraxu, a fork of Diffrax modified to natively handle physical units via brainunit.
Additionally, Markov Chain Monte Carlo (MCMC) operations require explicit unit stripping:
Critical Limitation
This approach bypasses (but does not resolve) the underlying incompatibility between Catalax's dependency constraints and newer Diffrax versions.
Integration of
brainunitlibrary:catalax/mcmc/mcmc.py: Updated to usebrainunit.Quantityfor data conversion and unit consistency checks in therun_mcmcfunction. [1] [2]catalax/mcmc/priors.py: Addedunitattribute to thePriorclass and updated prior distributions to supportQuantitytypes. [1] [2]Enhancements to model simulation:
catalax/model/model.py: Updated thesimulatefunction to handleQuantitytypes for initial conditions and added anorigin_solveparameter to force re-setup of the simulation system. [1] [2]add_termmethod to the model class for adding terms to the model.Improvements to plotting functions:
catalax/mcmc/plotting.py: Enhanced plotting functions (plot_corner,plot_posterior,plot_trace, andplot_forest) to display parameter units when available. [1] [2] [3] [4]These changes improve the handling of physical quantities in simulations and visualizations, ensuring consistency and clarity in the results.