Ticket #3623 (new enhancement)

Opened 5 months ago

Last modified 4 hours ago

[with patch, needs review] Factory and pickling framework (part of coercion branch)

Reported by: robertwb Assigned to: robertwb
Priority: major Milestone: sage-3.2.2
Component: coercion Keywords:
Cc:

Description

Uniqueness of parents makes Sage operate much more smoothly. This leads to an enormous amount of nearly identical caching code scattered throughout the library. This factory handles all the caching for you, and also provides a good pickling mechanism.

Attachments

3623-factory-1.patch (6.8 kB) - added by robertwb on 09/23/2008 04:11:01 PM.
3623-factory-2.patch (29.5 kB) - added by robertwb on 09/23/2008 04:11:12 PM.
3623-factory-3.patch (13.4 kB) - added by robertwb on 09/23/2008 04:11:26 PM.
3623-factory-4.patch (13.5 kB) - added by robertwb on 09/23/2008 04:11:44 PM.
3623-factory-5.patch (0.7 kB) - added by robertwb on 09/23/2008 10:29:50 PM.
3623-all-3.2.1.patch (56.7 kB) - added by robertwb on 12/02/2008 04:37:34 AM.
patches 1-5 folded and rebased onto 3.2.1

Change History

07/09/2008 01:16:34 AM changed by robertwb

Code documented and works great/passes tests. Just need some doctests in factory.pyx (perhaps via a fake test class?)

07/30/2008 10:34:20 PM changed by robertwb

  • summary changed from Factory and pickling framework (part of coercion branch) to [with patch, needs review] Factory and pickling framework (part of coercion branch).

09/06/2008 08:54:02 AM changed by anakha

  • summary changed from [with patch, needs review] Factory and pickling framework (part of coercion branch) to [with patch, needs rebase] Factory and pickling framework (part of coercion branch).

Needs to be rebased against 3.1.2.alpha4:

sage: hg_sage.apply('http://trac.sagemath.org/sage_trac/attachment/ticket/3623/3623-factory-2.patch')
Attempting to load remote file: http://trac.sagemath.org/sage_trac/attachment/ticket/3623/3623-factory-2.patch?format=raw
Loading: [....]
cd "/Volumes/Place/anakha/sage-3.1.2.alpha4/devel/sage" && hg status
cd "/Volumes/Place/anakha/sage-3.1.2.alpha4/devel/sage" && hg status
cd "/Volumes/Place/anakha/sage-3.1.2.alpha4/devel/sage" && hg import   "/Users/anakha/.sage/temp/fullmetal.umn/58245/tmp_1.patch"
applying /Users/anakha/.sage/temp/fullmetal.umn/58245/tmp_1.patch
patching file sage/modules/free_module.py
Hunk #1 FAILED at 157
Hunk #2 FAILED at 261
2 out of 2 hunks FAILED -- saving rejects to file sage/modules/free_module.py.rej
abort: patch failed to apply

Otherwise, I like this very much after having gone through the pain of implementing a unique factory for a parent already, I would have wasted a week less if this had already been in sage.

09/08/2008 09:26:21 AM changed by robertwb

Thanks. I'll rebase this as soon as 3.1.2 comes out (as I doubt this ticket will make it into there).

09/23/2008 04:11:01 PM changed by robertwb

  • attachment 3623-factory-1.patch added.

09/23/2008 04:11:12 PM changed by robertwb

  • attachment 3623-factory-2.patch added.

09/23/2008 04:11:26 PM changed by robertwb

  • attachment 3623-factory-3.patch added.

09/23/2008 04:11:44 PM changed by robertwb

  • attachment 3623-factory-4.patch added.

09/23/2008 04:12:25 PM changed by robertwb

All four patches rebased.

09/23/2008 10:29:50 PM changed by robertwb

  • attachment 3623-factory-5.patch added.

09/23/2008 10:30:02 PM changed by robertwb

  • summary changed from [with patch, needs rebase] Factory and pickling framework (part of coercion branch) to [with patch, needs review] Factory and pickling framework (part of coercion branch).

11/28/2008 01:36:39 PM changed by was

  • summary changed from [with patch, needs review] Factory and pickling framework (part of coercion branch) to [with patch, needs work] Factory and pickling framework (part of coercion branch).

Hi Robert,

This bitrotted again. Sorry!

