Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make np.array compatible with numpy 2.0 #3339

Merged
merged 2 commits into from
Jul 29, 2024

Conversation

Guangyun-Xu
Copy link
Contributor

Parameter copy in np.array

in version 2.0:

copy:bool, optional
If True (default), then the array data is copied. If None, a copy will only be made if array returns a copy, if obj is a nested sequence, or if a copy is needed to satisfy any of the other requirements (dtype, order, etc.). Note that any copy of the data is shallow, i.e., for arrays with object dtype, the new array will point to the same objects. See Examples for ndarray.copy. For False it raises a ValueError if a copy cannot be avoided. Default: True.

in version 1.x:

copybool, optional
If true (default), then the object is copied. Otherwise, a copy will only be made if array returns a copy, if obj is a nested sequence, or if a copy is needed to satisfy any of the other requirements (dtype, order, etc.).

@Guangyun-Xu
Copy link
Contributor Author

if numpy in version 2.0, run script ns-render interpolate --load-config will get error like this:

Traceback (most recent call last):
File "/home/guangyun/miniconda3/envs/ns_train/bin/ns-render", line 8, in
sys.exit(entrypoint())
File "/home/guangyun/Project/open_source/nerfstudio/ns_gitlab_update/nerfstudio/scripts/render.py", line 897, in ent
rypoint
tyro.cli(Commands).main()
File "/home/guangyun/Project/open_source/nerfstudio/ns_gitlab_update/nerfstudio/scripts/render.py", line 614, in mai
n
camera_path = get_interpolated_camera_path(
File "/home/guangyun/Project/open_source/nerfstudio/ns_gitlab_update/nerfstudio/cameras/camera_paths.py", line 42, i
n get_interpolated_camera_path
poses, Ks = get_interpolated_poses_many(poses, Ks, steps_per_transition=steps, order_poses=order_poses)
File "/home/guangyun/Project/open_source/nerfstudio/ns_gitlab_update/nerfstudio/cameras/camera_utils.py", line 271,
in get_interpolated_poses_many
poses_ab = get_interpolated_poses(pose_a, pose_b, steps=steps_per_transition)
File "/home/guangyun/Project/open_source/nerfstudio/ns_gitlab_update/nerfstudio/cameras/camera_utils.py", line 171,
in get_interpolated_poses
quat_a = quaternion_from_matrix(pose_a[:3, :3])
File "/home/guangyun/Project/open_source/nerfstudio/ns_gitlab_update/nerfstudio/cameras/camera_utils.py", line 57, i
n quaternion_from_matrix
M = np.array(matrix, dtype=np.float64, copy=False)[:4, :4]
ValueError: Unable to avoid copy while creating an array as requested.
If using np.array(obj, copy=False) replace it with np.asarray(obj) to allow a copy when needed (no behavior change
in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword
.

Copy link
Collaborator

@kerrj kerrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kerrj kerrj merged commit b0dd3d4 into nerfstudio-project:main Jul 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants