From 44d078d4d3626a0a23063289f6c55c7e0675a3b1 Mon Sep 17 00:00:00 2001 From: Frank Sauerburger <f.sauerburger@cern.ch> Date: Wed, 3 Jul 2019 15:57:19 +0200 Subject: [PATCH] Update docstring examples to new cut behavior --- nnfwtbn/cut.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/nnfwtbn/cut.py b/nnfwtbn/cut.py index 0a410f0..74227e4 100644 --- a/nnfwtbn/cut.py +++ b/nnfwtbn/cut.py @@ -14,18 +14,27 @@ class Cut: >>> sel_all = Cut() >>> sel_pos = Cut(lambda df: df.value > 0) - The cut object lives independently of the dataframe. The index array for a - given data set is calculated by calling the cut with data dataframe. + The cut object lives independently of the dataframe. Calling the cut with + a dataframe returns a new dataframe containing only rows which pass the + selection criteria. >>> df = pd.DataFrame([0, 1, -2, -3, 4], columns=["value"]) >>> sel_all(df) - 0 True - 1 True - 2 True - 3 True - 4 True - dtype: bool + value + 0 0 + 1 1 + 2 -2 + 3 -3 + 4 4 >>> sel_pos(df) + value + 1 1 + 4 4 + + The index array for a given data set is calculated by calling the + idx_array() method with a data dataframe. + + >>> sel_pos.idx_array(df) 0 False 1 True 2 False @@ -39,23 +48,15 @@ class Cut: >>> sel_even = Cut(lambda df: df.value % 2 == 0) >>> sel_pos_even = sel_pos & sel_even >>> sel_pos_even(df) - 0 False - 1 False - 2 False - 3 False - 4 True - Name: value, dtype: bool + value + 4 4 Equivalently, cuts support logical operations directly using lambdas. >>> sel_pos_even_lambda = sel_pos & (lambda df: df.value % 2 == 0) >>> sel_pos_even_lambda(df) - 0 False - 1 False - 2 False - 3 False - 4 True - Name: value, dtype: bool + value + 4 4 """ def __init__(self, func=None): -- GitLab