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

fix p3 #12

Merged
merged 8 commits into from
Jul 28, 2024
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
34 changes: 34 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# codecov can find this file anywhere in the repo, so we don't need to clutter
# the root folder.
#comment: false

codecov:
notify:
require_ci_to_pass: no

coverage:
status:
patch:
default:
target: '70'
if_no_uploads: error
if_not_found: success
if_ci_failed: failure
project:
default: false
library:
target: auto
if_no_uploads: error
if_not_found: success
if_ci_failed: error
paths: '!*/tests/.*'

tests:
target: 97.9%
paths: '*/tests/.*'
if_not_found: success

flags:
tests:
paths:
- tests/
13 changes: 13 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[run]
source =
diffpy.srmise
[report]
omit =
*/python?.?/*
*/site-packages/nose/*
# ignore _version.py and versioneer.py
.*version.*
*_version.py

exclude_lines =
if __name__ == '__main__':
11 changes: 11 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[flake8]
exclude =
.git,
__pycache__,
build,
dist,
doc/source/conf.py
max-line-length = 115
# Ignore some style 'errors' produced while formatting by 'black'
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings
extend-ignore = E203
43 changes: 43 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build Documentation

on:
push:
branches:
- main
release:

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: build
auto-update-conda: true

- name: install requirements
run: >-
conda install -n build -c conda-forge
--file requirements/build.txt
--file requirements/run.txt
--file requirements/docs.txt
--quiet --yes

- name: install the package
run: python -m pip install . --no-deps

- name: build documents
run: make -C doc html

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc/build/html
55 changes: 55 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI

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

jobs:
miniconda:
name: Miniconda ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest"]
steps:
- name: check out diffpy.srmise
uses: actions/checkout@v3
with:
repository: diffpy/diffpy.srmise
path: .
fetch-depth: 0 # avoid shallow clone with no tags

- name: initialize miniconda
# this uses a marketplace action that sets up miniconda in a way that makes
# it easier to use. I tried setting it up without this and it was a pain
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: test
# environment.yml file is needed by this action. Because I don't want
# maintain this but rather maintain the requirements files it just has
# basic things in it like conda and pip
environment-file: ./environment.yml
python-version: 3
auto-activate-base: false

- name: install diffpy.srmise requirements
shell: bash -l {0}
run: |
conda config --set always_yes yes --set changeps1 no
conda config --add channels conda-forge
conda activate test
conda install --file requirements/run.txt
conda install --file requirements/test.txt
pip install .

- name: Validate diffpy.srmise
shell: bash -l {0}
run: |
conda activate test
coverage run -m pytest -vv -s
coverage report -m
codecov
19 changes: 19 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: pre-commit

on:
pull_request:
push:
workflow_dispatch:

jobs:
pre-commit:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0
with:
extra_args: --all-files
4 changes: 4 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[settings]
line_length = 115
multi_line_output = 3
include_trailing_comma = True
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
default_language_version:
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
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: '\.(rst|txt)$'
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: no-commit-to-branch
name: Prevent Commit to Main Branch
args: ["--branch", "main"]
stages: [pre-commit]
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ include doc/examples/README
recursive-include doc/manual/source *.rst *.txt
include doc/manual/source/conf.py
include doc/manual/Makefile

98 changes: 49 additions & 49 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ SrMise
`DiffPy project <http://www.diffpy.org>`_ tool for unbiased peak extraction from
atomic pair distribution functions.

SrMise is an implementation of the `ParSCAPE algorithm
<https://dx.doi.org/10.1107/S2053273315005276>`_ for peak extraction from
atomic pair distribution functions (PDFs). It is designed to function even
when *a priori* knowledge of the physical sample is limited, utilizing the
Akaike Information Criterion (AIC) to estimate whether peaks are
statistically justified relative to alternate models. Three basic use cases
are anticipated for SrMise. The first is peak fitting a user-supplied
collections of peaks. The second is peak extraction from a PDF with no (or
only partial) user-supplied peaks. The third is an AIC-driven multimodeling
analysis where the output of multiple SrMise trials are ranked.

The framework for peak extraction defines peak-like clusters within the data,
extracts a single peak within each cluster, and iteratively combines nearby
clusters while performing a recursive search on the residual to identify
occluded peaks. Eventually this results in a single global cluster
containing many peaks fit over all the data. Over- and underfitting are
SrMise is an implementation of the `ParSCAPE algorithm
<https://dx.doi.org/10.1107/S2053273315005276>`_ for peak extraction from
atomic pair distribution functions (PDFs). It is designed to function even
when *a priori* knowledge of the physical sample is limited, utilizing the
Akaike Information Criterion (AIC) to estimate whether peaks are
statistically justified relative to alternate models. Three basic use cases
are anticipated for SrMise. The first is peak fitting a user-supplied
collections of peaks. The second is peak extraction from a PDF with no (or
only partial) user-supplied peaks. The third is an AIC-driven multimodeling
analysis where the output of multiple SrMise trials are ranked.

The framework for peak extraction defines peak-like clusters within the data,
extracts a single peak within each cluster, and iteratively combines nearby
clusters while performing a recursive search on the residual to identify
occluded peaks. Eventually this results in a single global cluster
containing many peaks fit over all the data. Over- and underfitting are
discouraged by use of the AIC when adding or, during a pruning step, removing
peaks. Termination effects, which can lead to physically spurious peaks in
the PDF, are incorporated in the mathematical peak model and the pruning step
attempts to remove peaks which are fit better as termination ripples due to
another peak.

Where possible, SrMise provides physically reasonable default values
for extraction parameters. However, the PDF baseline should be estimated by
the user before extraction, or by performing provisional peak extraction with
varying baseline parameters. The package defines a linear (crystalline)
baseline, arbitrary polynomial baseline, a spherical nanoparticle baseline,
and an arbitrary baseline interpolated from a list of user-supplied values.
In addition, PDFs with accurate experimentally-determined uncertainties are
necessary to provide the most reliable results, but historically such PDFs
are rare. In the absence of accurate uncertainties an *ad hoc* uncertainty
must be specified.
peaks. Termination effects, which can lead to physically spurious peaks in
the PDF, are incorporated in the mathematical peak model and the pruning step
attempts to remove peaks which are fit better as termination ripples due to
another peak.

Where possible, SrMise provides physically reasonable default values
for extraction parameters. However, the PDF baseline should be estimated by
the user before extraction, or by performing provisional peak extraction with
varying baseline parameters. The package defines a linear (crystalline)
baseline, arbitrary polynomial baseline, a spherical nanoparticle baseline,
and an arbitrary baseline interpolated from a list of user-supplied values.
In addition, PDFs with accurate experimentally-determined uncertainties are
necessary to provide the most reliable results, but historically such PDFs
are rare. In the absence of accurate uncertainties an *ad hoc* uncertainty
must be specified.

For more information about SrMise, see the users manual at
http://diffpy.github.io/diffpy.srmise.
Expand Down Expand Up @@ -65,7 +65,7 @@ individual and/or academic use, but some also have commercial version. Links to
executables, installation instructions, and licensing information
for some popular options are listed below.

* `Anaconda <http://www.continuum.io/downloads>`_
* `Anaconda <https://www.anaconda.com/download>`_
* `Enthought Canopy <https://www.enthought.com/products/canopy/>`_
* `Python(x,y) <https://code.google.com/p/pythonxy/>`_
* `WinPython <http://winpython.github.io>`_
Expand Down Expand Up @@ -120,7 +120,7 @@ in MacPorts::

The simplest way to obtain diffpy.srmise on Mac OS X systems
is using ``pip`` to download and install the latest release from
`PyPI <https://pypi.python.org>`_. ::
`PyPI <https://pypi.python.org>`_. ::

sudo pip install diffpy.srmise

Expand All @@ -131,9 +131,9 @@ Uncompress them to a directory, and from that directory run ::

sudo python setup.py install

This installs diffpy.srmise for all users in the default system location. If
administrator (root) access is not available, see the usage info from
``python setup.py install --help`` for options to install to user-writable
This installs diffpy.srmise for all users in the default system location. If
administrator (root) access is not available, see the usage info from
``python setup.py install --help`` for options to install to user-writable
directories.


Expand All @@ -154,7 +154,7 @@ For other Linux distributions consult the appropriate package manager.

The simplest way to obtain diffpy.srmise on Linux systems
is using ``pip`` to download and install the latest release from the
`PyPI <https://pypi.python.org>`_. ::
`PyPI <https://pypi.python.org>`_. ::

sudo pip install diffpy.srmise

Expand All @@ -165,24 +165,24 @@ Uncompress them to a directory, and from that directory run ::

sudo python setup.py install

This installs diffpy.srmise for all users in the default system location. If
administrator (root) access is not available, see the usage info from
``python setup.py install --help`` for options to install to user-writable
directories.
This installs diffpy.srmise for all users in the default system location. If
administrator (root) access is not available, see the usage info from
``python setup.py install --help`` for options to install to user-writable
directories.


DEVELOPMENT
===========

diffpy.srmise is open-source software developed with support of the Center of
Research Excellence in Complex Materials at Michigan State University, in
cooperation with the DiffPy-CMI complex modeling initiative at the Brookhaven
National Laboratory. The diffpy.srmise sources are hosted at
https://github.com/diffpy/diffpy.srmise.
diffpy.srmise is open-source software developed with support of the Center of
Research Excellence in Complex Materials at Michigan State University, in
cooperation with the DiffPy-CMI complex modeling initiative at the Brookhaven
National Laboratory. The diffpy.srmise sources are hosted at
https://github.com/diffpy/diffpy.srmise.

Feel free to fork the project and contribute. To install diffpy.srmise in a
development mode, with its sources being directly used by Python rather than
copied to a package directory, use ::
Feel free to fork the project and contribute. To install diffpy.srmise in a
development mode, with its sources being directly used by Python rather than
copied to a package directory, use ::

python setup.py develop --user

Expand Down
Loading