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
12 changes: 6 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Coverage
on:
pull_request:
paths:
- src
- extern
- tests
- src/**
- extern/**
- tests/**
- pyproject.toml
- noxfile.py
- CMakeLists.txt
Expand All @@ -16,9 +16,9 @@ on:
- develop
- beta/*
paths:
- src
- extern
- tests
- src/**
- extern/**
- tests/**
- pyproject.toml
- noxfile.py
- CMakeLists.txt
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Test
on:
pull_request:
paths:
- src
- extern
- tests
- src/**
- extern/**
- tests/**
- pyproject.toml
- CMakeLists.txt
- .github/workflows/test.yml
Expand Down
10 changes: 7 additions & 3 deletions src/iminuit/cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -2306,17 +2306,21 @@ def visualize(

x, y, ye = self._masked.T
plt.errorbar(x, y, ye, fmt="ok")

xmin = np.min(x)
xmax = np.max(x)
if isinstance(model_points, Iterable):
xm = np.array(model_points)
ym = self.model(xm, *args)
elif model_points > 0:
# beware, x may not be sorted
if _detect_log_spacing(x):
xm = np.geomspace(x[0], x[-1], model_points)
xm = np.geomspace(xmin, xmax, model_points)
else:
xm = np.linspace(x[0], x[-1], model_points)
xm = np.linspace(xmin, xmax, model_points)
ym = self.model(xm, *args)
else:
xm, ym = _smart_sampling(lambda x: self.model(x, *args), x[0], x[-1])
xm, ym = _smart_sampling(lambda x: self.model(x, *args), xmin, xmax)
plt.plot(xm, ym)
return (x, y, ye), (xm, ym)

Expand Down
10 changes: 10 additions & 0 deletions tests/test_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,16 @@ def test_LeastSquares_visualize():
assert_equal(xm, np.linspace(1, 100))


def test_LeastSquares_visualize_unsorted():
# make sure that xm uses max and min of x, not assuming x is sorted
pytest.importorskip("matplotlib")

c = LeastSquares([1, 0, 3, 2], [2, 1, 4, 3], 0.1, line)
xm, _ = c.visualize((1, 1))[1]
assert xm[0] == 0
assert xm[-1] == 3


def test_LeastSquares_visualize_par_array():
pytest.importorskip("matplotlib")

Expand Down
Loading