Skip to content

Commit

Permalink
Matrix: Catch error with different-sized input arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
iyerr3 committed Apr 25, 2018
1 parent 1c81cb1 commit 9448759
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ports/postgres/modules/linalg/matrix_ops.py_in
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ def matrix_ndims(schema_madlib, matrix_in, in_args, is_block):


def get_dims(matrix, matrix_args, is_block=False):

if is_block:
block_dim = plpy.execute("""
SELECT
Expand Down Expand Up @@ -287,12 +286,15 @@ def get_dims(matrix, matrix_args, is_block=False):
if row_dim != 0:
rv = plpy.execute("""
SELECT
(array_upper({matrix_args[val]}::float8[], 1) -
array_lower({matrix_args[val]}::float8[], 1) + 1)
DISTINCT(array_upper({matrix_args[val]}::float8[], 1) -
array_lower({matrix_args[val]}::float8[], 1) + 1)
AS col_dim
FROM
{matrix}
""".format(matrix=matrix, matrix_args=matrix_args))
_assert(rv and len(rv) == 1,
"dimensions mismatch: row_array.size() != vec.size(). "
"Data contains different sized arrays")
col_dim = rv[0]['col_dim']
else:
col_dim = 0
Expand Down

0 comments on commit 9448759

Please sign in to comment.