Skip to content

Commit

Permalink
Merge remote-tracking branch 'marscher/fix_xarray_lcs_join' into fix_…
Browse files Browse the repository at this point in the history
…xarray_lcs_join
  • Loading branch information
CagtayFabry committed Apr 3, 2023
2 parents 510f9df + bf24a1a commit 2e0ea22
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
fetch-depth: 0 # Fetch all history for all tags and branches
- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.8'

- name: Cache pip
uses: actions/cache@v3
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
py: ['3.9', '3.10', '3.11']
py: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -61,17 +61,17 @@ jobs:
run: micromamba activate weldx

- name: install cookiecutter
if: matrix.py == '3.9'
if: matrix.py == '3.8'
run: |
pip install cookiecutter
- name: create installable quality standard from repo
if: matrix.py == '3.9'
if: matrix.py == '3.8'
run: |
cookiecutter --no-input https://github.com/BAMWeldx/quality-standard-template
- name: install quality standard
if: matrix.py == '3.9'
if: matrix.py == '3.8'
run: |
pip install -e ./quality_standard_demo
Expand All @@ -87,32 +87,32 @@ jobs:
path: pytest.xml

- name: run pytest on notebooks (append coverage)
if: matrix.py == '3.9'
if: matrix.py == '3.8'
run: |
pytest -n 2 --dist loadfile --nbval --current-env --cov-append ./doc/src/tutorials/
- name: test with WeldxFile
if: matrix.py == '3.9'
if: matrix.py == '3.8'
run: |
pytest -n 2 --weldx-file-rw-buffer --weldx-file-rw-buffer-disp-header --cov-append ./weldx/tests/asdf_tests
- name: test quality standard
if: matrix.py == '3.9'
if: matrix.py == '3.8'
run: |
pytest --cov-append ./weldx/tests/asdf_tests/quality_standards_check.py
- name: test installable quality standard from template repository
if: matrix.py == '3.9'
if: matrix.py == '3.8'
run: |
pytest --cov-append ./weldx/tests/asdf_tests/installable_quality_standard_check.py
- name: coverage xml (combination is performed by pytest-cov)
if: matrix.py == '3.9'
if: matrix.py == '3.8'
run: coverage xml

- name: codecov.io
if: matrix.py == '3.9'
if: matrix.py == '3.8'
uses: codecov/codecov-action@v3.1.1

compat:
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.242
rev: v0.0.259
hooks:
- id: ruff
args:
Expand All @@ -45,7 +45,7 @@ repos:
- id: validate-pyproject
# ----- Jupyter Notebooks -----
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.6.1
rev: 1.6.4
hooks:
- id: nbqa-black
- id: nbqa-ruff # ruff handles isort
Expand All @@ -60,7 +60,7 @@ repos:
- --remove-kernel-metadata
# ----- spellchecking -----
- repo: https://github.com/codespell-project/codespell/
rev: v2.2.2
rev: v2.2.4
hooks:
- id: codespell
exclude: doc/src/legal-notice.md
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Dependencies

- require XArray >= 2023.3.0, as `LocalCoordinateSystem` now handles merges correctly \[{pull}`861`\].
- require XArray >= 2022.9.0, as `LocalCoordinateSystem` now handles merges correctly \[{pull}`861`\].

## 0.6.4 (09.02.2023)

Expand Down
2 changes: 1 addition & 1 deletion devtools/conda.recipe/build_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
- defaults
dependencies:
- python=3.9
- python=3.8
- setuptools
- setuptools_scm
- conda-verify
Expand Down
2 changes: 1 addition & 1 deletion devtools/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- defaults
- conda-forge
dependencies:
- python=3.9
- python=3.8
- setuptools_scm
- numpy>=1.18
- pandas>=1.0
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ classifiers = [
]

