コード例 #1
0
    def _InvalidAssignments(self, tested_object):
        # Note: the expected behavior is to obtain a pybind-defined TypeError complaining about "incompatible function arguments".
        # However, in debug compilations ublas may detect size inconsistencies first and throw a ValueError (bad argument) instead.

        # Forbidden implicit conversion from wrong-size Array
        with self.assertRaisesRegex(TypeError, ".*incompatible function arguments.*"):
            u = KM.Array6([1,2,3,4,5,6])
            tested_object.SetValue(KM.VORTICITY, u)

        # Forbidden implicit conversion from wrong-size Vector
        with self.assertRaises((TypeError,ValueError)):
            v = KM.Vector([1,2,3,4])
            tested_object.SetValue(KM.VORTICITY, v)

        # Forbidden implicit conversion from wrong-size list
        with self.assertRaises((TypeError,ValueError)):
            l = [1,2,3,4]
            tested_object.SetValue(KM.VORTICITY, l)