Skip to content

Commit

Permalink
Merge branch 'develop' into hs/eom-params
Browse files Browse the repository at this point in the history
  • Loading branch information
HGSilveri authored Aug 29, 2023
2 parents 3c6e802 + f742f5c commit fde1486
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# For generating documentation.
Sphinx
Sphinx < 7
sphinx-rtd-theme # documentation theme
sphinx_autodoc_typehints == 1.21.3
nbsphinx
Expand Down
10 changes: 5 additions & 5 deletions pulser-core/pulser/json/abstract_repr/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
from typing import Literal

import jsonschema
from referencing import Registry, Resource

from pulser.json.abstract_repr import SCHEMAS, SCHEMAS_PATH
from pulser.json.abstract_repr import SCHEMAS

RESOLVER = jsonschema.validators.RefResolver(
base_uri=f"{SCHEMAS_PATH.resolve().as_uri()}/",
referrer=SCHEMAS["sequence"],
REGISTRY: Registry = Registry().with_resources(
[("device-schema.json", Resource.from_contents(SCHEMAS["device"]))]
)


Expand All @@ -37,5 +37,5 @@ def validate_abstract_repr(
obj = json.loads(obj_str)
validate_args = dict(instance=obj, schema=SCHEMAS[name])
if name == "sequence":
validate_args["resolver"] = RESOLVER
validate_args["registry"] = REGISTRY
jsonschema.validate(**validate_args)
2 changes: 1 addition & 1 deletion pulser-core/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jsonschema < 4.18
jsonschema >= 4.18
matplotlib
# Numpy 1.20 introduces type hints, 1.24.0 breaks matplotlib < 3.6.1
numpy >= 1.20, != 1.24.0
Expand Down
4 changes: 2 additions & 2 deletions tests/test_abstract_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
AbstractReprEncoder,
abstract_repr,
)
from pulser.json.abstract_repr.validation import RESOLVER
from pulser.json.abstract_repr.validation import REGISTRY
from pulser.json.exceptions import AbstractReprError, DeserializeDeviceError
from pulser.parametrized.decorators import parametrize
from pulser.parametrized.paramobj import ParamObj
Expand Down Expand Up @@ -282,7 +282,7 @@ def validate_schema(instance):
"pulser-core/pulser/json/abstract_repr/schemas/" "sequence-schema.json"
) as f:
schema = json.load(f)
jsonschema.validate(instance=instance, schema=schema, resolver=RESOLVER)
jsonschema.validate(instance=instance, schema=schema, registry=REGISTRY)


class TestSerialization:
Expand Down

0 comments on commit fde1486

Please sign in to comment.