Skip to content

skpkg: setup CI after migrating tests, src, requirements, and .github folder #151

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

Merged
merged 10 commits into from
Jun 15, 2025
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
8 changes: 4 additions & 4 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
coverage:
status:
project: # more options at https://docs.codecov.com/docs/commit-status
project: # more options at https://docs.codecov.com/docs/commit-status
default:
target: auto # use the coverage from the base commit, fail if coverage is lower
threshold: 0% # allow the coverage to drop by
threshold: 0% # allow the coverage to drop by

comment:
layout: " diff, flags, files"
behavior: default
require_changes: false
require_base: false # [true :: must have a base report to post]
require_head: false # [true :: must have a head report to post]
require_base: false # [true :: must have a base report to post]
require_head: false # [true :: must have a head report to post]
hide_project_coverage: false # [true :: only show coverage on the git diff aka patch coverage]
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/release_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ assignees: ""
- [ ] All the badges on the README are passing.
- [ ] License information is verified as correct. If you are unsure, please comment below.
- [ ] Locally rendered documentation contains all appropriate pages, including API references (check no modules are
missing), tutorials, and other human written text is up-to-date with any changes in the code.
missing), tutorials, and other human written text is up-to-date with any changes in the code.
- [ ] Installation instructions in the README, documentation and on the website (e.g., diffpy.org) are updated.
- [ ] Successfully run any tutorial examples or do functional testing with the latest Python version.
- [ ] Grammar and writing quality are checked (no typos).
Expand All @@ -31,5 +31,5 @@ version information and details about the pre-release here:

<!-- Before closing this issue, please complete the following: -->

