File: progress.session

package info (click to toggle)
regina-normal 7.4.1-1.1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 154,244 kB
  • sloc: cpp: 295,026; xml: 9,992; sh: 1,344; python: 1,225; perl: 616; ansic: 138; makefile: 26
file content (57 lines) | stat: -rw-r--r-- 1,937 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
example$ regina-python
Regina 7.0
Software for low-dimensional topology
Copyright (c) 1999-2021, The Regina development team
>>> ################################
>>> #
>>> #  Sample Python Script
>>> #
>>> #  Illustrates progress reporting during long operations.
>>> #
>>> #  See the file "progress.session" for the results of running this script.
>>> #
>>> ################################
>>>
>>> import threading
>>> import time
>>>
>>> # Create an 18-tetrahedron triangulation of a knot complement with real
>>> # boundary faces (not an ideal vertex).  The knot is L106003 from the
>>> # knot/link census.  We used Regina to truncate the ideal vertex, and
>>> # then copied the isomorphism signature so that we can reconstruct the
>>> # triangulation here.
>>> sig = 'sfLfvQvwwMQQQccjghjkmqlonrnrqpqrnsnksaisnrobocksks'
>>> tri = Triangulation3(sig)
>>> print(tri)
Bounded orientable 3-D triangulation, f = ( 1 20 37 18 )
>>>
>>> # Create a progress tracker to use during the normal surface enumeration.
>>> # This will report the state of progress while the enumeration runs in
>>> # the background.
>>> tracker = ProgressTracker()
>>>
>>> # Start the normal surface enumeration in a new thread.
>>> surfaces = None
>>> def run():
...     global surfaces, tracker
...     surfaces = NormalSurfaces(tri, NormalCoords.Standard, NormalList.Vertex,
...         NormalAlg.Default, tracker)
...
>>> thread = threading.Thread(target = run)
>>> thread.start()
>>>
>>> # At this point the enumeration is up and running.
>>> # Output a progress report every quarter-second until it finishes.
>>> while not tracker.isFinished():
...     print('Progress:', tracker.percent(), '%')
...     time.sleep(0.25)
...
Progress: 0.17578125 %
Progress: 54.20654296875 %
Progress: 91.80555555555556 %
>>>
>>> # The surface enumeration is now complete.
>>> thread.join()
>>> print(surfaces)
2319 embedded, vertex surfaces (Standard normal (tri-quad))
>>>