sametz / nmrsim

A Python library for NMR simulation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

numba TypingError

mahkame24 opened this issue · comments

Describe the bug
The typing error appears every time that I run the code. This code is one of the examples of ' nmrsim Documentation'

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Google Colab '
  2. Click on 'Note book link '
  3. Scroll down to '4th cell'
  4. See error

Expected behavior
I expected to see the array of H.

Screenshots
image

Desktop (please complete the following information):

  • OS: [windows 10]
  • Browser [chrome]
  • Version [84.0.4147.135 (Official Build) (64-bit)]

**nmrsim:
image

Additional context
This error appears for 'SpinSystem' too.

I'll try to dig into this when time allows (the start of the semester is very busy for me!) It might be Colab specific. Have you tried using outside of Colab, e.g. a Jupyter notebook?

It looks like your collab notebook has been modified since you had the error? I executed all four cells fine just now.

For reproducing a bug, it's important to have a code reference that won't change over time. If you're still having a problem, please provide a code block that would allow the issue to be replicated. Also, if the error messages indicate an error arising in one of nmrsim's dependencies (here, in sparse), please provide the versions of the dependency plus of nmrsim (versions of other dependencies may also help).

I haven't changed the notebook and I checked it again, it is still involve the errors.

I edited the issue, now the version of my nmrsim is added.

Sorry for the delay. Creating and running online courses during the pandemic has been eating my time.

The notebook still runs fine on my end. Cell 1 concludes with:

Successfully installed llvmlite-0.35.0 nmrsim-0.5.1 numba-0.52.0 sparse-0.11.2

Cell 2:

def parameter():
    v = np.array([50,20])
    J = np.zeros((2,2))
    J[0,1] = 100

    J = J + J.T
    return v, J
v, J = parameter()
H = hamiltonian_sparse(v, J)
print(H)
print(H.todense())

gives:

<COO: shape=(4, 4), dtype=complex128, nnz=6, fill_value=0j>
[[ 60.+0.j   0.+0.j   0.+0.j   0.+0.j]
 [  0.+0.j -10.+0.j  50.+0.j   0.+0.j]
 [  0.+0.j  50.+0.j -40.+0.j   0.+0.j]
 [  0.+0.j   0.+0.j   0.+0.j -10.+0.j]]

cell 3:

abx_system = SpinSystem(v, J)
#mplplot(abx_system.peaklist(), y_max=0.2)
abx_system.peaklist()

gives:

[(67.20153254455275, 0.021086857389424313),
 (137.20153254455275, 0.021086857389424313),
 (37.20153254455275, 0.9789131426105757),
 (32.79846745544725, 0.9789131426105757)]

and cell 4:

from nmrsim import plt, qm
abx_system = qm.qm_spinsystem(v, J)
abx_system

gives:

[(67.20153254455275, 0.021086857389424313),
 (137.20153254455275, 0.021086857389424313),
 (37.20153254455275, 0.9789131426105757),
 (32.79846745544725, 0.9789131426105757)]

"It works on my end" isn't a satisfying response, I know. If there's an unusual issue with the sparse library, perhaps a fix to #6 may resolve it.

I was finally able to return to this. sparse 0.11.0 broke how nmrsim used tensordot, somehow. The current workaround is to pin your sparse version to <=0.10.1. See Issue #8 .

The sparse bug was fixed in sparse 0.13.0. Future nmrsim versions will allow sparse>=0.13 as well as <=0.10.