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
After adding the recent feature to obtain a np.array of all mesh values via .values() (81abab7 and 1ba2695) it would be helpful to improve the functionality for MeshImFreq further. Right now calling .values() on a MeshImFreq gives back an array of mesh points:
Calling .imag directly on the array does not work, as numpy does not know how to use the dispatcher on a triqs mesh point object. I tried to find a solution for this on the python level but it seems no so straight forward to teach numpy to do this. If someone knows this would be the easiest! Other options:
(a) create a class that inherits from np.ndarray that is returned when .values() is called. Then this new class has a member attribute called .imag that will just do the np.vectorize call.
(b) implement a real C++ function that returns the values as an array (right now this only lives in the meshes_desc file) and add an optional keyword that switches between returning meshpoints or cmplx numbers, i.e. something like this:
This can be shortened to np.vectorize(np.imag)(mesh.values()).
Also, one does not really need the .values() method to get the imaginary parts.
map(np.imag, mesh) # -> an iterator returning floatlist(map(np.imag, mesh)) # -> a list of floatnp.fromiter(map(np.imag, mesh), float) # -> an np.ndarray of float
Calling .imag directly on the array does not work, as numpy does not know how to use the dispatcher on a triqs mesh point object. I tried to find a solution for this on the python level but it seems no so straight forward to teach numpy to do this.
After adding the recent feature to obtain a np.array of all mesh values via
.values()
(81abab7 and 1ba2695) it would be helpful to improve the functionality for MeshImFreq further. Right now calling.values()
on a MeshImFreq gives back an array of mesh points:It would be helpful to return back directly a list of complex numbers. This can right now be achieved only via:
Calling
.imag
directly on the array does not work, as numpy does not know how to use the dispatcher on a triqs mesh point object. I tried to find a solution for this on the python level but it seems no so straight forward to teach numpy to do this. If someone knows this would be the easiest! Other options:(a) create a class that inherits from np.ndarray that is returned when
.values()
is called. Then this new class has a member attribute called.imag
that will just do thenp.vectorize
call.(b) implement a real C++ function that returns the values as an array (right now this only lives in the meshes_desc file) and add an optional keyword that switches between returning meshpoints or cmplx numbers, i.e. something like this:
where the default can be to return mesh points.
The text was updated successfully, but these errors were encountered: