Skip to content

Commit

Permalink
Merge pull request #5 from kamalsaleh/master
Browse files Browse the repository at this point in the history
Adjust the output of  `AsCythonFunction` & add tests
  • Loading branch information
kamalsaleh authored Jul 11, 2024
2 parents e171462 + 466d606 commit 9a7c93d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "MachineLearningForCAP",
Subtitle := "Exploring categorical machine learning in CAP",
Version := "2024.07-12",
Version := "2024.07-13",
Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ),
License := "GPL-2.0-or-later",

Expand Down
14 changes: 14 additions & 0 deletions examples/Expressions.g
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ LazyDiff( e, 1 )( dummy_input );;
# "(((Sin(x1))/(Cos(x1)))+((Sin(x2))^(2)))+((Cos(x2))^(2))", 1 )( [ x1, x2, x3 ] );
JacobianMatrixUsingPython( [ x1*Cos(x2)+Exp(x3), x1*x2*x3 ], [ 1, 2, 3 ] );
#! [ [ "Cos(x2)", "-x1*Sin(x2)", "Exp(x3)" ], [ "x2*x3", "x1*x3", "x1*x2" ] ]
JacobianMatrix( [ "x1", "x2", "x3" ], [ "x1*Cos(x2)+Exp(x3)", "x1*x2*x3" ],
[ 1, 2, 3 ] )(dummy_input);
#! [ [ Cos(x2), (-x1)*Sin(x2), Exp(x3) ], [ x2*x3, x1*x3, x1*x2 ] ]
LaTeXOutputUsingPython( e );
#! "\\frac{\\sin{\\left(x_{1} \\right)}}{\\cos{\\left(x_{1} \\right)}}
#! + \\sin^{2}{\\left(x_{2} \\right)} + \\cos^{2}{\\left(x_{2} \\right)}"
Expand All @@ -93,4 +96,15 @@ labels := List( points, point -> SelectBasedOnCondition( point[2] < 0.5, 0, 1 )
#! 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ScatterPlotUsingPython( points, labels : size := "100", action := "save" );;
# e.g, dir("/tmp/gaptempdirX7Qsal/")
AsCythonFunction( [ [ "x", "y" ], [ "z" ] ], [ "f", "g" ], [ "x*y", "Sin(z)" ] );;
# e.g.,
# cd /tmp/gaptempdirI6rq3l/
#
# start python!
#
# from cython_functions import f, g;
#
# # w = [ 2 entries :) ]
#
# # f(w)
#! @EndExample
4 changes: 2 additions & 2 deletions gap/Tools.gi
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,8 @@ InstallMethod( AsCythonFunction,

fi;

Print(
Concatenation( "cd ", Filename( dir, "" ), "\n\n" ),
return
Concatenation( "cd ", Filename( dir, "" ), "\n\n",
"start python!\n\n",
"from cython_functions import ",
JoinStringsWithSeparator( function_names, ", " ),
Expand Down

0 comments on commit 9a7c93d

Please sign in to comment.