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
|
################################
#
# Sample Python Script
#
# Illustrates progress reporting during long operations.
#
# See the file "progress.session" for the results of running this script.
#
################################
import time
# Create a new triangulation of the lens space L(49,12).
tri = regina.NTriangulation()
tri.insertLayeredLensSpace(49,12)
print tri.getNumberOfTetrahedra(), 'tetrahedra'
# Create a progress manager to use during the lengthy surface enumeration.
# This will be responsible for reporting the state of progress while the
# enumeration runs in the background.
manager = regina.NProgressManager()
# Start the normal surface enumeration.
# Because we are passing a progress manager to enumerate(), the
# enumeration will be started in the background and control will be
# returned immediately to the python console.
surfaces = regina.NNormalSurfaceList.enumerate(tri,
regina.NNormalSurfaceList.STANDARD, 1, manager)
# Wait for the surface enumeration to fully start up.
while not manager.isStarted():
time.sleep(1)
# At this point the surface enumeration is now running.
# Output a progress report every second until it's finished.
prog = manager.getProgress()
while not manager.isFinished():
print 'Progress:', prog.getDescription()
time.sleep(1)
# The surface enumeration is now complete.
print surfaces.getNumberOfSurfaces(), 'normal surfaces'
# Output the total time spent during the surface enumeration.
print 'Total real time:', prog.getRealTime(), 'seconds'
print 'Total cpu time:', prog.totalCPUTime(), 'seconds'
|