-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Maybe there is a bug in code of Array Operations with NumPy #60
Comments
Thank you for opening this issue @fidle. Here is a small example that reflects this issue: > python
Python 3.6.8 |Anaconda custom (64-bit)| (default, Dec 29 2018, 19:04:46)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.15.4'
>>> c = 1.0
>>> dx = 2 / 80
>>> dy = 2 / 80
>>> sigma = 0.2
>>> dt = sigma * dx
>>> un = numpy.random.rand(80, 80)
>>> u1 = un[1:, 1:] - ((c * dt / dx * (un[1:, 1:] - un[1:, 0:-1])) - (c * dt / dy * (un[1:, 1:] - un[0:-1, 1:])))
>>> u2 = (un[1:, 1:] - (c * dt / dx * (un[1:, 1:] - un[1:, 0:-1])) - (c * dt / dy * (un[1:, 1:] - un[0:-1, 1:])))
>>> numpy.allclose(u1, u2)
False
>>> Since you found the bug @fidle, would you like to provide a patch in a pull-request? |
sorry to reply you so late. @mesnardo nx = 81 x = numpy.linspace(0,2,nx) for n in range(nt + 1): ##loop across number of time steps `%%timeit for n in range(nt + 1): ##loop across number of time steps |
Fix barbagroup#60 The parenthesis in In [6] were miscplaced. @fidle caught the bug and opened an issue (barbagroup#60). Thank you for reporting the error @fidle. Also: * Re-run notebook to get updated execution times. * Update execution times in Markdown cells. * Add info about machine used to re-run notebook.
Thank you @fidle.
|
In . There is a little bug in sentence:
u[1:, 1:] = un[1:, 1:] - ((c * dt / dx * (un[1:, 1:] - un[1:, 0:-1])) -
(c * dt / dy * (un[1:, 1:] - un[0:-1, 1:])))
The bold left bracket "(" is in a wrong place. It should follow "=" . Correct code should be:
u[1:, 1:] = ( un[1:, 1:] -(c * dt / dx * (un[1:, 1:] - un[1:, 0:-1])) -
(c * dt / dy * (un[1:, 1:] - un[0:-1, 1:])))
This little bug make cell5 and cell6 show a different result which suppose to be same.
The text was updated successfully, but these errors were encountered: