From 38e40266a7ad2744fce904a02faa383676950e1e Mon Sep 17 00:00:00 2001 From: Luiz Scheinkman Date: Fri, 12 Jan 2018 15:02:27 -0800 Subject: [PATCH] Issue #1380: Update SP parameter validation test checking array dimensions --- .../algorithms/spatial_pooler_cpp_unit_test.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/unit/nupic/algorithms/spatial_pooler_cpp_unit_test.py b/tests/unit/nupic/algorithms/spatial_pooler_cpp_unit_test.py index 9a36ebb1f0..238ba44c44 100755 --- a/tests/unit/nupic/algorithms/spatial_pooler_cpp_unit_test.py +++ b/tests/unit/nupic/algorithms/spatial_pooler_cpp_unit_test.py @@ -183,19 +183,33 @@ def testComputeParametersValidation(self): inputGood = np.ones(5, dtype=uintDType) outGood = np.zeros(5, dtype=uintDType) inputBad = np.ones(5, dtype=realDType) + inputBad2D = np.ones((5, 5), dtype=realDType) outBad = np.zeros(5, dtype=realDType) + outBad2D = np.zeros((5, 5), dtype=realDType) # Validate good parameters sp.compute(inputGood, False, outGood) + # Validate bad parameters + with self.assertRaises(RuntimeError): + sp.compute(inputBad, False, outBad) + # Validate bad input with self.assertRaises(RuntimeError): sp.compute(inputBad, False, outGood) + # Validate bad 2d input + with self.assertRaises(RuntimeError): + sp.compute(inputBad2D, False, outGood) + # Validate bad output with self.assertRaises(RuntimeError): sp.compute(inputGood, False, outBad) + # Validate bad 2d output + with self.assertRaises(RuntimeError): + sp.compute(inputGood, False, outBad2D) + if __name__ == "__main__": unittest.main()