Loading numerical_labelling/labelling.py +15 −3 Original line number Diff line number Diff line Loading @@ -15,13 +15,19 @@ def int_to_bool_list(num, nSensorCandidate): bin_string = format(num, form) return [x == "1" for x in bin_string[::-1]], bin_string, form def bool_list_to_int(bool_str, nSensorCandidate): def bool_list_to_int(layout, nSensorCandidate): """ takey a boolean layout (True=measured, False=unmeasured) and converts it into the unique id generated from int_to_bool_list """ # reverse the layout to comply with soar rev_layout = layout[8:] + layout[:8] # Assuming layout is a list tlayout_np = np.array(rev_layout) rev_bin = [str(x) for x in tlayout_np[::-1].astype(int)] rev_bin_str = str.join("", rev_bin) int_layout = int(rev_bin_str, 2) return return int_layout def jacnum(x0, fx, dx=1e-6): Loading Loading @@ -123,10 +129,16 @@ def get_red_rref(J, bool_measured): return bool_redundant def observability_redundancy_labelling_rref(J, bool_measured,x0={}, debug=False, le_red_method=False): def observability_redundancy_labelling_rref(J, bool_measured,x0={}, debug=False, le_red_method=False, enforce_integer =True): if len(x0) > 0: J = J.subs(x0) if enforce_integer and len(x0) > 0: # convert to int matrix J = sy.Matrix(np.matrix(J).astype(int)) bool_measured = np.array(bool_measured).astype(bool) Jm = J[:, list(np.where(bool_measured)[0])] Ju = J[:, list(np.where(~bool_measured)[0])] Loading Loading
numerical_labelling/labelling.py +15 −3 Original line number Diff line number Diff line Loading @@ -15,13 +15,19 @@ def int_to_bool_list(num, nSensorCandidate): bin_string = format(num, form) return [x == "1" for x in bin_string[::-1]], bin_string, form def bool_list_to_int(bool_str, nSensorCandidate): def bool_list_to_int(layout, nSensorCandidate): """ takey a boolean layout (True=measured, False=unmeasured) and converts it into the unique id generated from int_to_bool_list """ # reverse the layout to comply with soar rev_layout = layout[8:] + layout[:8] # Assuming layout is a list tlayout_np = np.array(rev_layout) rev_bin = [str(x) for x in tlayout_np[::-1].astype(int)] rev_bin_str = str.join("", rev_bin) int_layout = int(rev_bin_str, 2) return return int_layout def jacnum(x0, fx, dx=1e-6): Loading Loading @@ -123,10 +129,16 @@ def get_red_rref(J, bool_measured): return bool_redundant def observability_redundancy_labelling_rref(J, bool_measured,x0={}, debug=False, le_red_method=False): def observability_redundancy_labelling_rref(J, bool_measured,x0={}, debug=False, le_red_method=False, enforce_integer =True): if len(x0) > 0: J = J.subs(x0) if enforce_integer and len(x0) > 0: # convert to int matrix J = sy.Matrix(np.matrix(J).astype(int)) bool_measured = np.array(bool_measured).astype(bool) Jm = J[:, list(np.where(bool_measured)[0])] Ju = J[:, list(np.where(~bool_measured)[0])] Loading