Skip to content

C11: a NaN beside a decimal through PROV-O, in the property test and the caveat (#701) - #702

Merged
trungdong merged 5 commits into
mainfrom
test/3.3.0-rdf-nan-beside-decimal
Oct 29, 2026
Merged

trungdong merged 5 commits into
mainfrom
test/3.3.0-rdf-nan-beside-decimal

Conversation

@trungdong

Copy link
Copy Markdown
Owner

rdflib's Turtle, long Turtle, TriG and N3 writers sort the values of each predicate, and a Decimal has no order against a NaN. A record holding a NaN of any numeric datatype beside an xsd:decimal value under one attribute therefore raises decimal.InvalidOperation when written to PROV-O in those syntaxes, as does a decimal NaN beside any number. 3.2.3 behaves the same, and N-Triples, N-Quads, RDF/XML, JSON-LD, TriX, Hext and every other prov format write such a record. This is the documented limitation conformance caveat C11 describes, so there is no fix in prov or rdflib.

The 3.3.0 property test test_generated_record_roundtrips[rdf] found the double-NaN-beside-decimal shape, which C11's text did not name, and .hypothesis/examples replays it on every default-profile run. The test now skips, for rdf only, a record with a NaN and an xsd:decimal value under one attribute; the exclusion sits in the test's assume, so strategies.py keeps generating the shape for every other format. The C11 pinning test in test_value_forms.py covers both shapes with four rows.

C11 in docs/reference/conformance.md and its one-liner in docs/howto/provo-rdf.md now name both pairs, the four writers that raise and the syntaxes that write. Spec 5 section 3.6 records the same wording. No changelog entry: no library behaviour changes.

Closes #701.

…alue under one attribute, and the C11 test pins that shape beside the decimal NaN (spec 5, 3.6)

rdflib's Turtle, TriG and N3 writers order a predicate's values and a Decimal has no order against a NaN, so the replayed Hypothesis example raised decimal.InvalidOperation; the exclusion is per attribute and for rdf only, and strategies.py keeps generating the shape for the other formats.
…s cannot order, and says the other RDF syntaxes write them (spec 5, 3.6)

C11 named only a decimal NaN beside a number, while #701's failing shape is a NaN of another numeric datatype beside an xsd:decimal value, measured in spec 5 section 2.1.
…order without an ambiguous pronoun (spec 5, 3.6)

The final review found "which" and "such a pair" in the two pages and "whichever comes first" in the pinning test's comment without a clear antecedent; the facts and the code are unchanged.
… well-formed decimal as the value a NaN cannot be ordered against, and the C11 tests' helpers and comments state what the model stores (spec 5, 3.6)

The review regime measured rdflib's longturtle writer raising on both pairs and an ill-formed decimal text writing beside a NaN, so C11 and spec 3.6 name four writers and a well-formed decimal; a well-formed double NaN is stored as a float, so the helper's Literal arm tests xsd:float only; the pinning test's rows carry ids.
…two name sets, the decimal-text check reuses the decimal predicate, the RDF exclusions are two flat assumes, and spec 3.6 and 9 name the pinning test's second row (spec 5, 3.6)

The generated documents the property test skips are unchanged; the NaN-beside-decimal helper drops three imports (defaultdict, Any and QualifiedName).
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 12 complexity

Metric Results
Complexity 12

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 98.381%. remained the same — test/3.3.0-rdf-nan-beside-decimal into main

@trungdong
trungdong merged commit 9b350d8 into main Oct 29, 2026
24 checks passed
@trungdong
trungdong deleted the test/3.3.0-rdf-nan-beside-decimal branch October 29, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An xsd:decimal NaN beside another decimal on one attribute makes the RDF writer raise InvalidOperation

2 participants