-
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
Connections can take points for functions #1010
Conversation
else: | ||
raise ValidationError("Invalid connection function type %r " | ||
"(must be callable or array-like)" | ||
% function.__class__.__name__, |
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.
If the function failed the above checks then it might not have a class name attribute.
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.
I was assuming that everything has a __class__
attribute, but I don't think that's quite true. Better to use type()
instead? There are probably other places we make this assumption, too (e.g. node outputs).
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.
I think there are only a couple rare cases in Python 2 where this attribute won't exist. I'm not really up to snuff on Python 3 so I'm afraid I don't know what the different cases are, or what the best suggestion would be. type
does sound more reliable, but again I don't know.
Edit: It may be that the only case in Python 2 is with old-style classes, and so this is fine in Python 3. I can't offer any sources to substantiate this unfortunately.
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.
Ok, well I fixed it everywhere anyway.
Okay, fixed this up. The first three commits are fixes to the code that help with the final commit, which actually allows function points to be passed to connections. The first three commits can be separated out and merged independently if there are questions about the fourth. I'd like to get them in ASAP, since the second one in particular touches large amounts of the codebase and is annoying to rebase. |
Function to compute across the connection. Note that ``pre`` must be | ||
an ensemble to apply a function across the connection. | ||
If an array is passed, the function is implicitly defined by the | ||
array points and the provided ``eval_points``. |
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.
Maybe say "the array points referenced" since you explicitly don't copy them?
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.
Also maybe mention that the array has to be 2D?
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 gives the required shape above. Does that make it clear that it's 2D?
If I read "array points referenced" I'm not sure I would think that means they're passed by reference, i.e. not copied. Also, I think the assumption is that anything passed as a parameter is not copied, so if you pass an array and then change a value it will change that in your model. Of course, when everything is built, we make copies as needed so that the built model would never be changed.
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 gives the required shape above. Does that make it clear that it's 2D?
Aw jeez, I totally missed that notation.
I think the assumption is that anything passed as a parameter is not copied
That's true. I forgot about that assumption when it comes to Python.
I did my best at reviewing. Other than some documentation nitpicks, it LGTM. |
Could this be looked at soon? It would be helpful for my tutorial. |
with nengo.Network() as model: | ||
# type errors |
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.
This comment is misleading. The next few lines are perfectly fine and don't produce type errors. (Took me a few moments to realize why there is no check for raised exceptions for this lines.)
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.
The last line of this section is a "type" error (i.e. the node output is not an acceptable type, not literally a TypeError, though). But you're right, this is mostly checking that the supported types work fine. Would you prefer no comment? Or a different comment?
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.
Maybe move the comment down to where actually a type error occurs and change this line to something like # valid values
?
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.
Yeah, okay.
Comments aside LGTM 🍰 |
This looks good to me too! The speed concern I think outweighs the concern of making the I made two small fixup commits to reword some strings and add a deprecation warning to This also needs a changelog entry. If my changes look good to @hunse I'll merge when a changelog entry is pushed! |
Oh also, this is a relatively big API change and we've already done several minor bugfixes; once this is merged, should we cut a 2.1.1 release? My thinking is yes to start getting in the habit of more frequent, smaller releases. |
+1 for more releases (especially timely bugfix releases) |
I wouldn't be too strict about that. Especially if we want to do more releases (which I agree with), if we do minor increments for stuff like this we'll be at 2.100.0 before we know it, and that just looks ridiculous. Do we want to do that mini-sprint we were talking about before the release, @tbekolay? I'd be fine releasing after this, but I think there are also a number of things waiting that we might as well get merged and released. |
Right you are! And actually, the switch in the LIF model is also probably 2.2 worthy. Any objections to that? |
If we're going to go to 2.2, I'd try to get a few more of the waiting PRs in. |
Yes, but at the moment it looks pretty random to me which makes the versioning scheme somewhat useless. We could also do a 2.1.1 bugfix release with what's been merged (and maybe a few other small bugfix PRs) and then do this and more in a 2.2 release. |
Indeed, Linux switched arbitrarily from 2.6.39 to 3.0 because the .39 was just too much. I think we will eventually want to do API-breaking changes, so we shouldn't be that opposed to bumping up to 3 sometime.
This crossed my mind also. My thoughts for other small bugfix PRs to merge for 2.1.1 (in no particular order): #1074, #1027, #1005 (if that's still valid) |
Replied in #1005 regarding validity. |
The message used to use `node.output`, which at that point was still unset. Now uses `output`.
Rather than using `<obj>.__class__`, we now use `type(<obj>)`, since this is safer for some old types of objects.
``size_in``, ``size_mid``, and ``size_out`` are now well defined, and used properly when identifying function and transform sizes.
db8788f
to
3f00c04
Compare
I rebased this and fixed up the fixups. It's been reviewed already, but I'm going to give people the weekend to give this a look-over as it's a relatively big change; I'll merge Monday morning if no issues come up. |
Pushed a fixup to change a |
8522f9b
to
58d65f3
Compare
When specifying a Connection function, points can now be passed to implicitly define the function along with the eval points. This addresses #323.
58d65f3
to
5be289d
Compare
When specifying a Connection function, points can now be passed to
implicitly define the function along with the eval points. This
addresses #323.