Ticket #13425: trac_13425-review_four-cs.patch

File trac_13425-review_four-cs.patch, 4.5 KB (added by stumpc5, 6 years ago)
  • sage/combinat/cluster_algebra_quiver/mutation_type.py

    # HG changeset patch
    # User Christian Stump <christian.stump at gmail.com>
    # Date 1364062528 -3600
    # Node ID c21b4398f55be652478897d112cff384df9f8766
    # Parent  b68cd454ab658d224913ce514b8b1081c46db331
    Trac 13425: Fixed requests in comment 23
    
    diff --git a/sage/combinat/cluster_algebra_quiver/mutation_type.py b/sage/combinat/cluster_algebra_quiver/mutation_type.py
    a b def load_data( n ): 
    11891189    and with values being lists or sets containing all mutation equivalent
    11901190    quivers as dig6 data.
    11911191
     1192    We check
     1193     - if the data is stored by the user, and if this is not the case
     1194     - if the data is stored by the optional package install
     1195
    11921196    EXAMPLES::
    11931197
    11941198        sage: from sage.combinat.cluster_algebra_quiver.mutation_type import load_data
    11951199        sage: load_data(2) # random
    11961200        {('G', 2): [('AO', (((0, 1), (1, -3)),)), ('AO', (((0, 1), (3, -1)),))]}
    1197 
    11981201    """
    11991202    import os.path
    12001203    import cPickle
    1201     from sage.misc.misc import SAGE_SHARE
    1202     types_path = os.path.join(SAGE_SHARE, 'cluster_algebra_quiver')
    1203     types_file = types_path+'/mutation_classes_%s.dig6'%n
    1204     if os.path.isfile(types_file):
    1205         f = open(types_file,'r')
    1206         data = cPickle.load(f)
    1207         f.close()
    1208         return data
    1209     else:
    1210         return {}
     1204    from sage.misc.misc import DOT_SAGE, SAGE_SHARE
     1205    relative_filename = 'cluster_algebra_quiver/mutation_classes_%s.dig6'%n
     1206    getfilename = lambda path: os.path.join(path,relative_filename)
     1207    # we check
     1208    # - if the data is stored by the user, and if this is not the case
     1209    # - if the data is stored by the optional package install
     1210    data_dict = dict()
     1211    for filename in [getfilename(DOT_SAGE),getfilename(SAGE_SHARE)]:
     1212        if os.path.isfile(filename):
     1213            f = open(filename,'r')
     1214            data_new = cPickle.load(f)
     1215            f.close()
     1216            data_dict.update(data_new)
     1217    return data_dict
    12111218
    12121219def _mutation_type_from_data( n, dig6, compute_if_necessary=True ):
    12131220    r"""
  • sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py

    diff --git a/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py b/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py
    a b def _construct_exceptional_mutation_clas 
    20592059
    20602060def _save_data_dig6(n, types='ClassicalExceptional', verbose=False):
    20612061    """
    2062     Saves all exceptional mutation classes as dig6 data into the file ``exc_classes_n.dig6`` in the folder ``SAGE_SHARE``.
     2062    Saves all exceptional mutation classes as dig6 data into the file ``exc_classes_n.dig6`` in the folder ``DOT_SAGE``.
    20632063
    20642064    TESTS::
    20652065
    def _save_data_dig6(n, types='ClassicalE 
    21012101    if types in possible_types[1:]:
    21022102        data.update(_construct_exceptional_mutation_classes(n))
    21032103
    2104     from sage.misc.misc import SAGE_SHARE
    2105     types_path = os.path.join(SAGE_SHARE, 'cluster_algebra_quiver')
    2106     types_file = types_path+'/mutation_classes_%s.dig6'%n
    2107     if not os.path.exists(types_path):
    2108         os.makedirs(types_path)
     2104    from sage.misc.misc import DOT_SAGE, sage_makedirs
     2105    types_path = os.path.join(DOT_SAGE, 'cluster_algebra_quiver')
     2106    types_file = os.path.join(types_path,'mutation_classes_%s.dig6'%n)
     2107    sage_makedirs(types_path)
    21092108    f = open(types_file,'w')
    21102109    cPickle.dump(data, f)
    21112110    f.close()
    def _save_data_dig6(n, types='ClassicalE 
    21182117def save_quiver_data(n, up_to=True, types='ClassicalExceptional', verbose=True):
    21192118    r"""
    21202119    Saves mutation classes of certain quivers of ranks up to and equal to ``n`` or equal to ``n``
    2121     to ``SAGE_SHARE/cluster_algebra_quiver/mutation_classes_n.dig6``.
     2120    to ``DOT_SAGE/cluster_algebra_quiver/mutation_classes_n.dig6``.
    21222121
    21232122    This data will then be used to determine quiver mutation types.
    21242123
    def save_quiver_data(n, up_to=True, type 
    21602159
    21612160        sage: save_quiver_data(2,up_to=False, verbose=False)
    21622161    """
     2162    from sage.combinat.cluster_algebra_quiver.mutation_type import load_data
    21632163    if up_to is True:
    21642164        ranks = range(1,n+1)
    21652165    elif up_to is False:
    21662166        ranks = [n]
    21672167    for i in ranks:
    21682168        _save_data_dig6(i,types=types,verbose=verbose)
    2169 
     2169    # we finally clear the load_data
     2170    load_data.clear_cache()
     2171       
    21702172def _bipartite_graph_to_digraph( g ):
    21712173    """
    21722174    Returns a digraph obtained from a bipartite graph g by choosing one