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

Try to get Nengo working with PyPy #1166

Closed
wants to merge 1 commit into from
Closed

Try to get Nengo working with PyPy #1166

wants to merge 1 commit into from

Conversation

jgosmann
Copy link
Collaborator

@jgosmann jgosmann commented Sep 7, 2016

Motivation and context:
These are just explaratory changes to see if we can get Nengo working with PyPy. So far I commented out all setflags calls which are not supported by PyPy's NumPy, but are only used to prevent writing of things that should be readonly. So commenting this out should not be a problem, though for a production version we might find a better solution.

With these changes I'm hitting this NotImplementedError:

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    with nengo.Simulator(model) as sim:
  File "/home/jgosmann/Documents/projects/nengo/nengo/simulator.py", line 132, in __init__
    self.model.build(network)
  File "/home/jgosmann/Documents/projects/nengo/nengo/builder/builder.py", line 119, in build
    return Builder.build(self, obj, *args, **kwargs)
  File "/home/jgosmann/Documents/projects/nengo/nengo/builder/builder.py", line 211, in build
    return cls.builders[obj_cls](model, obj, *args, **kwargs)
  File "/home/jgosmann/Documents/projects/nengo/nengo/builder/network.py", line 91, in build_network
    model.build(conn)
  File "/home/jgosmann/Documents/projects/nengo/nengo/builder/builder.py", line 119, in build
    return Builder.build(self, obj, *args, **kwargs)
  File "/home/jgosmann/Documents/projects/nengo/nengo/builder/builder.py", line 211, in build
    return cls.builders[obj_cls](model, obj, *args, **kwargs)
  File "/home/jgosmann/Documents/projects/nengo/nengo/builder/connection.py", line 273, in build_connection
    signal = model.build(conn.synapse, signal)
  File "/home/jgosmann/Documents/projects/nengo/nengo/builder/builder.py", line 119, in build
    return Builder.build(self, obj, *args, **kwargs)
  File "/home/jgosmann/Documents/projects/nengo/nengo/builder/builder.py", line 211, in build
    return cls.builders[obj_cls](model, obj, *args, **kwargs)
  File "/home/jgosmann/Documents/projects/nengo/nengo/builder/processes.py", line 149, in build_synapse
    synapse, sig_in, sig_out, model.time, mode='update'))
  File "/home/jgosmann/Documents/projects/nengo/nengo/builder/builder.py", line 107, in add_op
    op.make_step(signals, self.dt, np.random)
  File "/home/jgosmann/Documents/projects/nengo/nengo/builder/processes.py", line 80, in make_step
    step_f = self.process.make_step(shape_in, shape_out, dt, rng)
  File "/home/jgosmann/Documents/projects/nengo/nengo/synapses.py", line 361, in make_step
    shape_in, shape_out, dt, rng, y0=y0, dtype=dtype, **kwargs)
  File "/home/jgosmann/Documents/projects/nengo/nengo/synapses.py", line 219, in make_step
    num, den, _ = cont2discrete((num, den), dt, method=method)
  File "/home/jgosmann/Documents/projects/nengo/nengo/utils/filter_design.py", line 451, in cont2discrete
    return ss2tf(sysd[0], sysd[1], sysd[2], sysd[3]) + (dt,)
  File "/home/jgosmann/Documents/projects/nengo/nengo/utils/filter_design.py", line 326, in ss2tf
    den = poly(A)
  File "/home/jgosmann/.virtualenvs/pypy/site-packages/numpy/lib/polynomial.py", line 143, in poly
    mode='full')
  File "/home/jgosmann/.virtualenvs/pypy/site-packages/numpy/core/numeric.py", line 1005, in convolve
    return multiarray.correlate(a, v[::-1], mode)
  File "/home/jgosmann/.virtualenvs/pypy/site-packages/numpy/core/multiarray.py", line 83, in tmp
    raise NotImplementedError("%s not implemented yet" % func)
NotImplementedError: correlate not implemented yet

I'm not familiar enough with the filtering code to figure out how it could be implemented without using that missing function. So if no one else takes a stab at it, we probably have to wait until the PyPy people implement it.

How has this been tested?
To test this, I used PyEnv to install PyPy. These are the steps:

  1. pyenv install pypy-5.4.0
  2. mkvirtualenv -p pypy pypy
  3. workon pypy
  4. git clone https://bitbucket.org/pypy/numpy.git
  5. cd numpy; pypy setup.py install
  6. Go to nengo directory and pypy setup.py develop

Then I ran this script:

import nengo


with nengo.Network() as model:
    a = nengo.Ensemble(10, 1)
    b = nengo.Ensemble(10, 1)
    nengo.Connection(a, b)

with nengo.Simulator(model) as sim:
    sim.run(1.)

How long should this take to review?

Not ready for review.

Where should a reviewer start?

Types of changes:

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have read the CONTRIBUTING.rst document.
  • I have updated the documentation accordingly.
  • I have included a changelog entry.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Still to do:

@jgosmann
Copy link
Collaborator Author

@jgosmann jgosmann commented Oct 6, 2017

PyPy v5.9 was just released and claims to support NumPy. Maybe it's time to give this another shot.

@jgosmann
Copy link
Collaborator Author

@jgosmann jgosmann commented Nov 7, 2018

@drasmuss I don't think I'll invest time into this in the foreseeable future.

@drasmuss
Copy link
Member

@drasmuss drasmuss commented Nov 7, 2018

Sounds good. I'll close it for now, but anyone interested in working on this feel free to re-open.

@drasmuss drasmuss closed this Nov 7, 2018
@tbekolay tbekolay deleted the pypy branch Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants