Source code for symforce.ops.impl.scalar_lie_group_ops
# ----------------------------------------------------------------------------# SymForce - Copyright 2022, Skydio, Inc.# This source code is under the Apache 2.0 license found in the LICENSE file.# ----------------------------------------------------------------------------importsymforce.internal.symbolicassffromsymforceimporttypingasTfrom.abstract_vector_lie_group_opsimportAbstractVectorLieGroupOps
[docs]@staticmethoddeffrom_storage(a:T.Any,elements:T.Sequence[T.Scalar])->T.ScalarElement:# NOTE: This returns a numeric type if both arguments are numeric types. If either argument# is a symbolic type, this returns a symbolic type.assertlen(elements)==1,"Scalar needs one element."ifisinstance(a,type):ifissubclass(a,sf.Expr)orisinstance(elements[0],sf.Expr):returnsf.S(elements[0])returna(elements[0])# type: ignore [call-arg]else:ifisinstance(a,sf.Expr)orisinstance(elements[0],sf.Expr):returnsf.S(elements[0])returntype(a)(elements[0])