From 9658372b95546ad53109914e31dc535fa22b8e1b Mon Sep 17 00:00:00 2001 From: aeturrell Date: Sat, 29 Oct 2022 19:28:40 +0100 Subject: [PATCH] switch to github pages --- .github/dependabot.yml | 2 +- .github/workflows/constraints.txt | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 2 +- .readthedocs.yml | 21 --------------------- README.md | 7 +++---- docs/_config.yml | 10 ++++++---- docs/contributing.md | 20 +++++++++++++++++++- docs/index.ipynb | 9 ++++----- poetry.lock | 2 +- pyproject.toml | 5 +++-- src/specification_curve/__init__.py | 12 ++++++------ 12 files changed, 46 insertions(+), 48 deletions(-) delete mode 100644 .readthedocs.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c236bda..a0a5c73 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -15,4 +15,4 @@ updates: - package-ecosystem: pip directory: "/" schedule: - interval: daily \ No newline at end of file + interval: daily diff --git a/.github/workflows/constraints.txt b/.github/workflows/constraints.txt index 2b45a39..50b25e4 100644 --- a/.github/workflows/constraints.txt +++ b/.github/workflows/constraints.txt @@ -2,4 +2,4 @@ pip==22.3 nox==2022.8.7 nox-poetry==1.0.1 poetry==1.2.2 -virtualenv==20.16.5 \ No newline at end of file +virtualenv==20.16.5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e89688..18a413f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,4 +70,4 @@ jobs: publish: ${{ steps.check-version.outputs.tag != '' }} tag: ${{ steps.check-version.outputs.tag }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3c33434..dddc46e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -122,4 +122,4 @@ jobs: run: | nox --force-color --session=coverage -- xml - name: Upload coverage report - uses: codecov/codecov-action@v3.1.1 \ No newline at end of file + uses: codecov/codecov-action@v3.1.1 diff --git a/.readthedocs.yml b/.readthedocs.yml deleted file mode 100644 index be31bcf..0000000 --- a/.readthedocs.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: 2 -build: - os: ubuntu-22.04 - tools: - python: "3.8" - jobs: - pre_build: - # Generate the Sphinx configuration for this Jupyter Book so it builds. - - "pip install jupyter-book furo" - - "jupyter-book config sphinx docs/" - -python: - install: - - method: pip - path: . - extra_requirements: - - sphinx - -sphinx: - builder: html - fail_on_warning: true \ No newline at end of file diff --git a/README.md b/README.md index 6653572..0abbe69 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Specification Curve is a Python package that performs specification curve analys [![Status](https://img.shields.io/pypi/status/specification_curve.svg)](https://pypi.org/project/specification_curve/) [![Python Version](https://img.shields.io/pypi/pyversions/specification_curve)](https://pypi.org/project/specification_curve) [![License](https://img.shields.io/pypi/l/specification_curve)](https://opensource.org/licenses/MIT) -[![Read the documentation at https://specification_curve.readthedocs.io/](https://img.shields.io/readthedocs/specification_curve/latest.svg?label=Read%20the%20Docs)](https://specification_curve.readthedocs.io/) [![Tests](https://github.com/aeturrell/specification_curve/workflows/Tests/badge.svg)](https://github.com/aeturrell/specification_curve/actions?workflow=Tests) [![Codecov](https://codecov.io/gh/aeturrell/specification_curve/branch/main/graph/badge.svg)](https://codecov.io/gh/aeturrell/specification_curve) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) @@ -19,9 +18,9 @@ Specification Curve is a Python package that performs specification curve analys [![macOS](https://svgshare.com/i/ZjP.svg)](https://svgshare.com/i/ZjP.svg) [![Windows](https://svgshare.com/i/ZhY.svg)](https://svgshare.com/i/ZhY.svg) -[![Soure](https://img.shields.io/badge/source%20code-github-lightgrey?style=for-the-badge)](https://github.com/aeturrell/specification_curve) +[![Source](https://img.shields.io/badge/source%20code-github-lightgrey?style=for-the-badge)](https://github.com/aeturrell/specification_curve) -[Go to the full documentation for **Specification Curve**](https://specification_curve.readthedocs.io/). +[Go to the full documentation for **Specification Curve**](https://aeturrell.github.io/specification_curve/). ## Quickstart @@ -41,7 +40,7 @@ import pandas as pd # Set seed for random numbers seed_for_prng = 78557 # prng=probabilistic random number generator -prng = np.random.default_rng(seed_for_prng) +prng = np.random.default_rng(seed_for_prng) n_samples = 400 # Number of dimensions n_dim = 4 diff --git a/docs/_config.yml b/docs/_config.yml index 11594bd..102de3d 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -25,6 +25,10 @@ repository: path_to_book: docs # Optional path to your book, relative to the repository root branch: master # Which branch of the repository should be used when creating links (optional) +launch_buttons: + colab_url : "https://colab.research.google.com" # The URL of Google Colab + + # Add GitHub buttons to your book # See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository html: @@ -32,12 +36,10 @@ html: use_repository_button: true extra_navbar: "" home_page_in_navbar: false # Whether to include your home page in the left Navigation Bar - baseurl: "https://specification-curve.readthedocs.io/" - favicon: "favicon.ico" + baseurl: "https://aeturrell.github.io/specification_curve" + # favicon: "favicon.ico" sphinx: - config: - html_theme: furo extra_extensions: - 'sphinx.ext.autodoc' - 'sphinx.ext.napoleon' # for google-style docstrings diff --git a/docs/contributing.md b/docs/contributing.md index 3db37c4..d41fd5b 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -8,7 +8,7 @@ and pull requests. Here is a list of important resources for contributors: - [Source Code](https://github.com/aeturrell/specification_curve) -- [Documentation](https://specification_curve.readthedocs.io/) +- [Documentation](https://aeturrell.github.io/specification_curve/) - [Issue Tracker](https://github.com/aeturrell/specification_curve/issues) ## How to report a bug @@ -115,3 +115,21 @@ To upload the documentation, it’s ```bash poetry run ghp-import -n -p -f docs/_build/html ``` + +## How to create a package release + +- Open a new branch with the version name + +- Change the version in pyproject.toml + +- Commit the change with a new version label as the commit message (checking the tests pass) + +- Head to github and merge into main + +- Draft a new release based on that most recent merge commit, using the new version as the tag + +- Run `poetry build` to produce the distributable files + +- Confirm the release draft on gitub + +- The automatic release github action will push to PyPI. \ No newline at end of file diff --git a/docs/index.ipynb b/docs/index.ipynb index 1b68042..aa3bbed 100644 --- a/docs/index.ipynb +++ b/docs/index.ipynb @@ -17,7 +17,6 @@ "[![Status](https://img.shields.io/pypi/status/specification_curve.svg)](https://pypi.org/project/specification_curve/)\n", "[![Python Version](https://img.shields.io/pypi/pyversions/specification_curve)](https://pypi.org/project/specification_curve)\n", "[![License](https://img.shields.io/pypi/l/specification_curve)](https://opensource.org/licenses/MIT)\n", - "[![Read the documentation at https://specification_curve.readthedocs.io/](https://img.shields.io/readthedocs/specification_curve/latest.svg?label=Read%20the%20Docs)](https://specification_curve.readthedocs.io/)\n", "[![Tests](https://github.com/aeturrell/specification_curve/workflows/Tests/badge.svg)](https://github.com/aeturrell/specification_curve/actions?workflow=Tests)\n", "[![Codecov](https://codecov.io/gh/aeturrell/specification_curve/branch/main/graph/badge.svg)](https://codecov.io/gh/aeturrell/specification_curve)\n", "[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)\n", @@ -43,17 +42,17 @@ "\n", "Typically this happens when there isn’t a clear way to do \"feature engineering\" on the data or the data are imperfect in some way. For example, you have a high frequency time series which needs to be aggregated to a lower frequency: you could take the maximum, the minimum, or the average over each high frequency time period. A different choice may be appropriate in different settings.\n", "\n", - "There's formal evidence that researchers really do make different decisions; one study {cite:ps}`silberzahn2018many` gave the same research question---whether soccer referees are more likely to give red cards to players with dark skin tones than to players with light skin tones---to 29 different teams. From the abstract of that paper:\n", + "There's formal evidence that researchers really do make different decisions; one study {cite:p}`silberzahn2018many` gave the same research question---whether soccer referees are more likely to give red cards to players with dark skin tones than to players with light skin tones---to 29 different teams. From the abstract of that paper:\n", "\n", "> Analytic approaches varied widely across the teams, and the estimated effect sizes ranged from 0.89 to 2.93 (Mdn = 1.31) in odds-ratio units. Twenty teams (69%) found a statistically significant positive effect, and 9 teams (31%) did not observe a significant relationship. Overall, the 29 different analyses used 21 unique combinations of covariates. Neither analysts’ prior beliefs about the effect of interest nor their level of expertise readily explained the variation in the outcomes of the analyses. Peer ratings of the quality of the analyses also did not account for the variability.\n", "\n", "So not only can different decisions made, but there seems to be no clearly identifiable reason for them!\n", "\n", - "There have since been a number of papers that find similar conclusions {cite:ps}`huntington2021influence`.\n", + "There have since been a number of papers that find similar conclusions {cite:p}`huntington2021influence`.\n", "\n", - "Specification curves have been invented {cite:ps}`simonsohn2020specification` as a way to better grasp the garden of forking paths that analysts face, and help them show how sensitive their results are to alternative specifications.\n", + "Specification curves have been invented {cite:p}`simonsohn2020specification` as a way to better grasp the garden of forking paths that analysts face, and help them show how sensitive their results are to alternative specifications.\n", "\n", - "More than one piece of software {cite:ps}`masur2019specr` has appeared to help researchers and analysts use this technique: **specification curve** is one such package!" + "More than one piece of software {cite:p}`masur2019specr` has appeared to help researchers and analysts use this technique: **specification curve** is one such package!" ] }, { diff --git a/poetry.lock b/poetry.lock index cebe56a..ebd272f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2403,7 +2403,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "flake8 [metadata] lock-version = "1.1" python-versions = ">=3.8,<4.0.0" -content-hash = "fa11058c2b6eff3b497b53d2a97af56ba59c6d71e8f6502e7ebeaddc2af6f4e1" +content-hash = "c1c2339f7d2380b9feac354b60fd6a90df1fc9961a50c32b2d6438fd85b906e3" [metadata.files] alabaster = [ diff --git a/pyproject.toml b/pyproject.toml index 23fb130..2593549 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,9 +5,9 @@ description = "Specification_Curve" authors = ["aeturrell "] license = "MIT" readme = "README.md" -homepage = "https://github.com/aeturrell/specification_curve" +homepage = "https://aeturrell.github.io/specification_curve/" repository = "https://github.com/aeturrell/specification_curve" -documentation = "https://specification_curve.readthedocs.io" +documentation = "https://aeturrell.github.io/specification_curve/" classifiers = [ "Development Status :: 3 - Alpha", "Programming Language :: Python :: 3.8", @@ -43,6 +43,7 @@ ghp-import = "^2.1.0" xdoctest = "^1.1.0" mypy = "^0.982" reorder-python-imports = "^3.9.0" +sphinxcontrib-bibtex = "^2.5.0" [tool.poetry.scripts] specification_curve = "specification_curve.__main__:main" diff --git a/src/specification_curve/__init__.py b/src/specification_curve/__init__.py index cf0d402..9bbe1d8 100644 --- a/src/specification_curve/__init__.py +++ b/src/specification_curve/__init__.py @@ -20,6 +20,7 @@ import pkg_resources import statsmodels.api as sm + EXAMPLE_FILE = pkg_resources.resource_filename( "specification_curve", os.path.join("data", "example_data.csv") ) @@ -144,12 +145,11 @@ def __init__( self.cat_expand = cat_expand self.always_include = always_include - def fit(self, estimator=sm.OLS): - """ - Fits a specification curve. + def fit(self, estimator=sm.OLS) -> None: + """Fits a specification curve by performing regressions. - :statsmodels.regression.linear_model estimator: statsmodels estimator - object. Default is OLS. + Args: + estimator (statsmodels.regression.linear_model or statsmodels.discrete.discrete_model, optional): statsmodels estimator. Defaults to sm.OLS. """ self.estimator = estimator self.controls = _single_list_check_str(self.controls) @@ -418,7 +418,7 @@ def plot(self, save_path=None, pretty_plots=True, preferred_spec=[]): loc_y = loc_y.values[0] cn_styl = "angle3,angleA=0,angleB=-90" axarr[0].annotate( - f"Preferred\nspecification: {loc_y:+.2f}", + f"Preferred specification: {loc_y:+.2f}", xy=(loc_x, loc_y), xycoords="data", xytext=(-30, 60),