# Dependencies
requires-python = ">=3.9"
requires-python = ">=3.8"
dependencies = [
"numpy >=1.20",
"asdf >=2.8.2,!=2.14.0,!=2.14.1,!=2.14.2",
"pandas >=1.0",
"xarray >=2023.3.0",
"xarray >=2022.9.0",
"scipy >=1.4,!=1.6.0,!=1.6.1",
"sympy >=1.6",
"pint >=0.18",
Expand Down Expand Up @@ -114,7 +114,7 @@ addopts = "--tb=short --color=yes -rsw --cov=weldx --cov-report=term-missing:ski
testpaths = "weldx"
# custom test markers, see https://docs.pytest.org/en/latest/example/markers.html#mark-examples
markers = "slow: marks tests as slow to run (skipped by default, enable with --runslow option)"
asdf_schema_root = "weldx/schemas/weldx.bam.de/weldx" # TODO: couldn"t we just use the entry points to resolve this?
asdf_schema_root = "weldx/schemas/weldx.bam.de/weldx" # TODO: couldn't we just use the entry points to resolve this?
#asdf_schema_tests_enabled = true
#asdf_schema_skip_tests =
# weldx.bam.de/weldx/datamodels/single_pass_weld-1.0.0.schema.yaml
Expand Down
11 changes: 8 additions & 3 deletions weldx/asdf/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def get_schema_path(schema: str) -> Path: # pragma: no cover
if len(schemas) == 0:
raise ValueError(f"No matching schema for filename '{schema}'.")
elif len(schemas) > 1:
warn(f"Found more than one matching schema for filename '{schema}'.")
warn(
f"Found more than one matching schema for filename '{schema}'.",
stacklevel=1,
)
return schemas[0]


Expand Down Expand Up @@ -477,7 +480,9 @@ def get_converter_for_tag(tag: str) -> Union[WeldxConverter, None]:
"""Get the converter class that handles a given tag."""
converters = [s for s in WeldxConverter.__subclasses__() if uri_match(s.tags, tag)]
if len(converters) > 1:
warn(f"Found more than one converter class for {tag=}", UserWarning)
warn(
f"Found more than one converter class for {tag=}", UserWarning, stacklevel=1
)
if converters:
return converters[0]
return None
Expand Down Expand Up @@ -664,7 +669,7 @@ def _warn_protected_keys(self, stacklevel=3):
)


