Ticket #10460 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Pickling of Functors

Reported by: SimonKing Owned by: nthiery
Priority: major Milestone: sage-4.7
Component: categories Keywords: pickling, functors
Cc: Work issues:
Report Upstream: N/A Reviewers: Martin Raum
Authors: Simon King Merged in: sage-4.7.alpha2
Dependencies: Stopgaps:

Description

We used to have:

sage: F = QQ['t'].construction()[0]
sage: G = loads(dumps(F))
sage: G == F
True
sage: G.domain() == F.domain()
False
sage: G.codomain() is None
True

In other words, the cdef'd attributes of the construction functor are lost.

I created a generic pickling method for functors, so that it works a lot better:

sage: F = QQ['t'].construction()[0]
sage: G = loads(dumps(F))
sage: G == F
True
sage: G.domain() == F.domain()
True
sage: G.codomain() is None
False

The patch contains two tests, showing that the problem is solved.

Attachments

10460_pickling_functors.patch Download (2.3 KB) - added by SimonKing 2 years ago.
Pickling of functors. Independent of #8800
trac-10460-pickling_functors-review.patch Download (2.4 KB) - added by mraum 2 years ago.
Replacement for original patch.

Change History

comment:1 Changed 2 years ago by SimonKing

  • Status changed from new to needs_review

To the patchbot / release manager:

Depends on #8800

So, in fact, it also depends on #8807 and #10318.

Up to now, I only tested sage/categories/functor.pyx and sage/categories/pushout.py. However, since they use functors intensely, I am already marking the ticket as "needs review".

comment:2 Changed 2 years ago by SimonKing

Since the patchbot complained, I updated the patch. It should cleanly apply to sage-4.6.2.alpha0.

It turns out that the patch does in fact not depend on #8800. It only depends on #8807 and #10318, which are already merged. So, no dependency.

comment:3 Changed 2 years ago by SimonKing

I don't know why the patchbot complains. The patch applies cleanly to a fresh sage-4.6.2.alpha4.

Changed 2 years ago by SimonKing

Pickling of functors. Independent of #8800

comment:4 Changed 2 years ago by SimonKing

Since the patchbot did not try to apply the patch again and since the patch cleanly applies to sage-4.6.1.alpha4, I now try to trigger another attempt of the patchbot by posting a new copy of the patch.

And, by the way, this rather simple patch still needs review...

comment:5 follow-up: ↓ 6 Changed 2 years ago by mraum

  • Status changed from needs_review to positive_review
  • Reviewers set to Martin Raum
  • Milestone changed from sage-4.7 to sage-4.6.2

I only corrected tiny typos in the documentation, and I altered one doctest to better reflect the change that you introduced.

Changed 2 years ago by mraum

Replacement for original patch.

comment:6 in reply to: ↑ 5 Changed 2 years ago by SimonKing

Replying to mraum:

I only corrected tiny typos in the documentation, and I altered one doctest to better reflect the change that you introduced.

Thank you, Martin!

For the record, the patchbot and the release manager:

Apply trac-10460-pickling_functors-review.patch

comment:7 Changed 2 years ago by mvngu

  • Milestone changed from sage-4.6.2 to sage-4.7

comment:8 Changed 2 years ago by jdemeyer

  • Status changed from positive_review to closed
  • Resolution set to fixed
  • Merged in set to sage-4.7.alpha2
Note: See TracTickets for help on using tickets.