@@ -526,6 +526,24 @@ def assert_parameter_estimate_is_boolean(parameter_df: pd.DataFrame) -> None:
526526 f"Expected 0 or 1 but got { estimate } in { ESTIMATE } column." )
527527
528528
529+ def is_scalar_float (x : Any ):
530+ """
531+ Checks whether input is a number or can be transformed into a number
532+ via float
533+ :param x:
534+ input
535+ :return:
536+ True if is or can be converted to number, False otherwise.
537+ """
538+ if isinstance (x , numbers .Number ):
539+ return True
540+ try :
541+ float (x )
542+ return True
543+ except (ValueError , TypeError ):
544+ return False
545+
546+
529547def measurement_table_has_timepoint_specific_mappings (
530548 measurement_df : pd .DataFrame ,
531549 allow_scalar_numeric_noise_parameters : bool = False ,
@@ -553,23 +571,6 @@ def measurement_table_has_timepoint_specific_mappings(
553571 # since we edit it, copy it first
554572 measurement_df = copy .deepcopy (measurement_df )
555573
556- def is_scalar_float (x : Any ):
557- """
558- Checks whether input is a number or can be transformed into a number
559- via float
560- :param x:
561- input
562- :return:
563- True if is or can be converted to number, False otherwise.
564- """
565- if isinstance (x , numbers .Number ):
566- return True
567- try :
568- float (x )
569- return True
570- except (ValueError , TypeError ):
571- return False
572-
573574 # mask numeric values
574575 for col , allow_scalar_numeric in [
575576 (OBSERVABLE_PARAMETERS , allow_scalar_numeric_observable_parameters ),
@@ -622,7 +623,8 @@ def observable_table_has_nontrivial_noise_formula(
622623 """
623624
624625 return not observable_df [NOISE_FORMULA ].apply (
625- lambda x : re .match (r'^[\w_\.]+$' , x ) is not None
626+ lambda x : is_scalar_float (x ) or
627+ re .match (r'^[\w]+$' , str (x )) is not None
626628 ).all ()
627629
628630
0 commit comments