-
Notifications
You must be signed in to change notification settings - Fork 174
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
Copy #984
Conversation
FrozenObjects already have |
c37f092
to
6c96a6a
Compare
cdb2ee4
to
448eb56
Compare
I'm slightly surprised by the two failing test runs ... as the other test envs pass it is probably something going wrong with the warnings filtering? |
😠 The debug commit made the tests pass ... what the hell? |
I got a bit closer to the issue: |
4b7540b
to
6f45862
Compare
@tbekolay Is py.test running tests in parallel on Travis-CI? |
Yes, it runs with -n 2
|
Those changes look okay to me. |
Found a bug that won't let connections with slices be pickled. Given the following code:
I get the error:
|
I just looked over the code; it might work if you just remove the |
Yep, just removing the code solved the problem! Thanks Jan! |
nengo_gui is using it: nengo/nengo-gui#819 I suppose the options are:
The last option might lead to a lot of conditionals. So I would probably prefer option 1 or 2. The new interface is nice, but I'm fine with 1 if people think that the compatibility to older Nengo versions is important. |
I'd be in favour of partially reverting the changes, and making I could also go for option 2. The situation I worry about is someone upgrading Nengo, and not not realizing they also have to upgrade nengo_gui. How quickly does it fail? I don't think option 3 really needs that many conditionals. We should just be able to do EDIT: I should clarify, I think EDIT2: So I should also clarify, I am most in favour of just making |
It fails immediately by stopping you from running |
Yeah, it seems to be only that one place in the GUI. |
I made the necessary changes to allow copies of object views and added some tests for that. Still waiting on @tbekolay to give his ok to revert |
I added a commit to turn |
After a bit of head scratching, I decided the history of this branch is not too important and squashed this all into one commit with co-authors. I added a fixup (4790cbb) to change the properties that were returning iterators to instead return lists (or tuples where appropriate), which I think is the right call. I'll test this with the snippet in nengo/nengo-gui#819 to see if it works, but assuming it does, I'll merge this tomorrow morning (in case anyone wants to take a final look at this branch today). |
catcher.__enter__() | ||
warnings.simplefilter( | ||
'error', category=NotAddedToNetworkWarning) | ||
request.addfinalizer(lambda: catcher.__exit__(None, None, None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes all the with warns(NotAddedToNetworkWarning)
tests fail (since they error when the warning is raised). It seemed more complicated than it was worth to disable this check in the cases in which we wanted to check the warning. Any ideas on how to do it simply?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, this is a fixture not a test. Removing this LGTM.
LGTM. Excited to see this merged! |
This commit makes it possible to copy and pickle NengoObjects, and objects related to NengoObjects like Neuron and LearningRule. In order to make Neurons and LearningRules copyable, some changes were made to those classes: * When accessing special connection points like Ensemble.neurons or Connection.learning_rule we now recreate the corresponding object. Those objects are basically just indicators from or to where a connection is; they neither implement any behaviour on their own nor do they store a lot of data (except the back-reference to their parent). That resolves cyclic references (always good) and the performance and memory impact should be negligible. * The weak references in those classes are turned into strong references. Thanks to the broken reference cycle we don't have to worry about these being garbage collected anymore (and even with strong reference and a reference cycle they would be garbage collected sooner or later). The main benefit is that we don't have to manually handle those references when copying or pickling objects. * Methods for hashing and equality testing have been implemented on those classes to keep the builder working that uses them as keys in a dictionary. Unrelated to that, this seems to be the proper thing to do as two Neurons objects referring to the same ensemble should be treated as equal. None of these changes should affect user models. Some other miscellaneous cleanup is done in this commit as well, including removing some within function imports, and making some properties return lists instead of iterables. See the diff for more details. Co-authored by: Eric Hunsberger <erichuns@gmail.com> Co-authored by: Trevor Bekolay <tbekolay@gmail.com>
Addresses #977.
Nengo objects should be copyable and pickable now. There might be some weird effects for objects referencing other objects (e.g., connections). I might have to think about those and whether that works as expected (though, technically it works in some way).
Still todo: