NuMojo v0.6: Expanding Capabilities with Powerful New Features
The latest release of NuMojo, version 0.6, introduces a host of exciting new features, optimizations, and improvements designed to enhance the library’s functionality and efficiency. From new array operations to significant performance boosts, this update brings NuMojo closer to full feature parity with NumPy while taking advantage of Mojo’s powerful capabilities.
New Features
Enhanced Array Manipulation
broadcast_to()
Method: Enables broadcasting an array to any compatible shape, making it easier to work with differently shaped arrays in mathematical operations.apply_along_axis()
Function: This function allows you to apply a 1D function along a specified axis of an n-dimensional array, streamlining data transformation workflows.diagonal()
Function & Method: Retrieve the diagonal elements of a matrix with ease.compress()
andclip()
Functions: These methods allow users to selectively extract and constrain array values efficiently.
Iterators and Performance Enhancements
- New
_NDAxisIter
Type: Enables iteration over 1D slices along a specific axis, supporting both C-order and F-order traversal. - New
ith()
Method: Enhances_NDArrayIter
and_NDIter
, enabling retrieval of the i-th item directly. - Memory Layout Optimization: The
Flags
type has been introduced to replace dictionary-based tracking of memory layout, improving efficiency and readability.
Changes and Improvements
Syntax and API Updates
NuMojo has been updated to align with Mojo 25.1’s latest syntax and best practices:
- Constructor calls such as
str()
have been replaced withString()
. index()
is now replaced withInt()
for better type clarity.- The
isdigit()
function has been converted into a method. - Arrays are now constructed directly via
NDArray()
instead ofNDArray.__init__()
.
Optimized Statistical and Sorting Functions
- Random Module Updates: Added
randint()
withShape
as the first argument for flexibility. - Statistics Module Improvements: Variance (
variance()
) and standard deviation (std()
) now support axis-wise computation. - Sorting Performance Boosts: The
sort()
function has been significantly optimized, andargsort()
now supports sorting along any axis. - Extrema Functions Expanded:
max()
andmin()
now operate across any axis, enhancing flexibility.
0-D Array Behavior Adjustments
- NuMojo scalars (0-D arrays) now support basic operations and can be unpacked using either
[]
or.item()
.
Deprecated & Removed Features
- Removed Redundant Statistical Functions:
cumvariance
,cumstd
,cumpvariance
, andcumpstd
have been deprecated. - Removed
maxT()
andminT()
Functions: These have been replaced with more general and powerful alternatives.
Bug Fixes & Performance Enhancements
ravel()
Fix for F-Order Arrays: Ensures correct flattening behavior.NDArray.sort()
Now Defaults to Last Axis (-1
)- Boolean Evaluation Fix:
NDArray.__bool__()
now returns correct results. - Printing Performance Boost: Displaying large arrays is now significantly faster.
- Boundary Checks for Safety:
NDArrayShape
andNDArrayStrides
now include stricter boundary checks to prevent errors.
Documentation & Roadmap Updates
- All
NDArray
methods now adhere to the Mojo Docstring Style Guide, improving clarity and usability. - The project roadmap has been revised to reflect current progress and upcoming milestones.
Looking Ahead
NuMojo continues to evolve rapidly, with upcoming plans to introduce GPU support and further optimizations for large-scale numerical computations. If you’re looking to contribute or stay up-to-date with the latest developments, check out the project’s GitHub repository. Our api is documented and searchable on our readthedocs.
Stay tuned for more powerful updates in future releases!