Numpy BOOMED!!

Numpy BOOMED!!

Numpy 1.21.0 Update: New Features and Improvements

Numpy, short for Numerical Python, is a popular open-source library for numerical computing in Python. It provides an extensive set of tools for scientific computing, including support for arrays, linear algebra, Fourier analysis, random number generation, and more. Recently, Numpy released version 1.21.0, which comes with many new features and improvements. In this blog, we'll take a closer look at some of the exciting changes in Numpy 1.21.0.

      1. 1.Improved numpy.random

The numpy.random module has received several new features and improvements. One of the most significant changes is the addition of the Generator class, which provides a more flexible and consistent interface for generating random numbers. It also allows for more control over the seeding and state of the random number generator.

2.Another notable improvement is the addition of the PCG64 random number generator. PCG64 is a fast and statistically robust random number generator that is now the default for numpy.random.

  1. New functions for working with arrays

Numpy 1.21.0 introduces several new functions for working with arrays. One of the most useful is numpy.take_along_axis, which allows you to select elements from an array along a given axis. This can be useful for operations such as sorting or selecting the maximum value along a particular axis.

3.Another new function is numpy.searchsorted, which returns the indices where elements should be inserted to maintain the order of the array. This function can be useful for tasks such as finding the rank of an element in an array or finding the nearest value in a sorted array.

  1. 4.Improved indexing and slicing

Indexing and slicing are fundamental operations in Numpy, and version 1.21.0 introduces several improvements in this area. One of the most significant changes is the addition of a new syntax for boolean indexing. You can now use a Boolean array to index an array, which can be more concise and easier to read.

Another improvement is the addition of the np.newaxis keyword, which allows you to add a new axis to an array. This can be useful for operations such as broadcasting or reshaping arrays.

  1. 5.Performance improvements

Numpy 1.21.0 includes several performance improvements, especially for operations involving large arrays. One of the most significant changes is the use of the BLAS library for matrix multiplication. BLAS is a highly optimized library for linear algebra operations, and using it can significantly improve the performance of matrix multiplication.

6.Another improvement is the use of multi-threading for some operations, which can take advantage of multiple CPU cores to perform computations more quickly.

  1. Other changes

Aside from the above changes, Numpy 1.21.0 includes several other improvements, such as:

  • A new dtype, "datetime64[s]", which provides nanosecond precision for datetime operations.

  • The ability to use named dtype fields in ufunc signatures.

  • Support for PEP 604, which allows for using dictionary unpacking in array creation.

  1. 7.Conclusion

Numpy 1.21.0 is a significant update that brings many new features and improvements to the library. With the addition of the Generator class and the PCG64 random number generator, numpy.random is more flexible.