was@sage:~/build/sage-3.2.1.alpha1$ ./sage
----------------------------------------------------------------------
| Sage Version 3.2.1.alpha1, Release Date: 2008-11-26                |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: hg_sage.apply('http://trac.sagemath.org/sage_trac/attachment/ticket/3623/3623-factory-1.patch')
Attempting to load remote file: http://trac.sagemath.org/sage_trac/attachment/ticket/3623/3623-factory-1.patch?format=raw
Loading: [.]
cd "/home/was/build/sage-3.2.1.alpha1/devel/sage" && hg status
cd "/home/was/build/sage-3.2.1.alpha1/devel/sage" && hg status
cd "/home/was/build/sage-3.2.1.alpha1/devel/sage" && hg import   "/home/was/.sage/temp/sage/14985/tmp_0.patch"
applying /home/was/.sage/temp/sage/14985/tmp_0.patch
patching file setup.py
Hunk #1 FAILED at 533
1 out of 1 hunk FAILED -- saving rejects to file setup.py.rej
abort: patch failed to apply
sage: 

Can you rebase it an email me asap so this can get properly refereed and *not* bitrot again.

12/02/2008 04:37:34 AM changed by robertwb

  • attachment 3623-all-3.2.1.patch added.

patches 1-5 folded and rebased onto 3.2.1

12/02/2008 04:42:03 AM changed by robertwb

  • summary changed from [with patch, needs work] Factory and pickling framework (part of coercion branch) to [with patch, needs review] Factory and pickling framework (part of coercion branch).

OK, this is once again rebased.

12/02/2008 07:46:15 AM changed by mabshoff

The patch applies cleanly against 3.2.1 and together with #4276 I am seeing two doctest failures:

sage -t -long "devel/sage/sage/structure/coerce.pyx"        
**********************************************************************
File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/devel/sage/sage/structure/coerce.pyx", line 862:
    sage: V is W
Expected:
    False
Got:
    True
**********************************************************************
File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/devel/sage/sage/structure/coerce.pyx", line 865:
    sage: cm.coercion_maps(V, W)
Expected:
    (None,
     Call morphism:
      From: Vector space of dimension 3 over Rational Field
      To:   Vector space of dimension 3 over Rational Field)
Got:
    (None, None)
**********************************************************************
File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/devel/sage/sage/structure/coerce.pyx", line 870:
    sage: cm.coercion_maps(W, V)
Expected:
    (None,
     Call morphism:
      From: Vector space of dimension 3 over Rational Field
      To:   Vector space of dimension 3 over Rational Field)
Got:
    (None, Free module morphism defined by the matrix
    [1 0 0]
    [0 1 0]
    [0 0 1]
    Domain: Vector space of dimension 3 over Rational Field
    Codomain: Vector space of dimension 3 over Rational Field)
**********************************************************************
1 items had failures:
   3 of  21 in __main__.example_15
***Test Failed*** 3 failures.

I guess the first one is worrying while the rest is mostly a printing issue.

The other failure is:

sage -t -long "devel/sage/sage/schemes/elliptic_curves/ell_number_field.py"
**********************************************************************
File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/devel/sage/sage/schemes/elliptic_curves/ell_number_field.py", line 667:
    sage: [E.tamagawa_exponent(P) for P in K(11).support()]
Exception raised:
    Traceback (most recent call last):
      File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_20[7]>", line 1, in <module>
        [E.tamagawa_exponent(P) for P in K(Integer(11)).support()]###line 667:
    sage: [E.tamagawa_exponent(P) for P in K(11).support()]
      File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/local/lib/python2.5/site-packages/sage/schemes/elliptic_curves/ell_number_field.py", line 675, in tamagawa_exponent
        return self.local_data(P, proof).tamagawa_exponent()
      File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/local/lib/python2.5/site-packages/sage/schemes/elliptic_curves/ell_number_field.py", line 401, in local_data
        return self._get_local_data(P,proof)
      File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/local/lib/python2.5/site-packages/sage/schemes/elliptic_curves/ell_number_field.py", line 418, in _get_local_data
        self._local_data[P] = EllipticCurveLocalData(self, P, proof)
      File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/local/lib/python2.5/site-packages/sage/schemes/elliptic_curves/ell_local_data.py", line 140, in __init__
        self._Emin, ch, self._val_disc, self._fp, self._KS, self._cp, self._split = self._tate(proof)
      File "/scratch/mabshoff/release-cycle/sage-3.2.2.alpha0/local/lib/python2.5/site-packages/sage/schemes/elliptic_curves/ell_local_data.py", line 528, in _tate
        r = -pinv(12*c4) * (c6 + b2 * c4)
      File "element.pyx", line 1074, in sage.structure.element.RingElement.__mul__ (sage/structure/element.c:8580)
      File "coerce.pyx", line 697, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:5808)
    TypeError: unsupported operand parent(s) for '*': 'Maximal Order in Number Field in a with defining polynomial x^2 + 11' and 'Number Field in a with defining polynomial x^2 + 11'
**********************************************************************

Cheers,

Michael