Skip to content

Commit 45490b0

Browse files
authored
Fix miscellaneous doc strings. (#264)
1 parent be00292 commit 45490b0

File tree

2 files changed

+42
-43
lines changed

2 files changed

+42
-43
lines changed

src/datajudge/constraints/base.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,18 @@ class Constraint(abc.ABC):
101101
"""Express a DataReference constraint against either another DataReference or a reference value.
102102
103103
Constraints against other DataReferences are typically referred to as 'between' constraints.
104-
Please use the the `ref2` argument to instantiate such a constraint.
104+
Please use the the ``ref2`` argument to instantiate such a constraint.
105105
Constraints against a fixed reference value are typically referred to as 'within' constraints.
106-
Please use the `ref_value` argument to instantiate such a constraint.
106+
Please use the ``ref_value`` argument to instantiate such a constraint.
107107
108108
A constraint typically relies on the comparison of factual and target values. The former
109109
represent the key quantity of interest as seen in the database, the latter the key quantity of
110110
interest as expected a priori. Such a comparison is meant to be carried out in the `test`
111111
method.
112112
113-
In order to obtain such values, the `retrieve` method defines a mapping from DataReference,
114-
be it the DataReference of primary interest, `ref`, or a baseline DataReference, `ref2`, to
115-
value. If `ref_value` is already provided, usually no further mapping needs to be taken care of.
113+
In order to obtain such values, the ``retrieve`` method defines a mapping from DataReference,
114+
be it the DataReference of primary interest, ``ref``, or a baseline DataReference, ``ref2``, to
115+
value. If ``ref_value`` is already provided, usually no further mapping needs to be taken care of.
116116
117117
By default, retrieved arguments are cached indefinitely ``@lru_cache(maxsize=None)``.
118118
This can be controlled by setting the `cache_size` argument to a different value.

src/datajudge/requirements.py

+37-38
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ def add_uniqueness_constraint(
162162
) -> None:
163163
"""Columns should uniquely identify row.
164164
165-
Given a set of columns, satisfy conditions of a primary key, i.e.
166-
uniqueness of tuples from said columns. This constraint has a tolerance
167-
for inconsistencies, expressed via max_duplicate_fraction. The latter
165+
Given a list of columns ``columns``, validate the condition of a primary key, i.e.
166+
uniqueness of tuples in said columns. This constraint has a tolerance
167+
for inconsistencies, expressed via ``max_duplicate_fraction``. The latter
168168
suggests that the number of uniques from said columns is larger or equal
169-
to (1 - max_duplicate_fraction) the number of rows.
169+
to ``1 - max_duplicate_fraction`` times the number of rows.
170170
171-
If infer_pk_columns is True, columns will be retrieved from the primary keys.
172-
When columns=None and infer_pk_columns=False, the fallback is validating that all
173-
rows in a table are unique.
171+
If ``infer_pk_columns`` is ``True``, ``columns`` will be retrieved from the primary keys.
172+
If ``columns`` is ``None`` and ``infer_pk_column`` is ``False``, the fallback is
173+
validating that all rows in a table are unique.
174174
"""
175175
ref = DataReference(self.data_source, columns, condition)
176176
self._constraints.append(
@@ -194,9 +194,9 @@ def add_column_type_constraint(
194194
"""
195195
Check if a column type matches the expected column_type.
196196
197-
The column_type can be provided as a string (backend-specific type name), a backend-specific SQLAlchemy type, or a SQLAlchemy's generic type.
197+
The ``column_type`` can be provided as a string (backend-specific type name), a backend-specific SQLAlchemy type, or a SQLAlchemy's generic type.
198198
199-
If SQLAlchemy's generic types are used, the check is performed using `isinstance`, which means that the actual type can also be a subclass of the target type.
199+
If SQLAlchemy's generic types are used, the check is performed using ``isinstance``, which means that the actual type can also be a subclass of the target type.
200200
For more information on SQLAlchemy's generic types, see https://docs.sqlalchemy.org/en/20/core/type_basics.html
201201
202202
Parameters
@@ -319,7 +319,7 @@ def add_uniques_equality_constraint(
319319
specified via the ``uniques`` parameter.
320320
321321
Null values in the columns ``columns`` are ignored. To assert the non-existence of them use
322-
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint`` helper method
322+
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint` helper method
323323
for ``WithinRequirement``.
324324
By default, the null filtering does not trigger if multiple columns are fetched at once.
325325
It can be configured in more detail by supplying a custom ``filter_func`` function.
@@ -372,7 +372,7 @@ def add_uniques_superset_constraint(
372372
specified via ``uniques``, is contained in given columns of a ``DataSource``.
373373
374374
Null values in the columns ``columns`` are ignored. To assert the non-existence of them use
375-
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint`` helper method
375+
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint` helper method
376376
for ``WithinRequirement``.
377377
By default, the null filtering does not trigger if multiple columns are fetched at once.
378378
It can be configured in more detail by supplying a custom ``filter_func`` function.
@@ -435,7 +435,7 @@ def add_uniques_subset_constraint(
435435
``uniques``.
436436
437437
Null values in the columns ``columns`` are ignored. To assert the non-existence of them use
438-
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint`` helper method
438+
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint` helper method
439439
for ``WithinRequirement``.
440440
By default, the null filtering does not trigger if multiple columns are fetched at once.
441441
It can be configured in more detail by supplying a custom ``filter_func`` function.
@@ -508,9 +508,9 @@ def add_categorical_bound_constraint(
508508
Check if the distribution of unique values in columns falls within the
509509
specified minimum and maximum bounds.
510510
511-
The `CategoricalBoundConstraint` is added to ensure the distribution of unique values
512-
in the specified columns of a `DataSource` falls within the given minimum and maximum
513-
bounds defined in the `distribution` parameter.
511+
The ``CategoricalBoundConstraint`` is added to ensure the distribution of unique values
512+
in the specified columns of a ``DataSource`` falls within the given minimum and maximum
513+
bounds defined in the ``distribution`` parameter.
514514
515515
Parameters
516516
----------
@@ -571,7 +571,7 @@ def add_numeric_min_constraint(
571571
condition: Condition | None = None,
572572
cache_size=None,
573573
) -> None:
574-
"""All values in column are greater or equal min_value."""
574+
"""All values in ``column`` are greater or equal ``min_value``."""
575575
ref = DataReference(self.data_source, [column], condition)
576576
self._constraints.append(
577577
numeric_constraints.NumericMin(
@@ -587,7 +587,7 @@ def add_numeric_max_constraint(
587587
name: str | None = None,
588588
cache_size=None,
589589
) -> None:
590-
"""All values in column are less or equal max_value."""
590+
"""All values in ``column`` are less or equal ``max_value``."""
591591
ref = DataReference(self.data_source, [column], condition)
592592
self._constraints.append(
593593
numeric_constraints.NumericMax(
@@ -634,7 +634,7 @@ def add_numeric_mean_constraint(
634634
name: str | None = None,
635635
cache_size=None,
636636
) -> None:
637-
"""Assert the mean of the column deviates at most max_deviation from mean_value."""
637+
"""Assert the mean of the column ``column`` deviates at most ``max_deviation`` from ``mean_value``."""
638638
ref = DataReference(self.data_source, [column], condition)
639639
self._constraints.append(
640640
numeric_constraints.NumericMean(
@@ -695,9 +695,9 @@ def add_date_min_constraint(
695695
name: str | None = None,
696696
cache_size=None,
697697
) -> None:
698-
"""Ensure all dates to be superior than min_value.
698+
"""Ensure all dates to be superior than ``min_value``.
699699
700-
Use string format: min_value="'20121230'".
700+
Use string format: ``min_value="'20121230'"``.
701701
702702
For more information on ``column_type`` values, see ``add_column_type_constraint``.
703703
@@ -728,16 +728,15 @@ def add_date_max_constraint(
728728
name: str | None = None,
729729
cache_size=None,
730730
) -> None:
731-
"""Ensure all dates to be superior than max_value.
731+
"""Ensure all dates to be superior than ``max_value``.
732732
733-
Use string format: max_value="'20121230'".
733+
Use string format: ``max_value="'20121230'"``
734734
735-
For more information on ``column_type`` values, see ``add_column_type_constraint``.
735+
For more information on ``column_type`` values, see :meth:`~datajudge.requirements.WithinRequirement.add_column_type_constraint`.
736736
737-
If ``use_upper_bound_reference``, the max of the first table has to be
738-
smaller or equal to ``max_value``.
739-
If not ``use_upper_bound_reference``, the max of the first table has to
740-
be greater or equal to ``max_value``.
737+
If ``use_upper_bound_reference`` is ``True``, the maximum date in ``column`` has to be smaller or
738+
equal to ``max_value``. Otherwise the maximum date in ``column`` has to be greater or equal
739+
to ``max_value``.
741740
"""
742741
ref = DataReference(self.data_source, [column], condition)
743742
self._constraints.append(
@@ -761,7 +760,7 @@ def add_date_between_constraint(
761760
name: str | None = None,
762761
cache_size=None,
763762
) -> None:
764-
"""Use string format: lower_bound="'20121230'"."""
763+
"""Use string format: ``lower_bound="'20121230'"``."""
765764
ref = DataReference(self.data_source, [column], condition)
766765
self._constraints.append(
767766
date_constraints.DateBetween(
@@ -935,7 +934,7 @@ def add_date_no_gap_constraint(
935934
interest. A priori, a key is not a primary key, i.e., a key can have and often has
936935
several rows. Thereby, a key will often come with several date ranges.
937936
938-
If`` key_columns`` is ``None`` or ``[]``, all columns of the table will be
937+
If ``key_columns`` is ``None`` or ``[]``, all columns of the table will be
939938
considered as composing the key.
940939
941940
In order to express a tolerance for some violations of this gap property, use the
@@ -973,12 +972,12 @@ def add_functional_dependency_constraint(
973972
cache_size=None,
974973
):
975974
"""
976-
Expresses a functional dependency, a constraint where the `value_columns` are uniquely determined by the `key_columns`.
977-
This means that for each unique combination of values in the `key_columns`, there is exactly one corresponding combination of values in the `value_columns`.
975+
Expresses a functional dependency, a constraint where the ``value_columns`` are uniquely determined by the ``key_columns``.
976+
This means that for each unique combination of values in the ``key_columns``, there is exactly one corresponding combination of values in the ``value_columns``.
978977
979-
The ``add_unique_constraint`` constraint is a special case of this constraint, where the `key_columns` are a primary key,
980-
and all other columns are included `value_columns`.
981-
This constraint allows for a more general definition of functional dependencies, where the `key_columns` are not necessarily a primary key.
978+
The ``add_unique_constraint`` constraint is a special case of this constraint, where the ``key_columns`` are a primary key,
979+
and all other columns are included ``value_columns``.
980+
This constraint allows for a more general definition of functional dependencies, where the ``key_columns`` are not necessarily a primary key.
982981
983982
An additional configuration option (for details see the analogous parameter in for ``Uniques``-constraints)
984983
on how the output is sorted and how many counterexamples are shown is available as ``output_processors``.
@@ -1027,7 +1026,7 @@ def add_numeric_no_gap_constraint(
10271026
interest. A priori, a key is not a primary key, i.e., a key can have and often has
10281027
several rows. Thereby, a key will often come with several intervals.
10291028
1030-
If`` key_columns`` is ``None`` or ``[]``, all columns of the table will be
1029+
If ``key_columns`` is ``None`` or ``[]``, all columns of the table will be
10311030
considered as composing the key.
10321031
10331032
In order to express a tolerance for some violations of this gap property, use the
@@ -1648,7 +1647,7 @@ def add_uniques_equality_constraint(
16481647
columns.
16491648
16501649
Null values in the columns ``columns`` are ignored. To assert the non-existence of them use
1651-
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint`` helper method
1650+
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint` helper method
16521651
for ``WithinRequirement``.
16531652
By default, the null filtering does not trigger if multiple columns are fetched at once.
16541653
It can be configured in more detail by supplying a custom ``filter_func`` function.
@@ -1704,7 +1703,7 @@ def add_uniques_superset_constraint(
17041703
is contained in given columns of a ``DataSource``.
17051704
17061705
Null values in the columns ``columns`` are ignored. To assert the non-existence of them use
1707-
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint`` helper method
1706+
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint` helper method
17081707
for ``WithinRequirement``.
17091708
By default, the null filtering does not trigger if multiple columns are fetched at once.
17101709
It can be configured in more detail by supplying a custom ``filter_func`` function.
@@ -1769,7 +1768,7 @@ def add_uniques_subset_constraint(
17691768
``DataSource``.
17701769
17711770
Null values in the columns ``columns`` are ignored. To assert the non-existence of them use
1772-
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint`` helper method
1771+
the :meth:`~datajudge.requirements.WithinRequirement.add_null_absence_constraint` helper method
17731772
for ``WithinRequirement``.
17741773
By default, the null filtering does not trigger if multiple columns are fetched at once.
17751774
It can be configured in more detail by supplying a custom ``filter_func`` function.

0 commit comments

Comments
 (0)