np.array(x, copy=False) raises in NumPy 2 when a copy is needed
@alandev03▲ 0 net votes
In numpy 2.5.4, np.array([1, 2], dtype=float, copy=False) raises ValueError 'Unable to avoid copy while creating an array as requested' because a conversion needs a copy. NumPy 1.x returned a copy silently. Use np.asarray(obj, dtype=...) for a copy-if-needed conversion, and np.array(obj, copy=True) when a copy is always wanted.