From ee20cea219e95184367de16ac7cf9e4ce9ac5e98 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 12 Dec 2024 15:17:52 +0100 Subject: [PATCH] Replace JuliaTypeInfo by Julia.typeinf --- pkg/JuliaExperimental/gap/numfield.g | 4 +- .../ipynb/GAPJulia_Singular_blog.ipynb | 4 +- pkg/JuliaExperimental/tst/context.tst | 64 +++++++++---------- pkg/JuliaExperimental/tst/numfield.tst | 12 ++-- pkg/JuliaExperimental/tst/singular_blog.tst | 2 - pkg/JuliaInterface/gap/JuliaInterface.gd | 23 ++----- pkg/JuliaInterface/gap/JuliaInterface.gi | 10 --- pkg/JuliaInterface/tst/utils.tst | 10 --- 8 files changed, 46 insertions(+), 83 deletions(-) diff --git a/pkg/JuliaExperimental/gap/numfield.g b/pkg/JuliaExperimental/gap/numfield.g index 3170b321..16d3e32f 100644 --- a/pkg/JuliaExperimental/gap/numfield.g +++ b/pkg/JuliaExperimental/gap/numfield.g @@ -805,7 +805,7 @@ InstallMethod( Characteristic, local R; R:= ContextGAPNemo( FamilyObj( obj ) )!.JuliaDomain; - if JuliaTypeInfo( R ) = "Nemo.zzModRing" then + if Julia.isa(R, Julia.Nemo.zzModRing) then # We need this for matrix groups over residue class rings. # Nemo does not support it. return JuliaToGAP( IsInt, @@ -866,7 +866,7 @@ InstallOtherMethod( InverseMutable, res:= CallJuliaFunctionWithCatch( Julia.Base.inv, [ ptr ] ); if res.ok then res:= res.value; - elif JuliaTypeInfo( ptr ) <> "Nemo.zzModMatrix" then + elif Julia.isa( ptr, Julia.Nemo.zzModMatrix ) then Error( "matrix is not invertible" ); else # Perhaps the object is invertible: diff --git a/pkg/JuliaExperimental/ipynb/GAPJulia_Singular_blog.ipynb b/pkg/JuliaExperimental/ipynb/GAPJulia_Singular_blog.ipynb index 841200b7..eb180959 100644 --- a/pkg/JuliaExperimental/ipynb/GAPJulia_Singular_blog.ipynb +++ b/pkg/JuliaExperimental/ipynb/GAPJulia_Singular_blog.ipynb @@ -79,7 +79,7 @@ { "data": { "text/plain": [ - "\"Singular.n_Zn\"" + "" ] }, "execution_count": 4, @@ -90,7 +90,7 @@ } ], "source": [ - "JuliaTypeInfo( R(12) );" + "Julia.typeof( R(12) );" ] }, { diff --git a/pkg/JuliaExperimental/tst/context.tst b/pkg/JuliaExperimental/tst/context.tst index 2154d145..9a40eafb 100644 --- a/pkg/JuliaExperimental/tst/context.tst +++ b/pkg/JuliaExperimental/tst/context.tst @@ -35,20 +35,20 @@ gap> R:= Integers;; gap> c:= ContextGAPNemo( R ); gap> x:= GAPToNemo( c, 1 );; -gap> JuliaTypeInfo( JuliaPointer( x ) ); -"Nemo.ZZRingElem" +gap> Julia.typeof( JuliaPointer( x ) ); + gap> NemoToGAP( c, x ) = 1; true gap> gap_vec:= [ 1, 2 ];; gap> vec:= GAPToNemo( c, gap_vec );; -gap> JuliaTypeInfo( JuliaPointer( vec ) ); -"Nemo.ZZMatrix" +gap> Julia.typeof( JuliaPointer( vec ) ); + gap> NemoToGAP( c, vec ) = gap_vec; true gap> gap_mat:= [ [ 1, 2 ], [ 3, 4 ] ];; gap> mat:= GAPToNemo( c, gap_mat );; -gap> JuliaTypeInfo( JuliaPointer( mat ) ); -"Nemo.ZZMatrix" +gap> Julia.typeof( JuliaPointer( mat ) ); + gap> NemoToGAP( c, mat ) = gap_mat; true @@ -60,24 +60,24 @@ gap> gap_x:= One( R );; gap> x:= GAPToNemo( c, gap_x );; gap> x = GAPToNemo( c, 1 ); true -gap> JuliaTypeInfo( JuliaPointer( x ) ); -"Nemo.zzModRingElem" +gap> Julia.typeof( JuliaPointer( x ) ); + gap> NemoToGAP( c, x ) = gap_x; true gap> gap_vec:= [ 1, 2 ] * One( R );; gap> vec:= GAPToNemo( c, gap_vec );; gap> vec = GAPToNemo( c, [ 1, 2 ] ); true -gap> JuliaTypeInfo( JuliaPointer( vec ) ); -"Nemo.zzModMatrix" +gap> Julia.typeof( JuliaPointer( vec ) ); + gap> NemoToGAP( c, vec ) = gap_vec; true gap> gap_mat:= [ [ 1, 2 ], [ 3, 4 ] ] * One( R );; gap> mat:= GAPToNemo( c, gap_mat );; gap> mat = GAPToNemo( c, [ [ 1, 2 ], [ 3, 4 ] ] ); true -gap> JuliaTypeInfo( JuliaPointer( mat ) ); -"Nemo.zzModMatrix" +gap> Julia.typeof( JuliaPointer( mat ) ); + gap> NemoToGAP( c, mat ) = gap_mat; true @@ -87,20 +87,20 @@ gap> c:= ContextGAPNemo( R ); gap> gap_x:= 1/2;; gap> x:= GAPToNemo( c, gap_x );; -gap> JuliaTypeInfo( JuliaPointer( x ) ); -"Nemo.QQFieldElem" +gap> Julia.typeof( JuliaPointer( x ) ); + gap> NemoToGAP( c, x ) = gap_x; true gap> gap_vec:= [ 1/2, 2 ];; gap> vec:= GAPToNemo( c, gap_vec );; -gap> JuliaTypeInfo( JuliaPointer( vec ) ); -"Nemo.QQMatrix" +gap> Julia.typeof( JuliaPointer( vec ) ); + gap> NemoToGAP( c, vec ) = gap_vec; true gap> gap_mat:= [ [ 1/2, 2 ], [ 3, 4/3 ] ];; gap> mat:= GAPToNemo( c, gap_mat );; -gap> JuliaTypeInfo( JuliaPointer( mat ) ); -"Nemo.QQMatrix" +gap> Julia.typeof( JuliaPointer( mat ) ); + gap> NemoToGAP( c, mat ) = gap_mat; true @@ -113,22 +113,22 @@ gap> indets:= IndeterminatesOfPolynomialRing( R );; gap> x:= indets[1];; gap> gap_pol:= x^3 + x + 1;; gap> pol:= GAPToNemo( c, gap_pol );; -gap> JuliaTypeInfo( JuliaPointer( pol ) ); -"Nemo.QQPolyRingElem" +gap> Julia.typeof( JuliaPointer( pol ) ); + gap> NemoToGAP( c, pol ) = gap_pol; true gap> gap_vec:= [ x+1, x-1 ];; gap> vec:= GAPToNemo( c, gap_vec );; -#gap> JuliaTypeInfo( JuliaPointer( vec ) ); -#"AbstractAlgebra.Generic.Mat{Nemo.QQPolyRingElem}" +#gap> Julia.typeof( JuliaPointer( vec ) ); +# gap> NemoToGAP( c, vec ) = gap_vec; true gap> gap_mat:= [ [ x, x+1 ], [ 2*x, x^2+1 ] ];; gap> mat:= GAPToNemo( c, gap_mat );; -#gap> JuliaTypeInfo( JuliaPointer( mat ) ); -#"AbstractAlgebra.Generic.Mat{Nemo.QQPolyRingElem}" +#gap> Julia.typeof( JuliaPointer( mat ) ); +# gap> NemoToGAP( c, mat ) = gap_mat; true @@ -139,28 +139,28 @@ gap> c:= ContextGAPNemo( f ); gap> gap_elm:= One( f );; gap> elm:= GAPToNemo( c, gap_elm );; -gap> JuliaTypeInfo( JuliaPointer( elm ) ); -"Nemo.AbsSimpleNumFieldElem" +gap> Julia.typeof( JuliaPointer( elm ) ); + gap> NemoToGAP( c, elm ) = gap_elm; true gap> a:= RootOfDefiningPolynomial( f );; gap> elm:= GAPToNemo( c, a );; -gap> JuliaTypeInfo( JuliaPointer( elm ) ); -"Nemo.AbsSimpleNumFieldElem" +gap> Julia.typeof( JuliaPointer( elm ) ); + gap> NemoToGAP( c, elm ) = a; true gap> gap_vec:= [ a+1, a-1 ];; gap> vec:= GAPToNemo( c, gap_vec );; -#gap> JuliaTypeInfo( JuliaPointer( vec ) ); -#"AbstractAlgebra.Generic.Mat{Nemo.nf_elem}" +#gap> Julia.typeof( JuliaPointer( vec ) ); +# gap> NemoToGAP( c, vec ) = gap_vec; true gap> gap_mat:= [ [ a, a+1 ], [ 2*a, a^2+1 ] ];; gap> mat:= GAPToNemo( c, gap_mat );; -#gap> JuliaTypeInfo( JuliaPointer( mat ) ); -#"AbstractAlgebra.Generic.Mat{Nemo.nf_elem}" +#gap> Julia.typeof( JuliaPointer( mat ) ); +# gap> NemoToGAP( c, mat ) = gap_mat; true diff --git a/pkg/JuliaExperimental/tst/numfield.tst b/pkg/JuliaExperimental/tst/numfield.tst index 661f23f9..9797af0e 100644 --- a/pkg/JuliaExperimental/tst/numfield.tst +++ b/pkg/JuliaExperimental/tst/numfield.tst @@ -19,8 +19,8 @@ gap> mat:= [ [ o, a/2 ], [ z, o ] ]; gap> nmat:= GAPToNemo( c, mat ); <> -#gap> JuliaTypeInfo( JuliaPointer( nmat ) ); -#"AbstractAlgebra.Generic.Mat{Nemo.nf_elem}" +#gap> Julia.typeof( JuliaPointer( nmat ) ); +# gap> PrintObj( nmat ); Print( "\n" ); [1 1//2*a; 0 1] gap> IsZero( nmat ); @@ -67,12 +67,12 @@ gap> Characteristic( nmat ); 0 gap> tr:= TraceMat( nmat ); <> -gap> JuliaTypeInfo( JuliaPointer( tr ) ); -"Nemo.AbsSimpleNumFieldElem" +gap> Julia.typeof( JuliaPointer( tr ) ); + gap> det:= DeterminantMat( nmat ); <> -gap> JuliaTypeInfo( JuliaPointer( det ) ); -"Nemo.AbsSimpleNumFieldElem" +gap> Julia.typeof( JuliaPointer( det ) ); + gap> NemoToGAP( c, nmat ); [ [ !1, 1/2*a ], [ !0, !1 ] ] gap> no:= GAPToNemo( c, One( f ) ); diff --git a/pkg/JuliaExperimental/tst/singular_blog.tst b/pkg/JuliaExperimental/tst/singular_blog.tst index e209905f..05a48429 100644 --- a/pkg/JuliaExperimental/tst/singular_blog.tst +++ b/pkg/JuliaExperimental/tst/singular_blog.tst @@ -19,8 +19,6 @@ gap> R:= Julia.Nemo.residue_ring( Julia.Singular.ZZ, 23 ); gap> R(12) + R(7); -gap> JuliaTypeInfo( R(12) ); -"Singular.n_Zn" gap> Julia.Base.parent( R(12) ); diff --git a/pkg/JuliaInterface/gap/JuliaInterface.gd b/pkg/JuliaInterface/gap/JuliaInterface.gd index d1b2f44e..3fa67fdb 100644 --- a/pkg/JuliaInterface/gap/JuliaInterface.gd +++ b/pkg/JuliaInterface/gap/JuliaInterface.gd @@ -276,21 +276,6 @@ DeclareGlobalFunction( "JuliaImportPackage" ); #! @EndExampleSession DeclareGlobalVariable( "Julia" ); -#! @Arguments juliaobj -#! @Returns a string. -#! @Description -#! Returns the string that describes the &Julia; type of the object -#! juliaobj. -#! @BeginExampleSession -#! gap> JuliaTypeInfo( Julia.GAP ); -#! "Module" -#! gap> JuliaTypeInfo( Julia.sqrt(2) ); -#! "Float64" -#! gap> JuliaTypeInfo( 1 ); -#! "Int64" -#! @EndExampleSession -DeclareGlobalFunction( "JuliaTypeInfo" ); - #! @Arguments juliafunc, arguments[, kwargs] #! @Returns a record. #! @Description @@ -416,10 +401,10 @@ DeclareGlobalFunction( "CallJuliaFunctionWithKeywordArguments" ); #! false #! gap> val:= smalltype( 1 ); #! -#! gap> JuliaTypeInfo( val ); -#! "Int32" -#! gap> JuliaTypeInfo( 1 ); -#! "Int64" +#! gap> Julia.typeof( val ); +#! +#! gap> Julia.typeof( 1 ); +#! #! @EndExampleSession #! @Subsection Convenience methods for &Julia; objects diff --git a/pkg/JuliaInterface/gap/JuliaInterface.gi b/pkg/JuliaInterface/gap/JuliaInterface.gi index 2d7b68a6..a395fe4f 100644 --- a/pkg/JuliaInterface/gap/JuliaInterface.gi +++ b/pkg/JuliaInterface/gap/JuliaInterface.gi @@ -142,16 +142,6 @@ InstallGlobalFunction( JuliaImportPackage, function( pkgname ) end ); -InstallGlobalFunction( JuliaTypeInfo, - function( juliaobj ) - if IsFunction( juliaobj ) then - juliaobj:= Julia.GAP.UnwrapJuliaFunc( juliaobj ); - fi; - return JuliaToGAP( IsString, - Julia.Base.string( Julia.Core.typeof( juliaobj ) ) ); -end ); - - InstallGlobalFunction( GetJuliaScratchspace, function( key ) if not IsString( key ) then diff --git a/pkg/JuliaInterface/tst/utils.tst b/pkg/JuliaInterface/tst/utils.tst index 612a02b7..29386bca 100644 --- a/pkg/JuliaInterface/tst/utils.tst +++ b/pkg/JuliaInterface/tst/utils.tst @@ -1,16 +1,6 @@ ## gap> START_TEST( "utils.tst" ); -## -gap> JuliaTypeInfo( 1 ); -"Int64" -gap> JuliaTypeInfo( 0 ); -"Int64" -gap> JuliaTypeInfo( GAPToJulia( JuliaEvalString( "Tuple{Int64, Int64, Int64}" ), [ 1, 2, 3 ] ) ); -"Tuple{Int64, Int64, Int64}" -gap> JuliaTypeInfo( Julia.Base.parse ); -"typeof(parse)" - ## gap> CallJuliaFunctionWithCatch( Julia.Base.sqrt, [ 4 ] ); rec( ok := true, value := )