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

Can not iterate on values attribute of a Variable with PyObject dtype. #3431

Open
YooSunYoung opened this issue Apr 24, 2024 · 0 comments
Open

Comments

@YooSunYoung
Copy link
Member

YooSunYoung commented Apr 24, 2024

This works fine as expected:

var = sc.concat([sc.scalar([1,2,3])]*3, dim='x')
var.values
#  [[1, 2, 3], [1, 2, 3], [1, 2, 3]]

But this one fails:

var = sc.concat([sc.scalar([1,2,3])]*3, dim='x')

for val in var.values:
    print(val)

with this error messages:

TypeError: Unregistered type : scipp::python::PyObject

The above exception was the direct cause of the following exception:

TypeError                                 Traceback (most recent call last)
Cell In[22], [line 3](vscode-notebook-cell:?execution_count=22&line=3)
      [1](vscode-notebook-cell:?execution_count=22&line=1) var = sc.concat([sc.scalar([1,2,3])]*3, dim='x')
----> [3](vscode-notebook-cell:?execution_count=22&line=3) for val in var.values:
      [4](vscode-notebook-cell:?execution_count=22&line=4)     print(val)

TypeError: Unable to convert function return value to a Python type! The signature was
	(self: pybind11_builtins.iterator) -> scipp::python::PyObject

I came across this error because the Mtz file (for NMX) has a data column of lists(miller indices),
and I needed to convert them into string as a workaround for grouping...

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

No branches or pull requests

1 participant