‣ ExportAsQGraphString ( morphism ) | ( function ) |
Returns: a JSON string
Takes a morphism in a category of ZX-diagrams and exports the morphism as a JSON string. This function is only available if the package json
is available. See https://github.com/Quantomatic/quantomatic/blob/stable/docs/json_formats.txt for an overview of the qgraph format.
‣ ExportAsQGraphFile ( morphism, filename ) | ( function ) |
Takes a morphism in a category of ZX-diagrams and a filename file and exports the morphism to file. This function is only available if the package json
is available. See https://github.com/Quantomatic/quantomatic/blob/stable/docs/json_formats.txt for an overview of the qgraph format.
‣ ImportFromQGraphString ( category, string ) | ( function ) |
Returns: a morphism
Takes a category of ZX-diagrams and a JSON string describing a ZX-diagram and imports the ZX-diagram as a morphism. This function is only available if the package json
is available. See https://github.com/Quantomatic/quantomatic/blob/stable/docs/json_formats.txt for an overview of the qgraph format.
‣ ImportFromQGraphFile ( category, filename ) | ( function ) |
Returns: a morphism
Takes a category of ZX-diagrams and a filename file and imports the ZX-diagram in file as a morphism. This function is only available if the package json
is available. See https://github.com/Quantomatic/quantomatic/blob/stable/docs/json_formats.txt for an overview of the qgraph format.
Test ExportAsQGraphFile and ImportFromQGraphFile. Due to reordering during import/export, we have to make some roundtrips until import/export is stable.
gap> LoadPackage( "ZXCalculusForCAP", false ); true gap> ZX; CategoryOfZXDiagrams( ) gap> X_1_2 := X_Spider( 1, 2 ); <A morphism in CategoryOfZXDiagrams( )> gap> IsWellDefinedForMorphisms( X_1_2 ); true gap> Z_2_1 := Z_Spider( 2, 1 ); <A morphism in CategoryOfZXDiagrams( )> gap> IsWellDefinedForMorphisms( Z_2_1 ); true gap> X_1_2_Z_2_1 := PreCompose( X_1_2, Z_2_1 ); <A morphism in CategoryOfZXDiagrams( )> gap> IsWellDefinedForMorphisms( X_1_2_Z_2_1 ); true gap> tmp_dir := DirectoryTemporary( );; gap> ExportAsQGraphFile( X_1_2_Z_2_1, Filename( tmp_dir, "X_1_2_Z_2_1" ) ); gap> reimported := ImportFromQGraphFile( ZX, Filename( tmp_dir, "X_1_2_Z_2_1" ) ); <A morphism in CategoryOfZXDiagrams( )> gap> IsWellDefinedForMorphisms( reimported ); true gap> json := ExportAsQGraphString( X_1_2_Z_2_1 );; gap> mor1 := ImportFromQGraphString( ZX, json );; gap> json2 := ExportAsQGraphString( mor1 );; gap> mor2 := ImportFromQGraphString( ZX, json2 );; gap> json3 := ExportAsQGraphString( mor2 );; gap> mor3 := ImportFromQGraphString( ZX, json3 );; gap> IsEqualForMorphisms( mor2, mor3 ) and json2 = json3; true
generated by GAPDoc2HTML