I encountered some strange behavior with EMNumPy.numpy2em() under
Python 3. If I run the following, I get a blank array under
Python 3 but not Python 2:
import numpy as np aa = np.arange(9).reshape(3, 3) img = EMNumPy.numpy2em(aa) img.get_2dview()
If I cast the array as float32, things are OK again:
aa = np.arange(9).reshape(3, 3).astype(np.float32) img = EMNumPy.numpy2em(aa) img.get_2dview()
However, when I compute an FFT and inverse FFT, the output is
scrambled relative to the starting array, and only in Python 3:
aa = np.arange(9).reshape(3, 3).astype(np.float32) img = EMNumPy.numpy2em(aa) imgarray = img.get_2dview() imfft = np.fft.fft2(imgarray) real_array = np.fft.ifft2(imfft) eman_real = EMNumPy.numpy2em(real_array.real) eman_real.get_2dview()
Note 1: Without the ".real" in numpy2em, I get a blank array
again, only in Python 3.
Note 2: This was the original scenario when I encountered this
discrepancy.
Now, if in numpy2em I cast as float32 explicitly, things work again in Python 3:
aa = np.arange(9).reshape(3, 3).astype(np.float32) img = EMNumPy.numpy2em(aa) imgarray = img.get_2dview() imfft = np.fft.fft2(imgarray) real_array = np.fft.ifft2(imfft) eman_real = EMNumPy.numpy2em( real_array.real.astype(np.float32) ) eman_real.get_2dview()
However, I then get a 90-degree rotation in Python 2 (!).
Markus has a function called sp_utilities.numpy2em_python() which
works in both Python 2 & 3. He'd have to explain why it
works.
Looking quickly, e2proc2d uses numpy2em() once. Someone may want
to check on it.
Unrelated: In programs/e2spt_average.py:56, someone used double quotes inside double quotes: if verbose: print(f"{i} {s}: {d["xform.align3d"].get_trans}")
Is it OK if I fix it? One of my builds is failing because of it.
-Tapu
--
You received this message because you are subscribed to the Google Groups "EMAN2 and SPARX Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eman2-develope...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eman2-developers/2685a165-477c-ae8f-bd7a-d312a2fc7ae9%40gmail.com.