-
Notifications
You must be signed in to change notification settings - Fork 192
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
List
: register the class with the to_aiida_type
serializer
#5142
List
: register the class with the to_aiida_type
serializer
#5142
Conversation
Nice! Love the fact that you don't have to worry about passing in a Dict(dict={'a': 1}) == Dict(dict={'a': 1}) Now return |
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.
Yeh cheers, but just stick to the list addition for this PR
8354d3d
to
daecc11
Compare
Forgot about that long open discussion about node equality. Agree that I shouldn't change that here. Still I think that the |
I'm still in favour of actually making |
I would have to revise the discussion once again and make a summary of the pro's and con's. I am tempted to agree with you but I remember there being strong con's that I cannot remember right now.
Whether we change it or not, I think it would be good either way to come to a decision. So indeed good to try and make an executive summary and get a poll going with a final decision. |
Codecov Report
@@ Coverage Diff @@
## develop #5142 +/- ##
===========================================
+ Coverage 80.88% 80.90% +0.03%
===========================================
Files 536 536
Lines 37073 37076 +3
===========================================
+ Hits 29982 29993 +11
+ Misses 7091 7083 -8
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Alright, I'll try to go through the whole discussion again and write a summary by Wednesday. Then we can schedule a small meeting after the group meeting with everyone interested in discussing this (probably won't have enough time during the AiiDA meeting). |
Yeh I’m for whatever makes the user experience best, which is most likely comparing base types as there value. Just a pain, because there will probably be no way to deprecate in a nice way, and it will likely break someone’s code/plugin who has been relying on previous behaviour. I think perhaps a good way would be like sqlalchemy has done, you can add an environmental variable to turn on certain warnings. We could have this turn on a warning for any code that calls these |
(and this warning could be backported to v1) |
Would be good, if you manage in time, to send the summary by email, such that those who are interested can have a look before. It is not really possible to do this during the meeting. Not that we should have the discussion during the meeting, but it can be helpful for people to have the context beforehand. |
@chrisjsewell are there any objections left after I changed the @mbercx would also be good to make sure #4495 gets in soon, since we likely also want to add this in 2.0 now that we are on a campaign to make all base types equal. Did you want to do this yourself, or can I also go ahead and implement it? |
Will have a double check soon, bare with me, I’m just in the middle of Croatia waiting for a bus lol |
I think I should find time to do this on Friday, or next week at the latest. Note that we should probably first agree on what the equality comparison between base types should be though, because making |
@mbercx would addressing some of the feature requests really change the equality behavior? For example, adding the |
pinging @chrisjsewell |
yep will do after lunch |
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.
Errr, I still don't feel the equality change needs to be present in this PR 😬
But anyhow, it's very likely it will be changed again before v2 releases, so I'll leave it up to you 🤷
Well I guess it is not strictly necessary, but I don't think it hurts. And it allows the tests in the follow-up commit to use the same assert statement |
The `__eq__` method is overridden to not only let a `Dict` node compare true to itself, but also to the plain dictionary that represents its value. That is to say, the following: node = Dict(dict={'a': 1'}) assert node == node.value now passes the assert. This brings the behavior of `Dict` on par with all the other base types, `Bool`, `Float`, `Int`, `Str` and `Bool`.
This will allow users to pass a plain list as input for a port that accepts `List` nodes and specified the `to_aiida_type` dispatch as serializer. The value will be automatically converted to a `List` node. This brings the functionality for `List` on par with the other base type data node classes.
daecc11
to
2c8f7f3
Compare
Oh I see, in def __eq__(self, other):
if isinstance(other, BaseType):
return self.value == other.value
return self.value == other thats why This then raises the question, should |
The reason I added the Then on whether |
yeh |
Sorry, missed this reply! Will work on adding the |
Fixes #5141
This will allow users to pass a plain list as input for a port that
accepts
List
nodes and specified theto_aiida_type
dispatch asserializer. The value will be automatically converted to a
List
node.This brings the functionality for
List
on par with the other base typedata node classes.
To make the newly added test work, the
Dict
class needed a change to allow comparing to normal dictionaries. This is added in a separate commit.