NumPy integrationΒΆ

It is possible to easily go between numpy and apytypes and therefore also use plotting tools like Matplotlib in an integrated manner.

Consider the example from https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.convolve.html implemented using fixed-point arithmetic

import numpy as np
from scipy import signal
import apytypes as apy
import matplotlib.pyplot as plt

sig = np.repeat([0.0, 1.0, 0.0], 100)
sig_fx = apy.fx(sig, bits=12, int_bits=2)

win = signal.windows.hann(50)
win_fx = apy.fx(win, bits=10, int_bits=2)

filtered = signal.convolve(sig, win, mode="same") / sum(win)
filtered_fx = apy.convolve(sig_fx, win_fx, mode="same") / sum(win_fx)

The results can then be plotted in Matplotlib

Original pulse, Filter impulse response, Filtered signal

Total running time of the script: (0 minutes 0.604 seconds)

Gallery generated by Sphinx-Gallery