~ubuntu-branches/ubuntu/vivid/regina-normal/vivid

« back to all changes in this revision

Viewing changes to qtui/doc/regina/python.docbook

  • Committer: Package Import Robot
  • Author(s): Ben Burton
  • Date: 2014-08-29 17:37:46 UTC
  • mfrom: (19.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140829173746-igmqc9b67y366a7u
Tags: 4.96-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
    variables for you:
66
66
    <glosslist>
67
67
     <glossentry>
68
 
      <glossterm><varname>root</varname></glossterm>
69
 
      <glossdef><para>
70
 
       The variable <varname>root</varname> will refer to the packet
71
 
       at the top of your packet tree.
72
 
      </para></glossdef>
73
 
     </glossentry>
74
 
     <glossentry>
75
68
      <glossterm><varname>item</varname></glossterm>
76
69
      <glossdef>
77
70
       <para>
86
79
       </para>
87
80
      </glossdef>
88
81
     </glossentry>
 
82
     <glossentry>
 
83
      <glossterm><varname>root</varname></glossterm>
 
84
      <glossdef><para>
 
85
       The variable <varname>root</varname> will refer to the hidden
 
86
       root at the top of your packet tree (this root is not visible in the
 
87
       user interface, but its top-level children are).
 
88
      </para></glossdef>
 
89
     </glossentry>
89
90
    </glosslist>
90
91
   </para>
91
92
   <para>
196
197
   module called <parameter>regina</parameter>.
197
198
   For instance, the main 3-manifold triangulation class is
198
199
   <literal>regina.NTriangulation</literal>, and the main routine to
199
 
   read a data file is <literal>regina.readFileMagic</literal>.
 
200
   read a data file is <literal>regina.open</literal>.
200
201
  </para>
201
202
  <para>
202
203
   Whenever &regina; gives you access to &python; (either through a
212
213
  <para>
213
214
   This means, for instance, that you create a new triangulation by just
214
215
   calling <literal>NTriangulation()</literal>, and you can read a data file
215
 
   by calling <literal>readFileMagic(filename)</literal>.
 
216
   by calling <literal>open(filename)</literal>.
216
217
   For command-line sessions, if you wish to avoid the heavy-handed
217
218
   &ldquo;<literal>from regina import&nbsp;*</literal>&rdquo;, you can pass
218
219
   the option <option>--noautoimport</option> (in which case you will need to
219
220
   use fully qualified names such as
220
221
   <literal>regina.NTriangulation()</literal> and
221
 
   <literal>regina.readFileMagic(filename)</literal>).
 
222
   <literal>regina.open(filename)</literal>).
222
223
  </para>
223
224
  <tip>
224
225
   <para>
429
430
  </para>
430
431
  <para>
431
432
   Simply type <userinput>import snappy</userinput> from within any of
432
 
   &regina;'s &python; environments.  You can use
433
 
   &regina;'s functions
434
 
   <function>NTriangulation.snapPea()</function> and
435
 
   <function>NTriangulation()</function>
436
 
   to get information out of and into
437
 
   &regina; as strings, and you can hook these up to &snappy;'s functions
438
 
   <function>Manifold()</function> and
439
 
   <function>Manifold._to_string()</function> at the other end.
440
 
   See the example below.
 
433
   &regina;'s &python; environments.  To send information back and forth
 
434
   between &regina; and &snappy;:
 
435
   <itemizedlist>
 
436
    <listitem><para>
 
437
     &regina;'s triangulation classes
 
438
     <classname>NTriangulation</classname> and
 
439
     <classname>NSnapPeaTriangulation</classname> both have a
 
440
     <function>snapPea()</function> function, which gives a string that
 
441
     you can pass to &snappy;'s <classname>Manifold</classname> constructor.
 
442
    </para></listitem>
 
443
    <listitem><para>
 
444
     &snappy;'s <classname>Manifold</classname> class has a
 
445
     <function>_to_string()</function> function, which gives a string
 
446
     that you can pass to &regina;'s
 
447
     <classname>NTriangulation</classname> or
 
448
     <classname>NSnapPeaTriangulation</classname> constructor.
 
449
    </para></listitem>
 
450
   </itemizedlist>
 
451
  </para>
 
452
  <para>
 
453
   Regarding fillings and peripheral curves:
 
454
   &regina; does not store fillings or peripheral curves for its own native
 
455
   <link linkend="packet-triangulation">triangulation packets</link>,
 
456
   as represented by the <classname>NTriangulation</classname> class.
 
457
   However, it does store fillings and peripheral curves for its hybrid
 
458
   <link linkend="packet-snappea">&snappea; triangulation packets</link>,
 
459
   as represented by the <classname>NSnapPeaTriangulation</classname> class.
 
460
   The trade-off is that the native <classname>NTriangulation</classname>
 
461
   class offers &regina;'s full fine-grained control over the triangulation,
 
462
   whereas the hybrid <classname>NSnapPeaTriangulation</classname> class
 
463
   has a more limited (largely read-only) interface.
 
464
   <itemizedlist>
 
465
    <listitem><para>
 
466
     When sending data from &regina; to &snappy;,
 
467
     if your triangulation is of the class
 
468
     <classname>NTriangulation</classname>,
 
469
     then <function>NTriangulation.snapPea()</function> will
 
470
     create a &snappy; manifold in which all fillings and peripheral
 
471
     curves are marked as unknown.
 
472
     If your triangulation is of the class
 
473
     <classname>NSnapPeaTriangulation</classname>,
 
474
     and if you already have fillings and peripheral curves stored on
 
475
     each cusp, then <function>NSnapPeaTriangulation.snapPea()</function> will
 
476
     create a &snappy; manifold that preserves these.
 
477
    </para></listitem>
 
478
    <listitem><para>
 
479
     Conversely, when sending data from &snappy; to &regina;, you
 
480
     can choose to instantiate a triangulation using either the
 
481
     <classname>NTriangulation</classname> class or the
 
482
     <classname>NSnapPeaTriangulation</classname> class.
 
483
     If you use the <classname>NTriangulation</classname> class then all
 
484
     fillings and peripheral curves will be lost.
 
485
     If you use the <classname>NSnapPeaTriangulation</classname> class then
 
486
     fillings and peripheral curves will be preserved (but your interface
 
487
     will be more restricted).
 
488
    </para></listitem>
 
489
   </itemizedlist>
 
490
  </para>
 
491
  <para>
 
492
   Regarding the interface:
 
493
   the <classname>NSnapPeaTriangulation</classname> class
 
494
   inherits from <classname>NTriangulation</classname>, and so you can
 
495
   use it anywhere that a read-only triangulation is expected (in particular,
 
496
   you can use it for enumerating vertex normal surfaces or angle structures).
 
497
   However, because <classname>NSnapPeaTriangulation</classname> must
 
498
   maintain two synchronised copies of the triangulation (&regina;'s and
 
499
   &snappea;'s), it is essentially read-only: any attempt to modify the
 
500
   triangulation using &regina;'s native routines (e.g.,
 
501
   <function>twoThreeMove()</function> or
 
502
   <function>barycentricSubdivision()</function>) will cause the
 
503
   &snappea; triangulation to delete itself and become a
 
504
   &ldquo;null triangulation&rdquo; instead.
441
505
  </para>
442
506
  <warning><para>
443
507
   At present, &snappy; (version&nbsp;2.0.3) is not compatible with
447
511
   See <link linkend="trouble-python-snappy">this troubleshooting entry</link>
448
512
   for details.
449
513
  </para></warning>
 
514
  <para>
 
515
   The following &python; session illustrates several of the concepts
 
516
   discussed above.
 
517
  </para>
450
518
  <programlisting>
451
519
bab@ember:~$ regina-python 
452
 
Regina 4.95
 
520
Regina 4.96
453
521
Software for 3-manifold topology and normal surface theory
454
522
Copyright (c) 1999-2013, The Regina development team
455
523
&gt;&gt;&gt; import snappy
456
524
&gt;&gt;&gt; m = snappy.Manifold('m001')
457
 
&gt;&gt;&gt; t = NTriangulation(m._to_string())
 
525
&gt;&gt;&gt; t = NSnapPeaTriangulation(m._to_string())
458
526
&gt;&gt;&gt; print t.detail()
459
527
Size of the skeleton:
460
528
  Tetrahedra: 2
486
554
    0  |           0   1   2   3
487
555
    1  |           2   0   1   3
488
556
 
 
557
Tetrahedron shapes:
 
558
  0: ( -1.60812e-16, 1 )
 
559
  1: ( -1.60812e-16, 1 )
 
560
 
 
561
Cusps:
 
562
  0: Vertex 0, complete
 
563
 
 
564
&gt;&gt;&gt; print t.hasStrictAngleStructure()
 
565
True
 
566
&gt;&gt;&gt; print NAngleStructureList.enumerate(t).detail()
 
567
4 vertex angle structures (no restrictions):
 
568
0 1 0 ; 1 0 0
 
569
0 0 1 ; 1 0 0
 
570
1 0 0 ; 0 1 0
 
571
1 0 0 ; 0 0 1
489
572
 
490
573
&gt;&gt;&gt; t2 = NExampleTriangulation.figureEightKnotComplement()
491
574
&gt;&gt;&gt; m2 = snappy.Manifold(t2.snapPea())