# 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 ): 
1189  1189  and with values being lists or sets containing all mutation equivalent 
1190  1190  quivers as dig6 data. 
1191  1191  
 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  
1192  1196  EXAMPLES:: 
1193  1197  
1194  1198  sage: from sage.combinat.cluster_algebra_quiver.mutation_type import load_data 
1195  1199  sage: load_data(2) # random 
1196  1200  {('G', 2): [('AO', (((0, 1), (1, 3)),)), ('AO', (((0, 1), (3, 1)),))]} 
1197   
1198  1201  """ 
1199  1202  import os.path 
1200  1203  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 
1211  1218  
1212  1219  def _mutation_type_from_data( n, dig6, compute_if_necessary=True ): 
1213  1220  r""" 
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 
2059  2059  
2060  2060  def _save_data_dig6(n, types='ClassicalExceptional', verbose=False): 
2061  2061  """ 
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``. 
2063  2063  
2064  2064  TESTS:: 
2065  2065  
… 
… 
def _save_data_dig6(n, types='ClassicalE 
2101  2101  if types in possible_types[1:]: 
2102  2102  data.update(_construct_exceptional_mutation_classes(n)) 
2103  2103  
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) 
2109  2108  f = open(types_file,'w') 
2110  2109  cPickle.dump(data, f) 
2111  2110  f.close() 
… 
… 
def _save_data_dig6(n, types='ClassicalE 
2118  2117  def save_quiver_data(n, up_to=True, types='ClassicalExceptional', verbose=True): 
2119  2118  r""" 
2120  2119  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``. 
2122  2121  
2123  2122  This data will then be used to determine quiver mutation types. 
2124  2123  
… 
… 
def save_quiver_data(n, up_to=True, type 
2160  2159  
2161  2160  sage: save_quiver_data(2,up_to=False, verbose=False) 
2162  2161  """ 
 2162  from sage.combinat.cluster_algebra_quiver.mutation_type import load_data 
2163  2163  if up_to is True: 
2164  2164  ranks = range(1,n+1) 
2165  2165  elif up_to is False: 
2166  2166  ranks = [n] 
2167  2167  for i in ranks: 
2168  2168  _save_data_dig6(i,types=types,verbose=verbose) 
2169   
 2169  # we finally clear the load_data 
 2170  load_data.clear_cache() 
 2171  
2170  2172  def _bipartite_graph_to_digraph( g ): 
2171  2173  """ 
2172  2174  Returns a digraph obtained from a bipartite graph g by choosing one 