sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.22k stars 424 forks source link

Add doctests to toy_buchberger to get it to 100% #6504

Closed 5d2aaf09-c963-473a-bf79-1f742a72700f closed 15 years ago

5d2aaf09-c963-473a-bf79-1f742a72700f commented 15 years ago

Some functions were missing doctests, I think I have corrected that.

Component: algebra

Keywords: groebner basis, buchberger

Author: Marshall Hampton

Reviewer: Martin Albrecht, Minh Van Nguyen

Merged: Sage 4.1.1.alpha1

Issue created by migration from https://trac.sagemath.org/ticket/6504

5d2aaf09-c963-473a-bf79-1f742a72700f commented 15 years ago
comment:1

Attachment: trac_6504_toy_buch.patch.gz

Patches are the same, I just forgot to put the ticket number on the first one.

malb commented 15 years ago

fixes a few whitespace issues in the original patch

malb commented 15 years ago
comment:2

Attachment: trac_6504_toy_buch.2.patch.gz

I read the patch and it looks fine, it applies cleanly and passes doctest. There were a few whitespace issues w.r.t. the reference manual, which are fixed in the attached patch (only apply this one). The update needs signing off by mhampton.

5d2aaf09-c963-473a-bf79-1f742a72700f commented 15 years ago

Attachment: trac_6504_toy_buch.3.patch.gz

supersedes previous versions; better ref manual formatting

5d2aaf09-c963-473a-bf79-1f742a72700f commented 15 years ago
comment:3

I switched spol from a lambda definition to a documented function, since it seems important enough in this module. I also cleaned up a few things for the reference manual formatting (OUTPUT sections were in bold, for example, unintentionally).

Martin Albrect (malb) should get both contributor and reviewer credit for this, I think. But now that I have made a new version, I think it is appropriate that he reviews again (hopefully for a final time).

malb commented 15 years ago
comment:4

Apply only trac_6504_toy_buch.3.patch.

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago
comment:5

With the patch trac_6504_toy_buch.3.patch, I'm seeing some doctest failures:

sage -t -long devel/sage-exp/sage/rings/polynomial/multi_polynomial_ideal.py
**********************************************************************
File "/scratch/mvngu/release/sage-4.1.1.alpha0/devel/sage-exp/sage/rings/polynomial/multi_polynomial_ideal.py", line 944:
    sage: I.dimension()
Exception raised:
    Traceback (most recent call last):
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_19[9]>", line 1, in <module>
        I.dimension()###line 944:
    sage: I.dimension()
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/lib/python/site-packages/sage/rings/polynomial/multi_polynomial_ideal.py", line 402, in __call__
        return self.f(self._instance, *args, **kwds)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/lib/python/site-packages/sage/rings/polynomial/multi_polynomial_ideal.py", line 978, in dimension
        gb = toy_buchberger.buchberger_improved(self)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/lib/python/site-packages/sage/rings/polynomial/toy_buchberger.py", line 279, in buchberger_improved
        h = spol(g1,g2).reduce(G)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/lib/python/site-packages/sage/rings/polynomial/toy_buchberger.py", line 175, in spol
        return p(fg_lcm/LT(f)*f - fg_lcm/LT(g)*g)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/lib/python/site-packages/sage/rings/polynomial/multi_polynomial_ring.py", line 422, in __call__
        raise TypeError, "unable to coerce since the denominator is not 1"
    TypeError: unable to coerce since the denominator is not 1
**********************************************************************
File "/scratch/mvngu/release/sage-4.1.1.alpha0/devel/sage-exp/sage/rings/polynomial/multi_polynomial_ideal.py", line 948:
    sage: I.dimension()
Exception raised:
    Traceback (most recent call last):
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_19[11]>", line 1, in <module>
        I.dimension()###line 948:
    sage: I.dimension()
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/lib/python/site-packages/sage/rings/polynomial/multi_polynomial_ideal.py", line 402, in __call__
        return self.f(self._instance, *args, **kwds)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/lib/python/site-packages/sage/rings/polynomial/multi_polynomial_ideal.py", line 978, in dimension
        gb = toy_buchberger.buchberger_improved(self)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/lib/python/site-packages/sage/rings/polynomial/toy_buchberger.py", line 279, in buchberger_improved
        h = spol(g1,g2).reduce(G)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/lib/python/site-packages/sage/rings/polynomial/toy_buchberger.py", line 175, in spol
        return p(fg_lcm/LT(f)*f - fg_lcm/LT(g)*g)
      File "/scratch/mvngu/release/sage-4.1.1.alpha0/local/lib/python/site-packages/sage/rings/polynomial/multi_polynomial_ring.py", line 422, in __call__
        raise TypeError, "unable to coerce since the denominator is not 1"
    TypeError: unable to coerce since the denominator is not 1
**********************************************************************
1 items had failures:
   2 of  15 in __main__.example_19
***Test Failed*** 2 failures.
For whitespace errors, see the file /scratch/mvngu/release/sage-4.1.1.alpha0/tmp/.doctest_multi_polynomial_ideal.py
     [13.4 s]
5d2aaf09-c963-473a-bf79-1f742a72700f commented 15 years ago

Fixed an issue with spol function

5d2aaf09-c963-473a-bf79-1f742a72700f commented 15 years ago
comment:6

Attachment: trac_6504_toy_buch.4.patch.gz

OK, I fixed the spol function so that multi_polynomial_ideal.py passes tests as well. I had thought what I had done was equivalent but I guess not over finite fields - actually I wonder if this is a failure in coercion but that's beyond the scope of this ticket.

5d2aaf09-c963-473a-bf79-1f742a72700f commented 15 years ago
comment:7

New patch is cumulative, its the only one that needs to be applied.

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago

Merged: Sage 4.1.1.alpha1

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago

Changed reviewer from malb to Martin Albrecht, Minh Van Nguyen

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 15 years ago

Author: Marshall Hampton