Skip to content

Commit

Permalink
Replace JuliaTypeInfo by Julia.typeinf
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Dec 12, 2024
1 parent 9038df6 commit e15a66e
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 83 deletions.
4 changes: 2 additions & 2 deletions pkg/JuliaExperimental/gap/numfield.g
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 <x> is not invertible" );
else
# Perhaps the object is invertible:
Expand Down
4 changes: 2 additions & 2 deletions pkg/JuliaExperimental/ipynb/GAPJulia_Singular_blog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
{
"data": {
"text/plain": [
"\"Singular.n_Zn\""
"<Julia: Singular.n_Zn>"
]
},
"execution_count": 4,
Expand All @@ -90,7 +90,7 @@
}
],
"source": [
"JuliaTypeInfo( R(12) );"
"Julia.typeinfo( R(12) );"
]
},
{
Expand Down
64 changes: 32 additions & 32 deletions pkg/JuliaExperimental/tst/context.tst
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ gap> R:= Integers;;
gap> c:= ContextGAPNemo( R );
<context for Integers>
gap> x:= GAPToNemo( c, 1 );;
gap> JuliaTypeInfo( JuliaPointer( x ) );
"Nemo.ZZRingElem"
gap> Julia.typeof( JuliaPointer( x ) );
<Julia: ZZRingElem>
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 ) );
<Julia: ZZMatrix>
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 ) );
<Julia: ZZMatrix>
gap> NemoToGAP( c, mat ) = gap_mat;
true

Expand All @@ -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 ) );
<Julia: zzModRingElem>
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 ) );
<Julia: zzModMatrix>
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 ) );
<Julia: zzModMatrix>
gap> NemoToGAP( c, mat ) = gap_mat;
true

Expand All @@ -87,20 +87,20 @@ gap> c:= ContextGAPNemo( R );
<context for Rationals>
gap> gap_x:= 1/2;;
gap> x:= GAPToNemo( c, gap_x );;
gap> JuliaTypeInfo( JuliaPointer( x ) );
"Nemo.QQFieldElem"
gap> Julia.typeof( JuliaPointer( x ) );
<Julia: QQFieldElem>
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 ) );
<Julia: QQMatrix>
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 ) );
<Julia: QQMatrix>
gap> NemoToGAP( c, mat ) = gap_mat;
true

Expand All @@ -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 ) );
<Julia: QQPolyRingElem>
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 ) );
#<Julia: AbstractAlgebra.Generic.MatSpaceElem{QQPolyRingElem}>
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 ) );
#<Julia: AbstractAlgebra.Generic.MatSpaceElem{QQPolyRingElem}>
gap> NemoToGAP( c, mat ) = gap_mat;
true

Expand All @@ -139,28 +139,28 @@ gap> c:= ContextGAPNemo( f );
<context for alg. ext. field over Rationals, w.r.t. polynomial x_1^2+1>
gap> gap_elm:= One( f );;
gap> elm:= GAPToNemo( c, gap_elm );;
gap> JuliaTypeInfo( JuliaPointer( elm ) );
"Nemo.AbsSimpleNumFieldElem"
gap> Julia.typeof( JuliaPointer( elm ) );
<Julia: AbsSimpleNumFieldElem>
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 ) );
<Julia: AbsSimpleNumFieldElem>
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 ) );
#<Julia: AbstractAlgebra.Generic.MatSpaceElem{AbsSimpleNumFieldElem}>
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 ) );
#<Julia: AbstractAlgebra.Generic.MatSpaceElem{AbsSimpleNumFieldElem}>
gap> NemoToGAP( c, mat ) = gap_mat;
true

Expand Down
12 changes: 6 additions & 6 deletions pkg/JuliaExperimental/tst/numfield.tst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ gap> mat:= [ [ o, a/2 ], [ z, o ] ];
gap> nmat:= GAPToNemo( c, mat );
<<Julia: [1 1//2*a; 0 1]>>

#gap> JuliaTypeInfo( JuliaPointer( nmat ) );
#"AbstractAlgebra.Generic.Mat{Nemo.nf_elem}"
#gap> Julia.typeof( JuliaPointer( nmat ) );
#<Julia: AbstractAlgebra.Generic.MatSpaceElem{AbsSimpleNumFieldElem}>
gap> PrintObj( nmat ); Print( "\n" );
[1 1//2*a; 0 1]
gap> IsZero( nmat );
Expand Down Expand Up @@ -67,12 +67,12 @@ gap> Characteristic( nmat );
0
gap> tr:= TraceMat( nmat );
<<Julia: 2>>
gap> JuliaTypeInfo( JuliaPointer( tr ) );
"Nemo.AbsSimpleNumFieldElem"
gap> Julia.typeof( JuliaPointer( tr ) );
<Julia: AbsSimpleNumFieldElem>
gap> det:= DeterminantMat( nmat );
<<Julia: 1>>
gap> JuliaTypeInfo( JuliaPointer( det ) );
"Nemo.AbsSimpleNumFieldElem"
gap> Julia.typeof( JuliaPointer( det ) );
<Julia: AbsSimpleNumFieldElem>
gap> NemoToGAP( c, nmat );
[ [ !1, 1/2*a ], [ !0, !1 ] ]
gap> no:= GAPToNemo( c, One( f ) );
Expand Down
2 changes: 0 additions & 2 deletions pkg/JuliaExperimental/tst/singular_blog.tst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ gap> R:= Julia.Nemo.residue_ring( Julia.Singular.ZZ, 23 );
<Julia: Residue Ring of Integer Ring modulo 23>
gap> R(12) + R(7);
<Julia: 19>
gap> JuliaTypeInfo( R(12) );
"Singular.n_Zn"
gap> Julia.Base.parent( R(12) );
<Julia: Residue Ring of Integer Ring modulo 23>

Expand Down
23 changes: 4 additions & 19 deletions pkg/JuliaInterface/gap/JuliaInterface.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
#! <A>juliaobj</A>.
#! @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
Expand Down Expand Up @@ -416,10 +401,10 @@ DeclareGlobalFunction( "CallJuliaFunctionWithKeywordArguments" );
#! false
#! gap> val:= smalltype( 1 );
#! <Julia: 1>
#! gap> JuliaTypeInfo( val );
#! "Int32"
#! gap> JuliaTypeInfo( 1 );
#! "Int64"
#! gap> Julia.typeof( val );
#! <Julia: Int32>
#! gap> Julia.typeof( 1 );
#! <Julia: Int64>
#! @EndExampleSession

#! @Subsection Convenience methods for &Julia; objects
Expand Down
10 changes: 0 additions & 10 deletions pkg/JuliaInterface/gap/JuliaInterface.gi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions pkg/JuliaInterface/tst/utils.tst
Original file line number Diff line number Diff line change
@@ -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 := <Julia: 2.0> )
Expand Down

0 comments on commit e15a66e

Please sign in to comment.