def get_schema_tree( # noqa: C901 # ignore too high complexity
def get_schema_tree( # noqa: C901, MC0001, RUF100, codacy:ignore
schemafile: Union[str, Path], *, drop: set = None
) -> dict:
"""Get a dictionary representation of a weldx schema file with custom formatting.
Expand Down
15 changes: 9 additions & 6 deletions weldx/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def _determine_output_signal(

@staticmethod
def _determine_output_signal_type(type_transformation: str, input_type: str) -> str:
"""Determine the type of a transformations' output signal.
"""Determine the type of given transformations' output signal.
Parameters
----------
Expand Down Expand Up @@ -636,7 +636,7 @@ def add_transformation(
... )
Use the mathematical expression to create a signal transformation which also
performs a analog-digital conversion.
performs analog-digital conversion.
>>> current_ad_transform = SignalTransformation(
... name="Current AD conversion",
Expand Down Expand Up @@ -713,7 +713,7 @@ def add_transformation_from_equipment(
... )
Use the mathematical expression to create a signal transformation which also
performs a analog-digital conversion.
performs analog-digital conversion.
>>> current_ad_transform = SignalTransformation(
... name="Current AD conversion",
Expand All @@ -722,7 +722,7 @@ def add_transformation_from_equipment(
... type_transformation="AD"
... )
Create a new equipment that performs the transformation
Create new equipment that performs the transformation
>>> current_ad_converter = MeasurementEquipment(
... name="Current AD converter",
Expand Down Expand Up @@ -812,7 +812,7 @@ def create_transformation(
... )
Use the mathematical expression to create a new transformation which also
performs a analog-digital conversion.
performs an analog-digital conversion.
>>> mc.create_transformation(name="Current AD conversion",
... error=Error(deviation=Q_(1,"percent")),
Expand All @@ -825,7 +825,10 @@ def create_transformation(
output_signal_unit = U_(output_signal_unit)

if output_signal_type is None and output_signal_unit is None and func is None:
warn("The created transformation does not perform any transformations.")
warn(
"The created transformation does not perform any transformations.",
stacklevel=1,
)

input_signal_source = self._check_and_get_node_name(input_signal_source)
input_signal: Signal = self._graph.nodes[input_signal_source]["signal"]
Expand Down
4 changes: 3 additions & 1 deletion weldx/tags/core/mathematical_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def to_yaml_tree(self, obj: MathematicalExpression, tag: str, ctx) -> dict:
for k, v in obj.parameters.items():
if isinstance(v, DataArray):
if len(v.coords) > 0:
warnings.warn("Coordinates are dropped during serialization.")
warnings.warn(
"Coordinates are dropped during serialization.", stacklevel=0
)
dims = v.dims
v = v.data
setattr(v, META_ATTR, dict(dims=dims))
Expand Down
3 changes: 2 additions & 1 deletion weldx/transformations/cs_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,8 @@ def unmerge(self) -> list[CoordinateSystemManager]:
warnings.warn(
"The following coordinate systems are not part of any subsystem and "
f"lost connection to the CoordinateSystemManager instance: {lcs_rem}\n"
"These systems are removed."
"These systems are removed.",
stacklevel=1,
)

return subsystems
Expand Down
18 changes: 12 additions & 6 deletions weldx/transformations/local_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ def __init__(
):
warnings.warn(
"Provided time is dropped because of the given coordinates and "
"orientation."
"orientation.",
stacklevel=2,
)

if construction_checks:
Expand All @@ -113,7 +114,10 @@ def __init__(

# warn about dropped reference time
if time_ref is not None and time is None and self._time_ref is None:
warnings.warn("Reference time dropped. The system is not time dependent.")
warnings.warn(
"Reference time dropped. The system is not time dependent.",
stacklevel=2,
)

def __repr__(self):
"""Give __repr_ output in xarray format."""
Expand Down Expand Up @@ -167,6 +171,8 @@ def __add__(self, rhs_cs: LocalCoordinateSystem) -> LocalCoordinateSystem:
)

# handle time
# TODO: time var is unused! why? The var should be used in line 201?
# e.g. ... rhs_cs.interp_time(lhs_cs.time, time_ref)
time = lhs_cs.time
if time is None:
time = rhs_cs.time
Expand Down Expand Up @@ -407,7 +413,7 @@ def _unify_time_axis(
orientation = ut.xr_interp_orientation_in_time(orientation, time_union)
coordinates = ut.xr_interp_coordinates_in_time(coordinates, time_union)

return (orientation, coordinates)
return orientation, coordinates

@classmethod
def from_euler(
Expand All @@ -422,7 +428,7 @@ def from_euler(
"""Construct a local coordinate system from an euler sequence.
This function uses scipy.spatial.transform.Rotation.from_euler method to define
the coordinate systems orientation. Take a look at it's documentation, if some
the coordinate systems orientation. Take a look at its documentation, if some
information is missing here. The related parameter docs are a copy of the scipy
documentation.
Expand Down Expand Up @@ -724,7 +730,7 @@ def interp_time(
value will be stripped from the result.
Additionally, if the passed time range does not overlap with the time range of
the coordinate system, the resulting system won't be time dependent neither
because the values outside of the coordinate systems time range are considered
because the values outside the coordinate systems time range are considered
as being constant.
Parameters
Expand Down Expand Up @@ -826,7 +832,7 @@ def plot(
A reference timestamp that can be provided if the ``time`` parameter is a
`pandas.TimedeltaIndex`
time_index: int
If the coordinate system is time dependent, this parameter can be used to
If the coordinate system is time dependent, this parameter can be used
to select a specific key frame by its index.
scale_vectors :
A scaling factor or array to adjust the vector length
Expand Down
24 changes: 17 additions & 7 deletions weldx/util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import warnings
from collections.abc import Callable, Sequence, Set
from functools import wraps
from importlib.util import find_spec
from inspect import getmembers, isfunction
from typing import ClassVar, Collection, Hashable, Mapping, Union

Expand Down Expand Up @@ -36,6 +37,7 @@


class WeldxDeprecationWarning(DeprecationWarning):

"""Deprecation warning type."""


Expand Down Expand Up @@ -419,15 +421,23 @@ def apply_func_by_mapping(func_map: dict[Hashable, Callable], inputs):
@decorator
def check_matplotlib_available(func, *args, **kwargs):
"""Emit a warning if matplotlib is not available."""
try:
import matplotlib.pyplot as plt # noqa: F401
except ModuleNotFoundError:

def _warn():
warnings.warn(
"Matplotlib unavailable! Cannot plot. "
"Please install matplotlib or weldx_widgets.",
stacklevel=2,
stacklevel=3,
)
else:
return func(*args, **kwargs)

return None
try:
if find_spec("matplotlib.pyplot") is None:
_warn()
return
except ModuleNotFoundError:
_warn()
return
except ValueError:
warnings.warn("Matplotlib is unavailable (module set to None).", stacklevel=2)
return

return func(*args, **kwargs)

0 comments on commit 2e0ea22

Please sign in to comment.