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

small fixes #11

Merged
merged 1 commit into from
Aug 25, 2021
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
small fixes
- use isinstance instead of type
- check shape of array in concentration heatmap image
- removed unused imports
- increase tolerance of minimize test
  • Loading branch information
lkeegan committed Aug 25, 2021
commit cff2dd18c246f36ac526eb2a59adcc285ac447ff
1 change: 0 additions & 1 deletion sme_contrib/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from matplotlib import pyplot as plt
from matplotlib.colors import LinearSegmentedColormap as lscmap
from matplotlib import animation
import sme


def colormap(color, name="my colormap"):
Expand Down
14 changes: 7 additions & 7 deletions sme_contrib/tests/test_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def test_minimize() -> None:
iterations=20,
ps_options={"c1": 2.025, "c2": 2.025, "w": 0.5},
)
assert np.abs(res[0] - 0.375) < 0.100
assert np.abs(res[1] + 0.900) < 0.100
assert np.abs(res[0] - 0.375) < 0.200
assert np.abs(res[1] + 0.900) < 0.200


def test_rescale() -> None:
Expand Down Expand Up @@ -97,21 +97,21 @@ def test_steady_state() -> None:

# just check plots have correct titles for now
ax = ss.plot_target_concentration()
assert type(ax) == matplotlib.axes._subplots.Subplot
assert isinstance(ax, matplotlib.axes._subplots.Subplot)
assert ax.get_title() == "Target Concentration"

ax = ss.plot_model_concentration()
assert type(ax) == matplotlib.axes._subplots.Subplot
assert isinstance(ax, matplotlib.axes._subplots.Subplot)
assert ax.get_title() == "Model Concentration"

ax = ss.plot_cost_history()
assert type(ax) == matplotlib.axes._subplots.Subplot
assert isinstance(ax, matplotlib.axes._subplots.Subplot)
assert ax.get_title() == "Best cost history"

ax = ss.plot_cost_history_pbest()
assert type(ax) == matplotlib.axes._subplots.Subplot
assert isinstance(ax, matplotlib.axes._subplots.Subplot)
assert ax.get_title() == "Mean particle best cost history"

ax = ss.plot_timeseries(1, 1)
assert type(ax) == matplotlib.axes._subplots.Subplot
assert isinstance(ax, matplotlib.axes._subplots.Subplot)
assert ax.get_title() == "Concentration time series"
7 changes: 6 additions & 1 deletion sme_contrib/tests/test_plot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sme_contrib.plot as smeplot
import numpy as np
import sme
import os.path

Expand Down Expand Up @@ -32,15 +31,21 @@ def test_concentration_heatmap() -> None:
# single species
ax, im = smeplot.concentration_heatmap(results[-1], ["A_nucl"])
assert ax.title.get_text() == "Concentration of A_nucl at time 10.0"
assert im.get_array().shape == (100, 100)
assert im.get_array()[0, 0] == 0.0
# two species
ax, im = smeplot.concentration_heatmap(results[-1], ["A_nucl", "A_cell"])
assert ax.title.get_text() == "Concentration of A_nucl, A_cell at time 10.0"
assert im.get_array().shape == (100, 100)
assert im.get_array()[0, 0] == 0.0
# specify title, existing plot axis & colormap
colormap = smeplot.colormap((1, 0, 0), "red1")
ax, im = smeplot.concentration_heatmap(
results[-1], ["A_nucl", "A_cell"], "my Title", ax, colormap
)
assert ax.title.get_text() == "my Title"
assert im.get_array().shape == (100, 100)
assert im.get_array()[0, 0] == 0.0


def test_concentration_heatmap_animation() -> None:
Expand Down