Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: cleaner build process #107

Merged
merged 41 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
69e7360
build: use more recent version of setuptools
deepcharles Jan 9, 2021
e8e032b
build: automatic versionning using setuptools_scm
deepcharles Jan 9, 2021
ea2cf45
refactor: add version.py to gitignore
deepcharles Jan 9, 2021
84db8cb
ci: use pep517.build to build sdist
deepcharles Jan 9, 2021
de10ef0
docs: add conda badge
deepcharles Jan 9, 2021
bcf4b36
docs(readme): update installation instructions
deepcharles Jan 9, 2021
c1c5548
docs: better install instructions
deepcharles Jan 9, 2021
78007e4
docs: better install procedure
deepcharles Jan 9, 2021
49228e4
refactor: update pre-commit hooks
deepcharles Jan 9, 2021
a6c7925
refactor: remove requirements-dev.txt
deepcharles Jan 9, 2021
5911569
ci: update all pre-commit hooks
deepcharles Jan 9, 2021
8cb0cf4
style: clean useless comment
deepcharles Jan 9, 2021
193f297
build: cleaner MANIFEST.in
deepcharles Jan 9, 2021
1ac5f73
bug(costclinear): make it mutli-dimensional compatible (#104)
oboulant Jan 10, 2021
6a65928
test(costlinear): add test for CostLinear (#105)
oboulant Jan 12, 2021
a9d1827
test: Improve test coverage (#106)
oboulant Jan 12, 2021
e7c5651
build: change upload-to-pypi gh action
deepcharles Jan 12, 2021
b06b6d8
ci: install twine before uploading to pypi
deepcharles Jan 12, 2021
1b1f961
ci: test SETUPTOOLS_SCM_PRETEND_VERSION
deepcharles Jan 12, 2021
0a01e72
ci: add `with: fetch-depth: 0` to checkout gha
deepcharles Jan 12, 2021
509dfe5
build: use more recent version of setuptools
deepcharles Jan 9, 2021
e6219e2
build: automatic versionning using setuptools_scm
deepcharles Jan 9, 2021
29b710f
refactor: add version.py to gitignore
deepcharles Jan 9, 2021
8c9453b
ci: use pep517.build to build sdist
deepcharles Jan 9, 2021
188ae41
docs: add conda badge
deepcharles Jan 9, 2021
663e939
docs(readme): update installation instructions
deepcharles Jan 9, 2021
7bcd1cf
docs: better install instructions
deepcharles Jan 9, 2021
c6f519e
docs: better install procedure
deepcharles Jan 9, 2021
5e70979
refactor: update pre-commit hooks
deepcharles Jan 9, 2021
0424f2c
refactor: remove requirements-dev.txt
deepcharles Jan 9, 2021
425e7d5
ci: update all pre-commit hooks
deepcharles Jan 9, 2021
d71a706
style: clean useless comment
deepcharles Jan 9, 2021
d5e5ae3
build: cleaner MANIFEST.in
deepcharles Jan 9, 2021
677550a
build: change upload-to-pypi gh action
deepcharles Jan 12, 2021
416b5de
ci: install twine before uploading to pypi
deepcharles Jan 12, 2021
8e1b08b
ci: test SETUPTOOLS_SCM_PRETEND_VERSION
deepcharles Jan 12, 2021
3142deb
ci: add `with: fetch-depth: 0` to checkout gha
deepcharles Jan 12, 2021
61a341f
ci: cleaner upload to Pypi
deepcharles Jan 13, 2021
731f188
Merge branch 'build/clean-build-process' of https://github.com/deepch…
deepcharles Jan 13, 2021
406fa8d
ci: remove `check-linting` gha
deepcharles Jan 13, 2021
86a634f
ci: fix gha argument
deepcharles Jan 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .github/workflows/check-linting.yml

This file was deleted.

77 changes: 43 additions & 34 deletions .github/workflows/upload-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,36 @@ name: Upload package to Pypi

on:
workflow_dispatch:
release:
types: [created]
inputs:
overrideVersion:
description: Manually force a version

env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.overrideVersion }}
CIBW_BUILD_VERBOSITY: 1

jobs:
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install deps
run: python -m pip install build twine
- name: Build SDist
run: python -m build --sdist
- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz
- name: Check metadata
run: twine check dist/*

build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -36,52 +62,35 @@ jobs:
bitness: 32
- os: windows-latest
python: 39

steps:
- uses: actions/checkout@v2

with:
fetch-depth: 0
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'

- name: Install cibuildwheel and dependencies
- name: Install cibuildwheel
run: |
python -m pip install --upgrade pip
python -m pip install cibuildwheel twine

python -m pip install cibuildwheel
- name: Build wheels
env:
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m cibuildwheel --output-dir wheelhouse
python -m twine upload wheelhouse/*.whl

run: python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v2
with:
path: wheelhouse/*.whl

deploy_sdist:
upload_all:
needs: [build_wheels, make_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist
python -m twine upload dist/*.tar.gz
- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.4.1
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ docs/build/*
.Trashes
ehthumbs.db
Thumbs.db
site/
site/
src/ruptures/version.py
22 changes: 11 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
repos:
- repo: https://github.com/psf/black
rev: stable
rev: 20.8b1
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v3.4.0
hooks:
- id: trailing-whitespace # This hook trims trailing whitespace.
- id: check-docstring-first # Checks a common error of defining a docstring after code.
- id: check-merge-conflict # Check for files that contain merge conflict strings.
- id: check-yaml # This hook checks yaml files for parseable syntax.
- id: detect-private-key # Detects the presence of private keys.
- id: requirements-txt-fixer # Sorts entries in requirements.txt.
- id: check-symlinks
- id: check-toml
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.6.0
rev: v1.7.0
hooks:
- id: python-no-eval # A quick check for the eval() built-in function.
- repo: https://github.com/myint/docformatter
rev: v1.3.1
rev: v1.4
hooks:
- id: docformatter
args: [--in-place]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
rev: 3.8.4
hooks:
- id: flake8
# additional_dependencies: [flake8-docstrings, flake8-bugbear, flake8-spellcheck, flake8-import-order]
- repo: https://github.com/kynan/nbstripout
rev: master
rev: 0.3.9
hooks:
- id: nbstripout
- repo: https://github.com/asottile/blacken-docs
rev: v1.8.0
rev: v1.9.1
hooks:
- id: blacken-docs
- repo: https://github.com/nbQA-dev/nbQA
rev: 0.4.1
rev: 0.5.6
hooks:
- id: nbqa-black
args: [--nbqa-mutate]
# additional_dependencies: [black==20.8b1]
args: [--nbqa-mutate]
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
## Before contributing

In all following steps, it is highly recommended to use a virtual environment.
Build and installation are performed using `pip` so be sure to have the latest version available.

```
python -m pip install --upgrade pip
```

### Install the development version

Expand All @@ -22,7 +27,7 @@ python -m pip install --editable .[dev]
```

Note that `python -m` can be omitted most of the times, but within virtualenvs, it can prevent certain errors.
Also, in certain terminals (such as zsh), the square brackets must be escaped, e.g. replace `.[dev]` by `.\[dev\]`.
Also, in certain terminals (such as `zsh`), the square brackets must be escaped, e.g. replace `.[dev]` by `.\[dev\]`.

In addition to `numpy`, `scipy` and `ruptures`, this command will install all packages needed to develop `ruptures`.
The exact list of librairies can be found in the [`setup.cfg` file](https://github.com/deepcharles/ruptures/blob/master/setup.cfg) (section `[options.extras_require]`).
Expand All @@ -37,7 +42,6 @@ To activate the hooks, simply run the following command in your terminal.
pre-commit install
```


If you try to commit a non-compliant (i.e. badly formatted) file, `pre-commit` will modify this file and make the commit fail.
However you need to stage the new changes **yourself** as `pre-commit` will not do that for you (this is by design; see [here](https://github.com/pre-commit/pre-commit/issues/806) or [here](https://github.com/pre-commit/pre-commit/issues/747)).
Fortunately, `pre-commit` outputs useful messages.
Expand Down
8 changes: 7 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
include pyproject.toml
prune *
graft src
graft tests

include LICENSE README.md pyproject.toml setup.py setup.cfg
exclude CHANGELOG.md CONTRIBUTING.md mkdocs.yml mkdocs_macros.py
global-exclude __pycache__ *.py[cod] .*
18 changes: 2 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
![build](https://github.com/deepcharles/ruptures/workflows/build/badge.svg)
![python](https://img.shields.io/badge/python-3.6%20|%203.7%20|%203.8%20|%203.9-blue)
[![PyPI version](https://badge.fury.io/py/ruptures.svg)](https://badge.fury.io/py/ruptures)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/ruptures.svg)](https://anaconda.org/conda-forge/ruptures)
![docs](https://github.com/deepcharles/ruptures/workflows/docs/badge.svg)
![PyPI - License](https://img.shields.io/pypi/l/ruptures)
[![Downloads](https://pepy.tech/badge/ruptures)](https://pepy.tech/project/ruptures)
Expand Down Expand Up @@ -30,22 +31,7 @@ If you use `ruptures` in a scientific publication, we would appreciate citations

# Dependencies and install

`ruptures` is tested to work under Python >= 3.6.
It is written in pure Python and depends on the following libraries: `numpy`, `scipy` and `matplotlib` (optional).

- With **pip**:
> pip3 install ruptures

- With **conda**:
> conda install -c conda-forge ruptures

- From source: download the archive and run from inside the **ruptures** directory:

> python3 setup.py install

or

> python3 setup.py develop
Installation instructions can be found [here](https://centre-borelli.github.io/ruptures-docs/install/).

# Basic usage

Expand Down
3 changes: 2 additions & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Installation

This library requires Python3 and the following packages: `numpy`, `scipy` and `matplotlib` (the last one is optional and only for display purposes).
This library requires Python >=3.6 and the following packages: `numpy`, `scipy` and `matplotlib` (the last one is optional and only for display purposes).
You can either install the latest stable release or the development version.

## Stable release
Expand All @@ -13,6 +13,7 @@ To install the latest stable release, use `pip` or `conda`.
```

=== "With conda"
`ruptures` can be installed from the `conda-forge` channel (run `conda config --add channels conda-forge` to add it):
```
conda install ruptures
```
Expand Down
8 changes: 4 additions & 4 deletions docs/user-guide/costs/costlinear.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Let $0 < t_1 < t_2 < \dots < n$ be unknown change points indexes.
Consider the following multiple linear regression model

$$
y_t = z_t' \delta_j + \varepsilon_t, \quad \forall t=t_j,\dots,t_{j+1}-1
y_t = x_t' \delta_j + \varepsilon_t, \quad \forall t=t_j,\dots,t_{j+1}-1
$$

for $j>1$.
Expand All @@ -17,7 +17,7 @@ The least-squares estimates of the break dates is obtained by minimizing the sum
Formally, the associated cost function on an interval $I$ is

$$
c(y_{I}) = \min_{\delta\in\mathbb{R}^p} \sum_{t\in I} \|y_t - \delta' z_t \|_2^2.
c(y_{I}) = \min_{\delta\in\mathbb{R}^p} \sum_{t\in I} \|y_t - \delta' x_t \|_2^2.
$$

## Usage
Expand All @@ -31,7 +31,7 @@ import ruptures as rpt

# creation of data
n, n_reg = 2000, 3 # number of samples, number of regressors (including intercept)
n_bkps, sigma = 3, 5 # number of change points, noise standart deviation
n_bkps = 3 # number of change points
# regressors
tt = np.linspace(0, 10 * np.pi, n)
X = np.vstack((np.sin(tt), np.sin(5 * tt), np.ones(n))).T
Expand Down Expand Up @@ -74,4 +74,4 @@ algo = rpt.Dynp(model="linear")
## References

<a id="Bai2003">[Bai2003]</a>
J. Bai and P. Perron. Critical values for multiple structural change tests. Econometrics Journal, 6(1):72–78, 2003.
J. Bai and P. Perron. Critical values for multiple structural change tests. Econometrics Journal, 6(1):72–78, 2003.
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = [
"setuptools>=38.3.0", # version with most `setup.cfg` bugfixes
"setuptools>=42", # https://github.com/deepcharles/ruptures/pull/100#discussion_r553700339
"wheel",
"Cython>=0.28.5",
"setuptools_scm[toml]>=3.4", # https://scikit-hep.org/developer/packaging#git-tags-official-pypa-method

# PyPy needs numpy >= 1.14.0
# platform_python_implementation!='CPython' not needed >= Python 3.7 which is numpy 1.14.5
Expand Down Expand Up @@ -36,4 +37,7 @@ build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
minversion = "6.0"
addopts = "--cov-report=xml --cov-report=term:skip-covered --cov=ruptures"
testpaths = ["tests"]
testpaths = ["tests"]

[tool.setuptools_scm]
write_to = "src/ruptures/version.py"
13 changes: 0 additions & 13 deletions requirements-dev.txt

This file was deleted.

3 changes: 2 additions & 1 deletion src/ruptures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
from .exceptions import NotEnoughPoints
from .show import display

__version__ = "1.1.2"
# Convenient access to the version number
from .version import version as __version__
6 changes: 4 additions & 2 deletions src/ruptures/costs/costclinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ def error(self, start, end) -> float:
sub = self.signal[start:end]
slope = (self.signal[end - 1] - self.signal[start - 1]) / (end - start)
intercept = self.signal[start - 1]
approx = slope * (np.arange(1, end - start + 1)) + intercept
return np.sum((sub - approx) ** 2)
approx = slope.reshape(-1, 1) * np.arange(
1, end - start + 1
) + intercept.reshape(-1, 1)
return np.sum((sub - approx.transpose()) ** 2)
Loading