-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
An alternative implementation of the Unique Representation design pattern #5120
Comments
comment:1
Duplicate of #5119 |
comment:2
Well, Nicolas closed #5119 as a dupe, so I am reopening this one since I assume one ticket ought to stay open :) Cheers, Michael |
This comment has been minimized.
This comment has been minimized.
comment:4
I'm sure there are good reasons why this is needed, but I think it would be helpful to potential reviewers of you could give a real-life example where this class will be used! |
comment:5
I.e., lots of weird corrupted characters.
|
This comment has been minimized.
This comment has been minimized.
comment:7
Uploaded an updated patch which fixes 1) and 2) Ok to abide to a rule, even in a corner case like this where the extra doc really does not add any strength to the test suite, while actually making the code less readable. But it's frustrating to get complained at about documentation for a patch which has a doc/code ratio of 15/1. Next time a please will work better than a gun.
|
comment:8
The patch doesn't apply cleanly to sage-3.4.1 since the hunk in |
comment:9
Replying to @dwbump:
Thanks for the notice. The patch on sage-combinat has been rebased. I'll try to upload it today, after folding in two |
comment:10
Replying to @nthiery:
I just updated the patch, rebased for 3.4.1, with description header, default implementation of copy/deepcopy, and pickling by reduce rather than getnewargs. This later change is debatable. For some reason the reduce way was preferable for some application to categories, but I badly enough did not take notes about why |
comment:11
Replying to @nthiery:
Ah, I know why: keyword arguments. See updated, 100% doctested and proofread patch. |
comment:12
Oops trivial update to apply cleanly on 3.4.1. Thanks Dan for the notice. Michael: could we change the milestone to 3.4.2? |
comment:13
Replying to @nthiery: I deleted the old patch.
The assignment of milestones is generally insignificant (an exception is like right now when 3.4.2.rc0 was the last merge release and we are in blocker fixes only mode), but as long as this ticket would have gotten a positive review it would have had a chance to go into 3.4.2 regardless which milestone it would have been assigned to. This patch is also a new design pattern which warrants to be mentioned on sage-devel. It seems to be very well documented and AFAIK it should be properly covered :) Cheers, Michael |
This comment has been minimized.
This comment has been minimized.
comment:15
Applies cleanly to sage-3.4.2.rc0 and passes all tests. |
comment:16
Note that #5879 exposes a problem with this patch. To quote Anne:
I will mark this "needs work" until this issue is resolved. Cheers, Michael |
Changed keywords from none to unique representation |
This comment has been minimized.
This comment has been minimized.
comment:18
I changed a bit the underlying implementation which fixes the code and should be more robust. |
comment:19
Updated patch includes ReST fixes suggested by David Roe, as well as an example on how to handle properly default arguments. |
Attachment: unique_representation-5120-submitted.patch.gz |
comment:21
I'd like to see some more thought go into what use cases are best served by UniqueRepresentation and what by UniqueFactory. But the code is well documented, does what it claims to do, and UniqueRepresentation is easier to use than UniqueFactory. So positive review. |
comment:22
Merged in Sage 4.0.rc0. Cheers, Michael |
Class deriving from sage.structure.UniqueRepresentation inherit a
unique representation behavior for their instances (and consistent
default implementations of equality testing, copying, pickling, ...).
See the documentation for a brief discussion of the relative merits of
UniqueRepresentation? and UniqueFactory?.
As a prerequisite, this patch implements sage.misc.ClasscallMetaclass,
a (trivial) metaclass for customizing class calls via a static method
of the class.
This class is used extensively in upcoming sage-combinat patches:
~500 lines of doctest for 15 lines of code
CC: @sagetrac-sage-combinat
Component: misc
Keywords: unique representation
Issue created by migration from https://trac.sagemath.org/ticket/5120
The text was updated successfully, but these errors were encountered: