Skip to content

Commit

Permalink
Merge branch 'master' into el8
Browse files Browse the repository at this point in the history
  • Loading branch information
nsmith- authored Feb 26, 2025
2 parents 8d9cab4 + beef157 commit 7a890a4
Show file tree
Hide file tree
Showing 20 changed files with 262 additions and 154 deletions.
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

85 changes: 37 additions & 48 deletions .github/workflows/pr_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,55 @@ name: PR Tests
on:
pull_request:
branches:
- master
- master

jobs:
linter:
name: Linter
pre-commit:
name: Format
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
- uses: actions/checkout@v4
with:
python-version: 3.9

- name: Install Python dependencies
run: pip install black flake8

- name: Run black
uses: wearerequired/lint-action@v2
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: pre-commit/action@v3.0.1
with:
auto_fix: true
black: true
black_auto_fix: true

- name: Lint with flake8
run: flake8 rhalphalib --count --show-source --statistics
extra_args: --hook-stage manual --all-files

test:
name: Run pytest (Python ${{ matrix.python-version }}, ROOT ${{ matrix.root-version }})
needs: linter
name:
Run pytest (Python ${{ matrix.python-version }}, ROOT ${{
matrix.root-version }})
needs: pre-commit
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: true
matrix:
python-version: [3.7]
root-version: [6.16, 6.22]
python-version: ["3.10"]
root-version: ["6.30.04", "6.32.10"]
include:
- python-version: "3.9"
root-version: "6.22.8"

steps:
- uses: actions/checkout@v1
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v2.2.0
with:
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
channels: conda-forge,defaults
channel-priority: true
activate-environment: condaenv
- name: Install ROOT ${{ matrix.root-version }}
shell: bash -l {0}
run: |
mamba install -c conda-forge numpy scipy nomkl root==${{ matrix.root-version }}
- name: Install package
shell: bash -l {0}
run: |
pip install -e .
- name: Test with pytest
shell: bash -l {0}
run: |
pip install pytest
pytest tests
- uses: actions/checkout@v1
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
miniforge-version: latest
- name: Install ROOT ${{ matrix.root-version }}
shell: bash -l {0}
run: |
mamba install -c conda-forge numpy scipy nomkl root==${{ matrix.root-version }}
- name: Install package
shell: bash -l {0}
run: |
pip install .[test]
- name: Test with pytest
shell: bash -l {0}
run: |
pytest tests
32 changes: 16 additions & 16 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ __pycache__
*.egg-info
build
dist
.vscode
.vscode
81 changes: 76 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,80 @@
ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"

exclude: ^.cruft.json|.copier-answers.yml$

repos:
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.19.1"
hooks:
- id: blacken-docs
additional_dependencies: [black==24.*]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
rev: "v5.0.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: name-tests-test
args: ["--pytest-test-first"]
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/rbubley/mirrors-prettier
rev: "v3.4.2"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.9.2"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/codespell-project/codespell
rev: "v2.3.0"
hooks:
- id: codespell

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.10.0.1"
hooks:
- id: shellcheck

- repo: local
hooks:
- id: disallow-caps
name: Disallow improper capitalization
language: pygrep
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
exclude: .pre-commit-config.yaml

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.23"
hooks:
- id: flake8
- repo: https://github.com/psf/black-pre-commit-mirror
rev: "23.10.1"
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.31.0"
hooks:
- id: black-jupyter
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
## Quickstart

### CMSSW with EL8/EL9
Tested May 2024 on CMSLPC el8 (should work with lxplus9 as well). We use the [scram-venv](http://cms-sw.github.io/venv.html) utility
to create a python virtual environment in our CMSSW area.
We use the [scram-venv](http://cms-sw.github.io/venv.html) utility to create a python virtual environment in our CMSSW area:
```bash
cmsrel CMSSW_13_3_2
cd CMSSW_13_3_2/src
cmsenv
cmsrel CMSSW_14_1_0_pre4
cd CMSSW_14_1_0_pre4/src
scram-venv
cmsenv
git clone https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit.git HiggsAnalysis/CombinedLimit
cd HiggsAnalysis/CombinedLimit
git checkout v10.1.0
scram b -j4
python3 -m pip install https://github.com/nsmith-/rhalphalib/archive/master.zip
python3 -m pip install git+https://github.com/nsmith-/rhalphalib.git
```

### Elsewhere (no warranty)
First, install [Combine v9](https://cms-analysis.github.io/HiggsAnalysis-CombinedLimit/#installation-instructions) using
First, install [Combine v10](https://cms-analysis.github.io/HiggsAnalysis-CombinedLimit/#installation-instructions) using
your choice of installation instructions (with CMSSW, using LCG, or inside a Conda environment). In a python virtual environment, run:
```bash
python3 -m pip install --user https://github.com/nsmith-/rhalphalib/archive/master.zip
python3 -m pip install --user git+https://github.com/nsmith-/rhalphalib.git
```

## Usage
Expand All @@ -38,3 +38,15 @@ cd tmp/testModel
. build.sh
combine -M FitDiagnostics model_combined.root
```

An example output of the final line is:
```
<<< Combine >>>
<<< v10.1.0 >>>
>>> Random number generator seed is 123456
>>> Method used is FitDiagnostics
--- FitDiagnostics ---
Best fit r: 0.999999 -0.208174/+0.212715 (68% CL)
Done in 0.59 min (cpu), 0.59 min (real)
```
60 changes: 58 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
[tool.black]
line-length = 199
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "rhalphalib"
dynamic = ["version"]
authors = [
{name = "Nick Smith", email = "nick.smith@cern.ch"},
]
maintainers = [
{name = "Nick Smith", email = "nick.smith@cern.ch"},
]
description = "A binned fit intermediate representation library"
readme = "README.md"
license = {text = "BSD-3-Clause"}
# keywords = []
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Physics",
]
requires-python = ">=3.8"
dependencies = [
"numpy >=1.14",
"scipy",
"mplhep",
]

[project.optional-dependencies]
test = [
"pytest",
]
dev = [
"pre-commit",
]
docs = [
"sphinx>=7.0",
"myst_parser>=0.13",
"sphinx_copybutton",
"sphinx_autodoc_typehints",
"furo>=2023.08.17",
]

[project.urls]
Homepage = "https://github.com/nsmith-/rhalphalib"

[tool.setuptools_scm]
write_to = "src/rhalphalib/version.py"

[tool.ruff]
line-length = 199

[tool.codespell]
ignore-words-list = "fpt"
1 change: 0 additions & 1 deletion rhalphalib/version.py

This file was deleted.

Loading

0 comments on commit 7a890a4

Please sign in to comment.