Changeset: 20d2da35fa91 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=20d2da35fa91
Modified Files:
        sql/backends/monet5/Tests/pyapi25.sql
        sql/backends/monet5/Tests/pyapi25.stable.err
        sql/backends/monet5/Tests/pyapi25.stable.out
Branch: pythonudf
Log Message:

Fix pyapi25 so the testoutput does not depend on the amount of threads of 
mserver.


diffs (130 lines):

diff --git a/sql/backends/monet5/Tests/pyapi25.sql 
b/sql/backends/monet5/Tests/pyapi25.sql
--- a/sql/backends/monet5/Tests/pyapi25.sql
+++ b/sql/backends/monet5/Tests/pyapi25.sql
@@ -51,7 +51,6 @@ SELECT * FROM mytable; # 10000, 20000, 3
 
 # store stuff in a parallel query
 # we compute the mean in parallel, then store the mean of every thread in the 
table
-# I should probably find a way to force mtest to run with 8 threads, because 
the result will differ on machines without exactly 8 cores
 CREATE TABLE pyapi25medians(mean DOUBLE);
 
 CREATE FUNCTION pyapi25randomtable() returns TABLE(d DOUBLE) LANGUAGE PYTHON
@@ -64,14 +63,28 @@ CREATE FUNCTION pyapi25mediancompute(d D
 language PYTHON_MAP
 {
     mean = numpy.mean(d)
-    _conn.execute('INSERT INTO pyapi25medians (mean) VALUES (' + str(mean) + 
');')
+    _conn.execute('INSERT INTO pyapi25medians (mean) VALUES (%g);' % mean)
     return 1
 };
 
+# to verify that the output is correct, we check if the mean stored in 
pyapi25medians is within an epsilon of the actual mean of the data
+CREATE FUNCTION pyapi25checker(d DOUBLE) RETURNS BOOL LANGUAGE PYTHON {
+    actual_mean = numpy.mean(d)
+    numpy.random.seed(33)
+    expected_mean = numpy.mean(numpy.random.rand(1000000))
+    if numpy.abs(expected_mean - actual_mean) < 0.1:
+        print("Great success!")
+        return(True)
+    else:
+        print("Incorrect mean %g: expected %g" % (actual_mean, expected_mean))
+        print("Values:", d)
+        return(False)
+};
+
 CREATE TABLE randomtable AS SELECT * FROM pyapi25randomtable() WITH DATA;
 
 SELECT pyapi25mediancompute(d) FROM randomtable;
-SELECT * FROM pyapi25medians ORDER BY mean;
+SELECT pyapi25checker(mean) FROM pyapi25medians;
 
 # test error in parallel SQL query
 
diff --git a/sql/backends/monet5/Tests/pyapi25.stable.err 
b/sql/backends/monet5/Tests/pyapi25.stable.err
--- a/sql/backends/monet5/Tests/pyapi25.stable.err
+++ b/sql/backends/monet5/Tests/pyapi25.stable.err
@@ -31,7 +31,7 @@ stderr of test 'pyapi25` in directory 's
 # 12:40:00 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-21450" "--port=30737"
 # 12:40:00 >  
 
-MAPI  = (monetdb) /var/tmp/mtest-22812/.s.monetdb.39136
+MAPI  = (monetdb) /var/tmp/mtest-14818/.s.monetdb.37353
 QUERY = SELECT * FROM pyapi25errortable();
 ERROR = !SELECT: no such table 'hopefullynonexistanttable'
         !SELECT: no such table 'hopefullynonexistanttable'
diff --git a/sql/backends/monet5/Tests/pyapi25.stable.out 
b/sql/backends/monet5/Tests/pyapi25.stable.out
--- a/sql/backends/monet5/Tests/pyapi25.stable.out
+++ b/sql/backends/monet5/Tests/pyapi25.stable.out
@@ -22,6 +22,46 @@ stdout of test 'pyapi25` in directory 's
 # MonetDB/R   module loaded
 
 Ready.
+# SQL catalog created, loading sql scripts once
+# loading sql script: 09_like.sql
+# loading sql script: 10_math.sql
+# loading sql script: 11_times.sql
+# loading sql script: 12_url.sql
+# loading sql script: 13_date.sql
+# loading sql script: 14_inet.sql
+# loading sql script: 15_querylog.sql
+# loading sql script: 16_tracelog.sql
+# loading sql script: 17_temporal.sql
+# loading sql script: 20_vacuum.sql
+# loading sql script: 21_dependency_functions.sql
+# loading sql script: 22_clients.sql
+# loading sql script: 23_skyserver.sql
+# loading sql script: 24_zorder.sql
+# loading sql script: 25_debug.sql
+# loading sql script: 26_sysmon.sql
+# loading sql script: 27_rejects.sql
+# loading sql script: 39_analytics.sql
+# loading sql script: 39_analytics_hge.sql
+# loading sql script: 40_geom.sql
+# loading sql script: 40_json.sql
+# loading sql script: 40_json_hge.sql
+# loading sql script: 41_md5sum.sql
+# loading sql script: 45_uuid.sql
+# loading sql script: 46_gsl.sql
+# loading sql script: 46_profiler.sql
+# loading sql script: 51_sys_schema_extension.sql
+# loading sql script: 72_fits.sql
+# loading sql script: 74_netcdf.sql
+# loading sql script: 75_shp.sql
+# loading sql script: 75_storagemodel.sql
+# loading sql script: 80_statistics.sql
+# loading sql script: 80_udf.sql
+# loading sql script: 80_udf_hge.sql
+# loading sql script: 85_bam.sql
+# loading sql script: 90_generator.sql
+# loading sql script: 90_generator_hge.sql
+# loading sql script: 99_system.sql
+Great success!
 
 # 12:40:00 >  
 # 12:40:00 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-21450" "--port=30737"
@@ -142,19 +182,12 @@ Ready.
 [ 1    ]
 [ 1    ]
 [ 1    ]
-#SELECT * FROM pyapi25medians;
-% sys.pyapi25medians # table_name
-% mean # name
-% double # type
-% 24 # length
-[ 0.498218383  ]
-[ 0.4991642269 ]
-[ 0.4993118449 ]
-[ 0.499737365  ]
-[ 0.4997913804 ]
-[ 0.5000376408 ]
-[ 0.500048696  ]
-[ 0.5011960422 ]
+#SELECT pyapi25checker(mean) FROM pyapi25medians;
+% sys.L # table_name
+% pyapi25checker_mean # name
+% boolean # type
+% 5 # length
+[ true ]
 #CREATE FUNCTION pyapi25errortable() returns TABLE(d DOUBLE) LANGUAGE 
PYTHON_MAP
 #{
 #    return _conn.execute('SELECT * FROM HOPEFULLYNONEXISTANTTABLE;')
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to