You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have notice that rule behaviour is not implemented yet so this is a question/advice.
I still need to better understand what is the idea behind the rule module and/or class. I had a look at the current .json example (see below) and with a bit of interpretation my understanding is that once an SQI is computed (sqi), you want to use pre-defined steps to filter out the original signal (s). At the moment you are defining those steps in a .json file (PS1), with entries defining the operand (op), the value and the label. If we are considering that this is just for programmers using the package, you could allow users to just define their own rules and if necessary put some constraints (PS2). This function can be passed as a parameter and called dynamically.
Otherwise...
Is this planned for the user interface (app)?
What operands are you planning to consider?
How are you using the configuration information (PS1) in the code?
defrule_xx(sqi):
"""Rule This rule.... [1] XX et all Parameters ---------- sqi: pd.Series or np.array The series with quality indexes Returns ------- up to you """# I am assuming you want a dataframe where the # first column is the sqi index and the second # column is the label. But could be anything else # you want.#{"op": ">", "value": "10", "label": "reject"},#{"op": ">=", "value": "3", "label": "accept"},#{"op": "<", "value": "3", "label": "reject"}],# Create dataframer=pd.DataFrame()
r['sqi'] =pd.Series(sqi)
r['lbl'] ='reject'# Add labelsr.loc[r.sqi.between(3, 10), 'lbl'] ='accept'# Returnreturnr# If you really need a class rule for some reason you can use# something similar to the example show below, but it might# be a bit of an overkill as functions are just so easy to call.classRule:
"""Rule"""def__init__(self, name, f=None):
"""Constructor"""# Check name is string# Check if f is callable# Set attributesself.name=nameself.f=fdefapply(sqi, **kwargs):
"""Apply rule"""returnself.f(sqi)
classRuleXXX(Rule):
def__init__(self):
super().__init__('xxx', rule_xxx)
# ----------------------# Main# ----------------------# Opt I:rule=Rule('xxx', rule_xxx)
# Opt II:rule=RuleXXX()
The text was updated successfully, but these errors were encountered:
Hi guys,
I have notice that rule behaviour is not implemented yet so this is a question/advice.
I still need to better understand what is the idea behind the rule module and/or class. I had a look at the current .json example (see below) and with a bit of interpretation my understanding is that once an SQI is computed (sqi), you want to use pre-defined steps to filter out the original signal (s). At the moment you are defining those steps in a .json file (PS1), with entries defining the operand (op), the value and the label. If we are considering that this is just for programmers using the package, you could allow users to just define their own rules and if necessary put some constraints (PS2). This function can be passed as a parameter and called dynamically.
Otherwise...
Hope it helps.
Best
PS1: Example .json
"test_sqi": {
"name": "test_sqi",
"def": [
{"op": ">", "value": "10", "label": "reject"},
{"op": ">=", "value": "3", "label": "accept"},
{"op": "<", "value": "3", "label": "reject"}],
"desc": "",
"ref": ""
}
PS2: Example function
The text was updated successfully, but these errors were encountered: