Skip to content

Commit

Permalink
Fix pint intersphinx (#820)
Browse files Browse the repository at this point in the history
* [sphinx/conf] use `latest` for pint intersphinx mapping also removed duplicated tutorial file copying.

* [changelog] do not reference `pint` as for some non obvious reason it cannot be resolved...

* [weldx/constants] removed __module__ and __name__ hacking for Q_ and U_, since we have pint-0.20.1 now

* fix matplotlib import in asdf groove test
  • Loading branch information
marscher authored Oct 28, 2022
1 parent a028ddd commit e6f7d6a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ changes
- `CoordinateSystemManager.plot_graph` now renders static and
time-dependent edges differently [:pull:`291`]

- use `pint` compatible array syntax in
- use ``pint`` compatible array syntax in
`welding.groove.iso_9692_1.IsoBaseGroove.to_profile` methods [:pull:`189`]

- CSM and LCS plot function get a ``scale_vectors`` parameter. It
Expand Down Expand Up @@ -975,7 +975,7 @@ dependencies
added
=====

- Added `util.ureg_check_class` class decorator to enable `pint`
- Added `util.ureg_check_class` class decorator to enable ``pint``
dimensionality checks with ``@dataclass`` [:pull:`179`].

- Made coordinates and orientations optional for LCS schema. Missing
Expand Down Expand Up @@ -1070,7 +1070,7 @@ changes
- `util.xr_interp_like` now accepts non-iterable scalar inputs for
interpolation. [:pull:`97`]

- add `pint` compatibility to some `geometry` classes
- add ``pint`` compatibility to some `geometry` classes
(**experimental**)

- when passing quantities to constructors (and some functions),
Expand Down Expand Up @@ -1128,7 +1128,7 @@ fixes
- fix propagating the ``name`` attribute when reading an ndarray
`TimeSeries` object back from ASDF files [:pull:`104`]

- fix `pint` regression in `TimeSeries` when mixing integer and float
- fix ``pint`` regression in `TimeSeries` when mixing integer and float
values [:pull:`121`]

********************
Expand Down
9 changes: 1 addition & 8 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def _prevent_sphinx_circular_imports_bug():
except ModuleNotFoundError: # fallback for local use
sys.path.insert(0, os.path.abspath("../"))
import weldx
except Exception as ex:
raise


import weldx.visualization # load visualization (currently no auto-import in pkg).

Expand All @@ -84,12 +83,6 @@ def _copy_tut_files():
_copy_tut_files()


# TODO: git move tutorial files to tutorials_dir!
tutorial_files = pathlib.Path("./../tutorials/").glob("*.ipynb")
for f in tutorial_files:
shutil.copy(f, tutorials_dir)


# -- Project information -----------------------------------------------------
_now = datetime.datetime.now().year

Expand Down
4 changes: 0 additions & 4 deletions weldx/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

WELDX_QUANTITY = WELDX_UNIT_REGISTRY.Quantity
Q_ = WELDX_QUANTITY
Q_.__name__ = "Q_"
Q_.__module__ = "pint.quantity" # skipcq: PYL-W0212
Q_.__doc__ = """Create a quantity from a scalar or array.
The quantity class supports lots of physical units and will combine them during
Expand Down Expand Up @@ -63,8 +61,6 @@
__test__ = {"Q": Q_.__doc__} # enable doctest checking.

U_ = WELDX_UNIT_REGISTRY.Unit
U_.__name__ = "U_"
U_.__module__ = "pint.unit" # skipcq: PYL-W0212
U_.__doc__ = """For details on working with quantities and units, please see the
`pint documentation <https://pint.readthedocs.io/>`_
"""
Expand Down
4 changes: 2 additions & 2 deletions weldx/tags/units/pint_quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PintQuantityConverter(WeldxConverter):
"tag:stsci.edu:asdf/unit/quantity-1.*",
]
types = [
"pint.quantity.Quantity", # pint >= 0.20
"pint.util.Quantity", # pint >= 0.20
"pint.quantity.build_quantity_class.<locals>.Quantity", # pint < 0.20
"weldx.constants.Q_",
]
Expand Down Expand Up @@ -55,7 +55,7 @@ class PintUnitConverter(WeldxConverter):

tags = ["asdf://weldx.bam.de/weldx/tags/units/units-0.1.*"]
types = [
"pint.unit.Unit", # pint >= 0.20
"pint.util.Unit", # pint >= 0.20
"pint.unit.build_unit_class.<locals>.Unit", # pint < 0.20
"weldx.constants.U_",
]
Expand Down
22 changes: 15 additions & 7 deletions weldx/tests/asdf_tests/test_asdf_groove.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
"""Test all ASDF groove implementations."""
import pytest
from decorator import contextmanager
from matplotlib import pylab

from weldx.asdf.util import write_read_buffer
from weldx.constants import Q_
from weldx.constants import WELDX_UNIT_REGISTRY as UREG
from weldx.constants import _DEFAULT_LEN_UNIT, Q_
from weldx.geometry import Profile
from weldx.welding.groove.iso_9692_1 import (
IsoBaseGroove,
_create_test_grooves,
get_groove,
)

_DEFAULT_LEN_UNIT = UREG.millimeters

@contextmanager
def _close_plot():
try:
from matplotlib import pylab
except ImportError:
yield
else:
try:
yield
finally:
pylab.close()


test_params = _create_test_grooves()

Expand Down Expand Up @@ -50,10 +60,8 @@ def test_asdf_groove(groove: IsoBaseGroove, expected_dtype):
), f"Error calling plot function of {type(groove)} "

# call plot function
try:
with _close_plot():
groove.plot()
finally:
pylab.close()


def test_asdf_groove_exceptions():
Expand Down

0 comments on commit e6f7d6a

Please sign in to comment.