Skip to content

Commit

Permalink
Merge branch 'master' into schema_cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CagtayFabry authored Mar 12, 2024
2 parents ad3d658 + 2bceb68 commit ffdb3db
Show file tree
Hide file tree
Showing 70 changed files with 300 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
fetch-depth: 0 # Fetch all history for all tags and branches

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.8.0
uses: mamba-org/setup-micromamba@v1.8.1
with:
environment-file: ./devtools/conda.recipe/build_env.yml
environment-name: build_env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
fetch-depth: 0 # Fetch all history for all tags and branches

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.8.0
uses: mamba-org/setup-micromamba@v1.8.1
with:
environment-file: ./doc/rtd_environment.yml
environment-name: rtd
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
setup_requires: 'include'

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.8.0
uses: mamba-org/setup-micromamba@v1.8.1
with:
environment-file: ./environment.yml
environment-name: weldx
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:

- name: codecov.io
if: matrix.py == '3.10'
uses: codecov/codecov-action@v3.1.5
uses: codecov/codecov-action@v4.1.0

compat:
name: pytest
Expand All @@ -147,7 +147,7 @@ jobs:
setup_requires: 'include'

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.8.0
uses: mamba-org/setup-micromamba@v1.8.1
with:
environment-file: ./environment.yml
environment-name: weldx
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest_asdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
setup_requires: 'include'

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.8.0
uses: mamba-org/setup-micromamba@v1.8.1
with:
environment-file: ./environment.yml
environment-name: weldx
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
python-version: 3.x
- name: Lint
uses: pre-commit/action@v3.0.0
uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files --show-diff-on-failure

Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('./environment.yml') }}

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1.8.0
uses: mamba-org/setup-micromamba@v1.8.1
with:
environment-file: ./environment.yml
environment-name: weldx
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ repos:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.2.0
hooks:
- id: ruff
args:
- --quiet
- --fix
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
rev: v0.16
hooks:
- id: validate-pyproject
# ----- Jupyter Notebooks -----
Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# Release Notes

## 0.6.8 (unreleased)

### Changes

- use pandas.to_timedelta function to pass units to the TimeDeltaIndex object \[{pull}`918`\].

### Dependencies

- unpin nbval testing dependency.

## 0.6.7 (2023.08.24)

### Added

- added `weldx.exceptions` module with `WeldxException` \[{pull}`871`\] .
- added `weldx.exceptions` module with `WeldxException` \[{pull}`871`\].

### Fixes

Expand Down
1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""PyTest configuration."""

import pytest

collect_ignore_glob = [
Expand Down
1 change: 1 addition & 0 deletions devtools/scripts/clean_notebooks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Clean up jupyter notebooks in main directory."""

from __future__ import annotations

import json
Expand Down
1 change: 1 addition & 0 deletions devtools/scripts/update_manifest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Update the manifest file with schema files found in this directory."""

from pathlib import Path

import yaml
Expand Down
9 changes: 5 additions & 4 deletions doc/rtd_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ channels:
- conda-forge
- defaults
dependencies:
- python=3.9
- python=3.10
- setuptools_scm
# weldx base dependencies
- numpy>=1.18
- pandas>=1.0
- xarray>=0.15
- pint>=0.11
- scipy>=1.6.2
- scipy>=1.6.2,<1.12
- sympy>=1.6
- asdf>=2.8
- asdf>=2.8,<3
- bottleneck>=1.3
- matplotlib<3.8
# notebook execution
- myst-nb
- ipykernel
Expand All @@ -24,7 +25,7 @@ dependencies:
- urllib3<2
#- jinja2=3.0
- sphinx-copybutton
- pydata-sphinx-theme
- pydata-sphinx-theme<0.15 # parallel-write-unsafe
- numpydoc>=0.5
- sphinx-autodoc-typehints>=1.21.8
- typing_extensions
Expand Down
1 change: 1 addition & 0 deletions doc/src/tutorials/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common util functions used in weldx tutorials."""

from pathlib import Path

