Yes, numpy works seamlessly with the affinity.
My simple program.
import os
import numpy as np

os.sched_setaffinity(os.getpid(), {0, 1, 2})
print('Set PID-{} to affinity: {}'.format(os.getpid(),
                                          os.sched_getaffinity(os.getpid())))

while True:
    a = np.random.random_sample([100, 100])
    b = np.random.random_sample([100, 100])
    c = np.dot(a, b)

Without setting affinity.

Screen Shot 2020-02-24 at 10.43.25 AM1172×505 47.6 KB

With affinity 0.

Screen Shot 2020-02-24 at 10.43.58 AM1172×505 34.7 KB

With affinity 0, 1, 2.

Screen Shot 2020-02-24 at 10.44.20 AM1172×505 35.6 KB