Skip to content

Commit 871cd9a

Browse files
committed
Add example to Validate docstring
1 parent 288d297 commit 871cd9a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

pointblank/validate.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,43 @@ class Validate:
19001900
[`get_tabular_report()`](`pointblank.Validate.get_tabular_report`) method, which contains
19011901
options for modifying the display of the table.
19021902
1903+
### Adding briefs
1904+
1905+
Briefs are short descriptions of the validation steps. While they can be set for each step
1906+
individually, they can also be set globally. The global setting is done by using the
1907+
`brief=` argument in `Validate`. The global setting can be as simple as `True` to have
1908+
automatically-generated briefs for each step. Alternatively, we can use templating elements
1909+
like `"{step}"` (to insert the step number) or `"{auto}"` (to include an automatically generated
1910+
brief). Here's an example of a global setting for briefs:
1911+
1912+
```{python}
1913+
validation = (
1914+
pb.Validate(
1915+
data=pb.load_dataset(),
1916+
tbl_name="small_table",
1917+
label="Validation example with briefs",
1918+
brief="Step {step}: {auto}",
1919+
)
1920+
.col_vals_gt(columns="d", value=100)
1921+
.col_vals_between(columns="c", left=3, right=10, na_pass=True)
1922+
.col_vals_regex(
1923+
columns="b",
1924+
pattern=r"[0-9]-[a-z]{3}-[0-9]{3}",
1925+
brief="Regex check for column {col}"
1926+
)
1927+
.interrogate()
1928+
)
1929+
1930+
validation
1931+
```
1932+
1933+
We see the text of the briefs appear in the `STEP` column of the reporting table. Furthermore,
1934+
the global brief's template (`"Step {step}: {auto}"`) is applied to all steps except for the
1935+
final step, where the step-level `brief=` argument provided an override.
1936+
1937+
If you should want to cancel the globally-defined brief for one or more validation steps, you
1938+
can set `brief=False` in those particular steps.
1939+
19031940
### Post-interrogation methods
19041941
19051942
The `Validate` class has a number of post-interrogation methods that can be used to extract

0 commit comments

Comments
 (0)