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

Python 3.6 compatibility. #10

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Python 3.6 compatibility. #10

wants to merge 7 commits into from

Conversation

phn
Copy link

@phn phn commented Apr 9, 2017

Hello,

I have made some changes to the code to make it run under Python 3.6. The code now runs under 2.7, 3.5 and 3.6.

Please see the file CHANGES_FOR_PY36.md for a list of changes.

I have setup up Tox so that it is easy to run tests under different versions of Python (see tox.ini).

The tests succeed for all but the StaggeredMidpoint algorithm. This failures is present in all versions
of Python. So it seems like there is a bug in the algorithm. If you could let me know a fix I will
incorporate it into this pull request.

Testing RungeKutta4
...ok
Testing StaggeredMidpoint
____________________________________________ test_complex ____________________________________________

def test_complex():
  _run_test_problems(Complex)

odespy/tests/test_basics.py:310:


odespy/tests/test_basics.py:258: in _run_test_problems
u, t = solver.solve(problem['time_points'])
odespy/solvers.py:1043: in solve
self.u[n+1] = self.advance() # new value


self = <[UnboundLocalError("local variable 'f_name' referenced before assignment") raised in repr()] StaggeredMidpoint object at 0x7f1be05e6978>

def advance(self):
    """
        u[0], u[2], etc. are velocities at t=(i+1/2)*dt.
        u[1], u[3], etc. are positions at t=i*dt.
        """
    u, f, n, t = self.u, self.f, self.n, self.t
    dt = t[n+1] - t[n]
    u_new = u[n].copy()  # just need to allocate
    f_n = f(u[n], t[n])
    # March forward velocities
    if n == 0:
        # First step: use special formula for updating velocities
      for i in range(0, len(u[n]), 2):

E TypeError: object of type 'numpy.complex128' has no len()

odespy/solvers.py:1922: TypeError
---------------------------------------- Captured stdout call ----------------------------------------
Scalar ODE with complex value u' = 1./(t - 1 + 1j)
Testing AdamsBashMoulton2
...ok

Regards,
Prasanth

phn added 7 commits March 3, 2017 22:24
  made changes so that I can do "import odespy" at an IPython
  terminal without any errors.

  Changes made are in CHANGES_FOR_PY36.md.
Tests run, with a few failures. All related to the
StaggeredMidpoint solver. The same errors occur in py27. So not
specific to py36.
Runs with all deps in requirements.txt; and without any
deps (i.e., only Numpy, and scipy). In Py27, Py35 and Py36.
Using pip the setup doesn't compile fortran extensions. Either
pip -e (which runs python setup.py develop) or directly running
python setup.py install is required. To enable the former in
tox we need to use these two options.
In Py3 we can use func(*args, **kwargs), which is also valid
in Py2.
@Alienater
Copy link

how do I get your files to work with the latest jupyter notebook? I am unable to use python 2.7 for some reason

@phn
Copy link
Author

phn commented May 28, 2017

@Alienater

Sorry for the late reply. Can you be more specific about the errors you get? I am able to run tests in Python 2.7 and 3.6.

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

Successfully merging this pull request may close these issues.

2 participants