Skip to content

Commit

Permalink
Improved warning message, move import sorting to ruff (#213)
Browse files Browse the repository at this point in the history
* Better variable loss warning in shift_double_ended

* Move import sorting to ruff

* Update changelog

* Bump version: 3.0.2 → 3.0.3
  • Loading branch information
BSchilperoort authored Apr 18, 2024
1 parent 343daa8 commit f24245a
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.0.2
current_version = 3.0.3
commit = True
tag = True

Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
Changelog
=========

3.0.3 (2024-04-18)
---

Fixed

* Improved error message when some variables cannot be shifted by the suggest_shift_double_ended function.

Changed:

* [dev] Moved to Ruff instead of isort for import sorting


3.0.2 (2024-04-13)
---

Fixed

* Bumpversion configuration was incorrect since v3.0.0. Therefore the 3.0.1 release failed. This is a re-release of 3.0.1:

3.0.1 (2024-04-13)
---

Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ doi: "10.5281/zenodo.1410097"
license: "BSD-3-Clause"
repository-code: "https://github.com/dtscalibration/python-dts-calibration"
title: "Python distributed temperature sensing calibration"
version: "v3.0.2"
version: "v3.0.3"
url: "https://python-dts-calibration.readthedocs.io"
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Overview
:alt: PyPI Package latest release
:target: https://pypi.python.org/pypi/dtscalibration

.. |commits-since| image:: https://img.shields.io/github/commits-since/dtscalibration/python-dts-calibration/v3.0.2.svg
.. |commits-since| image:: https://img.shields.io/github/commits-since/dtscalibration/python-dts-calibration/v3.0.3.svg
:alt: Commits since latest release
:target: https://github.com/dtscalibration/python-dts-calibration/compare/v1.1.1...main

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
year = str(date.today().year)
author = "Bas des Tombe and Bart Schilperoort"
copyright = f"{year}, {author}"
version = release = "3.0.2"
version = release = "3.0.3"

pygments_style = "trac"
templates_path = [".", sphinx_autosummary_accessors.templates_path]
Expand Down
22 changes: 5 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ disable = true # Requires confirmation when publishing to pypi.

[project]
name = "dtscalibration"
version = "3.0.2"
version = "3.0.3"
description = "Load Distributed Temperature Sensing (DTS) files, calibrate the temperature and estimate its uncertainty."
readme = "README.rst"
license = "BSD-3-Clause"
Expand Down Expand Up @@ -71,7 +71,6 @@ dev = [
"hatch",
"bump2version",
"ruff",
"isort",
"black[jupyter]", # for formatting
"mypy", # for type checking
"types-PyYAML", # for pyyaml types
Expand Down Expand Up @@ -108,10 +107,9 @@ features = ["dev"]
lint = [
"ruff check src/ tests/ examples/",
"black --check docs/notebooks",
"isort --check-only --diff src/ tests/ examples/",
"mypy src/",
]
format = ["isort src/ tests/ examples/", "ruff check src/ tests/ examples/ --fix", "ruff format src/ tests/ examples/", "black docs/notebooks", "lint",]
format = ["ruff check src/ tests/ examples/ --fix", "ruff format src/ tests/ examples/", "black docs/notebooks", "lint",]
test = ["pytest ./src/ ./tests/",]
fast-test = ["pytest ./tests/ -m \"not slow\"",]
coverage = [
Expand Down Expand Up @@ -153,7 +151,7 @@ select = [ # It would be nice to have the commented out checks working.
"PLE", # Pylint error https://github.com/charliermarsh/ruff#error-ple
# "PLR", # Pylint refactor (e.g. too-many-arguments)
"PLW", # Pylint warning (useless-else-on-loop)
# "I", # isort
"I", # isort
"SIM", # flake8-simplify

]
Expand All @@ -167,9 +165,6 @@ ignore = [
"PLR2004", # magic value used in comparson
"E501", # Line too long (want to have fixed
]
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["E", "F", "UP", "PLE", "D"]
unfixable = []
line-length = 88
exclude = ["docs", "build"]
# Allow unused variables when underscore-prefixed.
Expand All @@ -186,17 +181,10 @@ convention = "google"
[tool.ruff.mccabe]
max-complexity = 10

[tool.ruff.lint.isort]
[tool.ruff.isort]
known-first-party = ["dtscalibration"]
force-single-line = true

[tool.isort]
py_version=39
force_single_line = true
known_first_party = ["dtscalibration"]
skip = [".gitignore", ".tox", "docs", ".venv"]
src_paths = ["src", "tests"]
line_length = 120

[tool.black]
line-length = 88
target-version = ['py39', 'py310', 'py311']
Expand Down
9 changes: 7 additions & 2 deletions src/dtscalibration/dts_accessor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,12 @@ def shift_double_ended(

not_included = [k for k in ds.data_vars if k not in d2_data]
if not_included and verbose:
print("I dont know what to do with the following data", not_included)
msg = (
"The following variables could not be shifted and are not included in the "
f"new dataset: {not_included}. You can silence this warning with the "
"keyword argument `verbose=False`."
)
warnings.warn(msg, UserWarning)

return xr.Dataset(data_vars=d2_data, coords=d2_coords, attrs=ds.attrs)

Expand Down Expand Up @@ -1062,7 +1067,7 @@ def suggest_cable_shift_double_ended(
f, (ax0, ax1) = plt.subplots(2, 1, sharex=False, **fig_kwargs)
f.suptitle(f"best shift is {ishift1} or {ishift2}")

dt = ds.isel(time=0)
dt = ds.isel(time=0)[["st", "ast", "rst", "rast", "x"]]
x = dt["x"].data
y = dt["st"].data
ax0.plot(x, y, label="ST original")
Expand Down
7 changes: 6 additions & 1 deletion src/dtscalibration/io/silixa.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import warnings
from pathlib import Path
from xml.etree import ElementTree

Expand Down Expand Up @@ -97,7 +98,11 @@ def read_silixa_files(
"Silixa xml version " + f"{xml_version} not implemented"
)

ds = xr.Dataset(data_vars=data_vars, coords=coords, attrs=attrs, **kwargs)
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", message="Converting non-nanosecond precision timedelta"
)
ds = xr.Dataset(data_vars=data_vars, coords=coords, attrs=attrs, **kwargs)
return ds


Expand Down

0 comments on commit f24245a

Please sign in to comment.