Skip to content

Commit 0284b01

Browse files
committed
Correct Docs for newer functionality
1 parent eb6f587 commit 0284b01

1 file changed

Lines changed: 8 additions & 36 deletions

File tree

docs/source/dev/data_model.md

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ for i, author in enumerate(data["author"], start=1):
214214
:caption: Value check
215215
for email in data["author"][0]["email"]:
216216
if email.endswith(".edu"):
217-
print("Author has an email address at an educational institution.")
217+
print("Shakespeare has an email address at an educational institution.")
218218
else:
219-
print("Cannot confirm affiliation with educational institution for author.")
219+
print("Cannot confirm affiliation with educational institution for Shakespeare.")
220220
221221
# Mock output
222222
# $> Cannot confirm affiliation with educational institution for author.
@@ -239,8 +239,8 @@ The API class {class}`hermes.model.SoftwareMetadata` hides many
239239
of the more complex aspects of JSON-LD and makes it easy to work
240240
with the data model.
241241

242-
Assertions, however, operate on the internal model objects.
243-
Therefore, they may not work as you would expect from plain
242+
So the API class hides the internal model objects.
243+
Therefore, they work as you would expect from plain
244244
Python data:
245245

246246
```{code-block} python
@@ -258,12 +258,10 @@ except AssertionError:
258258
raise
259259
260260
# Mock output
261-
# $> The author could not be found.
262-
# $> AssertionError:
263-
# assert
264-
# {'email': ['shakespeare@baz.net'], 'name': ['Shakespeare']}
265-
# in
266-
# _LDList(
261+
# $> The author was found!
262+
#
263+
#
264+
# Internal Model from data["author"]:
267265
# {'@list': [
268266
# {
269267
# 'http://schema.org/name': [{'@value': 'Shakespeare'}],
@@ -281,32 +279,6 @@ except AssertionError:
281279
# )
282280
```
283281

284-
The mock output in the example above shows the inequality of the expected and the actual value.
285-
The actual value is an internal data type wrapping the more complex JSON-LD data.
286-
287-
The complex data structure of JSON-LD is internally constructed in the `hermes` data
288-
model, and to make it possible to work with only the data that is important - the actual terms
289-
and their values - the internal data model types provide a function `.to_python()`.
290-
This function can be used in assertions to assert full data integrity:
291-
292-
```{code-block} python
293-
:caption: Containment assertion with `to_python()`
294-
:emphasize-lines: 5,13
295-
try:
296-
assert (
297-
{'name': ['Shakespeare'], 'email': ['shakespeare@baz.net']}
298-
in
299-
data["author"].to_python()
300-
)
301-
print("The author was found!")
302-
except AssertionError:
303-
print("The author could not be found.")
304-
raise
305-
306-
# Mock output
307-
# $> The author was found!
308-
```
309-
310282
---
311283

312284
## See Also

0 commit comments

Comments
 (0)