import numpy as np

from tkcompute import get_backend


def main():
    bk = get_backend("numpy", workers=1)

    x0 = np.arange(64, dtype=np.float64).reshape(8, 8)
    x = bk.asarray(x0)

    assert x is x0
    assert bk.to_numpy(x) is x
    assert bk.xp is np

    y = bk.fftn(x)
    y_ref = np.fft.fftn(x0)

    assert np.allclose(y, y_ref)
    assert bk.get_device_name()

    print("NumpyBackend smoke test: OK")


if __name__ == "__main__":
    main()
