Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/pre-commit/actio…
Browse files Browse the repository at this point in the history
…n-3.0.1
  • Loading branch information
CagtayFabry authored Mar 12, 2024
2 parents 457b672 + 6c20c5f commit fdf309a
Show file tree
Hide file tree
Showing 64 changed files with 287 additions and 176 deletions.
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
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
5 changes: 3 additions & 2 deletions weldx/tests/asdf_tests/test_asdf_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests asdf implementations of core module."""

from pathlib import Path
from tempfile import TemporaryDirectory

Expand Down Expand Up @@ -424,12 +425,12 @@ def test_coordinate_system_manager_time_dependencies(
lcs_tdp_1_time_ref = pd.Timestamp("2000-03-17")
lcs_tdp_1 = tf.LocalCoordinateSystem(
coordinates=Q_([[1, 2, 3], [4, 5, 6]], "mm"),
time=pd.TimedeltaIndex([1, 2], "D"),
time=pd.to_timedelta([1, 2], "D"),
time_ref=lcs_tdp_1_time_ref,
)
lcs_tdp_2 = tf.LocalCoordinateSystem(
coordinates=Q_([[3, 7, 3], [9, 5, 8]], "mm"),
time=pd.TimedeltaIndex([1, 2], "D"),
time=pd.to_timedelta([1, 2], "D"),
time_ref=pd.Timestamp("2000-03-21"),
)

Expand Down
1 change: 1 addition & 0 deletions weldx/tests/asdf_tests/test_asdf_graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test graph serializations."""

import unittest
from uuid import uuid4

Expand Down
1 change: 1 addition & 0 deletions weldx/tests/asdf_tests/test_asdf_groove.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test all ASDF groove implementations."""

import pytest
from decorator import contextmanager

Expand Down
1 change: 1 addition & 0 deletions weldx/tests/asdf_tests/test_asdf_time.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test time schema implementation."""

import numpy as np
import pandas as pd
import pytest
Expand Down
1 change: 1 addition & 0 deletions weldx/tests/asdf_tests/test_asdf_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""tests for asdf utility functions."""

from __future__ import annotations

import io
Expand Down
1 change: 1 addition & 0 deletions weldx/tests/asdf_tests/test_asdf_validators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test custom weldx ASDF validator functions."""

import numpy as np
import pandas as pd
import pytest
Expand Down
1 change: 1 addition & 0 deletions weldx/tests/asdf_tests/test_media_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for MediaFile."""

import numpy as np
import pytest
import xarray as xr
Expand Down
1 change: 1 addition & 0 deletions weldx/tests/asdf_tests/test_weldx_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the WeldxFile class."""

import itertools
import os
import pathlib
Expand Down
1 change: 1 addition & 0 deletions weldx/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""pytest configuration."""

import pytest

from weldx.asdf.cli.welding_schema import single_pass_weld_example
Expand Down
1 change: 1 addition & 0 deletions weldx/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test the `config` module."""

from pathlib import Path

import asdf
Expand Down
Loading

0 comments on commit fdf309a

Please sign in to comment.