Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: high is out of bounds for int32 #21

Open
njcleri opened this issue Jul 12, 2020 · 11 comments
Open

ValueError: high is out of bounds for int32 #21

njcleri opened this issue Jul 12, 2020 · 11 comments

Comments

@njcleri
Copy link

njcleri commented Jul 12, 2020

I am currently following the worked example listed under the documentation. Following the example code exactly, everything works fine until lm = linmix.LinMix(x, y, xsig, ysig , K = 2) lm.run_mcmc(silent = True), where I get an error ''ValueError: high is out of bounds for int32''. What do I need to change from the example to make this work?

@jjobel
Copy link

jjobel commented Sep 25, 2020

Hello,

I was having the same issue when running model = linmix.LinMix(x, y, err_x, err_y, xycov, delta, 2, 2) in my script and the
ValueError: high is out of bound for int32 would display. I managed to get my script up and running by doing the following:

  • Go to the linmix.py file (the error message itself displays the path to the file)
  • Open the file and go to line 402. Should look like this
if seed is None:
    seed = np.random.randint(2**32-1)
  • Change the line by adding dtype=np.int64 as follows:
if seed is None:
    seed = np.random.randint(2**32-1, dtype=np.int64)
  • Save the file and try running your program again.

Hope this helps!

@mbierschenk3
Copy link

Hello,

I was having the same issue when running model = linmix.LinMix(x, y, err_x, err_y, xycov, delta, 2, 2) in my script and the
ValueError: high is out of bound for int32 would display. I managed to get my script up and running by doing the following:

  • Go to the linmix.py file (the error message itself displays the path to the file)
  • Open the file and go to line 402. Should look like this
if seed is None:
    seed = np.random.randint(2**32-1)
  • Change the line by adding dtype=np.int64 as follows:
if seed is None:
    seed = np.random.randint(2**32-1, dtype=np.int64)
  • Save the file and try running your program again.

Hope this helps!

Hi!

I tried this and it seemed to be taking a long time to compile so I interrupted the kernel. Should I just let it run/does it normally take so long?

Thank you!

@jjobel
Copy link

jjobel commented Jul 27, 2021

Hello @mbierschenk3,

Are you running linmix.LinMix() separately and it is taking a long time to compile? or Is linmix.LinMix() implemented in your code and it is taking a long time to compile?

@mbierschenk3
Copy link

Hi @jjobel,

I am running the example exactly as given in the documentation, just as op was. I made the change that you suggested and ran again and it is still running!

@jjobel
Copy link

jjobel commented Jul 29, 2021

Hello @mbierschenk3,

I was able to reproduce the ValueError: high is out of bounds for int32 error while running the document example. Unfortunately, the solution I provided previously does not work.

I'm currently looking into another possible solution from the Numpy repository. An equivalent method to np.random.randint() exist for the current Numpy build. I'll post a solution once I make progress.

@mbierschenk3
Copy link

Hello @jjobel!

I was just writing back to see if you made any progress on a solution for this error? Please let me know! I look forward to your comments.

@jjobel
Copy link

jjobel commented Aug 10, 2021

Hello @mbierschenk3, sorry for the late reply I've been trying to figure out why mine works and not yours. I think I have a solution. Could you send me a screenshot of your error on the terminal.

There's a specific path that shows where the linmix.py file is located. Go to that file path, open linmix.py, and make the changes I initially suggested at the beginning of this issue.

@mbierschenk3
Copy link

mbierschenk3 commented Aug 11, 2021

@jjobel
Here is the screenshot of the error message. Following along the written example, I get the same/similar results as documentation up until this point in trying to execute "linmix.LinMix(...) ." I've also gone into the linmix.py file and included the "dtype=np.int64" where mentioned above but running this one block seemed endless.

image

@jjobel
Copy link

jjobel commented Aug 11, 2021

Okay based on your screenshot, open the linmix.py file using the path ~\Documents\Github\linmix\linmix\linmix.py and change line 402 from

seed = np.random.randint(2**32-1) --> seed = np.random.randint(2**32-1, dtype=np.int64)

save and run that cell again.

If you're still getting the same error, check if what you changed on line 402 shows up in the error message.

(sorry your message cut off halfway in the email and I thought there wasn't more to your comment)

I got mine to work by doing what I mentioned above. I had two linmix.py files. One was in the same folder as the git clone and the other one showed up in another folder after running python setup.py install. After the changes, the code example worked fine.

@mbierschenk3
Copy link

@jjobel

Did you do anything different with the lm.run_mcmc(silent=True) line? I noticed the lm = linmix.LinMix(x, y, xsig, ysig, K=2) line seems to compute but the MCMC is what is running for so long.

@jjobel
Copy link

jjobel commented Aug 11, 2021

No, I did nothing different. I copied and pasted the example to my jupyter notebook. Try restarting the jupyter notebook then running all cells after making any changes.

Someone was having this same ValueError error yesterday and we got it working with what I suggested in the previous comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants