Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Managed by copier — records template version for `copier update`. Do not edit.
_commit: v1.3.0
_src_path: gh:gojiplus/py-canon
author_email: gsood07@gmail.com
author_name: Gaurav Sood
coverage_floor: 90
default_branch: main
description: Numerically constructed tF critical values for single-instrument IV inference
needs_cli: true
org: finite-sample
package_name: tf_inference
project_name: tf-inference
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

35 changes: 35 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: 2
updates:
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
# Supply-chain guard: only propose releases that are at least a week old.
# Security updates are not delayed by cooldown.
cooldown:
default-days: 7
groups:
python-minor-and-patch:
applies-to: version-updates
update-types:
- "minor"
- "patch"
python-security:
applies-to: security-updates
patterns:
- "*"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
cooldown:
default-days: 7
groups:
actions-minor-and-patch:
applies-to: version-updates
update-types:
- "minor"
- "patch"
47 changes: 23 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
name: CI
on: [push, pull_request]

on:
push:
branches: [main]
pull_request:
schedule:
- cron: "17 6 * * 1" # weekly: surface ecosystem drift on quiet repos
# A merge made with GITHUB_TOKEN does not trigger workflows, so an
# auto-merged Dependabot PR leaves the default branch at a commit no CI run
# ever covered. The auto-merge sweep dispatches this after it lands one.
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.11', '3.14']
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/setup-python@v7.1.0
with:
python-version: ${{ matrix.python }}
- run: python -m pip install -e '.[dev]'
- run: make ci
- name: Test installed wheel outside the checkout
run: |
python -m venv /tmp/tf-wheel
/tmp/tf-wheel/bin/pip install dist/*.whl pytest
cp -R tests /tmp/tf-wheel-tests
cd /tmp/tf-wheel-tests
/tmp/tf-wheel/bin/python -m pytest --confcutdir=.
- uses: actions/upload-artifact@v7.0.2
with:
name: distributions-python-${{ matrix.python }}
path: dist/*
ci:
uses: gojiplus/py-canon/.github/workflows/reusable-ci.yml@v1
with:
wheel-import: tf_inference
coverage-floor: 90
run-preen: true
21 changes: 21 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Dependabot auto-merge

# All the logic lives in py-canon, so a fix there reaches this repo on its
# next run instead of waiting for someone to copy a file across.

on:
pull_request:
schedule:
# Every three hours, offset off the hour so it does not queue behind the
# crowd of on-the-hour jobs.
- cron: "37 */3 * * *"
workflow_dispatch:

permissions: {}

jobs:
auto-merge:
permissions:
contents: write # arm auto-merge, or squash-merge outright
pull-requests: write # label, comment, merge
uses: gojiplus/py-canon/.github/workflows/reusable-dependabot-auto-merge.yml@v1
23 changes: 23 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Docs

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true

jobs:
docs:
uses: gojiplus/py-canon/.github/workflows/reusable-docs.yml@v1
permissions:
contents: read
pages: write
id-token: write
with:
deploy: ${{ github.event_name == 'push' }}
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release

on:
push:
tags: ["v*.*.*"]
workflow_dispatch:
inputs:
publish:
description: >-
Upload to PyPI. Only takes effect when the run is started from a tag;
from a branch this is a build-and-check rehearsal.
type: boolean
default: false

permissions:
contents: read

# A manual run and a tag push can otherwise race for the same ref: two builds,
# and two `dist` artifacts uploaded under one name.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

jobs:
release:
uses: gojiplus/py-canon/.github/workflows/reusable-release.yml@v1
permissions:
contents: write
id-token: write
with:
# `gh release create` fails when the release already exists, so create it
# only on the original tag push — not on a manual re-run of a released tag.
github-release: ${{ github.event_name == 'push' }}

