74
74
import scipy
75
75
import scipy .interpolate
76
76
import numpy as np
77
+
78
+ from sage .matroids .advanced import newlabel
77
79
from sage .misc .lazy_import import lazy_import
78
- lazy_import ("sage.plot.all" , ["Graphics" , "line" , "text" , "polygon2d" , "point" , "points" ])
79
- lazy_import ("sage.plot.colors" , "Color" )
80
80
from sage .sets .set import Set
81
- from sage .matroids .advanced import newlabel
81
+
82
+ lazy_import ("sage.plot.all" , ["Graphics" , "line" , "text" ,
83
+ "polygon2d" , "point" , "points" ])
84
+ lazy_import ("sage.plot.colors" , "Color" )
82
85
83
86
84
- def it (M , B1 , nB1 , lps ):
87
+ def it (M , B1 , nB1 , lps ) -> tuple [ dict , list , list , list ] :
85
88
r"""
86
89
Return points on and off the triangle and lines to be drawn for a rank 3
87
90
matroid.
@@ -178,7 +181,7 @@ def it(M, B1, nB1, lps):
178
181
return pts , trilines , nontripts , curvedlines
179
182
180
183
181
- def trigrid (tripts ):
184
+ def trigrid (tripts ) -> list [ list ] :
182
185
"""
183
186
Return a grid of 4 points inside given 3 points as a list.
184
187
@@ -205,7 +208,7 @@ def trigrid(tripts):
205
208
206
209
.. NOTE::
207
210
208
- This method does NOT do any checks.
211
+ This method does NOT do any checks.
209
212
"""
210
213
pairs = [[0 , 1 ], [1 , 2 ], [0 , 2 ]]
211
214
cpt = [float (tripts [0 ][0 ] + tripts [1 ][0 ] + tripts [2 ][0 ]) / 3 ,
@@ -218,7 +221,7 @@ def trigrid(tripts):
218
221
return grid
219
222
220
223
221
- def addnontripts (tripts_labels , nontripts_labels , ptsdict ):
224
+ def addnontripts (tripts_labels , nontripts_labels , ptsdict ) -> dict :
222
225
"""
223
226
Return modified ``ptsdict`` with additional keys and values corresponding
224
227
to ``nontripts``.
@@ -260,16 +263,16 @@ def addnontripts(tripts_labels, nontripts_labels, ptsdict):
260
263
261
264
.. NOTE::
262
265
263
- This method does NOT do any checks.
266
+ This method does NOT do any checks.
264
267
"""
265
268
tripts = [list (ptsdict [p ]) for p in tripts_labels ]
266
269
pairs = [[0 , 1 ], [1 , 2 ], [0 , 2 ]]
267
270
q = [tripts ]
268
271
num = len (nontripts_labels )
269
- gridpts = [[float ((tripts [0 ][0 ]+ tripts [1 ][0 ]+ tripts [2 ][0 ])/ 3 ),
270
- float (tripts [0 ][1 ]+ tripts [1 ][1 ]+ tripts [2 ][1 ])/ 3 ]]
272
+ gridpts = [[float ((tripts [0 ][0 ] + tripts [1 ][0 ] + tripts [2 ][0 ]) / 3 ),
273
+ float (tripts [0 ][1 ] + tripts [1 ][1 ] + tripts [2 ][1 ]) / 3 ]]
271
274
n = 0
272
- while n < num + 1 :
275
+ while n < num + 1 :
273
276
g = trigrid (q [0 ])
274
277
q .extend ([[g [0 ], q [0 ][pairs [0 ][0 ]], q [0 ][pairs [0 ][1 ]]],
275
278
[g [0 ], q [0 ][pairs [1 ][0 ]], q [0 ][pairs [1 ][1 ]]],
@@ -285,7 +288,7 @@ def addnontripts(tripts_labels, nontripts_labels, ptsdict):
285
288
return ptsdict
286
289
287
290
288
- def createline (ptsdict , ll , lineorders2 = None ):
291
+ def createline (ptsdict , ll , lineorders2 = None ) -> tuple [ list , list , list , list ] :
289
292
"""
290
293
Return ordered lists of coordinates of points to be traversed to draw a
291
294
2D line.
@@ -334,7 +337,7 @@ def createline(ptsdict, ll, lineorders2=None):
334
337
335
338
.. NOTE::
336
339
337
- This method does NOT do any checks.
340
+ This method does NOT do any checks.
338
341
"""
339
342
x , lo = line_hasorder (ll , lineorders2 )
340
343
flip = False
@@ -367,7 +370,7 @@ def createline(ptsdict, ll, lineorders2=None):
367
370
return sortedx , sortedy , x_i , y_i
368
371
369
372
370
- def slp (M1 , pos_dict = None , B = None ):
373
+ def slp (M1 , pos_dict = None , B = None ) -> tuple :
371
374
"""
372
375
Return simple matroid, loops and parallel elements of given matroid.
373
376
@@ -413,7 +416,7 @@ def slp(M1, pos_dict=None, B=None):
413
416
414
417
.. NOTE::
415
418
416
- This method does NOT do any checks.
419
+ This method does NOT do any checks.
417
420
"""
418
421
L = set (M1 .loops ())
419
422
nP = L | set (M1 .simplify ().groundset ())
@@ -445,7 +448,7 @@ def slp(M1, pos_dict=None, B=None):
445
448
return [M1 .delete (L | P ), L , P ]
446
449
447
450
448
- def addlp (M , M1 , L , P , ptsdict , G = None , limits = None ):
451
+ def addlp (M , M1 , L , P , ptsdict , G = None , limits = None ) -> tuple :
449
452
"""
450
453
Return a graphics object containing loops (in inset) and parallel elements
451
454
of matroid.
@@ -482,7 +485,7 @@ def addlp(M, M1, L, P, ptsdict, G=None, limits=None):
482
485
483
486
.. NOTE::
484
487
485
- This method does NOT do any checks.
488
+ This method does NOT do any checks.
486
489
"""
487
490
if G is None :
488
491
G = Graphics ()
@@ -551,7 +554,7 @@ def addlp(M, M1, L, P, ptsdict, G=None, limits=None):
551
554
return G , limits
552
555
553
556
554
- def line_hasorder (l , lodrs = None ):
557
+ def line_hasorder (l , lodrs = None ) -> tuple [ bool , list ] :
555
558
"""
556
559
Determine if an order is specified for a line.
557
560
@@ -581,7 +584,7 @@ def line_hasorder(l, lodrs=None):
581
584
582
585
.. NOTE::
583
586
584
- This method does NOT do any checks.
587
+ This method does NOT do any checks.
585
588
"""
586
589
if lodrs is not None :
587
590
set_l = Set (l )
@@ -592,7 +595,7 @@ def line_hasorder(l, lodrs=None):
592
595
return False , []
593
596
594
597
595
- def lineorders_union (lineorders1 , lineorders2 ):
598
+ def lineorders_union (lineorders1 , lineorders2 ) -> list :
596
599
"""
597
600
Return a list of ordered lists of ground set elements that corresponds to
598
601
union of two sets of ordered lists of ground set elements in a sense.
@@ -633,7 +636,7 @@ def lineorders_union(lineorders1, lineorders2):
633
636
return None
634
637
635
638
636
- def posdict_is_sane (M1 , pos_dict ):
639
+ def posdict_is_sane (M1 , pos_dict ) -> bool :
637
640
"""
638
641
Return a boolean establishing sanity of ``posdict`` wrt matroid ``M``.
639
642
@@ -665,8 +668,8 @@ def posdict_is_sane(M1, pos_dict):
665
668
666
669
.. NOTE::
667
670
668
- This method does NOT do any checks. ``M1`` is assumed to be a
669
- matroid and ``posdict`` is assumed to be a dictionary.
671
+ This method does NOT do any checks. ``M1`` is assumed to be a
672
+ matroid and ``posdict`` is assumed to be a dictionary.
670
673
"""
671
674
L = set (M1 .loops ())
672
675
nP = L | set (M1 .simplify ().groundset ())
@@ -683,7 +686,7 @@ def posdict_is_sane(M1, pos_dict):
683
686
for x in list (set (M1 .groundset ()) - (L | set (allP ))))
684
687
685
688
686
- def tracklims (lims , x_i = [], y_i = []):
689
+ def tracklims (lims , x_i = [], y_i = []) -> list :
687
690
"""
688
691
Return modified limits list.
689
692
@@ -704,7 +707,7 @@ def tracklims(lims, x_i=[], y_i=[]):
704
707
705
708
.. NOTE::
706
709
707
- This method does NOT do any checks.
710
+ This method does NOT do any checks.
708
711
"""
709
712
if lims is not None and lims [0 ] is not None and lims [1 ] is not None and \
710
713
lims [2 ] is not None and lims [3 ] is not None :
@@ -752,7 +755,7 @@ def geomrep(M1, B1=None, lineorders1=None, pd=None, sp=False):
752
755
753
756
.. NOTE::
754
757
755
- This method does NOT do any checks.
758
+ This method does NOT do any checks.
756
759
"""
757
760
G = Graphics ()
758
761
# create lists of loops and parallel elements and simplify given matroid
0 commit comments