Skip to content

Deprecated numpy feature generates shape error #4

@ZGainsforth

Description

@ZGainsforth

While doing a reconstruction in linux, the following warning appears with numpy version 1.23.3.

   ______  ________  ____  _____  ________  _____  _______     ________
 .' ___  ||_   __  ||_   \|_   _||_   __  ||_   _||_   __ \   |_   __  |
/ .'   \_|  | |_ \_|  |   \ | |    | |_ \_|  | |    | |__) |    | |_ \_|
| |   ____  |  _| _   | |\ \| |    |  _|     | |    |  __ /     |  _| _
\ `.___]  |_| |__/ | _| |_\   |_  _| |_     _| |_  _| |  \ \_  _| |__/ |
 `._____.'|________||_____|\____||_____|   |_____||____| |___||________|

Projections = Fe_Ka_aligned.npy
Euler angles = tilts.txt
Support =
Initial Object = None
resultsFilename = Fe_Ka_reconstruction.mrc
griddingMethod = FFT
resolutionExtensionSuppressionState = 2
numIterations = 100
oversamplingRatio = 4
interpolationCutoffDistance = 0.7
useDefaultSupport = True
calculateRfree = True
constraintPositivity = True
constraintSupport = True
enforceResolutionCircle = True
permitMultipleGridding = True
Reading projections from .npy file.

Assembling Fourier grid.
Fourier grid assembled in 2.4 seconds
Reconstruction started
/home/zack/anaconda3/envs/genfire39/lib/python3.9/site-packages/numpy/core/fromnumeric.py:2009: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
result = asarray(a).shape
Iteration number: 1/100 error = 1.00000
Iteration number: 2/100 error = 0.63928
Iteration number: 3/100 error = 0.50803
etc.


However, on numpy version 1.26.4:

   ______  ________  ____  _____  ________  _____  _______     ________
 .' ___  ||_   __  ||_   \|_   _||_   __  ||_   _||_   __ \   |_   __  |
/ .'   \_|  | |_ \_|  |   \ | |    | |_ \_|  | |    | |__) |    | |_ \_|
| |   ____  |  _| _   | |\ \| |    |  _|     | |    |  __ /     |  _| _
\ `.___]  |_| |__/ | _| |_\   |_  _| |_     _| |_  _| |  \ \_  _| |__/ |
 `._____.'|________||_____|\____||_____|   |_____||____| |___||________|

Projections = Ni_Ka_aligned.npy
Euler angles = tilts.txt
Support =
Initial Object = None
resultsFilename = Ni_Ka_reconstruction.mrc
griddingMethod = FFT
resolutionExtensionSuppressionState = 2
numIterations = 100
oversamplingRatio = 4
interpolationCutoffDistance = 0.7
useDefaultSupport = True
calculateRfree = True
constraintPositivity = True
constraintSupport = True
enforceResolutionCircle = True
permitMultipleGridding = True
Reading projections from .npy file.

Assembling Fourier grid.

Fourier grid assembled in 10.9 seconds
Reconstruction started
Traceback (most recent call last):
File "/home/zack/anaconda3/envs/genfire39/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 2022, in shape
result = a.shape
AttributeError: 'list' object has no attribute 'shape'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/mnt/c/Users/zsg/Dropbox/ParticleBase/Unprocessed/20240519 - TitanX - OREX-803030-100/0072 - Sulfide Tomo/Output4bin/Aligned/DoGenfire.py", line 25, in
results = GF.reconstruct()
File "/home/zack/anaconda3/envs/genfire39/lib/python3.9/site-packages/genfire/reconstruct.py", line 1044, in reconstruct
results = reconstruct(self.params.numIterations,
File "/home/zack/anaconda3/envs/genfire39/lib/python3.9/site-packages/genfire/reconstruct.py", line 64, in reconstruct
Rfree_complex_bybin = np.zeros((np.shape(R_freeInd_complex)[2], numIterations),dtype=float)
File "/home/zack/anaconda3/envs/genfire39/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 2024, in shape
result = asarray(a).shape
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 3 dimensions. The detected shape was (3, 1, 64) + inhomogeneous part.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions