madlib-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From njaya...@apache.org
Subject madlib git commit: Install/Dev check: Add new test cases for some modules
Date Fri, 16 Nov 2018 00:14:13 GMT
Repository: madlib
Updated Branches:
  refs/heads/master 25d716328 -> 7d7a069a4


Install/Dev check: Add new test cases for some modules

Some modules such as array_ops and pmml did not have any install check
files, while stemmer did not have any test files. This commit adds some
basic test cases for these modules. We can add more comprehensive tests
in the future if need be.

Closes #338


Project: http://git-wip-us.apache.org/repos/asf/madlib/repo
Commit: http://git-wip-us.apache.org/repos/asf/madlib/commit/7d7a069a
Tree: http://git-wip-us.apache.org/repos/asf/madlib/tree/7d7a069a
Diff: http://git-wip-us.apache.org/repos/asf/madlib/diff/7d7a069a

Branch: refs/heads/master
Commit: 7d7a069a4815eb4674252fe8a3fd89877df016d7
Parents: 25d7163
Author: Nandish Jayaram <njayaram@apache.org>
Authored: Fri Sep 28 17:15:40 2018 -0700
Committer: Nandish Jayaram <njayaram@apache.org>
Committed: Thu Nov 15 16:11:53 2018 -0800

----------------------------------------------------------------------
 .../src/pg_gp/test/array_ops.ic.sql_in          | 77 ++++++++++++++++++++
 .../src/pg_gp/test/porter_stemmer.ic.sql_in     | 38 ++++++++++
 .../src/pg_gp/test/porter_stemmer.sql_in        | 38 ++++++++++
 .../postgres/modules/pmml/test/pmml.ic.sql_in   | 60 +++++++++++++++
 4 files changed, 213 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/madlib/blob/7d7a069a/methods/array_ops/src/pg_gp/test/array_ops.ic.sql_in
----------------------------------------------------------------------
diff --git a/methods/array_ops/src/pg_gp/test/array_ops.ic.sql_in b/methods/array_ops/src/pg_gp/test/array_ops.ic.sql_in
new file mode 100644
index 0000000..a13bce3
--- /dev/null
+++ b/methods/array_ops/src/pg_gp/test/array_ops.ic.sql_in
@@ -0,0 +1,77 @@
+/* ----------------------------------------------------------------------- *//**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *//* ----------------------------------------------------------------------- */
+---------------------------------------------------------------------------
+-- Rules:
+-- ------
+-- 1) Any DB objects should be created w/o schema prefix,
+--    since this file is executed in a separate schema context.
+-- 2) There should be no DROP statements in this script, since
+--    all objects created in the default schema will be cleaned-up outside.
+---------------------------------------------------------------------------
+
+---------------------------------------------------------------------------
+-- Setup:
+---------------------------------------------------------------------------
+CREATE TABLE data AS
+SELECT
+    '{1,2,3}'::float8[] AS an,
+    '{4,5,7}'::float8[] AS b;
+
+SELECT MADLIB_SCHEMA.array_dot(
+    MADLIB_SCHEMA.array_mult(
+        MADLIB_SCHEMA.array_add(an,b),
+        MADLIB_SCHEMA.array_sub(an,b)),
+    MADLIB_SCHEMA.array_mult(
+        MADLIB_SCHEMA.array_div(an,b),
+        MADLIB_SCHEMA.normalize(an))) AS result1
+FROM data;
+
+SELECT MADLIB_SCHEMA.array_max(b) FROM data;
+SELECT MADLIB_SCHEMA.array_min(b) FROM data;
+SELECT MADLIB_SCHEMA.array_sum(b) FROM data;
+SELECT MADLIB_SCHEMA.array_sum_big(b) FROM data;
+SELECT MADLIB_SCHEMA.array_mean(b) FROM data;
+SELECT MADLIB_SCHEMA.array_stddev(b) FROM data;
+
+SELECT MADLIB_SCHEMA.array_scalar_mult(
+        MADLIB_SCHEMA.array_fill(
+            MADLIB_SCHEMA.array_of_float(20),
+            234.343::FLOAT8),
+        3.7::FLOAT8)
+FROM data;
+
+SELECT MADLIB_SCHEMA.array_filter(ARRAY[0.8, 9.5, 0, 2.6]::float8[]);
+SELECT MADLIB_SCHEMA.array_filter(ARRAY[0.8, 9.5, 0, 2.6]::float8[], 2.5::float8, '<');
+
+--------------------------------------------------------------
+-- TESTING array_unnest_2d_to_1d FUNCTION
+--------------------------------------------------------------
+-- 2-element float8 arrays
+DROP TABLE IF EXISTS unnest_2d_tbl01;
+CREATE TABLE unnest_2d_tbl01 (id INT, val DOUBLE PRECISION[][]);
+INSERT INTO unnest_2d_tbl01 VALUES
+  (1, ARRAY[[1::float8,2],[3::float8,4],[5::float8,6]]),
+  (2, ARRAY[[101::float8,202],[303::float8,404],[505::float8,606]])
+;
+
+DROP TABLE IF EXISTS unnest_2d_tbl01_out;
+CREATE TABLE unnest_2d_tbl01_out AS
+  SELECT id, (MADLIB_SCHEMA.array_unnest_2d_to_1d(val)).* FROM unnest_2d_tbl01;

http://git-wip-us.apache.org/repos/asf/madlib/blob/7d7a069a/methods/stemmer/src/pg_gp/test/porter_stemmer.ic.sql_in
----------------------------------------------------------------------
diff --git a/methods/stemmer/src/pg_gp/test/porter_stemmer.ic.sql_in b/methods/stemmer/src/pg_gp/test/porter_stemmer.ic.sql_in
new file mode 100644
index 0000000..a21e220
--- /dev/null
+++ b/methods/stemmer/src/pg_gp/test/porter_stemmer.ic.sql_in
@@ -0,0 +1,38 @@
+/* ----------------------------------------------------------------------- *//**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *//* ----------------------------------------------------------------------- */
+
+CREATE TABLE token_tbl ( id integer,
+                         word text
+                       );
+
+INSERT INTO token_tbl VALUES
+ (1, 'kneel'), (2, 'kneeled'), (3, 'kneeling'), (4, 'kneels'), (5, 'knees'),
+ (6, 'knell'), (7, 'knelt'), (8, 'knew'), (9, 'knick'), (10, 'knif'),
+ (11, 'knife'), (12, 'knight'), (13, 'knightly'), (14, 'knights'), (15, 'knit'),
+ (16, 'knits'), (17, 'knitted'), (18, 'knitting'), (19, 'knives'), (20, 'knob'),
+ (21, 'knobs'), (22, 'knock'), (23, 'knocked'), (24, 'knocker'), (25, 'knockers'),
+ (26, 'knocking'), (27, 'knocks'), (28, 'knopp'), (29, 'knot'), (30, 'knots');
+
+ -- text input
+SELECT id, MADLIB_SCHEMA.stem_token(word) FROM token_tbl;
+
+ -- array input
+SELECT MADLIB_SCHEMA.stem_token_arr(array_agg(word order by id)) FROM token_tbl;

http://git-wip-us.apache.org/repos/asf/madlib/blob/7d7a069a/methods/stemmer/src/pg_gp/test/porter_stemmer.sql_in
----------------------------------------------------------------------
diff --git a/methods/stemmer/src/pg_gp/test/porter_stemmer.sql_in b/methods/stemmer/src/pg_gp/test/porter_stemmer.sql_in
new file mode 100644
index 0000000..a21e220
--- /dev/null
+++ b/methods/stemmer/src/pg_gp/test/porter_stemmer.sql_in
@@ -0,0 +1,38 @@
+/* ----------------------------------------------------------------------- *//**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *//* ----------------------------------------------------------------------- */
+
+CREATE TABLE token_tbl ( id integer,
+                         word text
+                       );
+
+INSERT INTO token_tbl VALUES
+ (1, 'kneel'), (2, 'kneeled'), (3, 'kneeling'), (4, 'kneels'), (5, 'knees'),
+ (6, 'knell'), (7, 'knelt'), (8, 'knew'), (9, 'knick'), (10, 'knif'),
+ (11, 'knife'), (12, 'knight'), (13, 'knightly'), (14, 'knights'), (15, 'knit'),
+ (16, 'knits'), (17, 'knitted'), (18, 'knitting'), (19, 'knives'), (20, 'knob'),
+ (21, 'knobs'), (22, 'knock'), (23, 'knocked'), (24, 'knocker'), (25, 'knockers'),
+ (26, 'knocking'), (27, 'knocks'), (28, 'knopp'), (29, 'knot'), (30, 'knots');
+
+ -- text input
+SELECT id, MADLIB_SCHEMA.stem_token(word) FROM token_tbl;
+
+ -- array input
+SELECT MADLIB_SCHEMA.stem_token_arr(array_agg(word order by id)) FROM token_tbl;

http://git-wip-us.apache.org/repos/asf/madlib/blob/7d7a069a/src/ports/postgres/modules/pmml/test/pmml.ic.sql_in
----------------------------------------------------------------------
diff --git a/src/ports/postgres/modules/pmml/test/pmml.ic.sql_in b/src/ports/postgres/modules/pmml/test/pmml.ic.sql_in
new file mode 100644
index 0000000..3bcdeb1
--- /dev/null
+++ b/src/ports/postgres/modules/pmml/test/pmml.ic.sql_in
@@ -0,0 +1,60 @@
+/* ----------------------------------------------------------------------- *//**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *//* ----------------------------------------------------------------------- */
+DROP TABLE IF EXISTS abalone CASCADE;
+
+CREATE TABLE abalone (
+    id integer,
+    sex text,
+    length double precision,
+    diameter double precision,
+    height double precision,
+    whole double precision,
+    shucked double precision,
+    viscera double precision,
+    shell double precision,
+    rings integer
+);
+
+INSERT INTO abalone VALUES
+(3151, 'F', 0.655000000000000027, 0.505000000000000004, 0.165000000000000008, 1.36699999999999999,
0.583500000000000019, 0.351499999999999979, 0.396000000000000019, 10),
+(2026, 'F', 0.550000000000000044, 0.469999999999999973, 0.149999999999999994, 0.920499999999999985,
0.381000000000000005, 0.243499999999999994, 0.267500000000000016, 10),
+(3751, 'I', 0.434999999999999998, 0.375, 0.110000000000000001, 0.41549999999999998, 0.170000000000000012,
0.0759999999999999981, 0.14499999999999999, 8),
+(720, 'I', 0.149999999999999994, 0.100000000000000006, 0.0250000000000000014, 0.0149999999999999994,
0.00449999999999999966, 0.00400000000000000008, 0.0050000000000000001, 2),
+(1635, 'F', 0.574999999999999956, 0.469999999999999973, 0.154999999999999999, 1.1160000000000001,
0.509000000000000008, 0.237999999999999989, 0.340000000000000024, 10),
+(2648, 'I', 0.5, 0.390000000000000013, 0.125, 0.582999999999999963, 0.293999999999999984,
0.132000000000000006, 0.160500000000000004, 8),
+(1796, 'F', 0.57999999999999996, 0.429999999999999993, 0.170000000000000012, 1.47999999999999998,
0.65349999999999997, 0.32400000000000001, 0.41549999999999998, 10),
+(209, 'F', 0.525000000000000022, 0.41499999999999998, 0.170000000000000012, 0.832500000000000018,
0.275500000000000023, 0.168500000000000011, 0.309999999999999998, 13),
+(1451, 'I', 0.455000000000000016, 0.33500000000000002, 0.135000000000000009, 0.501000000000000001,
0.274000000000000021, 0.0995000000000000051, 0.106499999999999997, 7),
+(1108, 'I', 0.510000000000000009, 0.380000000000000004, 0.115000000000000005, 0.515499999999999958,
0.214999999999999997, 0.113500000000000004, 0.166000000000000009, 8),
+(3675, 'F', 0.594999999999999973, 0.450000000000000011, 0.165000000000000008, 1.08099999999999996,
0.489999999999999991, 0.252500000000000002, 0.279000000000000026, 12),
+(2108, 'F', 0.675000000000000044, 0.550000000000000044, 0.179999999999999993, 1.68849999999999989,
0.562000000000000055, 0.370499999999999996, 0.599999999999999978, 15),
+(3312, 'F', 0.479999999999999982, 0.380000000000000004, 0.135000000000000009, 0.507000000000000006,
0.191500000000000004, 0.13650000000000001, 0.154999999999999999, 12);
+
+DROP TABLE IF EXISTS abalone_probit_out, abalone_probit_out_summary;
+SELECT MADLIB_SCHEMA.glm(
+    'abalone',
+    'abalone_probit_out',
+    'rings < 10',
+    'ARRAY[1, length, diameter, height, whole, shucked, viscera, shell]',
+    'family=binomial, link=probit', NULL, 'max_iter=1000, tolerance=1e-16'
+);
+
+SELECT MADLIB_SCHEMA.pmml('abalone_probit_out');


Mime
View raw message