Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing tests and documentation #684

Merged
merged 17 commits into from
Jan 28, 2022
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ changes
- The ``wx_property_tag`` validator now also accepts lists of different tags. [:pull:`670`]
When multiple tags are passed, validation will fail if *none* of the supplied patterns match.

- Due to a `pandas` update, using the + operator with `Time` and either a `pandas.TimedeltaIndex` or `pandas.DatetimeIndex`
now only works if the `Time` instance is on the left-hand side. [:pull:`684`]

fixes
=====

Expand Down
1 change: 1 addition & 0 deletions doc/nitpick_ignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ py:class k3d.plot
py:class np.ndarray
py:class DataArray
py:class InitVar
py:class dataclasses.InitVar
py:class Time

# inherited -------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions tutorials/01_02_time_dependent_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@
"source": [
"What remains now is to divide the result by the process duration.\n",
"We can get the time data either from the voltage or the current data as they were both measured simultaneously.\n",
"It can be accessed with `.time` which returns a `weldx.Time` instance.\n",
"It can be accessed with `.time` which returns a `weldx.time.Time` instance.\n",
vhirtham marked this conversation as resolved.
Show resolved Hide resolved
"We will talk a bit more about this class in another tutorial.\n",
"For now it is sufficient to know, that it provides a `.duration` method to get the duration of the contained time data as a new `weldx.Time` instance and that we can turn it into a quantity using `.as_quantity`.\n",
"For now it is sufficient to know, that it provides a `.duration` method to get the duration of the contained time data as a new `weldx.time.Time` instance and that we can turn it into a quantity using `.as_quantity`.\n",
vhirtham marked this conversation as resolved.
Show resolved Hide resolved
"So let's finally calculate the electrical power:"
]
},
Expand Down
22 changes: 12 additions & 10 deletions weldx/asdf/cli/welding_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,23 @@ def single_pass_weld_example(
import pandas as pd
from asdf.tags.core import Software

# importing the weldx package with prevalent default abbreviations
import weldx
import weldx.geometry as geo
import weldx.measurement as msm
from weldx import Q_, GmawProcess
from weldx import LocalCoordinateSystem as lcs
from weldx import TimeSeries, WXRotation, get_groove
from weldx.asdf.util import get_schema_path, write_buffer
from weldx.constants import META_ATTR
from weldx.core import MathematicalExpression

# importing the weldx package with prevalent default abbreviations
import weldx.transformations as tf
from weldx.asdf.util import get_schema_path, write_buffer, write_read_buffer
from weldx.constants import META_ATTR, Q_
from weldx.core import MathematicalExpression, TimeSeries
from weldx.tags.aws.process.gas_component import GasComponent
from weldx.tags.aws.process.shielding_gas_for_procedure import (
ShieldingGasForProcedure,
)
from weldx.tags.aws.process.shielding_gas_type import ShieldingGasType
from weldx.tags.processes.process import GmawProcess
from weldx.transformations.local_cs import LocalCoordinateSystem as lcs
from weldx.transformations.rotation import WXRotation
from weldx.welding.groove.iso_9692_1 import get_groove
from weldx.welding.util import sine

# Timestamp
Expand Down Expand Up @@ -71,7 +73,7 @@ def single_pass_weld_example(

# Setup the Coordinate System Manager (CSM)
# crete a new coordinate system manager with default base coordinate system
csm = weldx.transformations.CoordinateSystemManager("base")
csm = tf.CoordinateSystemManager("base")

# add the workpiece coordinate system
csm.add_cs(
Expand Down Expand Up @@ -296,7 +298,7 @@ def single_pass_weld_example(
model_path = get_schema_path("single_pass_weld-0.1.0.yaml")

# pre-validate?
weldx.asdf.util.write_read_buffer(
write_read_buffer(
tree,
asdffile_kwargs=dict(custom_schema=str(model_path)),
)
Expand Down
2 changes: 1 addition & 1 deletion weldx/asdf/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def software_history_entry(self):
def software_history_entry(self, value: dict):
"""Set the software used for making history entries."""
if value is None:
from weldx import __version__ as version
from weldx._version import __version__ as version

self._DEFAULT_SOFTWARE_ENTRY = {
"name": "weldx",
Expand Down
4 changes: 2 additions & 2 deletions weldx/asdf/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def show(wx):

if _use_weldx_file:
write_kwargs = dict(all_array_storage="inline")
from weldx import WeldxFile
from weldx.asdf.file import WeldxFile

with WeldxFile(
tree=tree,
Expand Down Expand Up @@ -181,7 +181,7 @@ def read_buffer(
if _use_weldx_file is None:
_use_weldx_file = _USE_WELDX_FILE
if _use_weldx_file:
from weldx import WeldxFile
from weldx.asdf.file import WeldxFile

return WeldxFile(buffer, asdffile_kwargs=open_kwargs)

Expand Down
2 changes: 1 addition & 1 deletion weldx/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

Examples
--------
>>> from weldx import Q_
>>> from weldx.constants import Q_
vhirtham marked this conversation as resolved.
Show resolved Hide resolved
>>> length = Q_(10, "mm")
>>> length
<Quantity(10, 'millimeter')>
Expand Down
3 changes: 2 additions & 1 deletion weldx/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,8 @@ def __init__(
Create a `GenericSeries` representing a translation with 3 m/s in x-direction
starting at point ``[0, 2 ,2] cm``

>>> from weldx import GenericSeries, Q_
>>> from weldx.core import GenericSeries
>>> from weldx.constants import Q_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a bug/import error when we import from the main weldx namespace in the doctests?

Copy link
Collaborator Author

@vhirtham vhirtham Jan 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment above --- no there isn't.

vhirtham marked this conversation as resolved.
Show resolved Hide resolved
>>> GenericSeries( # doctest: +NORMALIZE_WHITESPACE
... "a*t + b",
... parameters=dict(a=Q_([3, 0, 0], "mm/s"), b=Q_([0, 2, 2], "cm")),
Expand Down
5 changes: 2 additions & 3 deletions weldx/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import weldx.util as ut
from weldx.constants import Q_
from weldx.constants import WELDX_UNIT_REGISTRY as UREG
from weldx.time import Time
from weldx.types import QuantityLike

_DEFAULT_LEN_UNIT = UREG.millimeters
Expand Down Expand Up @@ -2530,8 +2529,8 @@ class SpatialData:
Shape should be [time * n, 3]."""
attributes: Dict[str, np.ndarray] = None
"""optional dictionary with additional attributes to store alongside data."""
time: InitVar[Time] = None
"""Time axis if data is time dependent."""
time: InitVar = None
"""The time axis if data is time dependent."""

def __post_init__(self, time):
"""Convert and check input values."""
Expand Down
12 changes: 6 additions & 6 deletions weldx/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def __init__(

Examples
--------
>>> from weldx import Q_
>>> from weldx.constants import Q_
vhirtham marked this conversation as resolved.
Show resolved Hide resolved
>>> from weldx.measurement import Error, MeasurementChain, Signal, SignalSource

Create a signal source
Expand Down Expand Up @@ -324,7 +324,7 @@ def from_equipment(

Examples
--------
>>> from weldx import Q_
>>> from weldx.constants import Q_
vhirtham marked this conversation as resolved.
Show resolved Hide resolved
>>> from weldx.measurement import Error, MeasurementChain,\
MeasurementEquipment, Signal, SignalSource

Expand Down Expand Up @@ -399,7 +399,7 @@ def from_parameters(

Examples
--------
>>> from weldx import Q_
>>> from weldx.constants import Q_
vhirtham marked this conversation as resolved.
Show resolved Hide resolved
>>> from weldx.measurement import Error, MeasurementChain

>>> mc = MeasurementChain.from_parameters(
Expand Down Expand Up @@ -613,7 +613,7 @@ def add_transformation(

Examples
--------
>>> from weldx import Q_
>>> from weldx.constants import Q_
vhirtham marked this conversation as resolved.
Show resolved Hide resolved
>>> from weldx.core import MathematicalExpression
>>> from weldx.measurement import Error, MeasurementChain, SignalTransformation

Expand Down Expand Up @@ -689,7 +689,7 @@ def add_transformation_from_equipment(

Examples
--------
>>> from weldx import Q_
>>> from weldx.constants import Q_
vhirtham marked this conversation as resolved.
Show resolved Hide resolved
>>> from weldx.core import MathematicalExpression
>>> from weldx.measurement import Error, MeasurementChain,\
MeasurementEquipment, SignalTransformation
Expand Down Expand Up @@ -789,7 +789,7 @@ def create_transformation(

Examples
--------
>>> from weldx import Q_
>>> from weldx.constants import Q_
vhirtham marked this conversation as resolved.
Show resolved Hide resolved
>>> from weldx.core import MathematicalExpression
>>> from weldx.measurement import Error, MeasurementChain, SignalTransformation

Expand Down
3 changes: 2 additions & 1 deletion weldx/tags/debug/test_shape_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import pandas as pd
import pint

from weldx import Q_, TimeSeries
from weldx.asdf.util import dataclass_serialization_class
from weldx.constants import Q_
from weldx.core import TimeSeries

__all__ = ["ShapeValidatorTestClass", "ShapeValidatorTestClassConverter"]

Expand Down
2 changes: 1 addition & 1 deletion weldx/tags/debug/test_unit_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import numpy as np
import pint

from weldx import Q_
from weldx.asdf.util import dataclass_serialization_class
from weldx.constants import Q_

__all__ = ["UnitValidatorTestClass", "UnitValidatorTestClassConverter"]

Expand Down
2 changes: 1 addition & 1 deletion weldx/tests/asdf_tests/test_asdf_gmaw_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from weldx import Q_
from weldx.asdf.util import write_read_buffer
from weldx.constants import Q_
from weldx.core import TimeSeries
from weldx.welding.processes import GmawProcess

Expand Down
2 changes: 1 addition & 1 deletion weldx/tests/asdf_tests/test_asdf_measurement.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from weldx import Q_
from weldx.asdf.util import write_read_buffer
from weldx.constants import Q_
from weldx.core import MathematicalExpression
from weldx.measurement import (
Error,
Expand Down
2 changes: 1 addition & 1 deletion weldx/tests/asdf_tests/test_asdf_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pandas as pd
import pytest

from weldx import Time
from weldx.asdf.util import write_buffer, write_read_buffer
from weldx.time import Time


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion weldx/tests/asdf_tests/test_asdf_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import pytest

from weldx import WeldxFile
from weldx.asdf.file import WeldxFile
from weldx.asdf.util import (
dataclass_serialization_class,
get_highest_tag_version,
Expand Down
3 changes: 2 additions & 1 deletion weldx/tests/asdf_tests/test_asdf_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import pytest
from asdf import ValidationError

from weldx import Q_, TimeSeries
from weldx.asdf.types import WxSyntaxError
from weldx.asdf.util import write_buffer, write_read_buffer
from weldx.asdf.validators import _custom_shape_validator
from weldx.constants import Q_
from weldx.core import TimeSeries
from weldx.tags.debug.test_property_tag import PropertyTagTestClass
from weldx.tags.debug.test_shape_validator import ShapeValidatorTestClass
from weldx.tags.debug.test_unit_validator import UnitValidatorTestClass
Expand Down
3 changes: 1 addition & 2 deletions weldx/tests/asdf_tests/test_weldx_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
import xarray as xr
from jsonschema import ValidationError

from weldx import WeldxFile
from weldx.asdf.cli.welding_schema import single_pass_weld_example
from weldx.asdf.file import _PROTECTED_KEYS, DEFAULT_ARRAY_INLINE_THRESHOLD
from weldx.asdf.file import _PROTECTED_KEYS, DEFAULT_ARRAY_INLINE_THRESHOLD, WeldxFile
from weldx.asdf.util import get_schema_path
from weldx.constants import META_ATTR
from weldx.types import SupportsFileReadWrite
Expand Down
2 changes: 1 addition & 1 deletion weldx/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import asdf
import pytest

from weldx import WeldxFile
from weldx.asdf.file import WeldxFile
from weldx.config import QualityStandard, add_quality_standard, enable_quality_standard
from weldx.constants import META_ATTR
from weldx.measurement import MeasurementEquipment
Expand Down
3 changes: 2 additions & 1 deletion weldx/tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
import weldx.geometry as geo
import weldx.tests._helpers as helpers
import weldx.transformations as tf
from weldx import Q_, CoordinateSystemManager
from weldx.constants import Q_
from weldx.geometry import SpatialData
from weldx.transformations import WXRotation
from weldx.transformations.cs_manager import CoordinateSystemManager

from ._helpers import matrix_is_close, vector_is_close

Expand Down
10 changes: 8 additions & 2 deletions weldx/tests/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
from pandas import Timestamp, date_range
from pint import DimensionalityError

from weldx import Q_, LocalCoordinateSystem, TimeSeries
from weldx.constants import Q_
from weldx.core import TimeSeries
from weldx.time import Time, types_time_like
from weldx.transformations.local_cs import LocalCoordinateSystem


def _initialize_delta_type(cls_type, values, unit):
Expand Down Expand Up @@ -336,6 +338,8 @@ def test_add_timedelta(
np.ndarray,
np.timedelta64,
np.datetime64,
DTI,
TDI,
):
return

Expand Down Expand Up @@ -419,7 +423,7 @@ def test_add_datetime(
return

# skip __radd__ cases where we got conflicts with the other types' __add__
if not other_on_rhs and other_type in (Q_, np.ndarray, np.timedelta64):
if not other_on_rhs and other_type in (Q_, np.ndarray, np.timedelta64, TDI):
return

# setup rhs
Expand Down Expand Up @@ -535,6 +539,8 @@ def test_sub(
np.ndarray,
np.timedelta64,
np.datetime64,
DTI,
TDI,
):
return

Expand Down
3 changes: 2 additions & 1 deletion weldx/tests/transformations/test_cs_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
from pandas import Timestamp as TS # noqa

import weldx.transformations as tf
from weldx import Q_, SpatialData
from weldx.constants import Q_
from weldx.core import MathematicalExpression, TimeSeries
from weldx.geometry import SpatialData
from weldx.tests._helpers import get_test_name, matrix_is_close
from weldx.time import Time, types_time_like, types_timestamp_like
from weldx.transformations import CoordinateSystemManager as CSM # noqa
Expand Down
2 changes: 1 addition & 1 deletion weldx/tests/transformations/test_local_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import weldx.transformations as tf
import weldx.util as ut
from weldx import Q_
from weldx.constants import Q_
from weldx.core import MathematicalExpression, TimeSeries
from weldx.tests._helpers import get_test_name
from weldx.time import Time
Expand Down