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

https://github.com/uberparagon/mgn
22 June 2021, 16:13:34 UTC
  • Code
  • Branches (5)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/tags/1.1.2
    • refs/tags/v1.0.4
    • refs/tags/v1.0.5
    • refs/tags/v1.0.9
    No releases to show
  • 97085ea
  • /
  • topintersections
  • /
  • intersection_ui.py
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

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
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:4617eebdfaa536d847ace94707c6c33e45489645
origin badgedirectory badge Iframe embedding
swh:1:dir:370d394cc10295b17330f0bd86b2e47ea9df92ec
origin badgerevision badge
swh:1:rev:87eacb93177c9d41edb525bb71ae03ae45f18d14
origin badgesnapshot badge
swh:1:snp:6e9d4128140ea9fc091a9d1ff362de9d8be50de2
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
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 87eacb93177c9d41edb525bb71ae03ae45f18d14 authored by Drew Johnson on 20 March 2020, 16:48:33 UTC
added a ps and ps_ member to strataalgebra
Tip revision: 87eacb9
intersection_ui.py
"""
This file implements the user interface.  This is the file that should be loaded by the user.  It will import everything you need.
"""
from __future__ import absolute_import

#from six.moves.cPickle import dump, load, UnpicklingError
import pickle

try:
    from .intersection7 import *
    from .TautRing3 import Mgn
    from sage.all import *
except ImportError:
    pass


default_file = "mgn_top_intersect.dat"
import sys
#if len(sys.argv) >= 2 and sys.argv[1] == "-i":        #Print this message if you load from interactive sage.
if False: #don't print this message any more
    print("""***************************************************************************
Welcome to the intersection number computer for the moduli space of curves!

Written by Drew Johnson, based on Carel Faber's exposition and Maple code.
 
The main commands are "intnum" to compute the intersection number, and 
"space" to select the space.  Type help(intnum) or help(space) for more 
information.
 
Type save_data("filename") to save the results computed this session and 
load_data("filname") to retrieve previously saved data.  The default filename is 
"{0}" if not specified.

Ctrl-D to quit.
***************************************************************************""".format(default_file))

current_space = None
def space(g,n, namespace = None, print_classes = True):
    """
    INPUT:
     - ``g`` -- The genus.
     - ``n`` -- The number of marked points.
     - ``print_classes`` -- (optional, defaults to True) Set this to False if you don't want to see a list of the classes    
     
    This performs three functions:
        1.  It prints a list of classes and indexes for easy reference.
        2.  It sets the defaut space for ``intnum``.
        3.  It injects the variables names into your namespace so you can use them to make polynomials.
    
    It also returns a Moduli space object, if you want to capture it.
    """
    global current_space
    current_space = Mgn(g,n,True)
    
    
    if print_classes:
        current_space.rij()           
    #exprwdata.ExprWithData.reset()
    
    return current_space
    
def intnum(*args, **keywrds):
    r"""
    A convenience method for the user to access the intersection number code.  There are several accepted syntaxes.
    
    INPUT:
     - ``p`` -- a polynomial in variables that can be interpreted as classes on `\mathcal M_{g,n}`.  You can inject variables into the global namespace using the ``space(genus, n)`` function. (Use ``space(genus, n, globals())`` if you imported this module instead of loading it.)  The intersection will be computed on the space specified by the most recent ``space`` call.
    
    INPUT:
      - ``l`` -- a list of indexes into the classes on `\mathcal M_{g,n}`.  The intersection will be computed on the space specified by the most recent ``space`` call.
    
    INPUT:
     - ``genus``
     - ``n`` -- number of marked points
     - ``p`` -- a polynomial in variables that can be interpreted as classes on `\mathcal M_{g,n}`.  This method call will interpret the variables on the space you specify, NOT on the space specified by the most recent ``space`` call.  You may have to call ``space``, however, to ensure that the variables you want to use are defined.
     
    INPUT:
     - ``genus``
     - ``n`` -- number of marked points
     - ``l`` -- a list of indexes into the classes on `\mathcal M_{g,n}`.  These indexes are displayed for you when you use the ``space(genus, n)`` command, but it is not necessary to call ``space`` before using this syntax.    
    """
    global current_space
    M = keywrds.get("space")
    if M != None:
        if len(args) != 1:
            print("If you specify the space, you need only one argument!")
        if isinstance(args[0], list):
            p = prod((M[i] for i in args[0]))
        else:
            p = change_space(args[0], M)  
    
    elif len(args) == 1:    
        if isinstance(current_space, type(None)):
            print('Please specify the genus and number of marked points as the first arguments, or set the default space you wish to work over using the "space" function')
            return
        M = current_space
        if isinstance(args[0], list):
            p = prod((M[i] for i in args[0]))            
        else:
            p = args[0]
        
    elif len(args) == 3:
        M = Mgn(args[0], args[1])
        if isinstance(args[2], list):
            p = prod((M[i] for i in args[2]))
        else:
            p = change_space(args[2],M)
    else:
        print("Syntax incorrect, please see docstring (type ``help(intnum)``)")
        return
    
    if keywrds.get("confirm", True):
        print("Computing the intersection of {0} over {1}...".format(repr(p), repr(M)))
    try:
        return intersect([M],p, keywrds.get("check_degree", True))
    except BadDegreeException as excpt:
        print(excpt)
        
        
    
def change_space(p, space):
    result = 0
    for m, coeff in p.monomials():
        result += coeff * prod([cl.change_space(space)**expon for cl, expon in m.decompose_monomial()])
    return result



    

def save_data(filename = default_file, prompt = True):
    global master_table
    import os
    if prompt and os.path.exists(filename):
        confirm = input("Overwrite existing file " + filename + " (y for yes)?  ")
        if confirm.lower() != "y":
            print("Save aborted.")
            return

    with open(filename, "wb") as f:
        try:
            pickle.dump(master_table, f, protocol = 2)
        except Exception as ex:
            print(ex)
            return
    print("Save suceeded.")
    
    
        
def load_data(filename = default_file):
    global master_table
    try:
        f = open(filename, "rb") 
        try:
            master_table.update(pickle.load(f))
        except pickle.UnpicklingError:
            print("Problem loading data... perhaps the data is corrupted or not in the right format?")
            return
        finally:
            f.close()
    except IOError:
        print("Could not load file.  Does the file exist?")
    else:
        print("Data loaded.")

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

back to top