Skip to content

Commit

Permalink
Merge branch 'main' of github.com:RDFLib/rdflib into issue-2692-embed…
Browse files Browse the repository at this point in the history
…ded-jsonld
  • Loading branch information
wallberg committed Jun 19, 2024
2 parents 3f3ea2a + 0ecc400 commit 53b353f
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 29 deletions.
9 changes: 5 additions & 4 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ Maurizio Nagni <[email protected]> kusamau <[email protected]>
Michel Pelletier <[email protected]> michel <devnull@localhost>
Mikael Nilsson <[email protected]> mikael <devnull@localhost>
Nathan Maynes <[email protected]> Nathan M <[email protected]>
Nicholas J. Car <[email protected]> Nicholas Car <[email protected]>
Nicholas J. Car <[email protected]> Nicholas Car <[email protected]>
Nicholas J. Car <[email protected]> nicholascar <[email protected]>
Nicholas J. Car <[email protected]> Nicholas Car <[email protected]>
Nicholas J. Car <[email protected]> Nicholas Car <[email protected]>
Nicholas J. Car <[email protected]> nicholascar <[email protected]>
Nicholas J. Car <[email protected]> Nicholas Car <[email protected]>
Niklas Lindström <[email protected]> lindstream <devnull@localhost>
Niklas Lindström <[email protected]> Niklas Lindstrom <[email protected]>
Olivier Grisel <[email protected]> ogrisel <devnull@localhost>
Expand Down Expand Up @@ -98,4 +99,4 @@ William Waites <[email protected]> wwaites <[email protected]>
William Waites <[email protected]> [email protected] <[email protected]>
Whit Morriss <[email protected]> whit <devnull@localhost>
Zach Lûster <[email protected]> kernc <[email protected]>
Zach Lûster <[email protected]> Kernc <[email protected]>
Zach Lûster <[email protected]> Kernc <[email protected]>
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ ci:
# https://pre-commit.com/#adding-pre-commit-plugins-to-your-project
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.1
rev: v0.4.9
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/psf/black-pre-commit-mirror
# WARNING: version should be the same as in `pyproject.toml`
rev: "24.4.0"
rev: "24.4.2"
hooks:
- id: black
pass_filenames: false
Expand Down
6 changes: 3 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ tasks:
desc: Fix auto-fixable linting errors
cmds:
- task: ruff
vars: { FIX: true }
vars: { FIX: "true" }
- task: black

lint:
desc: Perform linting
cmds:
- task: black
vars: { CHECK: true }
vars: { CHECK: "true" }
- task: ruff

validate:static:
Expand Down Expand Up @@ -250,7 +250,7 @@ tasks:
- task: install:system-deps
- task: install:tox
vars:
WITH_GITHUB_ACTIONS: true
WITH_GITHUB_ACTIONS: "true"
- cmd: "{{.PYTHON}} -m pip install coveralls"
- task: tox
vars:
Expand Down
2 changes: 1 addition & 1 deletion devtools/requirements-poetry.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Fixing this here as readthedocs can't use the compiled requirements-poetry.txt
# due to conflicts.
poetry==1.8.2
poetry==1.8.3
2 changes: 1 addition & 1 deletion docker/latest/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/library/python:3.12.2-slim@sha256:eb53cb99a609b86da6e239b16e1f2aed5e10cfbc538671fc4631093a00f133f2
FROM docker.io/library/python:3.12.2-slim@sha256:5c73034c2bc151596ee0f1335610735162ee2b148816710706afec4757ad5b1e

COPY docker/latest/requirements.txt /var/tmp/build/

Expand Down
2 changes: 1 addition & 1 deletion docs/developers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ Some useful commands for working with the task in the taskfile is given below:
task validate
# Build docs
task docs:build
task docs
# Run live-preview on the docs
task docs:live-server
Expand Down
2 changes: 1 addition & 1 deletion docs/intro_to_parsing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Working with multi-graphs
-------------------------

To read and query multi-graphs, that is RDF data that is context-aware, you need to use rdflib's
:class:`rdflib.ConjunctiveGraph` or :class:`rdflib.Dataset` class. These are extensions to :class:`rdflib.Graph` that
:class:`rdflib.Dataset` class. This an extension to :class:`rdflib.Graph` that
know all about quads (triples + graph IDs).

If you had this multi-graph data file (in the ``trig`` format, using new-style ``PREFIX`` statement (not the older
Expand Down
2 changes: 1 addition & 1 deletion docs/merging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ In RDFLib, blank nodes are given unique IDs when parsing, so graph merging can b
``graph`` now contains the merged graph of ``input1`` and ``input2``.


.. note:: However, the set-theoretic graph operations in RDFLib are assumed to be performed in sub-graphs of some larger data-base (for instance, in the context of a :class:`~rdflib.graph.ConjunctiveGraph`) and assume shared blank node IDs, and therefore do NOT do *correct* merging, i.e.::
.. note:: However, the set-theoretic graph operations in RDFLib are assumed to be performed in sub-graphs of some larger data-base (for instance, in the context of a :class:`~rdflib.graph.Dataset`) and assume shared blank node IDs, and therefore do NOT do *correct* merging, i.e.::

from rdflib import Graph

Expand Down
5 changes: 2 additions & 3 deletions docs/plugin_parsers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ xml :class:`~rdflib.plugins.parsers.rdfxml.RDFXMLParser`

Multi-graph IDs
---------------
Note that for correct parsing of multi-graph data, e.g. Trig, HexT, etc., into a ``ConjunctiveGraph`` or a ``Dataset``,
as opposed to a context-unaware ``Graph``, you will need to set the ``publicID`` of the ``ConjunctiveGraph`` a
``Dataset`` to the identifier of the ``default_context`` (default graph), for example::
Note that for correct parsing of multi-graph data, e.g. Trig, HexT, etc., into a ``Dataset``,
as opposed to a context-unaware ``Graph``, you will need to set the ``publicID`` of the ``Dataset`` to the identifier of the ``default_context`` (default graph), for example::

d = Dataset()
d.parse(
Expand Down
18 changes: 9 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ python = "^3.8.1"
isodate = "^0.6.0"
pyparsing = ">=2.1.0,<4"
berkeleydb = {version = "^18.1.0", optional = true}
networkx = {version = "^2.0.0", optional = true}
networkx = {version = ">=2,<4", optional = true}
html5lib = {version = "^1.0", optional = true}
lxml = {version = "^4.3.0", optional = true}

Expand Down
15 changes: 15 additions & 0 deletions rdflib/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
Conjunctive Graph
-----------------
.. warning::
ConjunctiveGraph is deprecated, use :class:`~rdflib.graph.Dataset` instead.
A Conjunctive Graph is the most relevant collection of graphs that are
considered to be the boundary for closed world assumptions. This
boundary is equivalent to that of the store instance (which is itself
Expand Down Expand Up @@ -249,6 +252,7 @@
import logging
import pathlib
import random
import warnings
from io import BytesIO
from typing import (
IO,
Expand Down Expand Up @@ -1893,6 +1897,9 @@ class ConjunctiveGraph(Graph):
"""A ConjunctiveGraph is an (unnamed) aggregation of all the named
graphs in a store.
.. warning::
ConjunctiveGraph is deprecated, use :class:`~rdflib.graph.Dataset` instead.
It has a ``default`` graph, whose name is associated with the
graph throughout its life. :meth:`__init__` can take an identifier
to use as the name of this default graph or it will assign a
Expand All @@ -1910,6 +1917,14 @@ def __init__(
default_graph_base: Optional[str] = None,
):
super(ConjunctiveGraph, self).__init__(store, identifier=identifier)

if type(self) is ConjunctiveGraph:
warnings.warn(
"ConjunctiveGraph is deprecated, use Dataset instead.",
DeprecationWarning,
stacklevel=2,
)

assert self.store.context_aware, (
"ConjunctiveGraph must be backed by" " a context aware store."
)
Expand Down
34 changes: 34 additions & 0 deletions rdflib/namespace/_GEO.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,39 @@ class GEO(DefinedNamespace):
"""

# http://www.w3.org/2000/01/rdf-schema#Datatype
dggsLiteral: URIRef # A DGGS serialization of a geometry object.
geoJSONLiteral: URIRef # A GeoJSON serialization of a geometry object.
gmlLiteral: URIRef # A GML serialization of a geometry object.
kmlLiteral: URIRef # A KML serialization of a geometry object.
wktLiteral: URIRef # A Well-known Text serialization of a geometry object.

# http://www.w3.org/2002/07/owl#Class
Feature: URIRef # This class represents the top-level feature type. This class is equivalent to GFI_Feature defined in ISO 19156:2011, and it is superclass of all feature types.
FeatureCollection: URIRef # A collection of individual Features.
Geometry: URIRef # The class represents the top-level geometry type. This class is equivalent to the UML class GM_Object defined in ISO 19107, and it is superclass of all geometry types.
GeometryCollection: URIRef # A collection of individual Geometries.
SpatialObject: URIRef # The class spatial-object represents everything that can have a spatial representation. It is superclass of feature and geometry.
SpatialObjectCollection: URIRef # A collection of individual Spatial Objects. This is the superclass of Feature Collection and Geometry Collection.

# http://www.w3.org/2002/07/owl#DatatypeProperty
asGML: URIRef # The GML serialization of a geometry
asWKT: URIRef # The WKT serialization of a geometry
asGeoJSON: URIRef # The GeoJSON serialization of a geometry
asKML: URIRef # The KML serialization of a geometry
asDGGS: URIRef # The DGGS serialization of a geometry
coordinateDimension: URIRef # The number of measurements or axes needed to describe the position of this geometry in a coordinate system.
dimension: URIRef # The topological dimension of this geometric object, which must be less than or equal to the coordinate dimension. In non-homogeneous collections, this will return the largest topological dimension of the contained objects.
hasMetricArea: URIRef # The area of a Spatial Object in square meters.
hasMetricLength: URIRef # The length of a Spatial Object in meters.
hasMetricPerimeterLength: (
URIRef # The length of the perimeter of a Spatial Object in meters.
)
hasMetricSpatialAccuracy: URIRef # The spatial resolution of a Geometry in meters.
hasMetricSpatialResolution: (
URIRef # The spatial resolution of a Geometry in meters.
)
hasMetricSize: URIRef # Subproperties of this property are used to indicate the size of a Spatial Object as a measurement or estimate of one or more dimensions of the Spatial Object's spatial presence. Units are always metric (meter, square meter or cubic meter)
hasMetricVolume: URIRef # The volume of a Spatial Object in cubic meters.
hasSerialization: (
URIRef # Connects a geometry object with its text-based serialization.
)
Expand All @@ -56,7 +76,21 @@ class GEO(DefinedNamespace):
ehInside: URIRef # Exists if the subject SpatialObject is spatially inside the object SpatialObject. DE-9IM: TFF*FFT**
ehMeet: URIRef # Exists if the subject SpatialObject spatially meets the object SpatialObject. DE-9IM: FT******* ^ F**T***** ^ F***T****
ehOverlap: URIRef # Exists if the subject SpatialObject spatially overlaps the object SpatialObject. DE-9IM: T*T***T**
hasArea: URIRef # The area of a Spatial Object.
hasBoundingBox: (
URIRef # The minimum or smallest bounding or enclosing box of a given Feature.
)
hasCentroid: URIRef # The arithmetic mean position of all the geometry points of a given Feature.
hasDefaultGeometry: URIRef # The default geometry to be used in spatial calculations, usually the most detailed geometry.
hasGeometry: URIRef # A spatial representation for a given feature.
hasLength: URIRef # The length of a Spatial Object.
hasPerimeterLength: URIRef # The length of the perimeter of a Spatial Object.
hasSize: URIRef # Subproperties of this property are used to indicate the size of a Spatial Object as a measurement or estimate of one or more dimensions of the Spatial Object's spatial presence.
hasSpatialAccuracy: (
URIRef # The positional accuracy of the coordinates of a Geometry.
)
hasSpatialResolution: URIRef # The spatial resolution of a Geometry.
hasVolume: URIRef # he volume of a three-dimensional Spatial Object.
rcc8dc: URIRef # Exists if the subject SpatialObject is spatially disjoint from the object SpatialObject. DE-9IM: FFTFFTTTT
rcc8ec: URIRef # Exists if the subject SpatialObject spatially meets the object SpatialObject. DE-9IM: FFTFTTTTT
rcc8eq: URIRef # Exists if the subject SpatialObject spatially equals the object SpatialObject. DE-9IM: TFFFTFFFT
Expand Down
2 changes: 0 additions & 2 deletions rdflib/plugins/sparql/algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,8 +1007,6 @@ def convert_node_arg(
return node_arg.n3()
elif isinstance(node_arg, CompValue):
return "{" + node_arg.name + "}"
elif isinstance(node_arg, Expr):
return "{" + node_arg.name + "}"
elif isinstance(node_arg, str):
return node_arg
else:
Expand Down
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_conjunctivegraph/test_conjunctive_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ def test_context_namespaces():
assert ("ex", ns) in g.namespace_manager.namespaces()


def test_deprecated():
with pytest.warns(
DeprecationWarning, match="ConjunctiveGraph is deprecated, use Dataset instead."
):
ConjunctiveGraph()


def get_graph_ids_tests():
def check(kws):
cg = ConjunctiveGraph()
Expand Down
12 changes: 12 additions & 0 deletions test/test_dataset/test_dataset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import shutil
import tempfile
import warnings
from test.data import CONTEXT1, LIKES, PIZZA, TAREK
from test.utils.namespace import EGSCHEME

Expand Down Expand Up @@ -261,3 +262,14 @@ def test_subgraph_without_identifier() -> None:
) == ("genid", genid_prefix)

assert f"{subgraph.identifier}".startswith(genid_prefix)


def test_not_deprecated():
"""
Ensure Dataset does not trigger the deprecation warning
from the ConjunctiveGraph superclass.
"""

with warnings.catch_warnings():
warnings.simplefilter("error")
Dataset()

0 comments on commit 53b353f

Please sign in to comment.