Fix things
This commit is contained in:
parent
96041932ec
commit
da9e633c04
6
a1.py
6
a1.py
@ -1,5 +1,5 @@
|
|||||||
# These could be from the std math lib, but I like the numpy ones better personally
|
# These could be from the std math lib, but I like the numpy ones better personally
|
||||||
from numpy import sin, cos, pi, sqrt, pow
|
from numpy import sin, cos, pi, sqrt
|
||||||
|
|
||||||
# Pull a1 support
|
# Pull a1 support
|
||||||
from a1_support import GRAVITY_ACC, WATER_DENSITY, HELP_MESSAGE
|
from a1_support import GRAVITY_ACC, WATER_DENSITY, HELP_MESSAGE
|
||||||
@ -145,7 +145,7 @@ def calc_heights_water_out(initial_height: float, final_height: float,
|
|||||||
water_mass.append(water_mass_out)
|
water_mass.append(water_mass_out)
|
||||||
|
|
||||||
|
|
||||||
return water_height, water_mass
|
return tuple(water_height), tuple(water_mass)
|
||||||
|
|
||||||
# Task 7
|
# Task 7
|
||||||
def calc_energy_power(heights: tuple[float, ...], water_mass_outs: tuple[float, ...],
|
def calc_energy_power(heights: tuple[float, ...], water_mass_outs: tuple[float, ...],
|
||||||
@ -167,7 +167,7 @@ def calc_energy_power(heights: tuple[float, ...], water_mass_outs: tuple[float,
|
|||||||
def calc_daily_profit(energy: tuple[float, ...], peak_tariff: float,
|
def calc_daily_profit(energy: tuple[float, ...], peak_tariff: float,
|
||||||
off_peak_tariff: float, efficiency: float) -> float:
|
off_peak_tariff: float, efficiency: float) -> float:
|
||||||
|
|
||||||
total_profit = sum(energy) * (peak_tariff - off_peak_tariff / pow(efficiency/100, 2))
|
total_profit = sum(energy) * (peak_tariff - off_peak_tariff / ((efficiency/100)**2))
|
||||||
|
|
||||||
return total_profit
|
return total_profit
|
||||||
|
|
||||||
|
37
generate_prams.py
Normal file
37
generate_prams.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import a1
|
||||||
|
|
||||||
|
import json, pprint, random
|
||||||
|
|
||||||
|
# Enums, never heard of her
|
||||||
|
class PRIVOUS_TASK: pass
|
||||||
|
class EXACT: pass
|
||||||
|
|
||||||
|
TESTS = (
|
||||||
|
(
|
||||||
|
3, # Task
|
||||||
|
5, # Number of tests
|
||||||
|
a1.determine_cost_to_pump, # The function to test
|
||||||
|
( # The args and their ranges
|
||||||
|
("gen_power", (float, 100, 600, 50)), # Type, min, max, inc
|
||||||
|
("pumping_time", (float, 1, 10, 1)),
|
||||||
|
("off_peak_tariff", (float, 0.01, 0.1, 0.01)),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
for task, iterations, function, args in TESTS:
|
||||||
|
print(f'\nTask {task}')
|
||||||
|
|
||||||
|
args_used = []
|
||||||
|
results = []
|
||||||
|
for i in range(iterations):
|
||||||
|
this_arg = {}
|
||||||
|
for arg, vals in args:
|
||||||
|
this_arg[arg] = random.randrange(vals[1], vals[2], vals[3])
|
||||||
|
|
||||||
|
args_used.append(this_arg)
|
||||||
|
results.append(function(*args_used[-1]))
|
||||||
|
|
||||||
|
pprint(args_used)
|
||||||
|
pprint(results)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user