- [ ] Run tutorial examples and conduct functional testing using the installation guide in the README. Attach screenshots/results as comments.
- [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures.
- [ ] Run tutorial examples and conduct functional testing using the installation guide in the README. Attach screenshots/results as comments.
- [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures.
6 changes: 4 additions & 2 deletions .github/workflows/build-wheel-release-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ on:
workflow_dispatch:
push:
tags:
- '*' # Trigger on all tags initially, but tag and release privilege are verified in _build-wheel-release-upload.yml
- "*" # Trigger on all tags initially, but tag and release privilege are verified in _build-wheel-release-upload.yml

jobs:
release:
uses: Billingegroup/release-scripts/.github/workflows/_build-wheel-release-upload.yml@v0
uses: scikit-package/release-scripts/.github/workflows/_build-wheel-release-upload.yml@v0
with:
project: diffpy.snmf
c_extension: false
maintainer_GITHUB_username: sbillinge
secrets:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/check-news-item.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Check for News
on:
pull_request_target:
branches:
- main
- main

jobs:
build:
uses: Billingegroup/release-scripts/.github/workflows/_check-news-item.yml@v0
check-news-item:
uses: scikit-package/release-scripts/.github/workflows/_check-news-item.yml@v0
with:
project: diffpy.snmf
4 changes: 2 additions & 2 deletions .github/workflows/matrix-and-codecov-on-merge-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:
workflow_dispatch:

jobs:
coverage:
uses: Billingegroup/release-scripts/.github/workflows/_matrix-and-codecov-on-merge-to-main.yml@v0
matrix-coverage:
uses: scikit-package/release-scripts/.github/workflows/_matrix-and-codecov-on-merge-to-main.yml@v0
with:
project: diffpy.snmf
c_extension: false
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/publish-docs-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Deploy Documentation on Release

on:
workflow_dispatch:

jobs:
docs:
uses: scikit-package/release-scripts/.github/workflows/_publish-docs-on-release.yml@v0
with:
project: diffpy.snmf
c_extension: false
headless: false
7 changes: 2 additions & 5 deletions .github/workflows/tests-on-pr.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
name: Tests on PR

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
validate:
uses: Billingegroup/release-scripts/.github/workflows/_tests-on-pr.yml@v0
tests-on-pr:
uses: scikit-package/release-scripts/.github/workflows/_tests-on-pr.yml@v0
with:
project: diffpy.snmf
c_extension: false
Expand Down
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __pycache__/
.Python
env/
build/
_build/
develop-eggs/
dist/
downloads/
Expand Down Expand Up @@ -90,10 +91,3 @@ target/

# Ipython Notebook
.ipynb_checkpoints

# version information
setup.cfg
/src/diffpy/*/version.cfg

# Rever
rever/
38 changes: 26 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
default_language_version:
python: python3
python: python3
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
autofix_prs: true
autoupdate_branch: 'pre-commit-autoupdate'
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: monthly
skip: [no-commit-to-branch]
submodules: false
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
autofix_prs: true
autoupdate_branch: "pre-commit-autoupdate"
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
autoupdate_schedule: monthly
skip: [no-commit-to-branch]
submodules: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
Expand Down Expand Up @@ -47,6 +47,20 @@ repos:
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli
- id: codespell
additional_dependencies:
- tomli
# prettier - multi formatter for .json, .yml, and .md files
- repo: https://github.com/pre-commit/mirrors-prettier
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
hooks:
- id: prettier
additional_dependencies:
- "prettier@^3.2.4"
# docformatter - PEP 257 compliant docstring formatter
- repo: https://github.com/s-weigand/docformatter
rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: [--in-place, --config, ./pyproject.toml]
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ build-backend = "setuptools.build_meta"
name = "diffpy.snmf"
dynamic=['version', 'dependencies']
authors = [
{ name="Simon J.L. Billinge group", email="[email protected]" },
{ name="Simon J.L. Billinge group", email="[email protected]" },
]
maintainers = [
{ name="Simon J.L. Billinge group", email="[email protected]" },
{ name="Simon J.L. Billinge group", email="[email protected]" },
]
description = "Python package implementing the stretched NMF algorithm."
keywords = ['diffpy', 'PDF']
readme = "README.rst"
requires-python = ">=3.11, <3.14"
classifiers = [
'Development Status :: 4 - Beta',
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
Expand Down
Empty file removed requirements/build.txt
Empty file.
3 changes: 1 addition & 2 deletions src/diffpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
##############################################################################
#
# (c) 2024 The Trustees of Columbia University in the City of New York.
# (c) 2024-2025 The Trustees of Columbia University in the City of New York.
# All rights reserved.
#
# File coded by: Billinge Group members and community contributors.
Expand All @@ -12,7 +12,6 @@
# See LICENSE.rst for license information.
#
##############################################################################

"""Blank namespace package for module diffpy."""


Expand Down
7 changes: 3 additions & 4 deletions src/diffpy/snmf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
##############################################################################
#
# (c) 2024 The Trustees of Columbia University in the City of New York.
# (c) 2024-2025 The Trustees of Columbia University in the City of New York.
# All rights reserved.
#
# File coded by: Billinge Group members and community contributors.
Expand All @@ -12,11 +12,10 @@
# See LICENSE.rst for license information.
#
##############################################################################

"""A python package implementing the stretched NMF algorithm."""
"""Python package implementing the stretched NMF algorithm."""

# package version
from diffpy.snmf.version import __version__
from diffpy.snmf.version import __version__ # noqa

# silence the pyflakes syntax checker
assert __version__ or True
Expand Down
8 changes: 6 additions & 2 deletions src/diffpy/snmf/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, grid, number_of_signals, id_number, perturbation=1e-3):
self.id = int(id_number)

def apply_stretch(self, m):
"""Applies a stretching factor to a component
"""Applies a stretching factor to a component.

Parameters
----------
Expand All @@ -41,7 +41,11 @@ def apply_stretch(self, m):
"""
normalized_grid = np.arange(len(self.grid))
interpolate_intensity = lambda stretching_factor: np.interp( # noqa: E731
normalized_grid / stretching_factor, normalized_grid, self.iq, left=0, right=0
normalized_grid / stretching_factor,
normalized_grid,
self.iq,
left=0,
right=0,
)
derivative_func = numdifftools.Derivative(interpolate_intensity)
second_derivative_func = numdifftools.Derivative(derivative_func)
Expand Down
3 changes: 2 additions & 1 deletion src/diffpy/snmf/factorizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@


def lsqnonneg(stretched_component_matrix, target_signal):
"""Finds the weights of stretched component signals under one-sided constraint.
"""Finds the weights of stretched component signals under one-sided
constraint.

Solves ``argmin_x || Ax - b ||_2`` for ``x>=0`` where A is the stretched_component_matrix and b is the
target_signal vector. Finds the weights of component signals given undecomposed signal data and stretched
Expand Down
5 changes: 2 additions & 3 deletions src/diffpy/snmf/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def initialize_variables(data_input, number_of_components, data_type, sparsity=1
guess for the weight factor matrix, an initial guess for the stretching factor matrix, a parameter
controlling smoothness of the solution, a parameter controlling sparseness of the solution, the matrix
representing the smoothness term, and a matrix used to construct a hessian matrix.

"""
signal_length = data_input.shape[0]
number_of_signals = data_input.shape[1]
Expand Down Expand Up @@ -74,7 +73,8 @@ def initialize_variables(data_input, number_of_components, data_type, sparsity=1


def load_input_signals(file_path=None):
"""Processes a directory of a series of PDF/XRD patterns into a usable format.
"""Processes a directory of a series of PDF/XRD patterns into a usable
format.

Constructs a 2d array out of a directory of PDF/XRD patterns containing each files dependent variable
column in a new column. Constructs a 1d array containing the grid values.
Expand All @@ -92,7 +92,6 @@ def load_input_signals(file_path=None):
The tuple whose first element is an R x M 2d array made of PDF/XRD patterns as each column; R is the
length of the signal and M is the number of patterns. The tuple contains a 1d array containing the values
of the grid points as its second element; Has length R.

"""

if file_path is None:
Expand Down
11 changes: 8 additions & 3 deletions src/diffpy/snmf/optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
from scipy.optimize import minimize


def get_weights(stretched_component_gram_matrix, linear_coefficient, lower_bound, upper_bound):
"""Finds the weights of stretched component signals under a two-sided constraint
def get_weights(
stretched_component_gram_matrix,
linear_coefficient,
lower_bound,
upper_bound,
):
"""Finds the weights of stretched component signals under a two-sided
constraint.

Solves min J(y) = (linear_coefficient)' * y + (1/2) * y' * (quadratic coefficient) * y where
lower_bound <= y <= upper_bound and stretched_component_gram_matrix is symmetric positive definite.
Expand Down Expand Up @@ -34,7 +40,6 @@ def get_weights(stretched_component_gram_matrix, linear_coefficient, lower_bound
1d array like
The vector containing the weightings of the components needed to reconstruct a given input signal from the
input set. Has length C

"""

stretched_component_gram_matrix = np.asarray(stretched_component_gram_matrix)
Expand Down
6 changes: 2 additions & 4 deletions src/diffpy/snmf/polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@


def compute_root(linear_coefficient, constant_term):
"""
Returns the largest real root of x^3+(linear_coefficient) * x + constant_term. If there are no real roots
return 0.
"""Returns the largest real root of x^3+(linear_coefficient) * x +
constant_term. If there are no real roots return 0.

Parameters
----------
Expand All @@ -18,7 +17,6 @@ def compute_root(linear_coefficient, constant_term):
ndarray of floats
The largest real root of x^3+(linear_coefficient) * x + constant_term if roots are real, else
return 0 array

"""
linear_coefficient = np.asarray(linear_coefficient)
constant_term = np.asarray(constant_term)
Expand Down
17 changes: 14 additions & 3 deletions src/diffpy/snmf/stretchednmfapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
from diffpy.snmf.io import initialize_variables, load_input_signals
from diffpy.snmf.subroutines import initialize_components, lift_data

ALLOWED_DATA_TYPES = ["powder_diffraction", "pd", "pair_distribution_function", "pdf"]
ALLOWED_DATA_TYPES = [
"powder_diffraction",
"pd",
"pair_distribution_function",
"pdf",
]


def create_parser():
parser = argparse.ArgumentParser(
prog="stretched_nmf", description="Stretched Nonnegative Matrix Factorization"
prog="stretched_nmf",
description="Stretched Nonnegative Matrix Factorization",
)
parser.add_argument(
"-i",
Expand Down Expand Up @@ -44,7 +50,12 @@ def create_parser():
type=int,
help="The number of component signals for the NMF decomposition. Must be an integer greater than 0",
)
parser.add_argument("-v", "--version", action="version", help="Print the software version number")
parser.add_argument(
"-v",
"--version",
action="version",
help="Print the software version number",
)
args = parser.parse_args()
return args

Expand Down
Loading
Loading