A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://learn.adafruit.com/ulab-crunch-numbers-fast-with-circuitpython below:

Overview | ulab: Crunch Numbers fast in CircuitPython

What is ulab

ulab (pronounced "micro lab") lets you perform number crunching tasks in CircuitPython more quickly, often around 10x as fast. This can be very handy when dealing with sensor data, as we'll see below.

Make sure you have CircuitPython 5.1.0 or newer, and any Adafruit CircuitPython board with an M4 or higher processor, including most SAMD51 and nRF boards.

It's a "built-in module", meaning that it is installed when you install CircuitPython, it's not a file or a set of files in a project bundle or installable via circup. Check the "Built-in modules available" list for a particular board on circuitpython.org to find out if it's available, or just run import ulab at the repl to find out for yourself immediately. If the result is an ImportError, then ulab is not available on that board.

ulab is modeled after numpy, but is not entirely compatible; so after the examples there are guidelines to help you move between numpy and ulab.

ulab is not available in Blinka, Adafruit's Single Board Computer layer for CircuitPython - for those boards we recommend using plain numpy since it's available! If your code needs to run on both CircuitPython and Blinka, you'll probably either need to use conditional code or forego the use of ulab altogether.

Starting with CircuitPython 7 the ulab APIs were changed to move the functions into ulab.numpy and ulab.scipy respectively based on where they exist in their CPython library counterparts. If you have projects using ulab functions you'll likely need to update the code to import and call the functions using the new names.

The ulab API

ulab makes things faster by operating on entire arrays of values in one operation.  For example, when you have two numbers a and b, a+b adds them together, returning a new number.  When you have two ulab arrays a and b, a+b adds the corresponding numbers in a to the corresponding numbers in b, returning a new array.  Want to double every number in an array?  That's a*2.  Compute its sine?  ulab.numpy.sin(a).  It also has special versions of functions like sum that act on a whole array and return a single number.  Documentation for all functions in ulab are on readthedocs.

These examples only cover a portion of the functions available in ulab.  The items below are beyond the scope of this gude:

Your browser does not support the video tag.

Do you feel like you just don't have a CLUE? Well, we can help with that - get a CLUE here at Adafruit by picking up this sensor-packed development board. We wanted to build some...

guides with product

This breakout is chock full o' sensors! Add basic gesture sensing, RGB color sensing, proximity sensing, or ambient light sensing to your project with the Adafruit...

guides with product

Bosch has stepped up their game with their new BMP280 sensor, an environmental sensor with temperature, barometric pressure that is the next generation upgrade to the...

guides with product Your browser does not support the video tag.

You love NeoPixels, and you love silicone diffusion? Peep this Flexible Silicone Neon-like Skinny NeoPixel LED Strip! OK it's a bit of a mouthful, but check...

This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or...

Page last edited March 08, 2024

Text editor powered by tinymce.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4