Skip to content

Commit 30978e5

Browse files
committed
add section heading to template string docs
1 parent 32fdfc5 commit 30978e5

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

docs/guides/template_strings.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ Comparison object must end with the word “was”. AuthoritySpoke will then
129129
build the rest of the phrase using the comparison sign and expression
130130
that you provide.
131131

132+
Comparisons with Measurements and Units
133+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134+
135+
To use a measurement as a Comparison’s ``expression``, pass the measurement as
136+
a string when constructing the Comparison object, and it will be converted to a :class:`pint.Quantity`\.
137+
132138
>>> from authorityspoke import Comparison
133139
>>> drug_comparison = Comparison(
134140
>>> "the weight of marijuana that $defendant possessed was",
@@ -183,6 +189,10 @@ asserted the weight was much greater.
183189
>>> drug_comparison_with_upper_bound.contradicts(drug_comparison)
184190
True
185191

192+
The unit that the Comparison parses doesn't have to be weight. It could also be distance, time, volume,
193+
units of surface area such as square kilometers or acres, or units that combine multiple dimensions
194+
such as miles per hour or meters per second.
195+
186196
Comparisons with Integer and Float Expressions
187197
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188198

notebooks/template_strings_and_explanations.ipynb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,20 @@
209209
"AuthoritySpoke's `Comparison` class extends the concept of a `Predicate`. A `Comparison` still contains a `truth` value and a `template` string, but that template should be used to identify a quantity that will be compared to an `expression` using a `sign` such as an equal sign or a greater-than sign. This `expression` must be a constant: either an integer, a floating point number, a date, or a physical quantity expressed in units that can be parsed using the [pint library](https://pint.readthedocs.io/en/stable/defining-quantities.html#using-string-parsing). To encourage consistent phrasing, the template string in every Comparison object must end with the word \"was\". AuthoritySpoke will then build the rest of the phrase using the comparison sign and expression that you provide."
210210
]
211211
},
212+
{
213+
"cell_type": "markdown",
214+
"metadata": {},
215+
"source": [
216+
"### Comparisons with Measurements and Units"
217+
]
218+
},
219+
{
220+
"cell_type": "markdown",
221+
"metadata": {},
222+
"source": [
223+
"To use a measurement as a Comparison's `expression`, pass the measurement as a string when constructing the Comparison object, and it will be converted to a `pint` object."
224+
]
225+
},
212226
{
213227
"cell_type": "code",
214228
"execution_count": 8,
@@ -364,6 +378,15 @@
364378
"drug_comparison_with_upper_bound.contradicts(drug_comparison)"
365379
]
366380
},
381+
{
382+
"cell_type": "markdown",
383+
"metadata": {},
384+
"source": [
385+
"The unit that the Comparison parses doesn't have to be weight. It could also be distance, time, volume,\n",
386+
"units of surface area such as square kilometers or acres, or units that combine multiple dimensions \n",
387+
"such as miles per hour or meters per second."
388+
]
389+
},
367390
{
368391
"cell_type": "markdown",
369392
"metadata": {},

0 commit comments

Comments
 (0)