Skip to content

Commit f24245a

Browse files
Improved warning message, move import sorting to ruff (#213)
* Better variable loss warning in shift_double_ended * Move import sorting to ruff * Update changelog * Bump version: 3.0.2 → 3.0.3
1 parent 343daa8 commit f24245a

8 files changed

Lines changed: 41 additions & 24 deletions

File tree

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 3.0.2
2+
current_version = 3.0.3
33
commit = True
44
tag = True
55

CHANGELOG.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22
Changelog
33
=========
44

5+
3.0.3 (2024-04-18)
6+
---
7+
8+
Fixed
9+
10+
* Improved error message when some variables cannot be shifted by the suggest_shift_double_ended function.
11+
12+
Changed:
13+
14+
* [dev] Moved to Ruff instead of isort for import sorting
15+
16+
17+
3.0.2 (2024-04-13)
18+
---
19+
20+
Fixed
21+
22+
* Bumpversion configuration was incorrect since v3.0.0. Therefore the 3.0.1 release failed. This is a re-release of 3.0.1:
23+
524
3.0.1 (2024-04-13)
625
---
726

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ doi: "10.5281/zenodo.1410097"
2222
license: "BSD-3-Clause"
2323
repository-code: "https://github.com/dtscalibration/python-dts-calibration"
2424
title: "Python distributed temperature sensing calibration"
25-
version: "v3.0.2"
25+
version: "v3.0.3"
2626
url: "https://python-dts-calibration.readthedocs.io"

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Overview
2929
:alt: PyPI Package latest release
3030
:target: https://pypi.python.org/pypi/dtscalibration
3131

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

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
year = str(date.today().year)
4848
author = "Bas des Tombe and Bart Schilperoort"
4949
copyright = f"{year}, {author}"
50-
version = release = "3.0.2"
50+
version = release = "3.0.3"
5151

5252
pygments_style = "trac"
5353
templates_path = [".", sphinx_autosummary_accessors.templates_path]

pyproject.toml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ disable = true # Requires confirmation when publishing to pypi.
1919

2020
[project]
2121
name = "dtscalibration"
22-
version = "3.0.2"
22+
version = "3.0.3"
2323
description = "Load Distributed Temperature Sensing (DTS) files, calibrate the temperature and estimate its uncertainty."
2424
readme = "README.rst"
2525
license = "BSD-3-Clause"
@@ -71,7 +71,6 @@ dev = [
7171
"hatch",
7272
"bump2version",
7373
"ruff",
74-
"isort",
7574
"black[jupyter]", # for formatting
7675
"mypy", # for type checking
7776
"types-PyYAML", # for pyyaml types
@@ -108,10 +107,9 @@ features = ["dev"]
108107
lint = [
109108
"ruff check src/ tests/ examples/",
110109
"black --check docs/notebooks",
111-
"isort --check-only --diff src/ tests/ examples/",
112110
"mypy src/",
113111
]
114-
format = ["isort src/ tests/ examples/", "ruff check src/ tests/ examples/ --fix", "ruff format src/ tests/ examples/", "black docs/notebooks", "lint",]
112+
format = ["ruff check src/ tests/ examples/ --fix", "ruff format src/ tests/ examples/", "black docs/notebooks", "lint",]
115113
test = ["pytest ./src/ ./tests/",]
116114
fast-test = ["pytest ./tests/ -m \"not slow\"",]
117115
coverage = [
@@ -153,7 +151,7 @@ select = [ # It would be nice to have the commented out checks working.
153151
"PLE", # Pylint error https://github.com/charliermarsh/ruff#error-ple
154152
# "PLR", # Pylint refactor (e.g. too-many-arguments)
155153
"PLW", # Pylint warning (useless-else-on-loop)
156-
# "I", # isort
154+
"I", # isort
157155
"SIM", # flake8-simplify
158156

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

189-
[tool.ruff.lint.isort]
184+
[tool.ruff.isort]
185+
known-first-party = ["dtscalibration"]
190186
force-single-line = true
191187

192-
[tool.isort]
193-
py_version=39
194-
force_single_line = true
195-
known_first_party = ["dtscalibration"]
196-
skip = [".gitignore", ".tox", "docs", ".venv"]
197-
src_paths = ["src", "tests"]
198-
line_length = 120
199-
200188
[tool.black]
201189
line-length = 88
202190
target-version = ['py39', 'py310', 'py311']

src/dtscalibration/dts_accessor_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,12 @@ def shift_double_ended(
956956

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

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

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

1065-
dt = ds.isel(time=0)
1070+
dt = ds.isel(time=0)[["st", "ast", "rst", "rast", "x"]]
10661071
x = dt["x"].data
10671072
y = dt["st"].data
10681073
ax0.plot(x, y, label="ST original")

src/dtscalibration/io/silixa.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import warnings
23
from pathlib import Path
34
from xml.etree import ElementTree
45

@@ -97,7 +98,11 @@ def read_silixa_files(
9798
"Silixa xml version " + f"{xml_version} not implemented"
9899
)
99100

100-
ds = xr.Dataset(data_vars=data_vars, coords=coords, attrs=attrs, **kwargs)
101+
with warnings.catch_warnings():
102+
warnings.filterwarnings(
103+
"ignore", message="Converting non-nanosecond precision timedelta"
104+
)
105+
ds = xr.Dataset(data_vars=data_vars, coords=coords, attrs=attrs, **kwargs)
101106
return ds
102107

103108

0 commit comments

Comments
 (0)