Skip to content

Commit a22a5d4

Browse files
committed
updated unit tests for test_heat.py and test_heat_charge.py
1 parent 4bbf0b9 commit a22a5d4

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

tests/test_components/test_heat.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,12 @@ def make_heat_sim(include_custom_source: bool = True):
335335
return heat_sim
336336

337337

338-
def test_heat_sim():
338+
@pytest.mark.parametrize("swap_axes", [True, False])
339+
def test_heat_sim(swap_axes):
339340
bc_temp, bc_flux, bc_conv = make_heat_bcs()
340341
heat_sim = make_heat_sim()
341342

342-
_ = heat_sim.plot(x=0)
343+
_ = heat_sim.plot(x=0, swap_axes=swap_axes)
343344

344345
# wrong names given
345346
for pl in [
@@ -373,14 +374,14 @@ def test_heat_sim():
373374
with pytest.raises(pd.ValidationError):
374375
heat_sim.updated_copy(monitors=[temp_mnt, temp_mnt])
375376

376-
_ = heat_sim.plot(x=0)
377+
_ = heat_sim.plot(x=0, swap_axes=swap_axes)
377378
plt.close()
378379

379-
_ = heat_sim.plot_heat_conductivity(y=0)
380+
_ = heat_sim.plot_heat_conductivity(y=0, swap_axes=swap_axes)
380381
plt.close()
381382

382383
heat_sim_sym = heat_sim.updated_copy(symmetry=(0, 1, 1))
383-
_ = heat_sim_sym.plot_heat_conductivity(z=0, colorbar="source")
384+
_ = heat_sim_sym.plot_heat_conductivity(z=0, colorbar="source", swap_axes=swap_axes)
384385
plt.close()
385386

386387
# no negative symmetry

tests/test_components/test_heat_charge.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,8 @@ def test_heat_charge_sources(structures):
852852
_ = td.HeatSource(structures=["solid_structure"], rate="100")
853853

854854

855-
def test_heat_charge_simulation(simulation_data):
855+
@pytest.mark.parametrize("swap_axes", [True, False])
856+
def test_heat_charge_simulation(swap_axes, simulation_data):
856857
"""Tests 'HeatChargeSimulation' and 'ConductionSimulation' objects."""
857858
heat_sim_data, cond_sim_data, voltage_capacitance_sim_data, current_voltage_simulation_data = (
858859
simulation_data
@@ -876,6 +877,18 @@ def test_heat_charge_simulation(simulation_data):
876877
"Current-Voltage simulation should be created successfully."
877878
)
878879

880+
_ = heat_sim.plot_heat_conductivity(x=0, swap_axes=swap_axes)
881+
plt.close()
882+
_ = heat_sim.plot_property(x=0, property="heat_conductivity", swap_axes=swap_axes)
883+
plt.close()
884+
_ = cond_sim.plot_property(x=0, property="electric_conductivity", swap_axes=swap_axes)
885+
plt.close()
886+
for sim in (heat_sim, cond_sim, voltage_capacitance_sim, current_voltage_sim):
887+
_ = sim.plot_boundaries(x=0, swap_axes=swap_axes)
888+
plt.close()
889+
_ = sim.plot_sources(x=0, swap_axes=swap_axes)
890+
plt.close()
891+
879892

880893
def test_sim_data_plotting(simulation_data):
881894
"""Tests whether simulation data can be plotted and appropriate errors are raised."""
@@ -1433,7 +1446,8 @@ def test_plotting_functions(simulation_data):
14331446
heat_sim_data.plot_field("test", invalid_param=0)
14341447

14351448

1436-
def test_bandgap_monitor():
1449+
@pytest.mark.parametrize("swap_axes", [True, False])
1450+
def test_bandgap_monitor(swap_axes):
14371451
"""Test energy bandgap monitor ploting function."""
14381452
# create a triangle grid
14391453
tri_grid_points = td.PointDataArray(
@@ -1573,8 +1587,8 @@ def test_bandgap_monitor():
15731587

15741588
# test check for the voltage value in the list of arguments
15751589

1576-
tri_single_voltage_data.plot(x=0.0)
1577-
tri_multi_voltage_data.plot(x=0.0, voltage=1.0)
1590+
tri_single_voltage_data.plot(x=0.0, swap_axes=swap_axes)
1591+
tri_multi_voltage_data.plot(x=0.0, voltage=1.0, swap_axes=swap_axes)
15781592

15791593
with pytest.raises(DataError):
15801594
tri_multi_voltage_data.plot(x=0.0)

0 commit comments

Comments
 (0)