Repository navigation
308 remove name - #313
308 remove name#313
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-3.0 #313 +/- ##
================================================
+ Coverage 83.82% 94.11% +10.29%
================================================
Files 69 51 -18
Lines 5272 4127 -1145
================================================
- Hits 4419 3884 -535
+ Misses 853 243 -610
Flags with carried forward coverage won't be shown. Click here to find out more.
|
forwarding serialization inclusions
damskii9992
left a comment
There was a problem hiding this comment.
So many lines changed but not actually that much relevant. Just a lot of name being replaced with display_name. In principle we could also just not have the name or display_name in tests or tutorials, but I'm also okay with this replacement.
I AM confused about the arg_spec change though . . .
There was a problem hiding this comment.
Why is this removed and why was this ever moved to legacy?
A document explaining how serialization works for dependent parameters should still be good to keep somewhere . . .
Even IF it needs to get updated, now that the name attribute is gone.
There was a problem hiding this comment.
Also, it should probably be moved to the documentation :)
There was a problem hiding this comment.
We don't want stray MD files. I thought the docs already had this info but apparently they don't. Will udpate the content of /doc
| class_links = self.__interface_obj.create(model) | ||
| props = model._get_linkable_attributes() | ||
| props_names = [prop.name for prop in props] | ||
| props_names = [prop.display_name for prop in props] |
There was a problem hiding this comment.
This should probably be the unique_name rather than the display_name. Even though the display_name defaults to the unique_name if it hasn't been explicitly set.
There was a problem hiding this comment.
name_conversion keys are short calculator-side names like "scale".
The old name was such a non-unique label, and display_name is its replacement.
unique_name has to be unique across the whole program, so two models couldn't both have a "scale".
The real fix would be to match on the attribute's key in the model, but we're redoing the interface anyway.
There was a problem hiding this comment.
We should probably nix this class as well. It only existed to satisfy EasyCrystallography, which has since been deprecated.
There was a problem hiding this comment.
Sure. I'll make this a separate PR to not conflate this.
| self, | ||
| name: str, | ||
| value: Union[list, np.ndarray], | ||
| *, |
There was a problem hiding this comment.
Why the wildcard arg? We're not processing this, so having it just makes the API more confusing.
There was a problem hiding this comment.
* isn't a wildcard. It makes all the remaining arguments keyword-only. It's deliberate - with name gone, an old call like Parameter('a', 1.0) now properly fails instead of setting 'a' as the value.
There was a problem hiding this comment.
Ahh, my bad. I'm not a fan of it though. Forcing keyword-only arguments is annoyingly restrictive. And doing Parameter("a", 1.0) should fail anyways since we check the type of inputs and value cannot be a str.
There was a problem hiding this comment.
Hmm, I think I might be in favour of the forcing keyword only arguments anyways, but I would put it after unit, so that you can still create a Parameter or DescriptorNumber fast and easily as:
a = Parameter(2.0, 'cm')| sign = signature(self.__class__.__init__) | ||
| return { | ||
| param.name | ||
| for param in sign.parameters.values() | ||
| if param.kind in (param.POSITIONAL_OR_KEYWORD, param.KEYWORD_ONLY) | ||
| and param.name != 'self' | ||
| } |
There was a problem hiding this comment.
Why is this neccesary?
Is the regular arg_spec from the NewBase not good enough? Does it not get all the fields?
If so, we should fix it in NewBase . . . .
This is needed because NewBase._arg_spec -> ['value']
DescriptorBase._arg_spec -> ['callback','description','display_name','fixed','max','min',
'unique_name','unit','url','value','variance']Without the override, I guess placing it in |
Actually, we should just simply update the |
Hmmm I guess this is slightly better than the existing impl. Fixing the generic path and deleting the NewBase override is cleaner. |
Remove _REDIRECT; serializer relies on _arg_spec only
Refactoring of Descriptor and Parameter Naming
Refactored all usages of
nameto usedisplay_nameforParameterinstantiationUpdated code that accesses parameter/descriptor names to use
display_nameinstead ofnameModernization of Descriptor Class Constructors
DescriptorAnyTypeandDescriptorArrayto remove thenamepositional argument, making all arguments aftervaluekeyword-only.