refactor np.py