Skip to content

Commit

Permalink
Coverage notebooks (#299)
Browse files Browse the repository at this point in the history
CI Setup
=======
* use full pip install for asdf schema tests
* use two jobs for sphinx
* use nbval in test action
* only run coverage and notebooks on ubuntu/3.8


General
======
* use settings from setup.cfg
* added pyproject.toml to allow install setuptools_scm etc in one shot
* [setup] declare test deps as extra-deps
* use pip install -e .[test] to install everything in one shot
* min req. python in recipe


Coverage measuring
===============

* remove "weldx/visualization/*" from codecov ignore
* remove some # pragma: no cover
* removed some "no cover" pragmas due to notebook cov

Co-authored-by: Cagtay Fabry <[email protected]>
  • Loading branch information
marscher and CagtayFabry authored Mar 29, 2021
1 parent 563eb12 commit 339fb98
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 27 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,23 @@ jobs:
${{ runner.os }}-pip-
- name: pip installs
run: |
pip install pytest pytest-cov pytest-xdist setuptools_scm
pip install -e .
run: pip install -e .[test]

- name: run pytest
run: |
pytest --runslow -n2
pytest -n 2 --runslow tests/
echo "Exited with '$?'"
- name: run pytest on notebooks (append coverage)
if: (matrix.os == 'ubuntu-latest') && (matrix.py == '3.8')
run: |
pytest -n 2 --dist loadscope --nbval --current-env --cov=weldx --cov-append tutorials/
echo "Exited with '$?'"
coverage xml
- name: coverage xml (combination is performed by pytest-cov)
if: (matrix.os == 'ubuntu-latest') && (matrix.py == '3.8')
run: coverage xml

- name: codecov.io
if: (matrix.os == 'ubuntu-latest') && (matrix.py == '3.8')
uses: codecov/codecov-action@v1
3 changes: 1 addition & 2 deletions .github/workflows/pytest_asdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
python-version: ${{ matrix.py }}
- name: pip installs
run: |
pip install pytest pytest-cov setuptools_scm
pip install .
pip install -e .[test]
- name: run pytest
run: |
pytest --asdf-tests --ignore=tests/ --no-cov
3 changes: 3 additions & 0 deletions .typo-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ excluded_words:
- functools
- boltons
- meshio
- pytest-xdist
- nbval
# matplotlib ----------------------------------
- gca
- mpl
Expand Down Expand Up @@ -151,6 +153,7 @@ excluded_words:
- quickstart
- nsecond
- iterutils
- pyproject
# German ---------------------------------------
- Bundesanstalt
- für
Expand Down
1 change: 0 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ coverage:
ignore:
- "tests"
- "*__init__.py"
- "weldx/visualization/*"
11 changes: 6 additions & 5 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ source:
path: ..

build:
script: python setup.py install --single-version-externally-managed --record=record.txt
script: pip install . -v
number: 0
noarch: python

requirements:
build:
- python
- setuptools
host:
- python >=3.8
- pip
- setuptools_scm
run:
- python
- python >=3.8
# dependencies are defined in setup.py
{% for dep in data['install_requires'] %}
- {{ dep.lower() }}
Expand All @@ -27,6 +27,7 @@ requirements:
test:
imports:
- weldx
- weldx.visualization

about:
home: www.bam.de/weldx
Expand Down
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ dependencies:
- pydocstyle=5
- pytest
- pytest-cov
- pytest-xdist
- nbval
# Plotting
- ipykernel
- ipympl
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build-system]
requires = [
"wheel",
"setuptools >= 40.9.0",
"setuptools_scm",
"numpy", # for bottleneck
]
build-backend = "setuptools.build_meta"
9 changes: 8 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ project_urls =
Changelog = https://github.com/BAMweldx/weldx/blob/master/CHANGELOG.md

[options]
packages = weldx
packages = find:
python_requires = >=3.8
setup_requires =
setuptools >=38.3.0
Expand All @@ -53,6 +53,13 @@ install_requires =
k3d
meshio

[options.extras_require]
test =
pytest
pytest-cov
pytest-xdist
nbval

