def test_zero_demand_ok():
    demand = Demand(np.array([0.0]))
def test_non_numpy_array_generation_raises_error():
    with pytest.raises(ValueError):
        demand = Demand([1.0])
def test_positive_demand_ok():
    demand = Demand(np.array([1.0]))
def test_negative_raises_error():
    with pytest.raises(ValueError):
        demand = Demand(np.array([-1.0]))
def test_demand_rejects_list():
    with pytest.raises(ValueError):
        demand = Demand([1.0])
def test_demand_accepts_none():
    demand = Demand()
def test_demand_accepts_positive_array():
    demand = Demand(np.array([0.0, 1.0]))
def test_demand_rejects_negative_values():
    with pytest.raises(ValueError):
        demand = Demand(np.array([-1.0]))
ax1 = fig.add_subplot(1, 1, 1)
l1, = ax1.plot(hrs, 4 * test_load, color=colors[0])
l2, = ax1.plot(hrs, 4 * test_pv, color=colors[1])
l3, = ax1.plot(hrs, 4 * net_load, color=colors[2])
ax1.set_xlabel('hour'), ax1.set_ylabel('kW')
ax1.legend([l1, l2, l3], ['Load', 'PV', 'Connection Point'], ncol=2)
ax1.set_xlim([0, len(test_load) / 4])
fig.tight_layout()

fig.show()

############################ Optimise this Example ########################################

energy_system = EnergySystem()
energy_system.add_energy_storage(battery)
load = Demand()
load.add_demand_profile(connection_point_import)
pv = Generation()
pv.add_generation_profile(connection_point_export)
local_tariff = LocalTariff()
local_tariff.add_local_energy_tariff_profile_export(le_export_tariff_dct)
local_tariff.add_local_energy_tariff_profile_import(le_import_tariff_dct)
local_tariff.add_local_transport_tariff_profile_export(lt_export_tariff_dct)
local_tariff.add_local_transport_tariff_profile_import(lt_import_tariff_dct)
local_tariff.add_remote_energy_tariff_profile_export(re_export_tariff_dct)
local_tariff.add_remote_energy_tariff_profile_import(re_import_tariff_dct)
local_tariff.add_remote_transport_tariff_profile_export(rt_export_tariff_dct)
local_tariff.add_remote_transport_tariff_profile_import(rt_import_tariff_dct)
energy_system.add_demand(load)
energy_system.add_generation(pv)
energy_system.add_local_tariff(local_tariff)