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

Issue when rotating 3D probes by specifying the axis as "xy"/"yz"/"zx" #273

Open
DrTaDa opened this issue May 13, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@DrTaDa
Copy link

DrTaDa commented May 13, 2024

It is written in the docstring of the method .rotate of the class Probe that the axis is to be specified as a string:

axis : "xy" | "yz" | "xz" | None, default: None
            Axis of rotation.
            It must be None for 2D probes
            It must be given for 3D probes

Howver, that leads to an error:

File "/home/tanguy.damart/virt_env/mozaik/lib/python3.8/site-packages/probeinterface/probe.py", line 1422, in _rotation_matrix_3d
    axis = axis / np.linalg.norm(axis)
  File "<__array_function__ internals>", line 180, in norm
  File "/home/tanguy.damart/virt_env/mozaik/lib/python3.8/site-packages/numpy/linalg/linalg.py", line 2511, in norm
    x = x.astype(float)
ValueError: could not convert string to float: 'xy'

Which hapens because the function _rotation_matrix_3d expects a list or array instead of a string:

axis : np.array or list

@alejoe91 alejoe91 added the bug Something isn't working label May 13, 2024
@alejoe91
Copy link
Member

Hi Tanguy!

Yeah indeed this is a bug. We should convert the string to the proper rotation axis (e.g., xy -> [0, 0, 1]). Alternatively we can ask the user to pass directly a 3D axis as input. What do you think?

@DrTaDa
Copy link
Author

DrTaDa commented May 13, 2024

Hey Alessio :))

I think having a function that would transform the string in a list as you suggested would be best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants