Skip to content

Commit

Permalink
Math expr param tag (#410)
Browse files Browse the repository at this point in the history
* add wx_property_tag to mathematical_expression-1.0.0.yaml

* add description

* use asdf.util.uri_match function for wx_tag validation

* update CHANGELOG.md

* remove deprecation from wx_tag_validator

* add schema test path
  • Loading branch information
CagtayFabry committed Jul 12, 2021
1 parent dfb6c7c commit 13dd216
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest_asdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
pip install -e .[test]
- name: run pytest
run: |
pytest --asdf-tests --ignore=weldx/tests/ --no-cov
pytest --asdf-tests --ignore=weldx/tests/ --no-cov weldx/asdf/schemas
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,19 @@
- update `wx_shape` syntax in `local_coordinate_system-1.0.0` [[#366]](https://github.com/BAMWelDX/weldx/pull/366)
- add custom `wx_shape` validation to `variable-1.0.0` [[#366]](https://github.com/BAMWelDX/weldx/pull/366)
- remove outdated `TimeSeries` shape validation code [[#399]](https://github.com/BAMWelDX/weldx/pull/399)
- use asdf tag validation pattern for `wx_property_tag` [[#410]](https://github.com/BAMWelDX/weldx/pull/410)
- update `MathematicalExpression` schema [[#410]](https://github.com/BAMWelDX/weldx/pull/410)

### fixes

- added check for symmetric key difference for mappings
with `util.compare_nested` [[#377]](https://github.com/BAMWelDX/weldx/pull/377)

### deprecations

- deprecate `wx_tag` validator (use default asdf uri pattern
matching) [[#410]](https://github.com/BAMWelDX/weldx/pull/410)

## 0.3.3 (30.03.2021)

This is a bugfix release to correctly include the asdf schema files in conda
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ examples:
type: object
properties:
expression:
description: |
A string representation of the mathematical expression.
The expression must conform to the sympy syntax.
type: string
parameters:
description: |
List of constant parameters that to be set in the mathematical expression.
type: object
wx_property_tag: "tag:stsci.edu:asdf/unit/quantity-1.*"

required: [expression]
propertyOrder: [expression, parameters]
Expand Down
5 changes: 4 additions & 1 deletion weldx/asdf/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
from asdf import ValidationError
from asdf.schema import _type_to_tag
from asdf.tagged import TaggedDict
from asdf.util import uri_match

from weldx.asdf.extension import WxSyntaxError
from weldx.asdf.tags.weldx.time.datetimeindex import DatetimeIndexType
from weldx.asdf.tags.weldx.time.timedeltaindex import TimedeltaIndexType
from weldx.constants import WELDX_QUANTITY as Q_
from weldx.constants import WELDX_UNIT_REGISTRY as UREG
from weldx.util import deprecated


def _walk_validator(
Expand Down Expand Up @@ -558,6 +560,7 @@ def wx_shape_validator(
)


@deprecated("0.4.0", "0.5.0", " _compare_tag_version will be removed in 0.5.0")
def _compare_tag_version(instance_tag: str, tagname: str):
"""Compare ASDF tag-strings with flexible version syntax.
Expand Down Expand Up @@ -631,7 +634,7 @@ def wx_tag_validator(validator, tagname, instance, schema):
instance_tag = _type_to_tag(type(instance))

if instance_tag is not None:
if not _compare_tag_version(instance_tag, tagname):
if not uri_match(tagname, instance_tag):
yield ValidationError(
"mismatched tags, wanted '{0}', got '{1}'".format(tagname, instance_tag)
)
Expand Down

0 comments on commit 13dd216

Please sign in to comment.