Source code for symforce.test_util.group_ops_test_mixin
# ----------------------------------------------------------------------------# SymForce - Copyright 2022, Skydio, Inc.# This source code is under the Apache 2.0 license found in the LICENSE file.# ----------------------------------------------------------------------------fromsymforce.opsimportGroupOpsfrom.storage_ops_test_mixinimportStorageOpsTestMixin
[docs]classGroupOpsTestMixin(StorageOpsTestMixin):""" Test helper for the GroupOps concept. Inherit a test case from this. """
[docs]deftest_group_ops(self)->None:""" Tests: - identity - inverse - compose - between """# Create an identity and non-identity elementelement=self.element()identity=GroupOps.identity(element)self.assertNotEqual(identity,element,".element() must be non-identity type")# Basic equalityself.assertEqual(identity,identity)self.assertEqual(element,element)# Inverse of identity is identityself.assertStorageNear(identity,GroupOps.inverse(identity))# Composition with identityself.assertStorageNear(element,GroupOps.compose(element,identity))self.assertStorageNear(element,GroupOps.compose(identity,element))# Composition with inverseself.assertStorageNear(identity,GroupOps.compose(GroupOps.inverse(element),element))self.assertStorageNear(identity,GroupOps.compose(element,GroupOps.inverse(element)))# Between for differencingself.assertStorageNear(identity,GroupOps.between(element,element))self.assertStorageNear(element,GroupOps.between(identity,element))self.assertStorageNear(GroupOps.inverse(element),GroupOps.between(element,identity))