# PyPI trusted publishing rejects reusable workflows (the OIDC claims
# must reference this repo's workflow file), so the publish step lives
# here rather than in py-canon's reusable-release.
publish:
needs: release
# A PyPI upload cannot be withdrawn, so publish only from a tag. The reusable
# build rejects the tag unless it matches the version in pyproject.toml.
if: >-
startsWith(github.ref, 'refs/tags/') &&
(github.event_name == 'push' || inputs.publish)
runs-on: ubuntu-latest
timeout-minutes: 15
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dist
path: dist/
- name: Publish (trusted publishing, PEP 740 attestations)
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
with:
attestations: true
# The `if:` above decides *which builds may publish*. This decides what
# happens when one version is published twice, which that guard cannot
# see. The concurrency group serializes a manual dispatch and a tag
# push aimed at the same version, it does not deduplicate them, and
# cancel-in-progress is false -- so the queued run starts once the
# first finishes and uploads identical files. A completed run is not
# covered by concurrency at all, so a plain rerun does the same. PyPI
# answers with a 400 and the release goes red having already
# succeeded, which is the worst of both readings.
skip-existing: true
7 changes: 7 additions & 0 deletions .github/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
unpinned-uses:
config:
policies:
"gojiplus/py-canon": ref-pin
"gojiplus/py-canon/*": ref-pin
"*": hash-pin
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repos:
# ruff runs from the project's own environment rather than a separately
# pinned rev. The dev group's ruff floats, and CI resolves it from uv.lock,
# so an exact `rev:` here is a second version that drifts against it -- and
# not always harmlessly: ruff 0.16 formats Python inside Markdown and 0.15
# does not, so `pre-commit run --all-files` passed while `ruff format
# --check` failed in CI on the same README, across five repos. A hook that
# green-lights what CI rejects is worse than no hook.
- repo: local
hooks:
- id: ruff
name: ruff check
entry: uv run ruff check --fix
language: system
types_or: [python, pyi]
require_serial: true
- id: ruff-format
name: ruff format
entry: uv run ruff format
language: system
# Not just Python: current ruff formats code blocks inside Markdown,
# and CI runs `ruff format --check .` over the whole tree.
types_or: [python, pyi, markdown]
require_serial: true
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- id: check-merge-conflict
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Changelog

## [Unreleased]

## 0.1.0 — 2026-11-06

First release of the independent Python implementation of the 2022 tF
construction for one endogenous regressor and one excluded instrument.

- Provide cached critical values and confidence intervals at 18 significance
levels, with explicit numerical calibration for other supported levels.
- Store generated curves in one typed Parquet dataset with a schema-versioned
checksum manifest, calibration diagnostics and validation on load.
- Offer optional CSV export for other statistical software.
- Reject complex inference inputs and stabilize rejection-probability
integration at extremely large finite instrument strength.
- Adopt py-canon development, documentation and release workflows; require
Python 3.12 or later, NumPy, SciPy and PyArrow.

Calibration checks a finite nuisance-parameter domain. It does not certify a
uniform size bound or finite-sample coverage. See the README for the numerical
method, validation and limitations.
12 changes: 12 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
title: "tf-inference"
# Kept in step with project.version by `preen release`, which offers the
# bump alongside the changelog rename. A stale one outlives the release in
# someone else's bibliography.
version: "0.1.0"
authors:
- family-names: "Sood"
given-names: "Gaurav"
repository-code: "https://github.com/finite-sample/tf-inference"
license: MIT
6 changes: 0 additions & 6 deletions MANIFEST.in

This file was deleted.

24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
PYTHON ?= python
ALPHAS = 0.0001 0.0005 0.001 0.002 0.005 0.01 0.02 0.025 0.03 0.04 0.05 0.06 0.075 0.1 0.125 0.15 0.2 0.25

.PHONY: lint test docs build ci ci-docker tables validate benchmark
lint:
$(PYTHON) -m black --check src tests validation benchmarks
$(PYTHON) -m isort --check-only src tests validation benchmarks
$(PYTHON) -m flake8 src tests validation benchmarks
$(PYTHON) -m ruff check src tests validation benchmarks
uv run ruff check .
uv run ruff format --check .
uv run pyright
uv run pydoclint src

test:
$(PYTHON) -m pytest
uv run pytest --cov --cov-report=term-missing

docs:
$(PYTHON) -m sphinx -W --keep-going -b html docs docs/_build/html
uv run --group docs sphinx-build -W --keep-going -b html docs docs/_build/html

build:
$(PYTHON) -m build --no-isolation
uv build
uv run twine check dist/*

ci: lint test docs build

ci-docker:
docker run --rm -v "$(CURDIR):/work" -w /work python:3.11 sh -c "pip install -e '.[dev]' && make ci"
docker run --rm -v "$(CURDIR):/work" -w /work -e UV_PROJECT_ENVIRONMENT=/tmp/tf-venv python:3.12 sh -c "pip install uv && uv sync --frozen --all-groups && make ci"

tables:
$(PYTHON) -m tf_inference.cli generate --alpha $(ALPHAS) --output src/tf_inference/data
uv run tf-inference generate --alpha $(ALPHAS) --output src/tf_inference/data

validate:
$(PYTHON) validation/validate.py --output validation/results.json
uv run python validation/validate.py --output validation/results.json

benchmark:
$(PYTHON) benchmarks/benchmark.py --output benchmarks/results.json
uv run python benchmarks/benchmark.py --output benchmarks/results.json
Loading
Loading