How to use the model from Python

#Make sure that cython extension is installed
#> pip install --user cython

# The source code of the add8s_7QY extension needs to be downloaded first
> curl -s "https://ehw.fit.vutbr.cz/evoapproxlib/v1.2022?folder=adders/8_signed/pareto_pwr_mae&file=add8s_7QY.c&pyx=bash" | bash

#Finally, the extension can be used in a Python script as follows
> python
import pyximport; pyximport.install()
import add8s_7QY

def u2s(v): # 8b unsigned to 8b signed
    if v & 128:
	return v - 256
    return v

wce = e = 0
for i in range(-2**7,2**7):
    for j in range(-2**7,2**7):
        if (i+j < -128) or (i+j > 127): continue #skip cases causing overflow
        diff = abs(u2s(add8s_7QY.add(i,j)) - (i+j))
        if diff > wce: wce = diff
        e += diff

print('average error magnitude (mae)',e/(2.0**(8)))
print('worst-case error magnitude (wce)',wce)