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

Modify existing and add new delta method transformations and begin work on documentation #2

Merged
merged 33 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e73b264
reimplement global dictionary as class and remove _check_transform_va…
mbi6245 Apr 30, 2024
03f1953
reimplement global dictionary as class and remove _check_transform_va…
mbi6245 Apr 30, 2024
f853c25
remove transform as a field due to incorrect syntax
mbi6245 Apr 30, 2024
51e0d68
test adding cd/ci features
mbi6245 May 6, 2024
f60c87f
remove coverage report in build.yml and remove use of API token in de…
mbi6245 May 6, 2024
8e76918
change pip install command from dev to test
mbi6245 May 6, 2024
ee7d4b2
add dependencies to array in pyproject.toml
mbi6245 May 6, 2024
378087b
change url to point to distrx instead of pypkg
mbi6245 May 6, 2024
78fab30
remove old setup.py and .DS_Store as well as edit pyproject.toml to n…
mbi6245 May 6, 2024
132c1f2
remove about.py
mbi6245 May 6, 2024
2425ac8
add warnings to the optional dependencies in pyproject.toml
mbi6245 May 6, 2024
07bd7ef
fix typo, was missing closing quotation mark when adding warnings in …
mbi6245 May 6, 2024
93f7a01
try python 3.12 in build and deploy.yml instead of 3.11
mbi6245 May 6, 2024
21a11e3
transfer required dependencies from test to dependencies in pyproject…
mbi6245 May 6, 2024
8be74bd
remove warnings from dependency list in pyproject.toml, ensure python…
mbi6245 May 6, 2024
469b794
fix bugs in transforms.py, tests now passing
mbi6245 May 14, 2024
f597641
implement first draft of transform_percentage_change function and doc…
mbi6245 May 16, 2024
c82ffd0
add function to handle raw counts for percentage change
mbi6245 May 19, 2024
e07bc06
reimplement percentage change transform for experimental and implemen…
mbi6245 May 23, 2024
fd2bbd4
create 2 versions of transform percentage change function, add jupyte…
mbi6245 Jun 20, 2024
c3d93ae
remove extraneous TODO comment
mbi6245 Jun 20, 2024
76371ce
add functionality to handle differnet input types, testing, and more …
mbi6245 Jun 27, 2024
606c66b
remove extraneous dependencies in transforms.py, add requirement of p…
mbi6245 Jun 27, 2024
8df9d6f
change counts to default option and update testing/simulations accord…
mbi6245 Jul 3, 2024
2e5ddc8
change univariate transformation class to be callable, implement c2fu…
mbi6245 Jul 9, 2024
0467f80
add msca to list of required dependencies
mbi6245 Jul 9, 2024
611c494
reorganize into univariate and bivariate functions, as well as adding…
mbi6245 Jul 16, 2024
5f082ee
added latex equation to percentage_change_trans and updated bivariate…
mbi6245 Jul 16, 2024
cb4aa73
fix documentation typos in docstrings in transforms.py, and in transf…
mbi6245 Jul 17, 2024
6304183
add missing scaling factor
mbi6245 Jul 18, 2024
549a2c9
create simulation function and run simulations on all 4 univariate tr…
mbi6245 Jul 19, 2024
76bd5e1
fix test failures by removing sample size scaling in testing file
mbi6245 Jul 19, 2024
e8e7c3d
Merge pull request #3 from ihmeuw-msca/reorganize
mbi6245 Jul 19, 2024
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
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build

on:
push:
branches:
- "*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: python -m pip install .[test] --upgrade pip --no-cache-dir
- name: Test with pytest
run: pytest # --cov=./ --cov-report=xml
# repository > settings > github apps > configure codecov

# - name: Build package distribution
# if: startsWith(github.ref, 'refs/tags')
# run: |
# python -m pip install build
# python -m build --sdist --wheel --outdir dist/ .
# - name: Publish package distribution to PyPI
# if: startsWith(github.ref, 'refs/tags')
# uses: pypa/gh-action-pypi-publish@master
# with:
# skip_existing: true
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
59 changes: 59 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: deploy

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

permissions:
contents: write

jobs:
pypi:
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: python -m pip install build . --upgrade pip
# - name: Build package distribution
# run: python-m build --sdist --wheel --outdir dist/ .
# - name: Publish package distribution to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# skip_existing: true
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}

