Skip to content

Commit d5e65a8

Browse files
Lucas-PratesGui-FernandesBR
authored andcommitted
MNT: refactoring class to match review suggestions
1 parent 5eb9cc1 commit d5e65a8

File tree

3 files changed

+203
-153
lines changed

3 files changed

+203
-153
lines changed

Diff for: .vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@
288288
"statsmodels",
289289
"STFT",
290290
"subintervals",
291+
"supremum",
291292
"suptitle",
292293
"supxlabel",
293294
"supylabel",

Diff for: test_mrs.ipynb renamed to docs/notebooks/test_mrs.ipynb

+54-44
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 80,
12+
"execution_count": 30,
1313
"metadata": {},
1414
"outputs": [
1515
{
@@ -29,78 +29,61 @@
2929
},
3030
{
3131
"cell_type": "code",
32-
"execution_count": 81,
32+
"execution_count": 31,
3333
"metadata": {},
3434
"outputs": [],
3535
"source": [
36-
"from rocketpy.simulation.multivariate_rejection_sampler import MultivariateRejectionSampler\n",
36+
"from rocketpy.simulation.multivariate_rejection_sampler import (\n",
37+
" MultivariateRejectionSampler,\n",
38+
")\n",
3739
"from rocketpy import MonteCarlo\n",
3840
"from scipy.stats import norm\n",
3941
"import numpy as np"
4042
]
4143
},
4244
{
4345
"cell_type": "code",
44-
"execution_count": 88,
46+
"execution_count": 32,
4547
"metadata": {},
4648
"outputs": [],
4749
"source": [
48-
"montecarlo_filepath = \"docs/notebooks/monte_carlo_analysis/monte_carlo_analysis_outputs/monte_carlo_class_example\"\n",
49-
"mrs_filepath = \"mrs\"\n",
50+
"monte_carlo_filepath = (\n",
51+
" \"monte_carlo_analysis/monte_carlo_analysis_outputs/monte_carlo_class_example\"\n",
52+
")\n",
53+
"mrs_filepath = \"monte_carlo_analysis/monte_carlo_analysis_outputs/mrs\"\n",
5054
"old_mass_pdf = norm(15.426, 0.5).pdf\n",
51-
"new_mass_pdf = norm(15, 0.5) .pdf\n",
55+
"new_mass_pdf = norm(15, 0.5).pdf\n",
5256
"distribution_dict = {\n",
5357
" \"mass\": (old_mass_pdf, new_mass_pdf),\n",
5458
"}\n",
5559
"mrs = MultivariateRejectionSampler(\n",
56-
" montecarlo_filepath=montecarlo_filepath,\n",
60+
" monte_carlo_filepath=monte_carlo_filepath,\n",
5761
" mrs_filepath=mrs_filepath,\n",
58-
" distribution_dict=distribution_dict,\n",
5962
")"
6063
]
6164
},
6265
{
6366
"cell_type": "code",
64-
"execution_count": 89,
65-
"metadata": {},
66-
"outputs": [
67-
{
68-
"data": {
69-
"text/plain": [
70-
"107.0"
71-
]
72-
},
73-
"execution_count": 89,
74-
"metadata": {},
75-
"output_type": "execute_result"
76-
}
77-
],
78-
"source": [
79-
"mrs.expected_sample_size"
80-
]
81-
},
82-
{
83-
"cell_type": "code",
84-
"execution_count": 90,
67+
"execution_count": 33,
8568
"metadata": {},
8669
"outputs": [],
8770
"source": [
88-
"mrs.sample()"
71+
"mrs.sample(distribution_dict=distribution_dict)"
8972
]
9073
},
9174
{
9275
"cell_type": "code",
93-
"execution_count": 91,
76+
"execution_count": 34,
9477
"metadata": {},
9578
"outputs": [
9679
{
9780
"name": "stdout",
9881
"output_type": "stream",
9982
"text": [
100-
"The following input file was imported: mrs.inputs.txt\n",
101-
"A total of 109 simulations results were loaded from the following output file: mrs.outputs.txt\n",
83+
"The following input file was imported: monte_carlo_analysis/monte_carlo_analysis_outputs/mrs.inputs.txt\n",
84+
"A total of 116 simulations results were loaded from the following output file: monte_carlo_analysis/monte_carlo_analysis_outputs/mrs.outputs.txt\n",
10285
"\n",
103-
"The following error file was imported: mrs.errors.txt\n"
86+
"The following error file was imported: monte_carlo_analysis/monte_carlo_analysis_outputs/mrs.errors.txt\n"
10487
]
10588
}
10689
],
@@ -110,17 +93,17 @@
11093
},
11194
{
11295
"cell_type": "code",
113-
"execution_count": 92,
96+
"execution_count": 35,
11497
"metadata": {},
11598
"outputs": [
11699
{
117100
"name": "stdout",
118101
"output_type": "stream",
119102
"text": [
120-
"A total of 109 simulations results were loaded from the following output file: mrs.outputs.txt\n",
103+
"A total of 116 simulations results were loaded from the following output file: monte_carlo_analysis/monte_carlo_analysis_outputs/mrs.outputs.txt\n",
121104
"\n",
122-
"The following input file was imported: mrs.inputs.txt\n",
123-
"The following error file was imported: mrs.errors.txt\n"
105+
"The following input file was imported: monte_carlo_analysis/monte_carlo_analysis_outputs/mrs.inputs.txt\n",
106+
"The following error file was imported: monte_carlo_analysis/monte_carlo_analysis_outputs/mrs.errors.txt\n"
124107
]
125108
}
126109
],
@@ -130,15 +113,15 @@
130113
},
131114
{
132115
"cell_type": "code",
133-
"execution_count": null,
116+
"execution_count": 36,
134117
"metadata": {},
135118
"outputs": [
136119
{
137120
"name": "stdout",
138121
"output_type": "stream",
139122
"text": [
140-
"MRS mass mean after resample: 15.029610376989238\n",
141-
"MRS mass std after resample: 0.5213162519453568\n"
123+
"MRS mass mean after resample: 15.041934326472004\n",
124+
"MRS mass std after resample: 0.48924085702427966\n"
142125
]
143126
}
144127
],
@@ -150,11 +133,38 @@
150133
"print(f\"MRS mass mean after resample: {np.mean(mrs_mass_list)}\")\n",
151134
"print(f\"MRS mass std after resample: {np.std(mrs_mass_list)}\")"
152135
]
136+
},
137+
{
138+
"cell_type": "code",
139+
"execution_count": 37,
140+
"metadata": {},
141+
"outputs": [
142+
{
143+
"data": {
144+
"text/plain": [
145+
"107.0"
146+
]
147+
},
148+
"execution_count": 37,
149+
"metadata": {},
150+
"output_type": "execute_result"
151+
}
152+
],
153+
"source": [
154+
"mrs.expected_sample_size"
155+
]
156+
},
157+
{
158+
"cell_type": "code",
159+
"execution_count": null,
160+
"metadata": {},
161+
"outputs": [],
162+
"source": []
153163
}
154164
],
155165
"metadata": {
156166
"kernelspec": {
157-
"display_name": "testnotebook",
167+
"display_name": "Python 3",
158168
"language": "python",
159169
"name": "python3"
160170
},
@@ -168,7 +178,7 @@
168178
"name": "python",
169179
"nbconvert_exporter": "python",
170180
"pygments_lexer": "ipython3",
171-
"version": "3.12.2"
181+
"version": "3.10.12"
172182
}
173183
},
174184
"nbformat": 4,

0 commit comments

Comments
 (0)