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
8 changes: 6 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ The preferred method is conda::
conda create -n diffpy.stretched-nmf_env diffpy.stretched-nmf
conda activate diffpy.stretched-nmf_env

For interactive plotting with ``show_plots=True``, use a GUI-capable desktop
environment. Conda installs use ``matplotlib-base``, which is sufficient for
plotting but still depends on an available interactive Matplotlib backend.

Alternatively, install from PyPI with pip::

pip install diffpy.stretched-nmf
Expand All @@ -79,13 +83,13 @@ For source installs (after cloning the repo)::

Quick check::

diffpy.stretched-nmf --version
snmf --version
python -c "import diffpy.stretched_nmf; print(diffpy.stretched_nmf.__version__)"


To view the basic usage and available commands, type ::

diffpy.stretched-nmf -h
snmf -h

Getting Started
---------------
Expand Down
6 changes: 5 additions & 1 deletion docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ The preferred method is conda:
conda create -n diffpy.stretched-nmf_env diffpy.stretched-nmf
conda activate diffpy.stretched-nmf_env

For interactive plotting with ``show_plots=True``, use a GUI-capable desktop
environment. Conda installs use ``matplotlib-base``, which is sufficient for
plotting but still depends on an available interactive Matplotlib backend.

Alternatively, install from PyPI with pip:

.. code-block:: bash
Expand All @@ -36,7 +40,7 @@ Verify the CLI and Python import:

.. code-block:: bash

diffpy.stretched-nmf --version
snmf --version
python -c "import diffpy.stretched_nmf; print(diffpy.stretched_nmf.__version__)"

Basic usage
Expand Down
24 changes: 24 additions & 0 deletions news/forge-cleanup.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**Added:**

* <news item>

**Changed:**

* Rename cli entrypoint to 'snmf' from 'diffpy.stretched-nmf'

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Produce an error if test files are missing
* Use matplotlib-base when installing with conda-forge

**Security:**

* <news item>
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exclude = [] # exclude packages matching these glob patterns (empty by default)
namespaces = false # to disable scanning PEP 420 namespaces (true by default)

[project.scripts]
"diffpy.stretched-nmf" = "diffpy.stretched_nmf.snmf_app:main"
"snmf" = "diffpy.stretched_nmf.snmf_app:main"

[tool.setuptools.dynamic]
dependencies = {file = ["requirements/pip.txt"]}
Expand Down
2 changes: 1 addition & 1 deletion requirements/conda.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
numpy
matplotlib
matplotlib-base
scipy
cvxpy
diffpy.utils
Expand Down
7 changes: 5 additions & 2 deletions src/diffpy/stretched_nmf/snmf_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

def main():
parser = argparse.ArgumentParser(
prog="diffpy.stretched-nmf",
prog="snmf",
description=(
"A python package implementing the stretched NMF algorithm.\n\n"
"Currently, this project is used by importing "
"`SNMFOptimizer` in Python rather than through a command-line "
"workflow.\n\n"
"For more information, visit: "
"https://github.com/diffpy/diffpy.stretched-nmf/"
),
Expand All @@ -23,7 +26,7 @@ def main():
args = parser.parse_args()

if args.version:
print(f"diffpy.stretched-nmf {__version__}")
print(f"snmf {__version__}")
else:
# Default behavior when no arguments are given
parser.print_help()
Expand Down
17 changes: 11 additions & 6 deletions tests/test_snmf_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,33 @@

from diffpy.stretched_nmf.snmf_class import SNMFOptimizer

DATA_DIR = Path(__file__).parent / "inputs/test_snmf_optimizer"
DATA_DIR = (
Path(__file__).resolve().parents[1]
/ "docs/examples/data/XRD-MgMnO-YCl-real"
)

# Skip the test entirely if any inputs file is missing
_required = [
"init-components.txt",
"source-matrix.txt",
"init-stretch.txt",
"init-weights.txt",
]
_missing = [f for f in _required if not (DATA_DIR / f).exists()]
pytestmark = pytest.mark.skipif(
_missing, reason=f"Missing test data files: {_missing}"
)


@pytest.fixture(scope="module")
def inputs():
if _missing:
pytest.fail(
f"Missing required test data files in {DATA_DIR}: {_missing}"
)
return {
"components": np.loadtxt(
DATA_DIR / "init-components.txt", dtype=float
),
"source": np.loadtxt(DATA_DIR / "source-matrix.txt", dtype=float),
"source": np.loadtxt(
DATA_DIR / "source-matrix.txt", dtype=float, skiprows=4
),
"stretch": np.loadtxt(DATA_DIR / "init-stretch.txt", dtype=float),
"weights": np.loadtxt(DATA_DIR / "init-weights.txt", dtype=float),
}
Expand Down
Loading