docs:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: python -m pip install .[docs] --upgrade pip
- name: Generate API docs & Build sphinx documentation
run: |
git fetch --tags
cd docs
python build.py
cd ..
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './docs/pages'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
29 changes: 0 additions & 29 deletions .github/workflows/python-build.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**/.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
},
"editor.rulers": [80],
},
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
}
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
19 changes: 19 additions & 0 deletions docs/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* reduce the size of the main text */
p {
font-size: 0.95rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: 500;
}

.sidebar-brand-text {
font-size: 1rem;
font-weight: 500;
margin: auto;
}
Binary file added docs/_static/logo/logo-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/logo/logo-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions docs/_templates/sidebar/variant-selector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="sidebar-tree">
<ul>
<li class="toctree-l1 has-children"><a class="reference internal" href="">Versions</a>
<input class="toctree-checkbox" id="toctree-checkbox-version" name="toctree-checkbox-version" role="switch" type="checkbox"/>
<label for="toctree-checkbox-version"><div class="visually-hidden">Toggle navigation of Versions</div>
<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>
</label>
<ul>
{% for version in versions %}
<li class="toctree-l2"><a class="reference internal" href="{{ pathto('/'.join(['..', version, pagename])) }}">{{ version }}</a></li>
{% endfor %}
</ul>
<li>
</ul>
</div>
5 changes: 5 additions & 0 deletions docs/api_reference/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pypkg.example
=============

.. automodule:: pypkg.example
:members:
13 changes: 13 additions & 0 deletions docs/api_reference/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
API reference
=============

.. toctree::
:hidden:
:glob:

*

.. note::
Briefly describe the organization of the API reference if any.

In PyPkg, we only provide a dummy function :py:func:`.example.add` to show the bone structure of a Python pacakge.
41 changes: 41 additions & 0 deletions docs/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import functools
import subprocess

import tomllib

run = functools.partial(subprocess.run, shell=True)


def build_doc(version: str) -> None:
run(f"git checkout v{version}")
run("git checkout main -- conf.py")
run("git checkout main -- versions.toml")

run("make html")
run(f"mv _build/html pages/{version}")
run("rm -rf _build")
run("git checkout main")


def build_init_page(version: str) -> None:
with open("pages/index.html", "w") as f:
f.write(f"""<!doctype html>
<meta http-equiv="refresh" content="0; url=./{version}/">""")


if __name__ == "__main__":
# create pages folder
run("rm -rf pages")
run("mkdir pages")

# get versions
with open("meta.toml", "rb") as f:
versions = tomllib.load(f)["versions"]
versions.sort(reverse=True, key=lambda v: tuple(map(int, v.split("."))))

# build documentations for different versions
for version in versions:
build_doc(version)

# build initial page that redirect to the latest version
build_init_page(versions[0])
106 changes: 106 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath("."))
import datetime

import tomllib

with open("../pyproject.toml", "rb") as f:
about = tomllib.load(f)["project"]


# -- Project information -----------------------------------------------------

project = about["name"]
author = ", ".join([info["name"] for info in about["authors"]])
copyright = f"2019-{datetime.datetime.today().year}, {author}"


# The full version, including alpha/beta/rc tags
version = about["version"]


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosectionlabel",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
]
autodoc_typehints = "description"
autodoc_member_order = "bysource"
autodoc_type_aliases = {
"ArrayLike": "ArrayLike",
"NDArray": "NDArray",
"DataFrame": "DataFrame",
}

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "furo"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_css_files = ["css/custom.css"]
html_title = f"{project} {version}"
html_theme_options = {
"sidebar_hide_name": False,
"light_logo": "logo/logo-light.png",
"dark_logo": "logo/logo-dark.png",
"light_css_variables": {
"color-brand-primary": "#008080",
"color-brand-content": "#008080",
"color-problematic": "#BF5844",
"color-background-secondary": "#F8F8F8",
"color-admonition-title--note": "#008080",
"color-admonition-title-background--note": "#00808033",
},
"dark_css_variables": {
"color-brand-primary": "#6FD8D1",
"color-brand-content": "#6FD8D1",
"color-problematic": "#FA9F50",
"color-background-secondary": "#202020",
"color-admonition-title--note": "#6FD8D1",
"color-admonition-title-background--note": "#6FD8D133",
},
}
# get versions
with open("meta.toml", "rb") as f:
versions = tomllib.load(f)["versions"]
html_context = {
"versions": versions,
}
Loading