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
Revision 1bceb8639f5a15c2e4f1f1c3602210aa5ed7d2e4 authored by Drew Johnson on 13 September 2017, 05:33:29 UTC, committed by Drew Johnson on 13 September 2017, 05:33:29 UTC
improved some docs, discoverd bug in top intersectsions
1 parent a6c0d3c
  • Files
  • Changes
    • 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
    • 1bceb8639f5a15c2e4f1f1c3602210aa5ed7d2e4
    No releases to show
  • 8900b14
  • /
  • 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.

  • revision
  • directory
  • content
  • snapshot
origin badgerevision badge
swh:1:rev:1bceb8639f5a15c2e4f1f1c3602210aa5ed7d2e4
origin badgedirectory badge Iframe embedding
swh:1:dir:9fce5015368efe8d632f2da9f56ca18adcadd775
origin badgecontent badge Iframe embedding
swh:1:cnt:2ae3c65557f6ea60ee7887b732221990148e8623
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.

  • revision
  • directory
  • content
  • 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: 1bceb8639f5a15c2e4f1f1c3602210aa5ed7d2e4 authored by Drew Johnson on 13 September 2017, 05:33:29 UTC
improved some docs, discoverd bug in top intersectsions
Tip revision: 1bceb86
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.
"""

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.
     -  ``namespace`` -- (optional) The namespace that you would like the variable names defined in.  If you are running this program as main (you started it from the command line or used sage's load or attach, then it will automatically insert the variables in the global namespace without you using this option.
     - ``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
    if namespace == None and __name__ == "__main__":
        namespace = globals()
    current_space = Mgn(g,n,globals())
    
    
    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 = raw_input("Overwrite existing file " + filename + " (y for yes)?  ")
        if confirm.lower() != "y":
            print "Save aborted."
            return
            
    import cPickle
    try:
        f = open(filename, "wb")
        try:
            cPickle.dump(master_table, f, protocol = 2)
        except Exception as ex:
            print ex
            return
        finally:
            f.close()            
    except IOError:
        print "Error opening file. Could not save." 
    else:
        print "Save suceeded."
    
    
        
def load_data(filename = default_file):
    global master_table
    import cPickle
    try:
        f = open(filename, "rb") 
        try:
            master_table.update(cPickle.load(f))
        except cPickle.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."
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

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