Skip to content

Commit

Permalink
Remove JuliaModule
Browse files Browse the repository at this point in the history
We didn't use it and JuliaModule("bla") can simply be replaced by Julia.bla
  • Loading branch information
fingolfin committed Sep 19, 2024
1 parent 785a93a commit f000bca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 47 deletions.
37 changes: 16 additions & 21 deletions pkg/JuliaInterface/gap/JuliaInterface.gd
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@
#! The result is <K>true</K> if and only if <A>obj</A> is a pointer to a
#! &Julia; object.
#!
#! The results of <Ref Func="JuliaModule"/> are always in
#! <Ref Filt="IsJuliaObject" Label="for IsObject"/>.
#! @BeginExampleSession
#! gap> julia_fun:= JuliaEvalString( "sqrt" );
#! <Julia: sqrt>
Expand All @@ -107,12 +105,22 @@
#! <Julia: 1.4142135623730951>
#! gap> IsJuliaObject( julia_val );
#! true
#! gap> julia_x:= JuliaEvalString( "x = 4" );
#! @EndExampleSession
#! However not every object living on the Julia side is in this filter.
#! For example Julia booleans and small <C>Int</C> values are directly
#! translated to GAP booleans and small integers, while for Julia functions
#! and wrappers dedicated wrappers are used for improved efficiency
#! respectively additional features.
#! @BeginExampleSession
#! gap> JuliaEvalString( "x = 4;" );;
#@ gap> Julia.x;
#! 4
#! gap> IsJuliaObject( julia_x );
#! gap> IsJuliaObject( Julia.x );
#! false
#! gap> IsJuliaObject( Julia.sqrt );
#! false
#! gap> IsJuliaObject( Julia.Main );
#! false
#! gap> IsJuliaObject( JuliaModule( "Main" ) );
#! true
#! @EndExampleSession
DeclareCategory( "IsJuliaObject", IsObject );

Expand All @@ -136,8 +144,8 @@ BindGlobal("TheTypeJuliaObject", NewType( JuliaObjectFamily, IsJuliaObject ));
#! should <E>not</E> be in the filter
#! <Ref Filt="IsJuliaObject" Label="for IsObject"/>.
#!
#! Examples of objects in <Ref Filt="IsJuliaWrapper" Label="for IsObject"/>
#! are the return values of <Ref Func="JuliaModule"/>.
#! For example, any Julia modules such as <C>Julia.Base</C> are
#! in the filter <Ref Filt="IsJuliaWrapper" Label="for IsObject"/>.
DeclareCategory( "IsJuliaWrapper", IsObject );

#! @Arguments obj
Expand Down Expand Up @@ -301,19 +309,6 @@ DeclareGlobalFunction( "JuliaFunction" );
#! @EndExampleSession
DeclareGlobalVariable( "Julia" );

#! @Arguments name
#! @Returns a &Julia; object
#! @Description
#! Returns the &Julia; object that points to the &Julia; module
#! with name <A>name</A>.
#! @BeginExampleSession
#! gap> gapmodule:= JuliaModule( "GAP" );
#! <Julia: GAP>
#! gap> gapmodule = JuliaPointer( Julia.GAP );
#! true
#! @EndExampleSession
DeclareGlobalFunction( "JuliaModule" );

#! @Arguments juliaobj
#! @Returns a string.
#! @Description
Expand Down
15 changes: 0 additions & 15 deletions pkg/JuliaInterface/gap/JuliaInterface.gi
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,6 @@ InstallGlobalFunction( JuliaTypeInfo,
end );


InstallGlobalFunction( JuliaModule,
function( name )
if not IsString( name ) then
Error( "JuliaModule: <name> must be a string" );
fi;
if not IsBound( Julia.(name) ) then
Error( "JuliaModule: Module <name> does not exist, did you import it?" );
fi;
if not IsJuliaModule( Julia.(name) ) then
Error( "JuliaModule: <name> is not a module" );
fi;
return JuliaPointer( Julia.(name) );
end );


InstallGlobalFunction( GetJuliaScratchspace,
function( key )
if not IsString( key ) then
Expand Down
12 changes: 1 addition & 11 deletions pkg/JuliaInterface/tst/utils.tst
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ gap> JuliaSymbol("");
gap> JuliaSymbol(1);
Error, JuliaSymbol: <name> must be a string (not the integer 1)

##
gap> JuliaModule("Base");
<Julia: Base>
gap> JuliaModule("This_Module_Does_Not_Exist");
Error, JuliaModule: Module <name> does not exist, did you import it?
gap> JuliaModule(1);
Error, JuliaModule: <name> must be a string
gap> JuliaModule( "sqrt" );
Error, JuliaModule: <name> is not a module

##
gap> _JuliaGetGlobalVariable(0);
Error, _JuliaGetGlobalVariable: <name> must be a string (not the integer 0)
Expand All @@ -74,7 +64,7 @@ gap> _JuliaGetGlobalVariableByModule("Base","sqrt");
Error, sqrt is not a module
gap> _JuliaGetGlobalVariableByModule("sqrt","Base");
<Julia: sqrt>
gap> _JuliaGetGlobalVariableByModule("sqrt", JuliaModule("Base"));
gap> _JuliaGetGlobalVariableByModule("sqrt", JuliaPointer(Julia.Base));
<Julia: sqrt>

##
Expand Down

0 comments on commit f000bca

Please sign in to comment.