tutorials_dir = Path(__file__).parent.absolute()
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ requires-python = ">=3.9"
dependencies = [
"numpy >=1.20",
"asdf >=2.15.1",
"pandas >=1.0",
"pandas >=1.5",
"xarray >=2022.9.0",
"scipy >=1.6.2",
"sympy >=1.6",
Expand All @@ -64,7 +64,7 @@ test = [
"pytest >=6",
"pytest-cov",
"pytest-xdist",
"nbval <0.10",
"nbval",
]
vis = [
"weldx_widgets >=0.2",
Expand Down Expand Up @@ -125,6 +125,7 @@ filterwarnings = [
"ignore::DeprecationWarning:traittypes.*:",
"ignore:Passing method to :FutureWarning:xarray.*:",
"error::pint.UnitStrippedWarning",
#"error::FutureWarning", # todo: we want to enable this, as it notifies us about upcoming failures due to upstream changes.
]

[tool.coverage.run]
Expand Down
1 change: 1 addition & 0 deletions weldx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
asdf.validators
"""

# isort:skip_file
import warnings

Expand Down
1 change: 1 addition & 0 deletions weldx/asdf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This submodule contains ASDF related weldx extensions and schemas."""

# isort:skip_file

from weldx import tags # implement tags before the asdf extensions here just to be safe
Expand Down
1 change: 1 addition & 0 deletions weldx/asdf/cli/welding_schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""single_pass_weld schema."""

from __future__ import annotations

import sys
Expand Down
1 change: 1 addition & 0 deletions weldx/asdf/extension.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ASDF-extensions for weldx types."""

from __future__ import annotations

from asdf.extension import ManifestExtension
Expand Down
4 changes: 2 additions & 2 deletions weldx/asdf/file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""`WeldxFile` wraps creation and updating of ASDF files and underlying files."""

from __future__ import annotations

import copy
Expand Down Expand Up @@ -211,8 +212,7 @@ def __init__(
write_kwargs: Mapping = None,
tree: Mapping = None,
sync: bool = True,
custom_schema: None
| (
custom_schema: None | (
types_path_like,
tuple[None, types_path_like],
) = None,
Expand Down
1 change: 1 addition & 0 deletions weldx/asdf/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for asdf files."""

from __future__ import annotations

from collections.abc import Callable, Hashable, Mapping, MutableMapping, Set
Expand Down
1 change: 1 addition & 0 deletions weldx/asdf/validators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ASDF-validators for weldx types."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions weldx/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Classes and functions to configure the WelDX package."""

from __future__ import annotations

from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions weldx/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Define constants for global library use."""

from pathlib import Path as _Path

import pint
Expand Down
1 change: 1 addition & 0 deletions weldx/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Collection of common classes and functions."""

# isort:skip_file
from weldx.core.math_expression import MathematicalExpression
from weldx.core.generic_series import GenericSeries
Expand Down
1 change: 1 addition & 0 deletions weldx/core/generic_series.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains GenericSeries class."""

from __future__ import annotations

from collections.abc import Callable, Mapping
Expand Down
1 change: 1 addition & 0 deletions weldx/core/math_expression.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the MathematicalExpression class."""

from __future__ import annotations

from typing import Any, Union
Expand Down
1 change: 1 addition & 0 deletions weldx/core/spatial_series.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the SpatialSeries class."""

from __future__ import annotations

import pint
Expand Down
1 change: 1 addition & 0 deletions weldx/core/time_series.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains TimeSeries class."""

from __future__ import annotations

from typing import TYPE_CHECKING, Any
Expand Down
1 change: 1 addition & 0 deletions weldx/geometry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provides classes to define lines and surfaces."""

from __future__ import annotations

import copy
Expand Down
2 changes: 1 addition & 1 deletion weldx/schemas/weldx.bam.de/weldx/time/time-0.1.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ examples:
values: !<asdf://weldx.bam.de/weldx/tags/time/datetimeindex-0.1.0>
start: !<asdf://weldx.bam.de/weldx/tags/time/timestamp-0.1.0> '2021-01-01T00:00:00'
end: !<asdf://weldx.bam.de/weldx/tags/time/timestamp-0.1.0> '2021-01-01T00:00:02'
freq: S
freq: s
min: !<asdf://weldx.bam.de/weldx/tags/time/timestamp-0.1.0> '2021-01-01T00:00:00'
max: !<asdf://weldx.bam.de/weldx/tags/time/timestamp-0.1.0> '2021-01-01T00:00:02'
reference_time: !<asdf://weldx.bam.de/weldx/tags/time/timestamp-0.1.0> '2021-01-01T00:00:00'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ examples:
!<asdf://weldx.bam.de/weldx/tags/time/timedeltaindex-0.1.0>
start: !<asdf://weldx.bam.de/weldx/tags/time/timedelta-0.1.0> P0DT0H0M0S
end: !<asdf://weldx.bam.de/weldx/tags/time/timedelta-0.1.0> P0DT0H0M10S
freq: 2S
freq: 2s
min: !<asdf://weldx.bam.de/weldx/tags/time/timedelta-0.1.0> P0DT0H0M0S
max: !<asdf://weldx.bam.de/weldx/tags/time/timedelta-0.1.0> P0DT0H0M10S
-
Expand Down
1 change: 1 addition & 0 deletions weldx/tags/base_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module providing ASDF implementations for basic python types."""

from uuid import UUID

from asdf.asdf import SerializationContext
Expand Down
1 change: 1 addition & 0 deletions weldx/tags/core/data_array.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Serialization for xarray.DataArray."""

from __future__ import annotations

import pint
Expand Down
1 change: 1 addition & 0 deletions weldx/tags/core/file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains classes for the asdf serialization of an external file."""

from copy import deepcopy

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions weldx/tags/core/media_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains classes for the asdf serialization of media files."""

import pathlib

from weldx.asdf.types import WeldxConverter
Expand Down
1 change: 1 addition & 0 deletions weldx/tags/core/time_series.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the serialization class for the weldx.core.TimeSeries."""

from __future__ import annotations

import pint
Expand Down
10 changes: 10 additions & 0 deletions weldx/tags/time/timedeltaindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

__all__ = ["TimedeltaIndexConverter"]

PANDAS_OLD_UNIT_SUFFIXES = dict(H="h", T="min", S="s", L="ms", U="us", N="ns")


def _handle_converted_pd_tdi_units(node: TaggedDict):
"""Convert changed units in Pandas.Datetimeindex to valid values."""
for suf in PANDAS_OLD_UNIT_SUFFIXES:
node["freq"] = node["freq"].replace(suf, PANDAS_OLD_UNIT_SUFFIXES[suf])


class TimedeltaIndexConverter(WeldxConverter):
"""A simple implementation of serializing pandas TimedeltaIndex."""
Expand All @@ -33,6 +41,7 @@ def to_yaml_tree(self, obj: pd.TimedeltaIndex, tag: str, ctx) -> dict:
def from_yaml_tree(self, node: dict, tag: str, ctx):
"""Construct TimedeltaIndex from tree."""
if "freq" in node:
_handle_converted_pd_tdi_units(node)
return pd.timedelta_range(
start=node["start"], end=node["end"], freq=node["freq"]
)
Expand All @@ -43,6 +52,7 @@ def from_yaml_tree(self, node: dict, tag: str, ctx):
def shape_from_tagged(node: TaggedDict) -> list[int]:
"""Calculate the shape from static tagged tree instance."""
if "freq" in node:
_handle_converted_pd_tdi_units(node)
tdi_temp = pd.timedelta_range(
start=str(node["start"]), # can't handle TaggedString directly
end=str(node["end"]),
Expand Down
1 change: 1 addition & 0 deletions weldx/tests/asdf_tests/test_asdf_aws_schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test ASDF serialization of AWS schema definitions."""

import pytest

from weldx.asdf.util import write_read_buffer_context
Expand Down
1 change: 1 addition & 0 deletions weldx/tests/asdf_tests/test_asdf_base_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests asdf implementations of python base types."""

import uuid

import numpy as np
Expand Down
Loading

0 comments on commit ffdb3db

Please sign in to comment.