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

Allow SPA style connection to BG utility input. #194

Merged
merged 6 commits into from
Jul 10, 2018
Merged

Allow SPA style connection to BG utility input. #194

merged 6 commits into from
Jul 10, 2018

Conversation

jgosmann
Copy link
Collaborator

@jgosmann jgosmann commented Jul 5, 2018

Motivation and context:
Closes #190. This is similar to allowing scalar inputs to appropriate network inputs. This does not make the second example in the issue

ens >> asel.bg.input[0]

possible. That would require to handle the slicing on SPA inputs which we currently don't do and I'm not convinced that it would be worthwhile to do so.

Interactions with other PRs:
none

How has this been tested?
added a test

How long should this take to review?

  • Lengthy (more than 150 lines changed or changes are complicated)

Where should a reviewer start?
Follow the commits. This PR moves some things around to prevent cyclic dependencies.

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.
  • I have run the test suite locally and all tests passed.

@jgosmann jgosmann added this to the 0.6 milestone Jul 5, 2018
return as_ast_node(self).translate(vocab, populate, keys, solver)


class ConnectorRegistry(object):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand most of this PR, except for this one class which is confusing me. This class associates a connection to a vocabulary? So it's basically a dictionary, but how it adds items is verified such that... This is where I'm lost. What exactly is happening with the types? Would it be helpful to add a comment?

Copy link
Collaborator Author

@jgosmann jgosmann Jul 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is pretty much copied from the spa.Network.declare_input and spa.Network.declare_output functions and put into a class to have the code only once (instead of duplicated in both methods). It associates a Nengo object with a vocabulary and allows it to be used in the SPA syntax by dynamically changing the class of the Nengo object instance. The new class is also dynamically generated as a class deriving from the original class of the Nengo object and SpaOperatorMixin. Because there is only a limited number of Nengo objects, I don't want to create a new type/class each time and cache them. Furthermore, this ensures that everything with the same type has an identical class.

This is definitely a bit of Python black magic ... so maybe I should add a comment, but not sure yet how to make it concise and helpful.

  • Writing this I noticed that the _type_cache should actually be a class variable.

@jgosmann jgosmann assigned jgosmann and unassigned jgosmann Jul 6, 2018
@jgosmann
Copy link
Collaborator Author

jgosmann commented Jul 6, 2018

Remaining TODOs should have been addressed in the new commits.

@jgosmann
Copy link
Collaborator Author

jgosmann commented Jul 6, 2018

One more commit because test coverage declined.

@Seanny123
Copy link
Collaborator

Still good.

jgosmann added 6 commits July 10, 2018 15:26
This reduces the amount of duplicated code and provides an interface
that is more easily useable outside of a network.
To make connectors independent of the actions module.
Closes #190.

This does not allow connections to the basal ganglia input node in this
style because this would require to allow SPA style connections to sliced
inputs which is currently not implemented.
@jgosmann jgosmann merged commit 9aa275e into master Jul 10, 2018
@jgosmann jgosmann deleted the bg-inputs branch July 10, 2018 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants