passagemath-graphs 10.6.1rc1__cp310-cp310-musllinux_1_2_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. passagemath_graphs-10.6.1rc1.dist-info/METADATA +292 -0
  2. passagemath_graphs-10.6.1rc1.dist-info/RECORD +260 -0
  3. passagemath_graphs-10.6.1rc1.dist-info/WHEEL +5 -0
  4. passagemath_graphs-10.6.1rc1.dist-info/top_level.txt +2 -0
  5. passagemath_graphs.libs/libgcc_s-69c45f16.so.1 +0 -0
  6. passagemath_graphs.libs/libgmp-8e78bd9b.so.10.5.0 +0 -0
  7. passagemath_graphs.libs/libstdc++-1f1a71be.so.6.0.33 +0 -0
  8. sage/all__sagemath_graphs.py +39 -0
  9. sage/combinat/abstract_tree.py +2723 -0
  10. sage/combinat/all__sagemath_graphs.py +34 -0
  11. sage/combinat/binary_tree.py +5306 -0
  12. sage/combinat/cluster_algebra_quiver/all.py +22 -0
  13. sage/combinat/cluster_algebra_quiver/cluster_seed.py +5208 -0
  14. sage/combinat/cluster_algebra_quiver/interact.py +124 -0
  15. sage/combinat/cluster_algebra_quiver/mutation_class.py +625 -0
  16. sage/combinat/cluster_algebra_quiver/mutation_type.py +1555 -0
  17. sage/combinat/cluster_algebra_quiver/quiver.py +2290 -0
  18. sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py +2468 -0
  19. sage/combinat/designs/MOLS_handbook_data.py +570 -0
  20. sage/combinat/designs/all.py +58 -0
  21. sage/combinat/designs/bibd.py +1655 -0
  22. sage/combinat/designs/block_design.py +1071 -0
  23. sage/combinat/designs/covering_array.py +269 -0
  24. sage/combinat/designs/covering_design.py +530 -0
  25. sage/combinat/designs/database.py +5615 -0
  26. sage/combinat/designs/design_catalog.py +122 -0
  27. sage/combinat/designs/designs_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
  28. sage/combinat/designs/designs_pyx.pxd +21 -0
  29. sage/combinat/designs/designs_pyx.pyx +993 -0
  30. sage/combinat/designs/difference_family.py +3951 -0
  31. sage/combinat/designs/difference_matrices.py +279 -0
  32. sage/combinat/designs/evenly_distributed_sets.cpython-310-aarch64-linux-gnu.so +0 -0
  33. sage/combinat/designs/evenly_distributed_sets.pyx +661 -0
  34. sage/combinat/designs/ext_rep.py +1064 -0
  35. sage/combinat/designs/gen_quadrangles_with_spread.cpython-310-aarch64-linux-gnu.so +0 -0
  36. sage/combinat/designs/gen_quadrangles_with_spread.pyx +339 -0
  37. sage/combinat/designs/group_divisible_designs.py +361 -0
  38. sage/combinat/designs/incidence_structures.py +2357 -0
  39. sage/combinat/designs/latin_squares.py +581 -0
  40. sage/combinat/designs/orthogonal_arrays.py +2244 -0
  41. sage/combinat/designs/orthogonal_arrays_build_recursive.py +1780 -0
  42. sage/combinat/designs/orthogonal_arrays_find_recursive.cpython-310-aarch64-linux-gnu.so +0 -0
  43. sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +967 -0
  44. sage/combinat/designs/resolvable_bibd.py +815 -0
  45. sage/combinat/designs/steiner_quadruple_systems.py +1306 -0
  46. sage/combinat/designs/subhypergraph_search.cpython-310-aarch64-linux-gnu.so +0 -0
  47. sage/combinat/designs/subhypergraph_search.pyx +530 -0
  48. sage/combinat/designs/twographs.py +306 -0
  49. sage/combinat/finite_state_machine.py +14874 -0
  50. sage/combinat/finite_state_machine_generators.py +2006 -0
  51. sage/combinat/graph_path.py +448 -0
  52. sage/combinat/interval_posets.py +3908 -0
  53. sage/combinat/nu_tamari_lattice.py +269 -0
  54. sage/combinat/ordered_tree.py +1446 -0
  55. sage/combinat/posets/all.py +46 -0
  56. sage/combinat/posets/bubble_shuffle.py +247 -0
  57. sage/combinat/posets/cartesian_product.py +493 -0
  58. sage/combinat/posets/d_complete.py +182 -0
  59. sage/combinat/posets/elements.py +273 -0
  60. sage/combinat/posets/forest.py +30 -0
  61. sage/combinat/posets/hasse_cython.cpython-310-aarch64-linux-gnu.so +0 -0
  62. sage/combinat/posets/hasse_cython.pyx +174 -0
  63. sage/combinat/posets/hasse_diagram.py +3672 -0
  64. sage/combinat/posets/hochschild_lattice.py +158 -0
  65. sage/combinat/posets/incidence_algebras.py +794 -0
  66. sage/combinat/posets/lattices.py +5117 -0
  67. sage/combinat/posets/linear_extension_iterator.cpython-310-aarch64-linux-gnu.so +0 -0
  68. sage/combinat/posets/linear_extension_iterator.pyx +292 -0
  69. sage/combinat/posets/linear_extensions.py +1037 -0
  70. sage/combinat/posets/mobile.py +275 -0
  71. sage/combinat/posets/moebius_algebra.py +776 -0
  72. sage/combinat/posets/poset_examples.py +2178 -0
  73. sage/combinat/posets/posets.py +9360 -0
  74. sage/combinat/rooted_tree.py +1070 -0
  75. sage/combinat/shard_order.py +239 -0
  76. sage/combinat/tamari_lattices.py +384 -0
  77. sage/combinat/yang_baxter_graph.py +923 -0
  78. sage/databases/all__sagemath_graphs.py +1 -0
  79. sage/databases/knotinfo_db.py +1231 -0
  80. sage/ext_data/all__sagemath_graphs.py +1 -0
  81. sage/ext_data/graphs/graph_plot_js.html +330 -0
  82. sage/ext_data/kenzo/CP2.txt +45 -0
  83. sage/ext_data/kenzo/CP3.txt +349 -0
  84. sage/ext_data/kenzo/CP4.txt +4774 -0
  85. sage/ext_data/kenzo/README.txt +49 -0
  86. sage/ext_data/kenzo/S4.txt +20 -0
  87. sage/graphs/all.py +42 -0
  88. sage/graphs/asteroidal_triples.cpython-310-aarch64-linux-gnu.so +0 -0
  89. sage/graphs/asteroidal_triples.pyx +320 -0
  90. sage/graphs/base/all.py +1 -0
  91. sage/graphs/base/boost_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  92. sage/graphs/base/boost_graph.pxd +106 -0
  93. sage/graphs/base/boost_graph.pyx +3045 -0
  94. sage/graphs/base/c_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  95. sage/graphs/base/c_graph.pxd +106 -0
  96. sage/graphs/base/c_graph.pyx +5096 -0
  97. sage/graphs/base/dense_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  98. sage/graphs/base/dense_graph.pxd +28 -0
  99. sage/graphs/base/dense_graph.pyx +801 -0
  100. sage/graphs/base/graph_backends.cpython-310-aarch64-linux-gnu.so +0 -0
  101. sage/graphs/base/graph_backends.pxd +5 -0
  102. sage/graphs/base/graph_backends.pyx +797 -0
  103. sage/graphs/base/overview.py +85 -0
  104. sage/graphs/base/sparse_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  105. sage/graphs/base/sparse_graph.pxd +90 -0
  106. sage/graphs/base/sparse_graph.pyx +1653 -0
  107. sage/graphs/base/static_dense_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  108. sage/graphs/base/static_dense_graph.pxd +5 -0
  109. sage/graphs/base/static_dense_graph.pyx +1032 -0
  110. sage/graphs/base/static_sparse_backend.cpython-310-aarch64-linux-gnu.so +0 -0
  111. sage/graphs/base/static_sparse_backend.pxd +27 -0
  112. sage/graphs/base/static_sparse_backend.pyx +1583 -0
  113. sage/graphs/base/static_sparse_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  114. sage/graphs/base/static_sparse_graph.pxd +37 -0
  115. sage/graphs/base/static_sparse_graph.pyx +1375 -0
  116. sage/graphs/bipartite_graph.py +2732 -0
  117. sage/graphs/centrality.cpython-310-aarch64-linux-gnu.so +0 -0
  118. sage/graphs/centrality.pyx +1038 -0
  119. sage/graphs/cographs.py +519 -0
  120. sage/graphs/comparability.cpython-310-aarch64-linux-gnu.so +0 -0
  121. sage/graphs/comparability.pyx +851 -0
  122. sage/graphs/connectivity.cpython-310-aarch64-linux-gnu.so +0 -0
  123. sage/graphs/connectivity.pxd +157 -0
  124. sage/graphs/connectivity.pyx +4813 -0
  125. sage/graphs/convexity_properties.cpython-310-aarch64-linux-gnu.so +0 -0
  126. sage/graphs/convexity_properties.pxd +16 -0
  127. sage/graphs/convexity_properties.pyx +870 -0
  128. sage/graphs/digraph.py +4754 -0
  129. sage/graphs/digraph_generators.py +1993 -0
  130. sage/graphs/distances_all_pairs.cpython-310-aarch64-linux-gnu.so +0 -0
  131. sage/graphs/distances_all_pairs.pxd +12 -0
  132. sage/graphs/distances_all_pairs.pyx +2938 -0
  133. sage/graphs/domination.py +1363 -0
  134. sage/graphs/dot2tex_utils.py +100 -0
  135. sage/graphs/edge_connectivity.cpython-310-aarch64-linux-gnu.so +0 -0
  136. sage/graphs/edge_connectivity.pyx +1215 -0
  137. sage/graphs/generators/all.py +1 -0
  138. sage/graphs/generators/basic.py +1769 -0
  139. sage/graphs/generators/chessboard.py +538 -0
  140. sage/graphs/generators/classical_geometries.py +1611 -0
  141. sage/graphs/generators/degree_sequence.py +235 -0
  142. sage/graphs/generators/distance_regular.cpython-310-aarch64-linux-gnu.so +0 -0
  143. sage/graphs/generators/distance_regular.pyx +2846 -0
  144. sage/graphs/generators/families.py +4759 -0
  145. sage/graphs/generators/intersection.py +565 -0
  146. sage/graphs/generators/platonic_solids.py +262 -0
  147. sage/graphs/generators/random.py +2623 -0
  148. sage/graphs/generators/smallgraphs.py +5741 -0
  149. sage/graphs/generators/world_map.py +724 -0
  150. sage/graphs/generic_graph.py +26867 -0
  151. sage/graphs/generic_graph_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
  152. sage/graphs/generic_graph_pyx.pxd +34 -0
  153. sage/graphs/generic_graph_pyx.pyx +1673 -0
  154. sage/graphs/genus.cpython-310-aarch64-linux-gnu.so +0 -0
  155. sage/graphs/genus.pyx +622 -0
  156. sage/graphs/graph.py +9645 -0
  157. sage/graphs/graph_coloring.cpython-310-aarch64-linux-gnu.so +0 -0
  158. sage/graphs/graph_coloring.pyx +2284 -0
  159. sage/graphs/graph_database.py +1177 -0
  160. sage/graphs/graph_decompositions/all.py +1 -0
  161. sage/graphs/graph_decompositions/bandwidth.cpython-310-aarch64-linux-gnu.so +0 -0
  162. sage/graphs/graph_decompositions/bandwidth.pyx +428 -0
  163. sage/graphs/graph_decompositions/clique_separators.cpython-310-aarch64-linux-gnu.so +0 -0
  164. sage/graphs/graph_decompositions/clique_separators.pyx +616 -0
  165. sage/graphs/graph_decompositions/cutwidth.cpython-310-aarch64-linux-gnu.so +0 -0
  166. sage/graphs/graph_decompositions/cutwidth.pyx +753 -0
  167. sage/graphs/graph_decompositions/fast_digraph.cpython-310-aarch64-linux-gnu.so +0 -0
  168. sage/graphs/graph_decompositions/fast_digraph.pxd +13 -0
  169. sage/graphs/graph_decompositions/fast_digraph.pyx +212 -0
  170. sage/graphs/graph_decompositions/graph_products.cpython-310-aarch64-linux-gnu.so +0 -0
  171. sage/graphs/graph_decompositions/graph_products.pyx +508 -0
  172. sage/graphs/graph_decompositions/modular_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
  173. sage/graphs/graph_decompositions/modular_decomposition.pxd +27 -0
  174. sage/graphs/graph_decompositions/modular_decomposition.pyx +1536 -0
  175. sage/graphs/graph_decompositions/slice_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
  176. sage/graphs/graph_decompositions/slice_decomposition.pxd +18 -0
  177. sage/graphs/graph_decompositions/slice_decomposition.pyx +1106 -0
  178. sage/graphs/graph_decompositions/tree_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
  179. sage/graphs/graph_decompositions/tree_decomposition.pxd +17 -0
  180. sage/graphs/graph_decompositions/tree_decomposition.pyx +1996 -0
  181. sage/graphs/graph_decompositions/vertex_separation.cpython-310-aarch64-linux-gnu.so +0 -0
  182. sage/graphs/graph_decompositions/vertex_separation.pxd +5 -0
  183. sage/graphs/graph_decompositions/vertex_separation.pyx +1963 -0
  184. sage/graphs/graph_editor.py +82 -0
  185. sage/graphs/graph_generators.py +3314 -0
  186. sage/graphs/graph_generators_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
  187. sage/graphs/graph_generators_pyx.pyx +95 -0
  188. sage/graphs/graph_input.py +812 -0
  189. sage/graphs/graph_latex.py +2064 -0
  190. sage/graphs/graph_list.py +410 -0
  191. sage/graphs/graph_plot.py +1756 -0
  192. sage/graphs/graph_plot_js.py +338 -0
  193. sage/graphs/hyperbolicity.cpython-310-aarch64-linux-gnu.so +0 -0
  194. sage/graphs/hyperbolicity.pyx +1704 -0
  195. sage/graphs/hypergraph_generators.py +364 -0
  196. sage/graphs/independent_sets.cpython-310-aarch64-linux-gnu.so +0 -0
  197. sage/graphs/independent_sets.pxd +13 -0
  198. sage/graphs/independent_sets.pyx +402 -0
  199. sage/graphs/isgci.py +1033 -0
  200. sage/graphs/isoperimetric_inequalities.cpython-310-aarch64-linux-gnu.so +0 -0
  201. sage/graphs/isoperimetric_inequalities.pyx +489 -0
  202. sage/graphs/line_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  203. sage/graphs/line_graph.pyx +743 -0
  204. sage/graphs/lovasz_theta.py +77 -0
  205. sage/graphs/matching.py +1633 -0
  206. sage/graphs/matching_covered_graph.py +3590 -0
  207. sage/graphs/orientations.py +1489 -0
  208. sage/graphs/partial_cube.py +459 -0
  209. sage/graphs/path_enumeration.cpython-310-aarch64-linux-gnu.so +0 -0
  210. sage/graphs/path_enumeration.pyx +2040 -0
  211. sage/graphs/pq_trees.py +1129 -0
  212. sage/graphs/print_graphs.py +201 -0
  213. sage/graphs/schnyder.py +865 -0
  214. sage/graphs/spanning_tree.cpython-310-aarch64-linux-gnu.so +0 -0
  215. sage/graphs/spanning_tree.pyx +1457 -0
  216. sage/graphs/strongly_regular_db.cpython-310-aarch64-linux-gnu.so +0 -0
  217. sage/graphs/strongly_regular_db.pyx +3340 -0
  218. sage/graphs/traversals.cpython-310-aarch64-linux-gnu.so +0 -0
  219. sage/graphs/traversals.pxd +9 -0
  220. sage/graphs/traversals.pyx +1872 -0
  221. sage/graphs/trees.cpython-310-aarch64-linux-gnu.so +0 -0
  222. sage/graphs/trees.pxd +15 -0
  223. sage/graphs/trees.pyx +310 -0
  224. sage/graphs/tutte_polynomial.py +713 -0
  225. sage/graphs/views.cpython-310-aarch64-linux-gnu.so +0 -0
  226. sage/graphs/views.pyx +794 -0
  227. sage/graphs/weakly_chordal.cpython-310-aarch64-linux-gnu.so +0 -0
  228. sage/graphs/weakly_chordal.pyx +604 -0
  229. sage/groups/all__sagemath_graphs.py +1 -0
  230. sage/groups/perm_gps/all__sagemath_graphs.py +1 -0
  231. sage/groups/perm_gps/partn_ref/all__sagemath_graphs.py +1 -0
  232. sage/groups/perm_gps/partn_ref/refinement_graphs.cpython-310-aarch64-linux-gnu.so +0 -0
  233. sage/groups/perm_gps/partn_ref/refinement_graphs.pxd +38 -0
  234. sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +1666 -0
  235. sage/knots/all.py +6 -0
  236. sage/knots/free_knotinfo_monoid.py +507 -0
  237. sage/knots/gauss_code.py +291 -0
  238. sage/knots/knot.py +682 -0
  239. sage/knots/knot_table.py +284 -0
  240. sage/knots/knotinfo.py +2900 -0
  241. sage/knots/link.py +4715 -0
  242. sage/sandpiles/all.py +13 -0
  243. sage/sandpiles/examples.py +225 -0
  244. sage/sandpiles/sandpile.py +6365 -0
  245. sage/topology/all.py +22 -0
  246. sage/topology/cell_complex.py +1214 -0
  247. sage/topology/cubical_complex.py +1976 -0
  248. sage/topology/delta_complex.py +1806 -0
  249. sage/topology/filtered_simplicial_complex.py +744 -0
  250. sage/topology/moment_angle_complex.py +823 -0
  251. sage/topology/simplicial_complex.py +5160 -0
  252. sage/topology/simplicial_complex_catalog.py +92 -0
  253. sage/topology/simplicial_complex_examples.py +1680 -0
  254. sage/topology/simplicial_complex_homset.py +205 -0
  255. sage/topology/simplicial_complex_morphism.py +836 -0
  256. sage/topology/simplicial_set.py +4102 -0
  257. sage/topology/simplicial_set_catalog.py +55 -0
  258. sage/topology/simplicial_set_constructions.py +2954 -0
  259. sage/topology/simplicial_set_examples.py +865 -0
  260. sage/topology/simplicial_set_morphism.py +1464 -0
