AllenDowney / ModSimPy

Text and supporting code for Modeling and Simulation in Python
https://allendowney.github.io/ModSimPy/
MIT License
823 stars 1.76k forks source link

Issue with Pint - Chapter 1 #69

Closed iacisme closed 1 year ago

iacisme commented 1 year ago

Hi;

I'm going through your book and I'm doing the Computation with units example.

When I run the following line:

t = math.sqrt(2 * h / a)

I get the following error:

image

I'm note sure how to trouble-shoot it.

Am I doing something wrong, or is there an issue with pint?

Thanks!

AllenDowney commented 1 year ago

Are you reporting an error or asking for help debugging?

It looks like the notebook is working: https://colab.research.google.com/github/AllenDowney/ModSimPy/blob/master/chapters/chap01.ipynb

If you have been experimenting in the notebook (which is good), you might have changed the value of h or a so they no longer have compatible units.

iacisme commented 1 year ago

I thought I was reporting an error.

The other day I tried your notebooks. It threw the same error on colab as the screen shot above. It's the reason I posted something because it didn't seem to work.

I just tried your colab notebook and it's working now, so I'll figure out what's going on.

Thanks.

AllenDowney commented 1 year ago

OK, not sure what happened there. Maybe you executed the cells out of order, so the variables did not have the intended values?

But let me know if you're able to track it down -- maybe there's something I should warn people about.