rewrote ndarray