@@ -0,0 +1,1064 @@
1
+ # sage_setup: distribution = sagemath-graphs
2
+ r"""
3
+ External representations of block designs
4
+
5
+ This module is an API to the abstract tree represented by
6
+ an XML document containing the External Representation of a list of
7
+ block designs. The module also provides the related I/O operations for
8
+ reading/writing ``ext-rep`` files or data. The parsing is based on expat.
9
+
10
+ This is a modified form of the module ``ext_rep.py`` (version 0.8)
11
+ written by Peter Dobcsanyi [Do2009]_ peter@designtheory.org.
12
+
13
+ .. TODO::
14
+
15
+ The XML data from the designtheory.org database contains a wealth of
16
+ information about things like automorphism groups, transitivity, cycle type
17
+ representatives, etc, but none of this data is made available through the
18
+ current implementation.
19
+ """
20
+
21
+ # ***********************************************************************
22
+ # This software is released under the terms of the GNU General Public
23
+ # License, version 2 or above (your choice). For details on licensing,
24
+ # see the accompanying documentation.
25
+ #
26
+ # This is a modified form of the module ext_rep.py (version 0.8)
27
+ # written by Peter Dobcsanyi peter@designtheory.org.
28
+ #
29
+ # Copyright 2004 Peter Dobcsanyi peter@designtheory.org
30
+ # 2009 Carlo Hamalainen carlo.hamalainen@gmail.com
31
+ # ***********************************************************************
32
+
33
+ import sys
34
+ import xml.parsers.expat
35
+ import re
36
+ import os.path
37
+ import gzip
38
+ import bz2
39
+
40
+ from urllib.request import urlopen
41
+
42
+ from sage.misc.temporary_file import tmp_filename
43
+
44
+
45
+ XML_NAMESPACE = 'http://designtheory.org/xml-namespace'
46
+ DTRS_PROTOCOL = '2.0'
47
+
48
+ # The following string is the file
49
+ # http://designtheory.org/database/v-b-k/v2-b2-k2.icgsa.txt.bz2
50
+ # We use this for doctests to make sure that the parsing works.
51
+
52
+ v2_b2_k2_icgsa = \
53
+ """<?xml version="1.0"?>
54
+ <list_of_designs
55
+ design_type="block_design"
56
+ dtrs_protocol="2.0"
57
+ no_designs="1"
58
+ pairwise_nonisomorphic="true"
59
+ xmlns="http://designtheory.org/xml-namespace">
60
+ <info>
61
+ <software>
62
+ [ DESIGN-1.1, GRAPE-4.2, GAPDoc-0.9999, GAP-4.4.3 ]
63
+ </software>
64
+ <software>
65
+ [ bdstat-0.8/280, numarray-1.1.1, pydesign-0.5/274, python-2.4.0.final.0 ]
66
+ </software>
67
+ </info>
68
+ <designs>
69
+ <block_design
70
+ b="2"
71
+ id="v2-b2-k2-0"
72
+ v="2">
73
+ <blocks ordered="true">
74
+ <block>
75
+ <z>0</z>
76
+ <z>1</z>
77
+ </block>
78
+ <block>
79
+ <z>0</z>
80
+ <z>1</z>
81
+ </block>
82
+ </blocks>
83
+ <indicators>
84
+ <repeated_blocks flag="true"/>
85
+ <resolvable flag="true"/>
86
+ <affine_resolvable
87
+ flag="true"
88
+ mu="2"/>
89
+ <equireplicate
90
+ flag="true"
91
+ r="2"/>
92
+ <constant_blocksize
93
+ flag="true"
94
+ k="2"/>
95
+ <t_design
96
+ flag="true"
97
+ maximum_t="2"/>
98
+ <connected
99
+ flag="true"
100
+ no_components="1"/>
101
+ <pairwise_balanced
102
+ flag="true"
103
+ lambda="2"/>
104
+ <variance_balanced flag="true"/>
105
+ <efficiency_balanced flag="true"/>
106
+ <cyclic flag="true"/>
107
+ <one_rotational flag="true"/>
108
+ </indicators>
109
+ <combinatorial_properties>
110
+ <point_concurrences>
111
+ <function_on_ksubsets_of_indices
112
+ domain_base="points"
113
+ k="1"
114
+ n="2"
115
+ ordered="true"
116
+ title="replication_numbers">
117
+ <map>
118
+ <preimage>
119
+ <entire_domain/>
120
+ </preimage>
121
+ <image>
122
+ <z>2</z>
123
+ </image>
124
+ </map>
125
+ </function_on_ksubsets_of_indices>
126
+ <function_on_ksubsets_of_indices
127
+ domain_base="points"
128
+ k="2"
129
+ n="2"
130
+ ordered="true"
131
+ title="pairwise_point_concurrences">
132
+ <map>
133
+ <preimage>
134
+ <entire_domain/>
135
+ </preimage>
136
+ <image>
137
+ <z>2</z>
138
+ </image>
139
+ </map>
140
+ </function_on_ksubsets_of_indices>
141
+ </point_concurrences>
142
+ <block_concurrences>
143
+ <function_on_ksubsets_of_indices
144
+ domain_base="blocks"
145
+ k="1"
146
+ n="2"
147
+ ordered="unknown"
148
+ title="block_sizes">
149
+ <map>
150
+ <preimage_cardinality>
151
+ <z>2</z>
152
+ </preimage_cardinality>
153
+ <image>
154
+ <z>2</z>
155
+ </image>
156
+ </map>
157
+ </function_on_ksubsets_of_indices>
158
+ <function_on_ksubsets_of_indices
159
+ domain_base="blocks"
160
+ k="2"
161
+ n="2"
162
+ ordered="unknown"
163
+ title="pairwise_block_intersection_sizes">
164
+ <map>
165
+ <preimage_cardinality>
166
+ <z>1</z>
167
+ </preimage_cardinality>
168
+ <image>
169
+ <z>2</z>
170
+ </image>
171
+ </map>
172
+ </function_on_ksubsets_of_indices>
173
+ </block_concurrences>
174
+ <t_design_properties>
175
+ <parameters
176
+ b="2"
177
+ k="2"
178
+ lambda="2"
179
+ r="2"
180
+ t="2"
181
+ v="2"/>
182
+ <square flag="true"/>
183
+ <projective_plane flag="false"/>
184
+ <affine_plane flag="false"/>
185
+ <steiner_system flag="false"/>
186
+ <steiner_triple_system flag="false"/>
187
+ </t_design_properties>
188
+ <alpha_resolvable>
189
+ <index_flag
190
+ flag="true"
191
+ index="2"/>
192
+ </alpha_resolvable>
193
+ <t_wise_balanced>
194
+ <index_flag
195
+ flag="true"
196
+ index="1"/>
197
+ <index_flag
198
+ flag="true"
199
+ index="2"/>
200
+ </t_wise_balanced>
201
+ </combinatorial_properties>
202
+ <automorphism_group>
203
+ <permutation_group
204
+ degree="2"
205
+ domain="points"
206
+ order="2">
207
+ <generators>
208
+ <permutation>
209
+ <z>1</z>
210
+ <z>0</z>
211
+ </permutation>
212
+ </generators>
213
+ <permutation_group_properties>
214
+ <primitive flag="true"/>
215
+ <generously_transitive flag="true"/>
216
+ <multiplicity_free flag="true"/>
217
+ <stratifiable flag="true"/>
218
+ <no_orbits value="1"/>
219
+ <degree_transitivity value="2"/>
220
+ <rank value="2"/>
221
+ <cycle_type_representatives>
222
+ <cycle_type_representative>
223
+ <permutation>
224
+ <z>1</z>
225
+ <z>0</z>
226
+ </permutation>
227
+ <cycle_type ordered="true">
228
+ <z>2</z>
229
+ </cycle_type>
230
+ <no_having_cycle_type>
231
+ <z>1</z>
232
+ </no_having_cycle_type>
233
+ </cycle_type_representative>
234
+ <cycle_type_representative>
235
+ <permutation>
236
+ <z>0</z>
237
+ <z>1</z>
238
+ </permutation>
239
+ <cycle_type ordered="true">
240
+ <z>1</z>
241
+ <z>1</z>
242
+ </cycle_type>
243
+ <no_having_cycle_type>
244
+ <z>1</z>
245
+ </no_having_cycle_type>
246
+ </cycle_type_representative>
247
+ </cycle_type_representatives>
248
+ </permutation_group_properties>
249
+ </permutation_group>
250
+ <automorphism_group_properties>
251
+ <block_primitive flag="not_applicable"/>
252
+ <no_block_orbits value="not_applicable"/>
253
+ <degree_block_transitivity value="not_applicable"/>
254
+ </automorphism_group_properties>
255
+ </automorphism_group>
256
+ <resolutions
257
+ all_classes_represented="true"
258
+ pairwise_nonisomorphic="true">
259
+ <resolution>
260
+ <function_on_indices
261
+ domain="blocks"
262
+ n="2"
263
+ ordered="true"
264
+ title="resolution">
265
+ <map>
266
+ <preimage>
267
+ <z>0</z>
268
+ </preimage>
269
+ <image>
270
+ <z>0</z>
271
+ </image>
272
+ </map>
273
+ <map>
274
+ <preimage>
275
+ <z>0</z>
276
+ </preimage>
277
+ <image>
278
+ <z>1</z>
279
+ </image>
280
+ </map>
281
+ </function_on_indices>
282
+ <automorphism_group>
283
+ <permutation_group
284
+ degree="2"
285
+ domain="points"
286
+ order="2">
287
+ <generators>
288
+ <permutation>
289
+ <z>1</z>
290
+ <z>0</z>
291
+ </permutation>
292
+ </generators>
293
+ </permutation_group>
294
+ </automorphism_group>
295
+ </resolution>
296
+ </resolutions>
297
+ <statistical_properties precision="9">
298
+ <canonical_variances
299
+ no_distinct="1"
300
+ ordered="true">
301
+ <value multiplicity="1">
302
+ <d>0.5</d>
303
+ </value>
304
+ </canonical_variances>
305
+ <pairwise_variances>
306
+ <function_on_ksubsets_of_indices
307
+ domain_base="points"
308
+ k="2"
309
+ n="2"
310
+ ordered="true">
311
+ <map>
312
+ <preimage>
313
+ <entire_domain/>
314
+ </preimage>
315
+ <image>
316
+ <d>1.0</d>
317
+ </image>
318
+ </map>
319
+ </function_on_ksubsets_of_indices>
320
+ </pairwise_variances>
321
+ <optimality_criteria>
322
+ <phi_0>
323
+ <value>
324
+ <d>-0.693147181</d>
325
+ </value>
326
+ <absolute_efficiency>
327
+ <z>1</z>
328
+ </absolute_efficiency>
329
+ <calculated_efficiency>
330
+ <z>1</z>
331
+ </calculated_efficiency>
332
+ </phi_0>
333
+ <phi_1>
334
+ <value>
335
+ <d>0.5</d>
336
+ </value>
337
+ <absolute_efficiency>
338
+ <z>1</z>
339
+ </absolute_efficiency>
340
+ <calculated_efficiency>
341
+ <z>1</z>
342
+ </calculated_efficiency>
343
+ </phi_1>
344
+ <phi_2>
345
+ <value>
346
+ <d>0.25</d>
347
+ </value>
348
+ <absolute_efficiency>
349
+ <z>1</z>
350
+ </absolute_efficiency>
351
+ <calculated_efficiency>
352
+ <z>1</z>
353
+ </calculated_efficiency>
354
+ </phi_2>
355
+ <maximum_pairwise_variances>
356
+ <value>
357
+ <d>1.0</d>
358
+ </value>
359
+ <absolute_efficiency>
360
+ <z>1</z>
361
+ </absolute_efficiency>
362
+ <calculated_efficiency>
363
+ <z>1</z>
364
+ </calculated_efficiency>
365
+ </maximum_pairwise_variances>
366
+ <E_criteria>
367
+ <E_value index="1">
368
+ <value>
369
+ <d>0.5</d>
370
+ </value>
371
+ <absolute_efficiency>
372
+ <z>1</z>
373
+ </absolute_efficiency>
374
+ <calculated_efficiency>
375
+ <z>1</z>
376
+ </calculated_efficiency>
377
+ </E_value>
378
+ </E_criteria>
379
+ </optimality_criteria>
380
+ <other_ordering_criteria>
381
+ <trace_of_square_of_C>
382
+ <value>
383
+ <d>4.0</d>
384
+ </value>
385
+ <absolute_comparison>
386
+ <z>1</z>
387
+ </absolute_comparison>
388
+ <calculated_comparison>
389
+ <z>1</z>
390
+ </calculated_comparison>
391
+ </trace_of_square_of_C>
392
+ <max_min_ratio_canonical_variances>
393
+ <value>
394
+ <d>1.0</d>
395
+ </value>
396
+ <absolute_comparison>
397
+ <z>1</z>
398
+ </absolute_comparison>
399
+ <calculated_comparison>
400
+ <z>1</z>
401
+ </calculated_comparison>
402
+ </max_min_ratio_canonical_variances>
403
+ <max_min_ratio_pairwise_variances>
404
+ <value>
405
+ <d>1.0</d>
406
+ </value>
407
+ <absolute_comparison>
408
+ <z>1</z>
409
+ </absolute_comparison>
410
+ <calculated_comparison>
411
+ <z>1</z>
412
+ </calculated_comparison>
413
+ </max_min_ratio_pairwise_variances>
414
+ <no_distinct_canonical_variances>
415
+ <value>
416
+ <z>1</z>
417
+ </value>
418
+ <absolute_comparison>
419
+ <z>1</z>
420
+ </absolute_comparison>
421
+ <calculated_comparison>
422
+ <z>1</z>
423
+ </calculated_comparison>
424
+ </no_distinct_canonical_variances>
425
+ <no_distinct_pairwise_variances>
426
+ <value>
427
+ <z>1</z>
428
+ </value>
429
+ <absolute_comparison>
430
+ <z>1</z>
431
+ </absolute_comparison>
432
+ <calculated_comparison>
433
+ <z>1</z>
434
+ </calculated_comparison>
435
+ </no_distinct_pairwise_variances>
436
+ </other_ordering_criteria>
437
+ <canonical_efficiency_factors
438
+ no_distinct="1"
439
+ ordered="true">
440
+ <value multiplicity="1">
441
+ <d>1.0</d>
442
+ </value>
443
+ </canonical_efficiency_factors>
444
+ <functions_of_efficiency_factors>
445
+ <harmonic_mean alias="A">
446
+ <value>
447
+ <d>1.0</d>
448
+ </value>
449
+ </harmonic_mean>
450
+ <geometric_mean alias="D">
451
+ <value>
452
+ <d>1.0</d>
453
+ </value>
454
+ </geometric_mean>
455
+ <minimum alias="E">
456
+ <value>
457
+ <d>1.0</d>
458
+ </value>
459
+ </minimum>
460
+ </functions_of_efficiency_factors>
461
+ </statistical_properties>
462
+ </block_design>
463
+ </designs>
464
+ </list_of_designs>
465
+ """
466
+
467
+
468
+ def dump_to_tmpfile(s):
469
+ """
470
+ Utility function to dump a string to a temporary file.
471
+
472
+ EXAMPLES::
473
+
474
+ sage: from sage.combinat.designs import ext_rep
475
+ sage: file_loc = ext_rep.dump_to_tmpfile("boo")
476
+ sage: os.remove(file_loc)
477
+ """
478
+
479
+ file_loc = tmp_filename()
480
+ f = open(file_loc,"w")
481
+ f.write(v2_b2_k2_icgsa)
482
+ f.close()
483
+ return file_loc
484
+
485
+
486
+ def check_dtrs_protocols(input_name, input_pv):
487
+ """
488
+ Check that the XML data is in a valid format. We can currently
489
+ handle version 2.0. For more information see
490
+ http://designtheory.org/library/extrep/
491
+
492
+ EXAMPLES::
493
+
494
+ sage: from sage.combinat.designs import ext_rep
495
+ sage: ext_rep.check_dtrs_protocols('source', '2.0')
496
+ sage: ext_rep.check_dtrs_protocols('source', '3.0')
497
+ Traceback (most recent call last):
498
+ ...
499
+ RuntimeError: Incompatible dtrs_protocols: program: 2.0 source: 3.0
500
+ """
501
+
502
+ program_pv = DTRS_PROTOCOL
503
+ ppv_major, ppv_minor = program_pv.split('.')
504
+ ipv_major, ipv_minor = input_pv.split('.')
505
+ if ppv_major != ipv_major or int(ppv_minor) < int(ipv_minor):
506
+ msg = ('''Incompatible dtrs_protocols: program: %s %s: %s''' % (program_pv, input_name, input_pv))
507
+ raise RuntimeError(msg)
508
+
509
+
510
+ def open_extrep_file(fname):
511
+ """
512
+ Try to guess the compression type from extension
513
+ and open the extrep file.
514
+
515
+ EXAMPLES::
516
+
517
+ sage: from sage.combinat.designs import ext_rep
518
+ sage: file_loc = ext_rep.dump_to_tmpfile(ext_rep.v2_b2_k2_icgsa)
519
+ sage: proc = ext_rep.XTreeProcessor()
520
+ sage: f = ext_rep.open_extrep_file(file_loc)
521
+ sage: proc.parse(f)
522
+ sage: f.close()
523
+ sage: os.remove(file_loc)
524
+ """
525
+
526
+ if fname == '-':
527
+ f = sys.stdin
528
+ else:
529
+ root, ext = os.path.splitext(fname)
530
+ if ext == '.gz':
531
+ f = gzip.GzipFile(fname)
532
+ elif ext == '.bz2':
533
+ f = bz2.BZ2File(fname)
534
+ else:
535
+ f = open(fname, 'rb')
536
+ return f
537
+
538
+
539
+ def open_extrep_url(url):
540
+ """
541
+ Try to guess the compression type from extension
542
+ and open the extrep file pointed to by the url. This function
543
+ (unlike open_extrep_file) returns the uncompressed text contained in
544
+ the file.
545
+
546
+ EXAMPLES::
547
+
548
+ sage: from sage.combinat.designs import ext_rep
549
+ sage: file_loc = ext_rep.dump_to_tmpfile(ext_rep.v2_b2_k2_icgsa)
550
+ sage: proc = ext_rep.XTreeProcessor()
551
+ sage: s = ext_rep.open_extrep_url("file://" + file_loc)
552
+ sage: proc.parse(s)
553
+ sage: os.remove(file_loc)
554
+
555
+ sage: from sage.combinat.designs import ext_rep
556
+ sage: s = ext_rep.designs_from_XML_url("http://designtheory.org/database/v-b-k/v3-b6-k2.icgsa.txt.bz2") # optional - internet
557
+ """
558
+
559
+ f = urlopen(url)
560
+
561
+ root, ext = os.path.splitext(url)
562
+ if ext == '.gz':
563
+ raise NotImplementedError
564
+ elif ext == '.bz2':
565
+ return bz2.decompress(f.read())
566
+ else:
567
+ return f.read()
568
+
569
+
570
+ pattern_integer = re.compile(r'\d+$')
571
+ pattern_decimal = re.compile(r'-?\d+\.\d+$')
572
+ pattern_rational = re.compile(r'-?\d+/\d+$')
573
+
574
+
575
+ def _encode_attribute(string):
576
+ """
577
+ Convert numbers in attributes into binary format.
578
+ Currently integer and floating point conversions are implemented.
579
+
580
+ EXAMPLES::
581
+
582
+ sage: from sage.combinat.designs.ext_rep import _encode_attribute
583
+ sage: _encode_attribute('1')
584
+ 1
585
+ sage: _encode_attribute('2')
586
+ 2
587
+ sage: _encode_attribute('12')
588
+ 12
589
+ sage: _encode_attribute('true')
590
+ 'true'
591
+ sage: _encode_attribute('A')
592
+ 'A'
593
+ sage: _encode_attribute('D')
594
+ 'D'
595
+ sage: _encode_attribute('E')
596
+ 'E'
597
+ """
598
+ if pattern_integer.match(string):
599
+ return int(string)
600
+ elif pattern_decimal.match(string):
601
+ return float(string)
602
+ else:
603
+ return string
604
+
605
+
606
+ class XTree:
607
+ '''
608
+ A lazy class to wrap a rooted tree representing an XML document.
609
+ The tree's nodes are tuples of the structure:
610
+ (name, {dictionary of attributes}, [list of children])
611
+
612
+ Methods and services of an XTree object ``t``:
613
+
614
+ - ``t.attribute`` -- attribute named
615
+ - ``t.child`` -- first child named
616
+ - ``t[i]`` -- `i`-th child
617
+ - ``for child in t:`` -- iterate over ``t``'s children
618
+ - ``len(t)`` -- number of ``t``'s children
619
+
620
+ If child is not an empty subtree, return the subtree as an ``XTree``
621
+ object. If child is an empty subtree, return ``_name`` of the subtree.
622
+ Otherwise return the child itself.
623
+
624
+ The lazy tree idea originated from a utility class of the
625
+ pyRXP 0.9 package by Robin Becker at ReportLab.
626
+ '''
627
+
628
+ def __init__(self, node):
629
+ """
630
+ Initialisation method given a node in an XML document.
631
+
632
+ EXAMPLES::
633
+
634
+ sage: from sage.combinat.designs.ext_rep import *
635
+ sage: xt = XTree(('blocks', {'ordered': 'true'}, [('block', {}, [[0, 1, 2]]), ('block', {}, [[0, 3, 4]]), ('block', {}, [[0, 5, 6]]), ('block', {}, [[0, 7, 8]]), ('block', {}, [[0, 9, 10]]), ('block', {}, [[0, 11, 12]]), ('block', {}, [[1, 3, 5]]), ('block', {}, [[1, 4, 6]]), ('block', {}, [[1, 7, 9]]), ('block', {}, [[1, 8, 11]]), ('block', {}, [[1, 10, 12]]), ('block', {}, [[2, 3, 7]]), ('block', {}, [[2, 4, 8]]), ('block', {}, [[2, 5, 10]]), ('block', {}, [[2, 6, 12]]), ('block', {}, [[2, 9, 11]]), ('block', {}, [[3, 6, 9]]), ('block', {}, [[3, 8, 12]]), ('block', {}, [[3, 10, 11]]), ('block', {}, [[4, 5, 11]]), ('block', {}, [[4, 7, 10]]), ('block', {}, [[4, 9, 12]]), ('block', {}, [[5, 7, 12]]), ('block', {}, [[5, 8, 9]]), ('block', {}, [[6, 7, 11]]), ('block', {}, [[6, 8, 10]])]))
636
+ sage: xt.xt_children
637
+ [('block', {}, [[0, 1, 2]]),
638
+ ('block', {}, [[0, 3, 4]]),
639
+ ('block', {}, [[0, 5, 6]]),
640
+ ('block', {}, [[0, 7, 8]]),
641
+ ('block', {}, [[0, 9, 10]]),
642
+ ('block', {}, [[0, 11, 12]]),
643
+ ('block', {}, [[1, 3, 5]]),
644
+ ('block', {}, [[1, 4, 6]]),
645
+ ('block', {}, [[1, 7, 9]]),
646
+ ('block', {}, [[1, 8, 11]]),
647
+ ('block', {}, [[1, 10, 12]]),
648
+ ('block', {}, [[2, 3, 7]]),
649
+ ('block', {}, [[2, 4, 8]]),
650
+ ('block', {}, [[2, 5, 10]]),
651
+ ('block', {}, [[2, 6, 12]]),
652
+ ('block', {}, [[2, 9, 11]]),
653
+ ('block', {}, [[3, 6, 9]]),
654
+ ('block', {}, [[3, 8, 12]]),
655
+ ('block', {}, [[3, 10, 11]]),
656
+ ('block', {}, [[4, 5, 11]]),
657
+ ('block', {}, [[4, 7, 10]]),
658
+ ('block', {}, [[4, 9, 12]]),
659
+ ('block', {}, [[5, 7, 12]]),
660
+ ('block', {}, [[5, 8, 9]]),
661
+ ('block', {}, [[6, 7, 11]]),
662
+ ('block', {}, [[6, 8, 10]])]
663
+ """
664
+
665
+ if isinstance(node, str):
666
+ node = (node, {}, [])
667
+ name, attributes, children = node
668
+ self.xt_node = node
669
+ self.xt_name = name
670
+ self.xt_attributes = attributes
671
+ self.xt_children = children
672
+
673
+ def __repr__(self):
674
+ """
675
+ String representation of an XTree object.
676
+
677
+ EXAMPLES::
678
+
679
+ sage: from sage.combinat.designs.ext_rep import *
680
+ sage: xt = XTree(('blocks', {'ordered': 'true'}, [('block', {}, [[0, 1, 2]]), ('block', {}, [[0, 3, 4]]), ('block', {}, [[0, 5, 6]]), ('block', {}, [[0, 7, 8]]), ('block', {}, [[0, 9, 10]]), ('block', {}, [[0, 11, 12]]), ('block', {}, [[1, 3, 5]]), ('block', {}, [[1, 4, 6]]), ('block', {}, [[1, 7, 9]]), ('block', {}, [[1, 8, 11]]), ('block', {}, [[1, 10, 12]]), ('block', {}, [[2, 3, 7]]), ('block', {}, [[2, 4, 8]]), ('block', {}, [[2, 5, 10]]), ('block', {}, [[2, 6, 12]]), ('block', {}, [[2, 9, 11]]), ('block', {}, [[3, 6, 9]]), ('block', {}, [[3, 8, 12]]), ('block', {}, [[3, 10, 11]]), ('block', {}, [[4, 5, 11]]), ('block', {}, [[4, 7, 10]]), ('block', {}, [[4, 9, 12]]), ('block', {}, [[5, 7, 12]]), ('block', {}, [[5, 8, 9]]), ('block', {}, [[6, 7, 11]]), ('block', {}, [[6, 8, 10]])]))
681
+ sage: xt.__repr__()
682
+ 'XTree<blocks>'
683
+ """
684
+
685
+ return 'XTree<%s>' % self.xt_name
686
+
687
+ def __getattr__(self, attr):
688
+ """
689
+ Return the data for the first attribute with name attr.
690
+
691
+ EXAMPLES::
692
+
693
+ sage: from sage.combinat.designs.ext_rep import *
694
+ sage: xt = XTree(('blocks', {'ordered': 'true'}, [('block', {}, [[0, 1, 2]]), ('block', {}, [[0, 3, 4]]), ('block', {}, [[0, 5, 6]]), ('block', {}, [[0, 7, 8]]), ('block', {}, [[0, 9, 10]]), ('block', {}, [[0, 11, 12]]), ('block', {}, [[1, 3, 5]]), ('block', {}, [[1, 4, 6]]), ('block', {}, [[1, 7, 9]]), ('block', {}, [[1, 8, 11]]), ('block', {}, [[1, 10, 12]]), ('block', {}, [[2, 3, 7]]), ('block', {}, [[2, 4, 8]]), ('block', {}, [[2, 5, 10]]), ('block', {}, [[2, 6, 12]]), ('block', {}, [[2, 9, 11]]), ('block', {}, [[3, 6, 9]]), ('block', {}, [[3, 8, 12]]), ('block', {}, [[3, 10, 11]]), ('block', {}, [[4, 5, 11]]), ('block', {}, [[4, 7, 10]]), ('block', {}, [[4, 9, 12]]), ('block', {}, [[5, 7, 12]]), ('block', {}, [[5, 8, 9]]), ('block', {}, [[6, 7, 11]]), ('block', {}, [[6, 8, 10]])]))
695
+ sage: xt.__getattr__('block')
696
+ [0, 1, 2]
697
+ """
698
+
699
+ if attr in self.xt_attributes:
700
+ return self.xt_attributes[attr]
701
+ else:
702
+ for child in self.xt_children:
703
+ name, attributes, children = child
704
+ if name == attr:
705
+ if len(attributes) > 0:
706
+ return XTree(child)
707
+ else:
708
+ if len(children) == 0:
709
+ # need this to get an empty Xtree, for append
710
+ return XTree(child)
711
+ grandchild = children[0]
712
+ if isinstance(grandchild, tuple):
713
+ if len(grandchild[1]) == 0 and \
714
+ len(grandchild[2]) == 0:
715
+ return grandchild[0]
716
+ else:
717
+ return XTree(child)
718
+ else:
719
+ return grandchild
720
+ msg = '"%s" is not found in attributes of %s or its children.' % \
721
+ (attr, self)
722
+ raise AttributeError(msg)
723
+
724
+ def __getitem__(self, i):
725
+ """
726
+ Get the ``i``-th item in the current node.
727
+
728
+ EXAMPLES::
729
+
730
+ sage: from sage.combinat.designs.ext_rep import *
731
+ sage: xt = XTree(('blocks', {'ordered': 'true'}, [('block', {}, [[0, 1, 2]]), ('block', {}, [[0, 3, 4]]), ('block', {}, [[0, 5, 6]]), ('block', {}, [[0, 7, 8]]), ('block', {}, [[0, 9, 10]]), ('block', {}, [[0, 11, 12]]), ('block', {}, [[1, 3, 5]]), ('block', {}, [[1, 4, 6]]), ('block', {}, [[1, 7, 9]]), ('block', {}, [[1, 8, 11]]), ('block', {}, [[1, 10, 12]]), ('block', {}, [[2, 3, 7]]), ('block', {}, [[2, 4, 8]]), ('block', {}, [[2, 5, 10]]), ('block', {}, [[2, 6, 12]]), ('block', {}, [[2, 9, 11]]), ('block', {}, [[3, 6, 9]]), ('block', {}, [[3, 8, 12]]), ('block', {}, [[3, 10, 11]]), ('block', {}, [[4, 5, 11]]), ('block', {}, [[4, 7, 10]]), ('block', {}, [[4, 9, 12]]), ('block', {}, [[5, 7, 12]]), ('block', {}, [[5, 8, 9]]), ('block', {}, [[6, 7, 11]]), ('block', {}, [[6, 8, 10]])]))
732
+ sage: xt.__getitem__(0)
733
+ [0, 1, 2]
734
+ sage: xt.__getitem__(1)
735
+ [0, 3, 4]
736
+
737
+ TESTS::
738
+
739
+ sage: xt.__getitem__(119)
740
+ Traceback (most recent call last):
741
+ ...
742
+ IndexError: XTree<blocks> has no index 119
743
+ """
744
+ try:
745
+ child = self.xt_children[i]
746
+ except IndexError:
747
+ raise IndexError('{!r} has no index {}'.format(self, i))
748
+ if isinstance(child, tuple):
749
+ name, attributes, children = child
750
+ if len(attributes) > 0:
751
+ return XTree(child)
752
+ else:
753
+ grandchild = children[0]
754
+ if isinstance(grandchild, tuple):
755
+ if len(grandchild[1]) == 0 and len(grandchild[2]) == 0:
756
+ return grandchild[0]
757
+ else:
758
+ return XTree(child)
759
+ else:
760
+ return grandchild
761
+ else:
762
+ return child
763
+
764
+ def __len__(self):
765
+ """
766
+ Return the length of the current node.
767
+
768
+ EXAMPLES::
769
+
770
+ sage: from sage.combinat.designs.ext_rep import *
771
+ sage: xt = XTree(('blocks', {'ordered': 'true'}, [('block', {}, [[0, 1, 2]]), ('block', {}, [[0, 3, 4]]), ('block', {}, [[0, 5, 6]]), ('block', {}, [[0, 7, 8]]), ('block', {}, [[0, 9, 10]]), ('block', {}, [[0, 11, 12]]), ('block', {}, [[1, 3, 5]]), ('block', {}, [[1, 4, 6]]), ('block', {}, [[1, 7, 9]]), ('block', {}, [[1, 8, 11]]), ('block', {}, [[1, 10, 12]]), ('block', {}, [[2, 3, 7]]), ('block', {}, [[2, 4, 8]]), ('block', {}, [[2, 5, 10]]), ('block', {}, [[2, 6, 12]]), ('block', {}, [[2, 9, 11]]), ('block', {}, [[3, 6, 9]]), ('block', {}, [[3, 8, 12]]), ('block', {}, [[3, 10, 11]]), ('block', {}, [[4, 5, 11]]), ('block', {}, [[4, 7, 10]]), ('block', {}, [[4, 9, 12]]), ('block', {}, [[5, 7, 12]]), ('block', {}, [[5, 8, 9]]), ('block', {}, [[6, 7, 11]]), ('block', {}, [[6, 8, 10]])]))
772
+ sage: xt.__len__()
773
+ 26
774
+ """
775
+
776
+ return len(self.xt_children)
777
+
778
+
779
+ class XTreeProcessor:
780
+ '''
781
+ An incremental event-driven parser for ext-rep documents.
782
+ The processing stages:
783
+
784
+ - ``<list_of_designs ...>`` opening element.
785
+ call-back: ``list_of_designs_proc``
786
+
787
+ - ``<list_definition>`` subtree.
788
+ call-back: ``list_definition_proc``
789
+
790
+ - ``<info>`` subtree.
791
+ call-back: ``info_proc``
792
+
793
+ - iterating over ``<designs>`` processing each ``<block_design>``
794
+ separately.
795
+ call-back: ``block_design_proc``
796
+
797
+ - finishing with closing ``</designs>`` and ``</list_of_designs>``.
798
+ '''
799
+ def _init(self):
800
+ """
801
+ Internal initialisation for the processor of XTrees.
802
+
803
+ EXAMPLES::
804
+
805
+ sage: from sage.combinat.designs import ext_rep
806
+ sage: proc = ext_rep.XTreeProcessor()
807
+ sage: proc._init()
808
+ sage: proc.current_node
809
+ ('root0', {}, [])
810
+ """
811
+
812
+ self.current_node = ('root0', {}, [])
813
+ self.node_stack = [self.current_node]
814
+ self.in_item = False
815
+
816
+ def __init__(self):
817
+ """
818
+ Internal initialisation for the processor of XTrees.
819
+
820
+ EXAMPLES::
821
+
822
+ sage: from sage.combinat.designs.ext_rep import *
823
+ sage: proc = XTreeProcessor()
824
+ sage: proc.current_node
825
+ ('root0', {}, [])
826
+ sage: proc.node_stack
827
+ [('root0', {}, [])]
828
+ sage: proc.in_item
829
+ False
830
+ """
831
+
832
+ self._init()
833
+ self.outf = sys.stdout
834
+ # call-back handlers
835
+ self.list_of_designs_start_proc = None
836
+ self.list_definition_proc = None
837
+ self.info_proc = None
838
+ self.designs_start_proc = None
839
+ self.block_design_proc = None
840
+ self.designs_end_proc = None
841
+ self.list_of_designs_end_proc = None
842
+
843
+ self.save_designs = False
844
+ self.list_of_designs = []
845
+
846
+ def _start_element(self, name, attrs):
847
+ """
848
+ Process the start of an element with certain name and
849
+ attributes.
850
+
851
+ EXAMPLES::
852
+
853
+ sage: from sage.combinat.designs.ext_rep import *
854
+ sage: name = "block_design"
855
+ sage: attrs = {'b': '26', 'id': 't2-v13-b26-r6-k3-L1-0', 'v': '13'}
856
+ sage: proc = XTreeProcessor()
857
+ sage: proc._start_element(name, attrs)
858
+ sage: proc.current_node
859
+ ('block_design', {'b': 26, 'id': 't2-v13-b26-r6-k3-L1-0', 'v': 13}, [])
860
+ """
861
+
862
+ if name == 'block_design' or name == 'info' or name == 'list_definition':
863
+ self.in_item = True
864
+ elif name == 'list_of_designs':
865
+ check_dtrs_protocols('source', attrs['dtrs_protocol'])
866
+ if self.list_of_designs_start_proc:
867
+ self.list_of_designs_start_proc(attrs)
868
+ # self.outf.write('<%s' % name)
869
+ # pp_attributes(self.outf, attrs, indent='', precision_stack=[])
870
+ # self.outf.write('>\n')
871
+ elif name == 'designs':
872
+ pass # self.outf.write(' <%s>\n' % name)
873
+ if self.in_item:
874
+ for k, v in attrs.items():
875
+ attrs[k] = _encode_attribute(v)
876
+ new_node = (name, attrs, [])
877
+ self.node_stack.append(new_node)
878
+ self.current_node[2].append(new_node)
879
+ self.current_node = new_node
880
+
881
+ def _end_element(self, name):
882
+ """
883
+ Finish processing the element name.
884
+
885
+ EXAMPLES::
886
+
887
+ sage: from sage.combinat.designs.ext_rep import *
888
+ sage: name = "block_design"
889
+ sage: attrs = {'b': '26', 'id': 't2-v13-b26-r6-k3-L1-0', 'v': '13'}
890
+ sage: proc = XTreeProcessor()
891
+ sage: proc._start_element(name, attrs)
892
+ sage: proc._end_element(name)
893
+ sage: proc.current_node
894
+ ('root0', {}, [])
895
+ """
896
+
897
+ if self.in_item:
898
+ children = self.current_node[2]
899
+ if len(children) > 0 and isinstance(children[0], tuple):
900
+ if children[0][0] == 'z' or children[0][0] == 'd' \
901
+ or children[0][0] == 'q':
902
+ if children[0][0] == 'z':
903
+ convert = int
904
+ elif children[0][0] == 'd':
905
+ convert = float
906
+ else:
907
+ raise NotImplementedError('rational numbers')
908
+ ps = []
909
+ for x in children:
910
+ ps.append(convert(''.join(x[2])))
911
+ del children[:]
912
+ if name == 'block' or name == 'permutation' \
913
+ or name == 'preimage' or name == 'ksubset' \
914
+ or name == 'cycle_type' or name == 'row':
915
+ # these enclose lists of numbers
916
+ children.append(ps)
917
+ else:
918
+ # the rest is a single number
919
+ children.append(ps[0])
920
+ self.node_stack.pop()
921
+ self.current_node = self.node_stack[-1]
922
+ if name == 'block_design':
923
+ if self.block_design_proc:
924
+ self.block_design_proc(self.current_node[2][0])
925
+ if self.save_designs:
926
+ init_bd = XTree(self.current_node[2][0])
927
+ self.list_of_designs.append((init_bd.v, list(init_bd.blocks)))
928
+ # print_subxt(self.current_node[2][0], level=2, outf=self.outf)
929
+ self._init()
930
+ elif name == 'info':
931
+ if self.info_proc:
932
+ self.info_proc(self.current_node[2][0])
933
+ # print_subxt(self.current_node[2][0], level=1, outf=self.outf)
934
+ self._init()
935
+ else:
936
+ if name == 'designs':
937
+ if self.designs_end_proc:
938
+ self.designs_end_proc()
939
+ # self.outf.write(' ')
940
+ # self.outf.write('</%s>\n' % name)
941
+
942
+ def _char_data(self, data):
943
+ """
944
+ Internal function to tidy up character data.
945
+
946
+ EXAMPLES::
947
+
948
+ sage: from sage.combinat.designs.ext_rep import *
949
+ sage: name = "block_design"
950
+ sage: attrs = {'b': '26', 'id': 't2-v13-b26-r6-k3-L1-0', 'v': '13'}
951
+
952
+ sage: proc = XTreeProcessor()
953
+ sage: proc._start_element(name, attrs)
954
+
955
+ sage: proc._char_data(r" [ DESIGN-1.1, GRAPE-4.2, GAPDoc-0.9999, GAP-4.4.3]")
956
+ sage: proc.current_node
957
+ ('block_design',
958
+ {'b': 26, 'id': 't2-v13-b26-r6-k3-L1-0', 'v': 13},
959
+ ['[ DESIGN-1.1, GRAPE-4.2, GAPDoc-0.9999, GAP-4.4.3]'])
960
+ """
961
+ if self.in_item:
962
+ # @ this stripping may distort char data in the <info> subtree
963
+ # if they are not bracketed in some way.
964
+ data = data.strip()
965
+ if data:
966
+ # we use the xtree's children list here to collect char data
967
+ # since only leaves have char data.
968
+ self.current_node[2].append(data)
969
+
970
+ def parse(self, xml_source):
971
+ """
972
+ The main parsing function. Given an XML source (either a file
973
+ handle or a string), parse the entire XML source.
974
+
975
+ EXAMPLES::
976
+
977
+ sage: from sage.combinat.designs import ext_rep
978
+ sage: file_loc = ext_rep.dump_to_tmpfile(ext_rep.v2_b2_k2_icgsa)
979
+ sage: proc = ext_rep.XTreeProcessor()
980
+ sage: proc.save_designs = True
981
+ sage: f = ext_rep.open_extrep_file(file_loc)
982
+ sage: proc.parse(f)
983
+ sage: f.close()
984
+ sage: os.remove(file_loc)
985
+ sage: proc.list_of_designs[0]
986
+ (2, [[0, 1], [0, 1]])
987
+ """
988
+
989
+ p = xml.parsers.expat.ParserCreate()
990
+ p.StartElementHandler = self._start_element
991
+ p.EndElementHandler = self._end_element
992
+ p.CharacterDataHandler = self._char_data
993
+
994
+ if isinstance(xml_source, (str, bytes)):
995
+ p.Parse(xml_source)
996
+ else:
997
+ p.ParseFile(xml_source)
998
+
999
+
1000
+ def designs_from_XML(fname):
1001
+ """
1002
+ Return a list of designs contained in an XML file fname. The list
1003
+ contains tuples of the form (v, bs) where v is the number of points of
1004
+ the design and bs is the list of blocks.
1005
+
1006
+ EXAMPLES::
1007
+
1008
+ sage: from sage.combinat.designs import ext_rep
1009
+ sage: file_loc = ext_rep.dump_to_tmpfile(ext_rep.v2_b2_k2_icgsa)
1010
+ sage: ext_rep.designs_from_XML(file_loc)[0]
1011
+ (2, [[0, 1], [0, 1]])
1012
+ sage: os.remove(file_loc)
1013
+
1014
+ sage: from sage.combinat.designs import ext_rep
1015
+ sage: from sage.combinat.designs.block_design import BlockDesign
1016
+ sage: file_loc = ext_rep.dump_to_tmpfile(ext_rep.v2_b2_k2_icgsa)
1017
+ sage: v, blocks = ext_rep.designs_from_XML(file_loc)[0]
1018
+ sage: d = BlockDesign(v, blocks)
1019
+ sage: d.blocks()
1020
+ [[0, 1], [0, 1]]
1021
+ sage: d.is_t_design(t=2)
1022
+ True
1023
+ sage: d.is_t_design(return_parameters=True)
1024
+ (True, (2, 2, 2, 2))
1025
+ """
1026
+
1027
+ proc = XTreeProcessor()
1028
+ proc.save_designs = True
1029
+ f = open_extrep_file(fname)
1030
+ proc.parse(f)
1031
+ f.close()
1032
+
1033
+ return proc.list_of_designs
1034
+
1035
+
1036
+ def designs_from_XML_url(url):
1037
+ """
1038
+ Return a list of designs contained in an XML file named by a URL.
1039
+ The list contains tuples of the form (v, bs) where v is the number
1040
+ of points of the design and bs is the list of blocks.
1041
+
1042
+ EXAMPLES::
1043
+
1044
+ sage: from sage.combinat.designs import ext_rep
1045
+ sage: file_loc = ext_rep.dump_to_tmpfile(ext_rep.v2_b2_k2_icgsa)
1046
+ sage: ext_rep.designs_from_XML_url("file://" + file_loc)[0]
1047
+ (2, [[0, 1], [0, 1]])
1048
+ sage: os.remove(file_loc)
1049
+
1050
+ sage: from sage.combinat.designs import ext_rep
1051
+ sage: ext_rep.designs_from_XML_url("http://designtheory.org/database/v-b-k/v3-b6-k2.icgsa.txt.bz2") # optional - internet
1052
+ [(3, [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 2]]),
1053
+ (3, [[0, 1], [0, 1], [0, 1], [0, 1], [0, 2], [0, 2]]),
1054
+ (3, [[0, 1], [0, 1], [0, 1], [0, 1], [0, 2], [1, 2]]),
1055
+ (3, [[0, 1], [0, 1], [0, 1], [0, 2], [0, 2], [0, 2]]),
1056
+ (3, [[0, 1], [0, 1], [0, 1], [0, 2], [0, 2], [1, 2]]),
1057
+ (3, [[0, 1], [0, 1], [0, 2], [0, 2], [1, 2], [1, 2]])]
1058
+ """
1059
+ proc = XTreeProcessor()
1060
+ proc.save_designs = True
1061
+ s = open_extrep_url(url)
1062
+ proc.parse(s)
1063
+
1064
+ return proc.list_of_designs