Release Notes#
Version 0.2.1#
Breaking Changes#
Removed
BlockCSRandBlockELLsparse classes: These experimental block-sparse matrix implementations (along with their benchmarks and tests) have been removed. Users should useCOO,CSR, orCSCinstead.SparseMatrixno longer inherits fromJAXSparse: The base class is now standalone, with its ownshape,size,ndim,T,block_until_ready,tree_flatten,tree_unflatten,transpose, andtodenseinterface.
Improvements#
Forward-compatible
**kwargsacross all wrapped functions: All unit-aware wrapper functions inmath,lax,linalg, andfftmodules now accept and forward**kwargsto the underlying JAX functions. This ensures compatibility with new keyword arguments added in future JAX releases without requiring saiunit updates.saiunit.math:concatenate,stack,vstack,hstack,dstack,column_stack,block,append,split,array_split,dsplit,hsplit,vsplit,tile,repeat,sort,argsort,unique,searchsorted,where,clip,interp, and many moresaiunit.lax:cond,switch,scan,while_loop,fori_loop,sort,top_k,broadcasted_iota,concatenate,conv,pad,slice,dynamic_slice,gather,scatter, and many moresaiunit.linalg:svd,cholesky,eig,eigh,eigvalsh,qr,lu,solve,det,norm,matrix_power,cross,tensordot, etc.saiunit.fft:fft,ifft,fft2,ifft2,fftn,ifftn,rfft,irfft,rfft2,irfft2,rfftn,irfftn,fftshift,ifftshift
Standalone
SparseMatrixbase class: Decoupled fromjax.experimental.sparse.JAXSparseto reduce external coupling and provide a self-contained sparse matrix interface with properties (size,ndim,nse,dtype) and methods (__repr__,__len__,block_until_ready).Improved validation in sparse classes: Replaced
assertstatements with descriptiveValueErrorexceptions inCOO.with_data,CSR.with_data, andCSC.with_datafor shape, dtype, and unit mismatches.Broader sparse type checking:
isinstancechecks in binary and matmul operations now accept bothJAXSparseandSparseMatrix, ensuring correct behavior after the inheritance change.Fixed
CSC.tree_unflattenerror message: Corrected the error message from"CSR.tree_unflatten"to"CSC.tree_unflatten".Explicit attribute assignment in
tree_unflatten:CSRandCSCnow setshape,indices, andindptrexplicitly instead of using__dict__.update, improving clarity and avoiding potential issues.
Version 0.2.0#
Highlights#
This release introduces unit-aware type annotations, string-based unit parsing, enhanced Matplotlib integration, and a comprehensive overhaul of error handling and unit display semantics.
New Features#
Unit-aware type annotations (
saiunit.typing): AddedQuantityLike,UnitLike, and related type aliases usingtyping.Annotated(PEP 593) for expressing physical-unit constraints in Python type hints.String-based unit parsing:
Quantitynow accepts string unit specifications during initialization (e.g.,Quantity(1.0, "meter")).Matplotlib
QuantityConverter: Full integration with Matplotlib’s unit conversion framework, enabling direct plotting ofQuantityobjects with automatic axis labeling and unit display.unit_to_scaleparameter for activation functions: Activation functions now accept an optionalunit_to_scaleparameter for explicit unit conversion.symmetrize_inputparameter: Added tocholesky,eigvalsh, andsvdfor optional input symmetrization before decomposition.amualias: Addedamuas an alias foratomic_mass/u/um_u.concrete_or_errorshim: Compatibility shim forjax.core.concrete_or_errorto maintain support across JAX versions.FFT
shapeparameter:_calculate_fftn_dimensionnow supports ashapeparameter for explicit output shape specification.
Improvements#
Unified unit display format: Refactored
display_in_unitand unit representation methods for consistent, human-readable output. Normalized exponent representation and improved formatting for dimensionless units. Removed thepython_codeparameter in favor of unified display.Error handling overhaul: Replaced
assertstatements with properTypeErrorandValueErrorexceptions across the codebase (Quantity, einops, lax, FFT, and unit-related functions) for clearer, more informative error messages.Updated physical constants (CODATA 2018):
atomic_mass,electron_volt,light_year,atmosphere,acre,fluid_ounce_imp,Btu_th,speed_of_sound, andIMFnow use more accurate conversion factors.Improved display names:
survey_foot/survey_milenow show"US survey ft"/"US survey mi";gallon_impshows"imp gal";fluid_ounce_impshows"imp fl oz";monthshows"mon";Btu_ITshows"Btu".Unit preference scoring: Standard unit retrieval now uses preference scoring for aliases, ensuring compound unit representations maintain grouping.
Removed
iscompoundattribute from theUnitclass, simplifying the internal representation.Cumulative product functions: Enhanced handling for unit-aware quantities.
Jacobian and vector gradient: Refactored to use
_argnums_partialfor improved multi-argument handling; added tests for list-styleargnums.Sparse matrix improvements: Refactored unit handling in
BlockCSRandBlockELL; addedtransposemethod.Module organization: Restructured imports across
__init__.pyand submodules for consistency; defined__all__for decorators and constants.Type annotations modernized: Updated
Union[A, B]toA | Bsyntax throughout the codebase.Documentation: Updated docstrings with examples for unit-aware functions; added installation instructions for CUDA and TPU; refreshed all Jupyter notebook examples.
Copyright updated to BrainX Ecosystem Limited.
Bug Fixes#
Fixed issue #17 (unit display edge case).
Fixed cumulative product operations for unit-aware quantities.
Fixed error handling in tests: corrected expected exception types from
AssertionErrortoTypeErrorfor invalid input cases.
Internal / CI#
Refactored version handling and updated main entry point structure.
Removed deprecated JAX version testing from CI configuration.
Added
brainstateto optional testing dependencies.Updated CI configurations to include BrainUnit installation steps.
Removed
sys.version_infochecks for Python version compatibility.
Version 0.1.4#
Added numerically stable
exprelfunction with comprehensive test coverageUpdated lax array creation to use
jax.numpyfor zero initializationUpdated CI JAX version for improved compatibility
Improved code quality and removed redundant tests
Version 0.1.3#
Compatible with
jax>=0.8.2
Version 0.1.2#
Renamed
CustomArray.valuetoCustomArray.datafor API consistencyStreamlined math unwrapping for improved performance
Refactored math module for better Quantity/CustomArray support
Added dtype aliases for convenience
Fixed matplotlib convert for zero-sized inputs
Registered Array class as a PyTree node for JAX compatibility
Added support for Python 3.14
Updated CI configuration and dependencies
Version 0.1.1#
Fixed dimension and unit checks in convert method to handle empty input
Bug fixes and stability improvements
Version 0.1.0#
Introduced
CustomArrayclass and integrated it across saiunit modulesAdded
Arrayclass inheriting fromCustomArrayAdded
maybe_custom_arrayandmaybe_custom_array_treeutilities for type checkingAdded comprehensive unit tests for CustomArray integration
Improved support for einops, activation functions, FFT, and linear algebra operations
Enhanced Celsius conversion functions with CustomArray compatibility
Added tutorial and documentation for CustomArray
Version 0.0.19#
Added
CustomArrayclass as the foundation for custom array typesRefactored activation functions to support CustomArray
Added
gatherfunctionRefined
math,linalg,autograd, and constants modulesEnabled Quantity hashing with
__hash__methodFixed interp function and adjusted unit handling in output
Moved metadata from setup.py to pyproject.toml
Version 0.0.2#
The new version of saiunit, which separates the Quantity into the mantissa and the unit.
This design is more flexible and allows for more complex operations, enabling to represent the very large or very small values.
Version 0.0.1#
The first release of the project.