Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
milescsmith committed Nov 4, 2023
1 parent 933acc5 commit 984e2a3
Show file tree
Hide file tree
Showing 7 changed files with 1,056 additions and 1,031 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"python.linting.mypyEnabled": true,
"python.linting.enabled": true,
"restructuredtext.confPath": "${workspaceFolder}/docs",
"restructuredtext.languageServer.disabled": true
"restructuredtext.languageServer.disabled": true,
"esbonio.sphinx.confDir": "${workspaceFolder}/docs"
}
35 changes: 22 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,73 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.0]
* [1.4.0]

## Changed

- Code cleanup.
- Make Python 3.9 the minimum version
- Update dependencies

# [1.3.0]

## Changed

- Altered the maximum allowed Python version so that newer versions of 3.10.* are not excluded


## [1.1.4]
# [1.1.4]

### Changed
## Changed

- Miscellaneous fixes for mypy and passing tests
- Add `smooth` to `__all__` for explicit export of the symbol

### Removed
## Removed

- Custom `Numeric` type for type hinting in lieu of following PEP 484 and the
Numeric Tower


## [1.1.3]
# [1.1.3]

### Changed
## Changed

- Renamed `smooth` submodule so that it does not conflict with the `smooth()`
function.
- Updated README.rst to include requirements and example usage


## [1.1.2]
# [1.1.2]

Version bump for pypi


## [1.1.1]
# [1.1.1]

### Changed
## Changed

- Decreased required vesions of numpy to 1.20.3 so that it does not conflict with
numba


## [1.1.0]
# [1.1.0]

### Added
## Added

- Added unit test to `sm_3` for a 2-element list

### Changed
## Changed

- Removed click, typer, and rich requirements
- Moved hypothesis and nox-poetry to dev requirements

### Removed
## Removed

- `main` function, as it was unused and `pysmooth` is not intended to be a cli
application

[1.4.0]: https://github.com/olivierlacan/keep-a-changelog/compare/1.3.0...1.4.0
[1.3.0]: https://github.com/olivierlacan/keep-a-changelog/compare/1.2.0...1.3.0
[1.2.0]: https://github.com/olivierlacan/keep-a-changelog/compare/1.1.3...1.2.0
[1.1.3]: https://github.com/olivierlacan/keep-a-changelog/compare/1.1.2...1.1.3
Expand Down
1,785 changes: 855 additions & 930 deletions poetry.lock

Large diffs are not rendered by default.

136 changes: 108 additions & 28 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,28 @@ classifiers = [
Changelog = "https://github.com/milescsmith/pysmooth/releases"

[tool.poetry.dependencies]
python = "^3.8,<3.11"
numpy = "^1.22"
python = "^3.9,<3.11"
numpy = "^1.26"

[tool.poetry.dev-dependencies]
hypothesis = "^6.49.0"
nox-poetry = "^1.0.1"
[tool.poetry.group.dev.dependencies]
hypothesis = "^6.88"
nox-poetry = "^1.0.3"
pytest = "^7.4.3"
coverage = {extras = ["toml"], version = "^6.4"}
safety = "^1.10.3"
mypy = "^0.931"
typeguard = "^2.13.3"
xdoctest = {extras = ["colors"], version = "^1.0.0"}
sphinx = "^5.3.0"
coverage = {extras = ["toml"], version = "^7.3"}
safety = "^2.3.5"
mypy = "^1.6"
typeguard = "^4.1"
xdoctest = {extras = ["colors"], version = "^1.1"}
sphinx = "^7.2"
sphinx-autobuild = "^2021.3.14"
pre-commit = "^2.19.0"
flake8 = "^4.0.1"
black = "^21.12b0"
flake8-bandit = "^2.1.2"
flake8-bugbear = "^21.9.2"
flake8-docstrings = "^1.6.0"
flake8-rst-docstrings = "^0.2.6"
pep8-naming = "^0.12.1"
darglint = "^1.8.1"
reorder-python-imports = "^3.0.1"
pre-commit-hooks = "^4.0.1"
sphinx-rtd-theme = "^1.0.0"
sphinx-click = "^3.0.2"
Pygments = "^2.12.0"
ipython = "^7.31.1"
isort = "^5.10.1"
types-decorator = "^5.1.7"
pre-commit = "^3.5"
black = "^23"
pre-commit-hooks = "^4.5"
sphinx-rtd-theme = "^1.3.0"
sphinx-click = "^5.0"
Pygments = "^2.16"
ipython = "^8.17.2"
ruff = "^0.1.3"

[tool.coverage.paths]
source = ["src", "*/site-packages"]
Expand All @@ -62,3 +53,92 @@ fail_under = 100
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
known_typing = "typing,types,typing_extensions,mypy,mypy_extensions"
sections = "FUTURE,TYPING,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"
include_trailing_comma = true
default_section = "FIRSTPARTY"
multi_line_output = 3
indent = 4
force_grid_wrap = 0
use_parentheses = true
line_length = 80

[tool.black]
line-length = 120
target-version = ["py309"]
skip-string-normalization = true

[tool.ruff]
target-version = "py309"
line-length = 120
select = [
"A",
"ARG",
"B",
"C",
"DTZ",
"E",
"EM",
"F",
"FBT",
"I",
"I001",
"ICN",
"ISC",
"N",
"PLC",
"PLE",
"PLR",
"PLW",
"Q",
"RUF",
"S",
"T",
"TID",
"UP",
"W",
"YTT",
]
ignore = [
"B027",
"FBT003",
"S105",
"S106",
"S107",
"C901",
"PLR0911",
"PLR0912",
"PLR0913",
"PLR0915",
]
unfixable = [
"F401",
"UP007",
]
exclude = [
".git",
".hg",
"__pycache__",
"_bin/*",
"_build/*",
"_ig_fbcode_wheel/*",
"buck-out/*",
"third-party-buck/*",
"third-party2/*",
"dist",
".venv",
".nox",
".mypy_cache",
".pytype",
".svn",
"__pypackages__",
]
src = ["src"]

[tool.ruff.mccabe]
max-complexity = 50

[tool.ruff.flake8-tidy-imports]
ban-relative-imports = "all"
2 changes: 1 addition & 1 deletion src/pysmooth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Pysmoother."""
from .__main__ import smooth
from pysmooth.__main__ import smooth

__all__ = ["smooth"]
36 changes: 18 additions & 18 deletions src/pysmooth/__main__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
"""Command-line interface."""
from typing import List

import numpy as np

from ._smooth import sm_3, sm_3R, sm_3RS3R, sm_3RSR, sm_3RSS, sm_split3
from pysmooth._smooth import sm_3, sm_3R, sm_3RS3R, sm_3RSR, sm_3RSS, sm_split3


def smooth(
x: List[float],
x: list[float],
kind: str = "3RS3R",
twiceit: bool = False,
twiceit: bool = False, # noqa FBT001
endrule: str = "Tukey",
do_ends: bool = False,
) -> List[float]:
do_ends: bool = False, # noqa FBT001
) -> list[float]:
"""Tukey's smoothers, translated from the `smooth` function found in the R module {stats}.
Parameters
Expand Down Expand Up @@ -40,38 +38,40 @@ def smooth(
number of iterations required to reach stable smoothing
"""
if kind not in ("3RS3R", "3RSS", "3RSR", "3R", "3", "S"):
raise RuntimeError("An invalid kind of smoother was selected")
msg = "An invalid kind of smoother was selected"
raise RuntimeError(msg)

if endrule == "copy":
iend = 1
elif endrule == "Tukey":
iend = 2
else:
raise RuntimeError(
f"endrule must be either 'copy' or 'Tukey', but {endrule} was passed"
)
msg = f"endrule must be either 'copy' or 'Tukey', but {endrule} was passed"
raise RuntimeError(msg)

if any(np.isnan(np.array(x, dtype=np.float64))):
raise ValueError(
msg = (
"The sequence to be smoothed contains NAs/nans. This algorithm "
"is unable to accomodate NAs."
)
raise ValueError(msg)

if not all([np.issubdtype(type(_), np.number) for _ in x]):
raise ValueError("The sequence contains non-float values.")
if not all(np.issubdtype(type(_), np.number) for _ in x):
msg = "The sequence contains non-float values."
raise ValueError(msg)

if kind.startswith("3RS") and not do_ends:
iend = -iend
elif kind == "S":
iend = int(bool(do_ends))

n: int = len(x)
y: List[float] = np.zeros(n, dtype=np.float64).tolist()
y: list[float] = np.zeros(n, dtype=np.float64).tolist()
split_ends = True if iend < 0 else False

if kind != "S":
z: List[float] = np.zeros(n, dtype=np.float64).tolist()
w: List[float] = np.zeros(n, dtype=np.float64).tolist()
z: list[float] = np.zeros(n, dtype=np.float64).tolist()
w: list[float] = np.zeros(n, dtype=np.float64).tolist()
if kind == "3RS3R":
_, x, y, z, w = sm_3RS3R(x, y, z, w, n, abs(iend), split_ends)
elif kind == "3RSS":
Expand All @@ -87,7 +87,7 @@ def smooth(
_, x, y = sm_split3(x, y, n, bool(iend))

if twiceit:
r: List[float] = smooth(
r: list[float] = smooth(
x=y, kind=kind, twiceit=False, endrule=endrule, do_ends=do_ends
)
y += r
Expand Down
Loading

0 comments on commit 984e2a3

Please sign in to comment.