Skip to content

Commit 29a922c

Browse files
author
John Halloran
committed
style: switch to local imports and plural folders
1 parent 42d4fc0 commit 29a922c

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

src/diffpy/snmf/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
# package version
1919
from diffpy.snmf.version import __version__
2020

21-
# public API
22-
from .snmf_class import SNMFOptimizer
23-
2421
__all__ = ["__version__", "SNMFOptimizer"]
2522

2623
# silence the pyflakes syntax checker

src/diffpy/snmf/main.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import numpy as np
2-
from snmf_class import SNMFOptimizer
2+
3+
from diffpy.snmf.snmf_class import SNMFOptimizer
34

45
# Example input files (not provided)
5-
init_components_file = np.loadtxt("input/init_components.txt", dtype=float)
6-
source_matrix_file = np.loadtxt("input/source_matrix.txt", dtype=float)
7-
init_stretch_file = np.loadtxt("input/init_stretch.txt", dtype=float)
8-
init_weights_file = np.loadtxt("input/init_weights.txt", dtype=float)
6+
init_components_file = np.loadtxt("inputs/init_components.txt", dtype=float)
7+
source_matrix_file = np.loadtxt("inputs/source_matrix.txt", dtype=float)
8+
init_stretch_file = np.loadtxt("inputs/init_stretch.txt", dtype=float)
9+
init_weights_file = np.loadtxt("inputs/init_weights.txt", dtype=float)
910

1011
my_model = SNMFOptimizer(
1112
source_matrix=source_matrix_file,

src/diffpy/snmf/snmf_class.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from scipy.optimize import minimize
44
from scipy.sparse import coo_matrix, diags
55

6-
from .plotter import SNMFPlotter
6+
from diffpy.snmf.plotter import SNMFPlotter
77

88

99
class SNMFOptimizer:
@@ -626,7 +626,7 @@ def update_stretch(self):
626626
Updates matrix A using constrained optimization (equivalent to fmincon in MATLAB).
627627
"""
628628

629-
# Flatten A for compatibility with the optimizer (since SciPy expects 1D input)
629+
# Flatten A for compatibility with the optimizer (since SciPy expects 1D inputs)
630630
stretch_flat_initial = self.stretch.flatten()
631631

632632
# Define the optimization function

tests/test_snmf_optimizer.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import numpy as np
44
import pytest
55

6-
from diffpy.snmf import SNMFOptimizer
6+
from diffpy.snmf.snmf_class import SNMFOptimizer
77

8-
DATA_DIR = Path(__file__).parent / "input"
8+
DATA_DIR = Path(__file__).parent / "inputs"
99

10-
# Skip the test entirely if any input file is missing
10+
# Skip the test entirely if any inputs file is missing
1111
_required = [
1212
"init_components.txt",
1313
"source_matrix.txt",
@@ -39,8 +39,10 @@ def test_final_objective_below_threshold(inputs):
3939
rho=1e12,
4040
eta=610,
4141
random_state=1,
42+
min_iter=5,
43+
max_iter=5,
4244
)
4345

4446
# Basic sanity check and the actual assertion
4547
assert np.isfinite(model.objective_function)
46-
assert model.objective_function < 4e6
48+
assert model.objective_function < 5e6

0 commit comments

Comments
 (0)