Source code for symforce.test_util.cam_cal_test_mixin
# ----------------------------------------------------------------------------# SymForce - Copyright 2022, Skydio, Inc.# This source code is under the Apache 2.0 license found in the LICENSE file.# ----------------------------------------------------------------------------importitertoolsfromsymforceimporttypingasTfromsymforce.test_util.cam_test_mixinimportCamTestMixin
[docs]classCamCalTestMixin(CamTestMixin):""" Test helper for camera calibration objects. Inherit a test case from this. """
[docs]deftest_storage_order(self)->None:""" Tests: - storage_order Specifically, that the names of storage_order match those of the argument of the class constructors, and the the order of the scalars in the storage matches the order specified by storage_order. """cam_cls=type(self.element())order=cam_cls.storage_order()counter=itertools.count(0)defget_counting_list(size:int)->T.Union[int,T.List[int]]:ifsize==1:returnnext(counter)return[next(counter)for_inrange(size)]ordered_args={arg:get_counting_list(size)forarg,sizeinorder}storage=cam_cls(**ordered_args).to_storage()self.assertEqual(storage,list(range(len(storage))))