-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fix Aggregator setter #216
Conversation
f9a5108
to
482f188
Compare
8644605
to
aedce9f
Compare
I refactored the transport functionality and now only the I also added tests for the aggregator, so once tests pass, I'd appreciate another thorough review. 🤓 |
aedce9f
to
7b70fc7
Compare
Usage in optimizationProblems works nicely. 👍 Setting slices of aggregators didn't work. It didn't raise an Error or Warning and also didn't change the values. I've extended the tests for that. If that is a use-case you don't see users using, feel free to remove the tests again. |
Damn, that's a tricky one, since we're always returning a new value that is being constructed by iterating over the internal instances. So there is no internal reference that points back to the underlying container elements. I'm honestly not completely sure how to handle this but I'll think a bit further about it. |
764464c
to
3c5ffc7
Compare
Puh, this was a "difficult birth". In the end I did decide to provide proxy objects to the aggregated parameters which now seems to work properly. I had to adapt one more test but I think it's fine now... |
self.aggregator = getattr(obj, 'aggregator', None) | ||
self.instance = getattr(obj, 'instance', None) | ||
|
||
def __array_function__(self, func, types, *args, **kwargs): |
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 one here caused a lot of trouble... 😅
3c5ffc7
to
cce4e92
Compare
Fixes #215
Added methods to indicate whether the internal data should be transposed (i.e., have shape
(n_containers, *parameter_shape))
. While this resolves the immediate issue, I had to overwrite the__set__
method of the Aggregator base class, which feels less than ideal. I'll revisit this implementation to explore alternative approaches, but it should work for now.Additionally, I noticed there are currently no tests for any aggregated parameters. This is unexpected, as I was fairly certain I had written some. Maybe they got lost somewhere...
ToDos:
SizedAggregator.__set__
Aggregator.__set__
SizedAggregator