include_package_data = True

[options.entry_points]
Expand Down
6 changes: 3 additions & 3 deletions weldx/asdf/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def write_read_buffer(
return read_buffer(buffer, open_kwargs)


def get_yaml_header(file) -> str: # pragma: no cover
def get_yaml_header(file) -> str:
"""Read the YAML header part (excluding binary sections) of an ASDF file.
Parameters
Expand Down Expand Up @@ -145,7 +145,7 @@ def get_yaml_header(file) -> str: # pragma: no cover
_write_read_buffer = write_read_buffer


def notebook_fileprinter(file, lexer="YAML"): # pragma: no cover
def notebook_fileprinter(file, lexer="YAML"):
"""Print the code from file/BytesIO to notebook cell with syntax highlighting.
Parameters
Expand Down Expand Up @@ -178,7 +178,7 @@ def notebook_fileprinter(file, lexer="YAML"): # pragma: no cover
)


def asdf_json_repr(file, path: Tuple = None, **kwargs): # pragma: no cover
def asdf_json_repr(file, path: Tuple = None, **kwargs):
"""Display YAML header using IPython JSON display repr.
This function works in JupyterLab.
Expand Down
6 changes: 2 additions & 4 deletions weldx/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,9 +1671,7 @@ def rasterize(self, raster_width):
return np.hstack([raster_data, last_point])

@UREG.wraps(None, (None, _DEFAULT_LEN_UNIT, None, None, None), strict=False)
def plot(
self, raster_width=1, axes=None, fmt=None, axes_equal=False
): # pragma: no cover
def plot(self, raster_width=1, axes=None, fmt=None, axes_equal=False):
"""Plot the trace.
Parameters
Expand Down Expand Up @@ -2218,7 +2216,7 @@ def plot(
color: Union[int, Tuple[int, int, int], Tuple[float, float, float]] = None,
label: str = None,
show_wireframe: bool = True,
) -> matplotlib.axes.Axes: # pragma: no cover
) -> matplotlib.axes.Axes:
"""Plot the geometry.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion weldx/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _add_node(
if parent_node is not None:
graph.add_edge(parent_node, node)

def plot(self, axes=None): # pragma: no cover
def plot(self, axes=None):
"""Plot the measurement chain.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion weldx/transformations/cs_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,7 @@ def plot(
show_traces: bool = True,
show_vectors: bool = True,
show_wireframe: bool = False,
): # pragma: no cover
):
"""Plot the coordinate systems of the coordinate system manager.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion weldx/transformations/local_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ def plot(
show_origin: bool = True,
show_trace: bool = True,
show_vectors: bool = True,
): # pragma: no cover
):
"""Plot the coordinate system.
Parameters
Expand Down
6 changes: 3 additions & 3 deletions weldx/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def sine(
amp: pint.Quantity,
bias: pint.Quantity = None,
phase: pint.Quantity = Q_(0, "rad"),
) -> TimeSeries: # pragma: no cover
) -> TimeSeries:
"""Create a simple sine TimeSeries from quantity parameters.
f(t) = amp*sin(f*t+phase)+bias
Expand Down Expand Up @@ -192,7 +192,7 @@ def sine(

def lcs_coords_from_ts(
ts: TimeSeries, time: Union[pd.DatetimeIndex, pint.Quantity]
) -> xr.DataArray: # pragma: no cover
) -> xr.DataArray:
"""Create translation coordinates from a TimeSeries at specific timesteps.
Parameters
Expand Down Expand Up @@ -1128,7 +1128,7 @@ def __init__(self, xarray_obj):
"""Construct a WeldX xarray object."""
self._obj = xarray_obj

def interp_like(self, da, *args, **kwargs) -> xr.DataArray: # pragma: no cover
def interp_like(self, da, *args, **kwargs) -> xr.DataArray:
"""Interpolate DataArray along dimensions of another DataArray.
Provides some utility options for handling out of range values and broadcasting.
Expand Down

0 comments on commit 339fb98

Please sign in to comment.