You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have a usage question regarding the usage of Vector3 class.
Before the change of data type for Vector3 class to array interface was made, it was possible to vectorize the PyObject to store arrays for x, y, z to create an array of Vector3d objects.
vec3d = np.vectorize(Vector3d)
dir = vec3d(x,y,z)
where x, y, z are numpy arrays derived from the direction data in CRPropa output. But now, this process yields the following error TypeError: Wrong number or type of arguments for overloaded function 'new_Vector3d'
So, I tried using arrays of x,y,z values stacked in an array, i.e., data = np.stack((x,y,z), axis=1),
but still I get the same error. A for loop will also do the job, but can I still use numpy vectorize in some way?
The text was updated successfully, but these errors were encountered:
from crpropa import Vector3d
import numpy as np
x = np.ones(10)
vec3d = np.vectorize(Vector3d)
vec3d(x)
TypeError Traceback (most recent call last)
Input In [6], in <cell line: 1>()
----> 1 vec3d(x)
File /rest/venvs/crp_docu/lib/python3.9/site-packages/numpy/lib/function_base.py:2304, in vectorize.__call__(self, *args, **kwargs)
2301 vargs = [args[_i] for _i in inds]
2302 vargs.extend([kwargs[_n] for _n in names])
-> 2304 return self._vectorize_call(func=func, args=vargs)
File /rest/venvs/crp_docu/lib/python3.9/site-packages/numpy/lib/function_base.py:2390, in vectorize._vectorize_call(self, func, args)
2387 outputs = ufunc(*inputs)
2389 if ufunc.nout == 1:
-> 2390 res = asanyarray(outputs, dtype=otypes[0])
2391 else:
2392 res = tuple([asanyarray(x, dtype=t)
2393 for x, t in zip(outputs, otypes)])
TypeError: float() argument must be a string or a number, not 'crpropa.Vector3d'
Hi, I have a usage question regarding the usage of Vector3 class.
Before the change of data type for Vector3 class to array interface was made, it was possible to vectorize the PyObject to store arrays for x, y, z to create an array of Vector3d objects.
where x, y, z are numpy arrays derived from the direction data in CRPropa output. But now, this process yields the following error
TypeError: Wrong number or type of arguments for overloaded function 'new_Vector3d'
So, I tried using arrays of x,y,z values stacked in an array, i.e.,
data = np.stack((x,y,z), axis=1)
,but still I get the same error. A for loop will also do the job, but can I still use numpy vectorize in some way?
The text was updated successfully, but these errors were encountered: