Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
staircase-dev committed Jun 24, 2024
2 parents 4c6d1d6 + b12f82d commit c837b98
Show file tree
Hide file tree
Showing 17 changed files with 2,218 additions and 1,766 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.10', '3.11']
python-version: ['3.8', '3.10', '3.11', '3.12']
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
Expand All @@ -43,19 +43,19 @@ jobs:
run: poetry run flake8 ./staircase
- name: Test with pytest
run: |
poetry run pytest ./tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov=staircase --cov-report=xml
poetry run pytest ./tests --junitxml=junit/test-results-${{ matrix.platform }}-${{ matrix.python-version }}.xml --cov=staircase --cov-report=xml
codecov
- name: Upload pytest test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml
name: pytest-results-${{ matrix.platform }}-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.platform }}-${{ matrix.python-version }}.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
fail_ci_if_error: false


4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
group: ${{ github.ref }}-pre-commit
cancel-in-progress: ${{github.event_name == 'pull_request'}}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
6 changes: 6 additions & 0 deletions docs/release_notes/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Changelog
=========


**v2.6.0 2024-06-24**

- support for Python 3.12 added
- support for Python 3.7 removed


**v2.5.2 2023-07-04**

- support for Python 3.11
Expand Down
3,870 changes: 2,150 additions & 1,720 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Poetry pyproject.toml: https://python-poetry.org/docs/pyproject/

[build-system]
requires = ["poetry>=1.0"]
build-backend = "poetry.masonry.api"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "staircase"
version = "2.5.2"
version = "2.6.0"
description = "A data analysis package based on modelling and manipulation of mathematical step functions. Strongly aligned with pandas."
readme = "README.md"
authors = ["Riley Clement <[email protected]>"]
Expand All @@ -30,11 +30,11 @@ keywords=[
classifiers=[
'Operating System :: OS Independent',
'Intended Audience :: Science/Research',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Scientific/Engineering',
]

Expand All @@ -43,28 +43,28 @@ classifiers=[


[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"
pytz = "*"
typing-extensions = "^4.4.0"

[[tool.poetry.dependencies.pandas]]
python = ">=3.7,<3.10"
python = ">=3.8,<3.10"
version = "^1"

[[tool.poetry.dependencies.pandas]]
python = "^3.10"
version = ">=1.3.4,<3"

[[tool.poetry.dependencies.numpy]]
python = ">=3.7,<3.10"
version = "^1.15"
python = ">=3.8,<3.10"
version = "^1.16"

[[tool.poetry.dependencies.numpy]]
python = "^3.10"
version = "^1.21.2"

[[tool.poetry.dependencies.matplotlib]]
python = ">=3.7,<3.11"
python = ">=3.8,<3.11"
version = ">=2"

[[tool.poetry.dependencies.matplotlib]]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
max-line-length = 88
ignore = E203, E231, E402, E501, F401, W503
ignore = E203, E231, E402, E501, F401, W503, W604
exclude = docs
2 changes: 1 addition & 1 deletion staircase/core/layering.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _layer_scalar(self, start, end, value):
if start in deltas.index:
deltas.loc[start] += value
else:
deltas.loc[start] = value
deltas.loc[start] = float(value)
if deltas.loc[start] == 0:
deltas.drop(start, inplace=True)

Expand Down
8 changes: 7 additions & 1 deletion staircase/core/ops/masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,15 @@ def _make_data_fillna_method(self, value):
data = None
else:
values = self._get_values().copy()
fillmethod = {
"pad": pd.Series.ffill,
"ffill": pd.Series.ffill,
"backfill": pd.Series.bfill,
"bfill": pd.Series.bfill,
}[value]
if value in ("pad", "ffill") and np.isnan(values.iloc[0]):
values.iloc[0] = self.initial_value
values = values.fillna(method=value)
values = fillmethod(values)
if value in ("backfill", "bfill") and np.isnan(self.initial_value):
initial_value = values.iloc[0]
data = pd.DataFrame({"value": values})
Expand Down
12 changes: 9 additions & 3 deletions staircase/core/stairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
staircase is a MIT licensed library, written in pure-Python, for
modelling step functions. See :ref:`Getting Started <getting_started>` for more information.
"""

from __future__ import annotations

import warnings
Expand Down Expand Up @@ -33,9 +34,11 @@

def _make_deltas_from_vals(init_val, vals: pd.DataFrame) -> pd.Series:
if not np.isnan(vals).any():
result = pd.Series(np.diff((np.append([init_val], vals.values))))
result = pd.Series(
np.diff((np.append([init_val], vals.values))), dtype="float64"
)
else:
temp = pd.Series(np.append([init_val], vals.values))
temp = pd.Series(np.append([init_val], vals.values), dtype="float64")
result = pd.Series.add(
temp[pd.notnull(temp)].diff(), temp[pd.isnull(temp)], fill_value=0
)[1:]
Expand Down Expand Up @@ -570,7 +573,10 @@ def __bool__(self) -> bool:
def describe(
self,
where: tuple[float | int, float | int]
| list[float | int, float | int] = (-inf, inf),
| list[float | int, float | int] = (
-inf,
inf,
),
percentiles: list[float | int] | tuple[float | int] = (25, 50, 75),
) -> pd.Series:
"""
Expand Down
1 change: 0 additions & 1 deletion staircase/util/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Appender:

"""
A function decorator that will append an addendum to the docstring
of the target function.
Expand Down
Empty file added tests/test_dates/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion tests/test_dates/test_dates_slicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


# Not testing "W", it's a pain for period index
@pytest.mark.parametrize("freq_str", ["N", "U", "L", "S", "T", "H", "D", "M"])
@pytest.mark.parametrize("freq_str", ["ns", "us", "ms", "s", "min", "h", "D", "M"])
def test_slice_month_period_range(freq_str):
# GH108
date_freq = "MS" if freq_str == "M" else freq_str
Expand Down
4 changes: 2 additions & 2 deletions tests/test_dates/test_dates_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def test_integral_dates_3(date_func):
s1(date_func).agg(
"integral", (timestamp(2020, 1, 4, date_func=date_func), None)
)
/ pd.Timedelta("1 H")
/ pd.Timedelta("1 h")
== 108
), "Expected integral to be 108 hours"

Expand All @@ -411,7 +411,7 @@ def test_integral_dates_4(date_func):
timestamp(2020, 1, 8, date_func=date_func),
),
)
/ pd.Timedelta("1 H")
/ pd.Timedelta("1 h")
== 132
), "Expected integral to be 132 hours"

Expand Down
8 changes: 4 additions & 4 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def test_layering_args_warning(start, end):
[(1, None), (None, 1), (1, sc.inf), (-sc.inf, 1)],
)
def test_layering_args_no_warning(start, end):
with pytest.warns(None) as warnings:
Stairs(start=start, end=end)
import warnings

if len(warnings) > 0:
raise AssertionError("Warnings were raised, but not expected")
with warnings.catch_warnings():
warnings.simplefilter("error")
Stairs(start=start, end=end)
Empty file added tests/test_floats/__init__.py
Empty file.
Empty file added tests/test_masking/__init__.py
Empty file.
29 changes: 17 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
[tox]
isolated_build=true
envlist = py{36,37,38,39,310,311}-numpy{114,115,116,117,118,119,120,121}-pandas{024,025,10,11,12,13}
envlist =
py{38}-pandas11
py{38,39}-pandas12
py{38,39}-pandas13
py{38,39,310}-pandas14
py{38,39,310}-pandas15
py{38,39,310,311}-pandas20
py{39,310,311}-pandas21
py{310,311,312}-pandas22
skipdist = true

[testenv]
deps =
matplotlib
pytz
typing-extensions
pytest
pytest-cov
pandas024: pandas>=0.24,<0.25
pandas025: pandas>=0.25,<1
pandas10: pandas>=1.0,<1.1
pandas11: pandas>=1.1,<1.2
pandas12: pandas>=1.2,<1.3
pandas13: pandas>=1.3,<1.4
numpy114: numpy>=1.14,<1.15
numpy115: numpy>=1.15,<1.16
numpy116: numpy>=1.16,<1.17
numpy117: numpy>=1.17,<1.18
numpy118: numpy>=1.18,<1.19
numpy119: numpy>=1.19,<1.20
numpy120: numpy>=1.20,<1.21
numpy121: numpy>=1.21,<1.22
pandas14: pandas>=1.4,<1.5
pandas15: pandas>=1.5,<1.6
pandas20: pandas>=2.0,<2.1
pandas21: pandas>=2.1,<2.2
pandas22: pandas>=2.2,<2.3
numpy <2
skip_install = true
commands =
pytest tests/
pytest tests/test_masking/test_masking_ne.py

0 comments on commit c837b98

Please sign in to comment.