Skip to content

Commit 9a7c93d

Browse files
authored
Merge pull request #5 from kamalsaleh/master
Adjust the output of `AsCythonFunction` & add tests
2 parents e171462 + 466d606 commit 9a7c93d

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

PackageInfo.g

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SetPackageInfo( rec(
1010

1111
PackageName := "MachineLearningForCAP",
1212
Subtitle := "Exploring categorical machine learning in CAP",
13-
Version := "2024.07-12",
13+
Version := "2024.07-13",
1414
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)( ),
1515
License := "GPL-2.0-or-later",
1616

examples/Expressions.g

+14
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ LazyDiff( e, 1 )( dummy_input );;
6767
# "(((Sin(x1))/(Cos(x1)))+((Sin(x2))^(2)))+((Cos(x2))^(2))", 1 )( [ x1, x2, x3 ] );
6868
JacobianMatrixUsingPython( [ x1*Cos(x2)+Exp(x3), x1*x2*x3 ], [ 1, 2, 3 ] );
6969
#! [ [ "Cos(x2)", "-x1*Sin(x2)", "Exp(x3)" ], [ "x2*x3", "x1*x3", "x1*x2" ] ]
70+
JacobianMatrix( [ "x1", "x2", "x3" ], [ "x1*Cos(x2)+Exp(x3)", "x1*x2*x3" ],
71+
[ 1, 2, 3 ] )(dummy_input);
72+
#! [ [ Cos(x2), (-x1)*Sin(x2), Exp(x3) ], [ x2*x3, x1*x3, x1*x2 ] ]
7073
LaTeXOutputUsingPython( e );
7174
#! "\\frac{\\sin{\\left(x_{1} \\right)}}{\\cos{\\left(x_{1} \\right)}}
7275
#! + \\sin^{2}{\\left(x_{2} \\right)} + \\cos^{2}{\\left(x_{2} \\right)}"
@@ -93,4 +96,15 @@ labels := List( points, point -> SelectBasedOnCondition( point[2] < 0.5, 0, 1 )
9396
#! 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
9497
ScatterPlotUsingPython( points, labels : size := "100", action := "save" );;
9598
# e.g, dir("/tmp/gaptempdirX7Qsal/")
99+
AsCythonFunction( [ [ "x", "y" ], [ "z" ] ], [ "f", "g" ], [ "x*y", "Sin(z)" ] );;
100+
# e.g.,
101+
# cd /tmp/gaptempdirI6rq3l/
102+
#
103+
# start python!
104+
#
105+
# from cython_functions import f, g;
106+
#
107+
# # w = [ 2 entries :) ]
108+
#
109+
# # f(w)
96110
#! @EndExample

gap/Tools.gi

+2-2
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,8 @@ InstallMethod( AsCythonFunction,
690690

691691
fi;
692692

693-
Print(
694-
Concatenation( "cd ", Filename( dir, "" ), "\n\n" ),
693+
return
694+
Concatenation( "cd ", Filename( dir, "" ), "\n\n",
695695
"start python!\n\n",
696696
"from cython_functions import ",
697697
JoinStringsWithSeparator( function_names, ", " ),

0 commit comments

Comments
 (0)