Goodman-lab/DP5

Proton_processing.py problem

xhliu7 opened this issue · 1 comments

Hi all,
I got the following error message when runing the PyDP4.py:
Traceback (most recent call last):
File "/home/drugdb/PycharmProjects/DP5/./PyDP4_GUI.py", line 2600, in runPyDP4
self.NMRData, self.Isomers, self.settings, self.DP4Data,self.DP5Data = PyDP4.main(ui.table_widget.Tab1.settings)
File "/home/drugdb/PycharmProjects/DP5/PyDP4.py", line 397, in main
NMRData = NMR.NMRData(settings)
File "/home/drugdb/PycharmProjects/DP5/NMR.py", line 73, in init
self.ProcessProton(settings,ind1)
File "/home/drugdb/PycharmProjects/DP5/NMR.py", line 213, in ProcessProton
= process_proton(NMR_file, settings,self.Type)
File "/home/drugdb/PycharmProjects/DP5/Proton_processing.py", line 52, in process_proton
peak_regions, grouped_peaks, sim_regions, integral_sum, cummulative_vectors, integrals, number_of_protons_structure, optimum_proton_number, total_integral = find_integrals(
File "/home/drugdb/PycharmProjects/DP5/Proton_processing.py", line 1709, in find_integrals
grouped_peaks, integrals, peak_regions, picked_peaks_, impurities, sim_regions,rounded_integrals = remove_impurities(integrals,
File "/home/drugdb/PycharmProjects/DP5/Proton_processing.py", line 1569, in remove_impurities
peak_regions = np.delete(peak_regions, to_remove)
File "<array_function internals>", line 200, in delete
File "/usr/local/lib/python3.10/dist-packages/numpy/lib/function_base.py", line 5126, in delete
arr = asarray(arr)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (32,) + inhomogeneous part.

It seemed that was caused by numpy (I am using 1.24.2) which do not allowed to create an array from "ragged" sequences. But how can I fix this? By the way, I am runing python 3.10.6 on Ubuntu 22.04.1. And the following packages were installed:
Package Version


apturl 0.5.2
asteval 0.9.28
bcrypt 3.2.0
blinker 1.4
Brlapi 0.8.3
certifi 2020.6.20
chardet 4.0.0
click 8.0.3
colorama 0.4.4
command-not-found 0.3
contourpy 1.0.7
cryptography 3.4.8
cupshelpers 1.0
cycler 0.11.0
Cython 0.29.33
dbus-python 1.2.18
defer 1.0.6
dill 0.3.6
distro 1.7.0
distro-info 1.1build1
duplicity 0.8.21
fasteners 0.14.1
fonttools 4.38.0
future 0.18.2
httplib2 0.20.2
idna 3.3
importlib-metadata 4.6.4
jeepney 0.7.1
keyring 23.5.0
kiwisolver 1.4.4
language-selector 0.1
launchpadlib 1.10.16
lazr.restfulclient 0.14.4
lazr.uri 1.0.6
lmfit 1.1.0
lockfile 0.12.2
louis 3.20.0
macaroonbakery 1.3.1
Mako 1.1.3
MarkupSafe 2.0.1
matplotlib 3.6.3
monotonic 1.6
more-itertools 8.10.0
multiprocess 0.70.14
netifaces 0.11.0
nmrglue 0.9
numpy 1.24.2
oauthlib 3.2.0
olefile 0.46
packaging 23.0
pandas 1.5.3
paramiko 2.9.3
pathos 0.3.0
patsy 0.5.3
pexpect 4.8.0
Pillow 9.0.1
pip 22.0.2
pox 0.3.2
ppft 1.7.6.6
protobuf 3.12.4
ptyprocess 0.7.0
pycairo 1.20.1
pycups 2.0.1
PyGObject 3.42.1
PyJWT 2.3.0
pymacaroons 0.13.0
PyNaCl 1.5.0
pyparsing 2.4.7
PyQt5 5.15.8
PyQt5-Qt5 5.15.2
PyQt5-sip 12.11.1
pyRFC3339 1.1
python-apt 2.4.0
python-dateutil 2.8.1
python-debian 0.1.43ubuntu1
pytz 2022.1
pyxdg 0.27
PyYAML 5.4.1
qml 0.4.0.27
rdkit 2022.9.4
reportlab 3.6.8
requests 2.25.1
scipy 1.10.0
screen-resolution-extra 0.0.0
SecretStorage 3.3.1
setuptools 59.6.0
six 1.16.0
ssh-import-id 5.11
statsmodels 0.13.5
systemd-python 234
ubuntu-advantage-tools 27.12
ubuntu-drivers-common 0.0.0
ufw 0.36.1
unattended-upgrades 0.1
uncertainties 3.1.7
urllib3 1.26.5
usb-creator 0.3.7
wadllib 1.3.6
wheel 0.37.1
xdg 5
xkit 0.0.0
zipp 1.0.0

It's ok now. I fixed the problem by adding the following 3 lines of code in line 1568,1570,1572 respectively:
peak_regions = np.array(peak_regions, dtype=object)
grouped_peaks = np.array(grouped_peaks, dtype=object)
sim_regions = np.array(sim_regions, dtype=object)