-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from alkemics/groupby_pnt
documentation update / flake8 ci fix
- Loading branch information
Showing
21 changed files
with
262 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @alk-lbinet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Python 3 Tests | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.5, 3.6, 3.7, 3.8] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements-test.txt | ||
python setup.py develop | ||
- name: Lint with flake8 | ||
run: | | ||
# ignore "line break before binary operator", and "invalid escape sequence '\_'" useful for doc | ||
flake8 --count --ignore=W503,W605 --show-source --statistics pandagg | ||
# on tests, more laxist: allow "missing whitespace after ','" and "line too long" | ||
flake8 --count --ignore=W503,W605,E231,E501 --show-source --statistics tests | ||
- name: Test with pytest | ||
run: | | ||
pytest |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
pandas | ||
pandas | ||
sphinx_rtd_theme | ||
recommonmark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
from textwrap import dedent | ||
|
||
|
||
# Substitution and Appender are copied from pandas.util._decorators | ||
# https://github.com/pandas-dev/pandas/blob/master/LICENSE | ||
|
||
|
||
class Substitution: | ||
""" | ||
A decorator to take a function's docstring and perform string | ||
substitution on it. | ||
This decorator should be robust even if func.__doc__ is None | ||
(for example, if -OO was passed to the interpreter) | ||
Usage: construct a docstring.Substitution with a sequence or | ||
dictionary suitable for performing substitution; then | ||
decorate a suitable function with the constructed object. e.g. | ||
sub_author_name = Substitution(author='Jason') | ||
@sub_author_name | ||
def some_function(x): | ||
"%(author)s wrote this function" | ||
# note that some_function.__doc__ is now "Jason wrote this function" | ||
One can also use positional arguments. | ||
sub_first_last_names = Substitution('Edgar Allen', 'Poe') | ||
@sub_first_last_names | ||
def some_function(x): | ||
"%s %s wrote the Raven" | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
if args and kwargs: | ||
raise AssertionError("Only positional or keyword args are allowed") | ||
|
||
self.params = args or kwargs | ||
|
||
def __call__(self, func): | ||
func.__doc__ = func.__doc__ and func.__doc__ % self.params | ||
return func | ||
|
||
def update(self, *args, **kwargs): | ||
""" | ||
Update self.params with supplied args. | ||
""" | ||
|
||
if isinstance(self.params, dict): | ||
self.params.update(*args, **kwargs) | ||
|
||
|
||
class Appender: | ||
""" | ||
A function decorator that will append an addendum to the docstring | ||
of the target function. | ||
This decorator should be robust even if func.__doc__ is None | ||
(for example, if -OO was passed to the interpreter). | ||
Usage: construct a docstring.Appender with a string to be joined to | ||
the original docstring. An optional 'join' parameter may be supplied | ||
which will be used to join the docstring and addendum. e.g. | ||
add_copyright = Appender("Copyright (c) 2009", join='\n') | ||
@add_copyright | ||
def my_dog(has='fleas'): | ||
"This docstring will have a copyright below" | ||
pass | ||
""" | ||
|
||
def __init__(self, addendum, join="", indents=0): | ||
if indents > 0: | ||
self.addendum = indent(addendum, indents=indents) | ||
else: | ||
self.addendum = addendum | ||
self.join = join | ||
|
||
def __call__(self, func): | ||
func.__doc__ = func.__doc__ if func.__doc__ else "" | ||
self.addendum = self.addendum if self.addendum else "" | ||
docitems = [func.__doc__, self.addendum] | ||
func.__doc__ = dedent(self.join.join(docitems)) | ||
return func | ||
|
||
|
||
def indent(text, indents=1): | ||
if not text or not isinstance(text, str): | ||
return "" | ||
jointext = "".join(["\n"] + [" "] * indents) | ||
return jointext.join(text.split("\n")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.