MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / test_flatten

Method test_flatten

tests/tests_unit.py:274–294  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

272 self.assertEqual(v, v2)
273
274 def test_flatten(self):
275 l = [[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]], [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]]
276 l2 = flatten(l)
277 dims = get_shape(l)
278 self.assertEqual(dims, [2, 3, 4])
279 self.assertNotEqual(l, l2)
280
281 l3 = _reshape(l2, (2, 3, 4))
282 self.assertEqual(l, l3)
283
284
285 l = [[[], [], []], [[], [], []]]
286 l2 = flatten(l)
287 dims = get_shape(l)
288 self.assertEqual(dims, [2, 3, 0])
289
290 l = [1, 2, 3, 4]
291 l2 = flatten(l)
292 dims = get_shape(l)
293 self.assertEqual(dims, [4])
294 self.assertEqual(l, l2)
295
296 def test_custom_variant(self):
297 with self.assertRaises(ua.UaError):

Callers

nothing calls this directly

Calls 3

flattenFunction · 0.90
get_shapeFunction · 0.90
_reshapeFunction · 0.90

Tested by

no test coverage detected