Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 447cb52
  • /
  • tests.py
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:865759239481d80ed96403842b7590312d6c2fcf
directory badge Iframe embedding
swh:1:dir:447cb5239fa3e8ccd77272cf3169cfc484a7f2c9
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
tests.py
"""
The ``tests`` module tests the implementation of the product and the FZ relations by comparing them to the ``topintersections`` code.

You can change which pairs you want to check by modifying the ``g_n_pairs_to_check variable`` in the source code ``tests.py``.

::

    sage: import strataalgebra.tests as tests
    sage: tests.run() # long time

"""

from sage.all import QQ, floor, WeightedIntegerVectors, subsets
#from sage.all import *
from strataalgebra import StrataAlgebra

from topintersections import intnum

g_n_pairs_to_check = [
(2,0),
(1,1),
(1,2),
(1,3),
(2,1),
(2,2)
]

def get_all_combis(g,n):
    dim = 3*g-3 + n
    reducible_boundaries = 0
    marks = range(1,n+1)
    if n != 0:
        first_mark_list = [marks.pop()]            
        for g1 in range(0, g + 1):
            for p in subsets(marks):
                r_marks = set(first_mark_list + p)
                if 3*g1 - 3 + len(r_marks) + 1 >= 0 and 3*(g-g1) - 3 + n - len(r_marks) + 1 >= 0:
                    reducible_boundaries+=1  
    
    else: #self.n == 0
        for g1 in range(1, floor(g/2.0)+1):
            reducible_boundaries+=1

    #print "computed red bound"
    indexes = range(1,n+dim+1) + range(n+dim+g+1, n+dim+g+reducible_boundaries + 2)
    codims = [1]*n + range(1,dim+1) + [1]*(reducible_boundaries +1)
    
    for w in WeightedIntegerVectors(dim,codims):
        combi = []
        #print w
        for index, wi in zip(indexes,w):
            combi += [index]*wi
        yield combi

def run():
    """
    run doc
    :return:
    """
    ok = 0
    bad = 0
    for g,n in g_n_pairs_to_check:
        print "Beginning to check g = {0}, n = {1}...".format(g,n)
        s = StrataAlgebra(QQ,g,tuple(range(1,n+1)),False)
        for c in get_all_combis(g,n):
            print c,
            v1 = intnum(g,n,c, confirm = False)
            v2 = s.MgnLb_int(c)
            if v1==v2:
                print " ok."
                ok+=1
            else:
                print
                print " FAILED!"
                bad+=1
                #print c
                print v1, "vs", v2

    print "{0} tests performed, {1} successful, {2} failed".format(ok+bad,ok,bad)
            
class doctestclass(object):
    """
    here is the doc
    """
    pass

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API