Skip to content

Commit e9f1e53

Browse files
ENH: adding tests
1 parent 88d3a47 commit e9f1e53

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

rocketpy/utilities.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ def du(z, u):
197197
return altitudeFunction, velocityFunction, final_sol
198198

199199

200-
# TODO: Needs tests
201200
def create_dispersion_dictionary(filename):
202201
"""Creates a dictionary with the rocket data provided by a .csv file.
203202
File should be organized in four columns: attribute_class, parameter_name,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
attribute_class; parameter_name; mean_value; standard_deviation;
2+
environment; ensembleMember; [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];;
3+
motor; impulse; 1415.15; 35.3;
4+
motor; burnOut; 5.274; 1;
5+
motor; nozzleRadius; 0.021642; 0.0005;
6+
motor; throatRadius; 0.008; 0.0005;
7+
motor; grainSeparation; 0.006; 0.001;
8+
motor; grainDensity; 1707; 50;
9+
motor; grainOuterRadius; 0.0214; 0.2;
10+
motor; grainInitialInnerRadius; .0097;0.000375;
11+
motor; grainInitialHeight; 0.12; 0.001
12+
rocket; rocketMass; 8.257; 0.001;
13+
rocket; inertiaI; 3.675; 0.03675;
14+
rocket; inertiaZ; 0.007; 0.00007;
15+
rocket; radius; 0.04045; 0.001;
16+
rocket; distanceRocketNozzle; -1.024; .001;
17+
rocket; distanceRocketPropellant; -0.51; 0.001;
18+
rocket; powerOffDrag; 0.864857143; 0.03;
19+
rocket; powerOnDrag; 0.864857143; 0.03;
20+
rocket; noseLength; 0.274; 0.001;
21+
rocket; noseDistanceToCM; 1.134; 0.001
22+
fins; finSpan; 0.077; 0.0005;
23+
fins; finRootChord; 0.058; 0.0005;
24+
fins; finTipChord; 0.018; 0.0005;
25+
fins; finDistanceToCM; -0.906; 0.001;
26+
parachute; CdSDrogue; 0.4537; 0.07;
27+
parachute; lag_rec; 1; 0.5;
28+
parachute; lag_se; 0.73; 0.16;
29+
flight; inclination; 84.7; 1;
30+
flight; heading; 53; 2;
31+
flight; railLength; 5.7; 0.0005;

tests/test_utilities.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
11
from rocketpy import utilities
2+
import numpy as np
23

34

45
def test_compute_CdS_from_drop_test():
56
assert (
67
utilities.compute_CdS_from_drop_test(31.064, 18, 1.0476) == 0.3492311157844522
78
)
9+
10+
11+
def test_create__dispersion_dictionary():
12+
"""Test if the function returns a dictionary with the correct keys.
13+
It reads the keys from the dictionary generated by the utilities function
14+
and compares them to the expected.
15+
Be careful if you change the "fixtures/dispersion/Valetudo_inputs.csv" file.
16+
"""
17+
18+
returned_dict = utilities.create_dispersion_dictionary(
19+
"fixtures/dispersion/Valetudo_inputs.csv"
20+
)
21+
22+
test_dict = np.genfromtxt(
23+
"fixtures/dispersion/Valetudo_inputs.csv",
24+
usecols=(1, 2, 3),
25+
skip_header=1,
26+
delimiter=";",
27+
dtype=str,
28+
)
29+
30+
assert returned_dict == test_dict

0 commit comments

Comments
 (0)