Hi Minh,

On Sep 10, 12:12 pm, Minh Nguyen <nguyenmi...@gmail.com> wrote:
> Hi Simon,
>
> On Thu, Sep 10, 2009 at 8:52 PM, Simon King <simon.k...@nuigalway.ie> wrote:
>
> <SNIP>
>
> > If this is part of your problem then I can elaborate on how I clumsily
> > solved that problem.
>
> I would love to know about the steps you took to solve the problem you
> mentioned. I'm writing some documentation on how to do doctesting; see
> ticket #6908
>
> http://trac.sagemath.org/sage_trac/ticket/6908
>
> I would like to expand that documentation with further information from you.

The problem struck me when I tried to write spkg-check for our group
cohomology spkg.

Setting:
We have a Python package pGroupCohomology containing a cohomology ring
constructor class CohomologyRingFactory, an instance of that class,
and containing 5 Cython extension modules "cohomology", "resolution",
"cochain", "mtx", and "dickson". Of course, the modules contain
further classes with many methods, and also some functions.

Problem 1:
Although "from pGroupCohomology import mtx" works, one could not do
"sage -t /path/to/pGroupCohomology/mtx.pyx", for the reason mentioned
in my previous post (mtx depends on some c-library).

Solution 1:
Write a python script that recursively crawls through the package.
I.e.:
Start
 * TestList = []
 * ToBeTested = [pGroupCohomology]
Recursion
 * import the next item FOO from ToBeTested
 * append the doc string of FOO to TestList
 * By introspection, find modules, classes, class instances (if FOO is
a module), methods (if FOO is a class or an instance), and append them
to ToBeTested.

Eventually, one has a long TestList, comprising the individual doc
strings from everything in pGroupCohomology. I do it in such a way
that it can be reconstructed from which item it comes.

Then, for each item from TestList, create a temporary dummy.py file
that just contains this doc string. Test it using sage -t. If an error
occurs, one can even tell the user *where* (in what module/class/
method) it occurs. Also, it is easy to determine whether a doc test is
missing, and the spkg-check script would complain if there is a method
without a doc test. I accept if a class itself has no doc test, but
all methods of a class must have a doc test.


Problem 2a):
The modules in the package import further things from Sage or from
other modules. Hence, some doc test would be done twice, or classes
from Sage (not from our package) would be doc tested.

Solution 2a):
Determine whether the item is actually defined in the module under
consideration. If it isn't, then it would not be doc tested *in this
module*. Of course, it would be tested if later the item's home module
is studied.


Problem 2b):
The classes from the package inherit from Ring, RingElement etc. By
consequence, they inherit several methods. If they aren't overloaded
then bad things may happen: One would again do a doc test for things
that are not in the package ( = wast of time), or there would be a
NotImplementedError, or the not overloaded methods have no doc tests,
resulting in a complaint of spkg-check.

Solution 2b):
I actually don't remember how, but in some way it is possible to
determine whether a method is just inherited and should thus be
disregarded.


The resulting spkg-check is part of
http://sage.math.washington.edu/home/SimonKing/Cohomology/p_group_cohomology-1.1.spkg
Compare http://trac.sagemath.org/sage_trac/ticket/6750

Best regards,
Simon

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to