Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

NumPy 1.17.0 is here, officially drops Python 2.7 support pushing forward Python 3 adoption

Save for later
  • 5 min read
  • 31 Jul 2019

article-image

Last week, the Python team released NumPy version 1.17.0. This version has many new features, improvements and changes to increase the performance of NumPy.

The major highlight of this release includes a new extensible numpy.random module, new radix sort & timsort sorting methods and a NumPy pocketfft FFT implementation for accurate transforms and better handling of datasets of prime length. Overriding of numpy functions has also been made possible by default.

NumPy 1.17.0 will support Python versions 3.5 - 3.7. Python 3.8b2 will work with the new release source packages, but may not find support in future releases.

The Python team had previously updated users that Python 2.7 maintenance will stop on January 1, 2020. NumPy 1.17.0 officially dropping Python 2.7 is a step towards the adoption of Python 3. Developers who want to port their Python 2 code in Python 3, can check out the official porting guide, released by Python.

Read More: NumPy drops Python 2 support. Now you need Python 3.5 or later.

What’s new in NumPy 1.17.0?

New extensible numpy.random module with selectable random number generators


NumPy 1.17.0 has a new extensible numpy.random module. It also includes four selectable random number generators and improved seeding designed for use in parallel processes. PCG64 is the new default numpy.random module while MT19937 is retained for backwards compatibility.

Timsort and radix sort have replaced mergesort for stable sorting


Both the radix sort and timsort have been implemented and can be used instead of mergesort. The sorting kind options ‘stable’ and ‘mergesort’ have been made aliases of each other with the actual sort implementation for maintaining backward compatibility. Radix sort is used for small integer types of 16 bits or less and timsort is used for all the remaining types of bits.

empty_like and related functions now accept a shape argument


Functions like empty_like, full_like, ones_like and zeros_like will now accept a shape keyword argument, which can be used to create a new array as the prototype and overriding its shape also. These functions become extremely useful when combined with the __array_function__ protocol, as it allows the creation of new arbitrary-shape arrays from NumPy-like libraries.

User-defined LAPACK detection order


numpy.distutils now uses an environment variable, comma-separated and case insensitive detection order to determine the detection order for LAPACK libraries. This aims to help users with MKL installation to try different implementations.

.npy files support unicode field names


A new format version of .npy files has been introduced. This enables structured types with non-latin1 field names. It can be used automatically when needed.

New mode “empty” for pad


The new mode “empty” pads an array to a desired shape without initializing any new entries.

New Deprications in NumPy 1.17.0

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at AU $24.99/month. Cancel anytime

numpy.polynomial functions warn when passed float in place of int


Previously, functions in numpy.polynomial module used to accept float values. With the latest NumPy version 1.17.0, using float values is deprecated for consistency with the rest of NumPy. In future releases, it will cause a TypeError.

Deprecate numpy.distutils.exec_command and temp_file_name


The internal use of these functions has been refactored for better alternatives such as replace exec_command with subprocess. Also, replace Popen and temp_file_name <numpy.distutils.exec_command> with tempfile.mkstemp.

Writeable flag of C-API wrapped arrays


When an array is created from the C-API to wrap a pointer to data, the writeable flag set during creation indicates the read-write nature of the data. In the future releases, it will not be possible to convert the writeable flag to True from python as it is considered dangerous.

Other improvements and changes

Replacement of the fftpack based fft module by the pocketfft library


pocketfft library contains additional modifications compared to fftpack which helps in improving accuracy and performance. If FFT lengths has large prime factors then pocketfft uses Bluestein's algorithm, which maintains O(N log N) run time complexity instead of deteriorating towards O(N*N) for prime lengths.

Array comparison assertions include maximum differences


Error messages from array comparison tests such as testing.assert_allclos now include “max absolute difference” and “max relative difference” along with previous “mismatch” percentage. This makes it easier to update absolute and relative error tolerances.

median and percentile family of functions no longer warn about nan


Functions like numpy.median, numpy.percentile, and numpy.quantile are used to emit a RuntimeWarning when encountering a nan. Since these functions return the nan value, the warning is redundant and hence has been removed.

timedelta64 % 0 behavior adjusted to return NaT


The modulus operation with two np.timedelta64 operands now returns NaT in case of division by zero, rather than returning zero.

Though users are happy with NumPy 1.17.0 features, some are upset over the Python version 2.7 being officially dropped.

https://twitter.com/antocuni/status/1156236201625624576

For the complete list of updates, head over to NumPy 1.17.0 release notes.

Plotly 4.0, popular python data visualization framework, releases with Offline Only, Express first, Displayable anywhere features

Python 3.8 new features: the walrus operator, positional-only parameters, and much more

Azure DevOps report: How a bug caused ‘sqlite3 for Python’ to go missing from Linux images