Skip to content

Commit c0def8b

Browse files
john-halloranJohn Halloran
andauthored
fix: make changes for conda-forge compatibility (#200)
* fix: use matplotlib-base when installing with conda-forge * refactor: rename cli entrypoint to 'snmf' from 'diffpy.stretched-nmf' * chore: add news item for previous commit * fix: produce an error if test files are missing * docs: explain the current entrypoint when the help command is used --------- Co-authored-by: John Halloran <jhalloran@oxy.edu>
1 parent a9448bd commit c0def8b

7 files changed

Lines changed: 53 additions & 13 deletions

File tree

README.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ The preferred method is conda::
6969
conda create -n diffpy.stretched-nmf_env diffpy.stretched-nmf
7070
conda activate diffpy.stretched-nmf_env
7171

72+
For interactive plotting with ``show_plots=True``, use a GUI-capable desktop
73+
environment. Conda installs use ``matplotlib-base``, which is sufficient for
74+
plotting but still depends on an available interactive Matplotlib backend.
75+
7276
Alternatively, install from PyPI with pip::
7377

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

8084
Quick check::
8185

82-
diffpy.stretched-nmf --version
86+
snmf --version
8387
python -c "import diffpy.stretched_nmf; print(diffpy.stretched_nmf.__version__)"
8488

8589

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

88-
diffpy.stretched-nmf -h
92+
snmf -h
8993

9094
Getting Started
9195
---------------

docs/source/getting-started.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ The preferred method is conda:
1717
conda create -n diffpy.stretched-nmf_env diffpy.stretched-nmf
1818
conda activate diffpy.stretched-nmf_env
1919
20+
For interactive plotting with ``show_plots=True``, use a GUI-capable desktop
21+
environment. Conda installs use ``matplotlib-base``, which is sufficient for
22+
plotting but still depends on an available interactive Matplotlib backend.
23+
2024
Alternatively, install from PyPI with pip:
2125

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

3741
.. code-block:: bash
3842
39-
diffpy.stretched-nmf --version
43+
snmf --version
4044
python -c "import diffpy.stretched_nmf; print(diffpy.stretched_nmf.__version__)"
4145
4246
Basic usage

news/forge-cleanup.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* Rename cli entrypoint to 'snmf' from 'diffpy.stretched-nmf'
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* Produce an error if test files are missing
20+
* Use matplotlib-base when installing with conda-forge
21+
22+
**Security:**
23+
24+
* <news item>

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ exclude = [] # exclude packages matching these glob patterns (empty by default)
4949
namespaces = false # to disable scanning PEP 420 namespaces (true by default)
5050

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

5454
[tool.setuptools.dynamic]
5555
dependencies = {file = ["requirements/pip.txt"]}

requirements/conda.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
numpy
2-
matplotlib
2+
matplotlib-base
33
scipy
44
cvxpy
55
diffpy.utils

src/diffpy/stretched_nmf/snmf_app.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55

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

2528
if args.version:
26-
print(f"diffpy.stretched-nmf {__version__}")
29+
print(f"snmf {__version__}")
2730
else:
2831
# Default behavior when no arguments are given
2932
parser.print_help()

tests/test_snmf_optimizer.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,33 @@
55

66
from diffpy.stretched_nmf.snmf_class import SNMFOptimizer
77

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

10-
# Skip the test entirely if any inputs file is missing
1113
_required = [
1214
"init-components.txt",
1315
"source-matrix.txt",
1416
"init-stretch.txt",
1517
"init-weights.txt",
1618
]
1719
_missing = [f for f in _required if not (DATA_DIR / f).exists()]
18-
pytestmark = pytest.mark.skipif(
19-
_missing, reason=f"Missing test data files: {_missing}"
20-
)
2120

2221

2322
@pytest.fixture(scope="module")
2423
def inputs():
24+
if _missing:
25+
pytest.fail(
26+
f"Missing required test data files in {DATA_DIR}: {_missing}"
27+
)
2528
return {
2629
"components": np.loadtxt(
2730
DATA_DIR / "init-components.txt", dtype=float
2831
),
29-
"source": np.loadtxt(DATA_DIR / "source-matrix.txt", dtype=float),
32+
"source": np.loadtxt(
33+
DATA_DIR / "source-matrix.txt", dtype=float, skiprows=4
34+
),
3035
"stretch": np.loadtxt(DATA_DIR / "init-stretch.txt", dtype=float),
3136
"weights": np.loadtxt(DATA_DIR / "init-weights.txt", dtype=float),
3237
}

0 commit comments

Comments
 (0)