Skip to content

Commit

Permalink
test 12 passing locally
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Jul 31, 2023
1 parent c618606 commit 78f6876
Show file tree
Hide file tree
Showing 21 changed files with 109 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"width_a = 100\n",
"width_b = 200\n",
"width_c = 500\n",
Expand Down Expand Up @@ -176,7 +175,7 @@
" roof_cell,\n",
" floor_cell,\n",
" ]\n",
")\n"
")"
]
},
{
Expand Down Expand Up @@ -223,8 +222,8 @@
"# all (100%) of source particles are 2.5MeV energy\n",
"energy = openmc.stats.Discrete([2.5e6], [1.0])\n",
"\n",
"source = openmc.Source(space=space, angle=angle, energy=energy)\n",
"source.particle = \"neutron\"\n"
"source = openmc.IndependentSource(space=space, angle=angle, energy=energy)\n",
"source.particle = \"neutron\""
]
},
{
Expand Down Expand Up @@ -357,8 +356,7 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"run_and_plot(model, \"no_survival_biasing.png\")\n"
"run_and_plot(model, \"no_survival_biasing.png\")"
]
},
{
Expand All @@ -375,13 +373,12 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"model.settings.survival_biasing = True\n",
"model.settings.cutoff = {\n",
" \"weight\": 0.3, # value needs to be between 0 and 1\n",
" \"weight_avg\": 0.9, # value needs to be between 0 and 1\n",
"}\n",
"run_and_plot(model, \"yes_survival_biasing.png\")\n"
"run_and_plot(model, \"yes_survival_biasing.png\")"
]
},
{
Expand All @@ -397,7 +394,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "openmc_dev",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -411,10 +408,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
},
"orig_nbformat": 4
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@
"\n",
"ww_statepoint_filename = model.run()\n",
"\n",
"print(f'total time without weight windows {int(time.time()-t0)}s')\n",
"t1 = time.time()\n",
"\n",
"print(f'total time without weight windows {int(t1-t0)}s')\n",
"\n",
"plot_mesh_tally(ww_statepoint_filename, 'no_ww.png')"
]
Expand Down Expand Up @@ -487,7 +489,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
"outputs": [],
"source": [
"model = openmc.model.Model(my_geometry, my_materials, my_settings, my_tallies)\n",
"!rm *.xml\n",
"model.export_to_xml()"
]
},
Expand Down Expand Up @@ -312,6 +313,7 @@
"model.settings.particles = int(model.settings.particles*(87/12470))\n",
"\n",
"# export the model again so the particles is updated\n",
"!rm model.xml\n",
"model.export_to_xml()\n",
"with openmc.lib.run_in_memory():\n",
"\n",
Expand Down
13 changes: 5 additions & 8 deletions tests/test_task_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import sys
import unittest
from pathlib import Path

import nbformat
Expand Down Expand Up @@ -40,10 +39,8 @@ def _notebook_run(path):
return nb, errors


class test_tasks(unittest.TestCase):

def test_task_1(self):
for notebook in Path().rglob("tasks/tasks/task_01_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
def test_task_1():
for notebook in Path().rglob("tasks/tasks/task_01_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
13 changes: 5 additions & 8 deletions tests/test_task_10.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import sys
import unittest
from pathlib import Path

import nbformat
Expand Down Expand Up @@ -40,10 +39,8 @@ def _notebook_run(path):
return nb, errors


class test_tasks(unittest.TestCase):

def test_task_10(self):
for notebook in Path().rglob("tasks/task_10_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
def test_task_10():
for notebook in Path().rglob("tasks/task_10_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
14 changes: 5 additions & 9 deletions tests/test_task_11.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import sys
import unittest
from pathlib import Path

import nbformat
Expand Down Expand Up @@ -39,11 +38,8 @@ def _notebook_run(path):

return nb, errors


class test_tasks(unittest.TestCase):

def test_task_11(self):
for notebook in Path().rglob("tasks/task_11_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
def test_task_11():
for notebook in Path().rglob("tasks/task_11_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
23 changes: 10 additions & 13 deletions tests/test_task_12.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import sys
import unittest
from pathlib import Path

import nbformat
Expand Down Expand Up @@ -40,16 +39,14 @@ def _notebook_run(path):
return nb, errors


class test_tasks(unittest.TestCase):
def test_task_12():
for notebook in Path().rglob("tasks/task_12_*/1*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []

def test_task_12(self):
for notebook in Path().rglob("tasks/task_12_*/1*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []

for notebook in Path().rglob("tasks/task_12_*/2_.ipynb"):
nb, errors = _notebook_run(notebook)
assert errors == []

# task 3 is skipped as it causes errors
for notebook in Path().rglob("tasks/task_12_*/2_.ipynb"):
nb, errors = _notebook_run(notebook)
assert errors == []

# task 3 is skipped as it causes errors, issue raised
18 changes: 5 additions & 13 deletions tests/test_task_13.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import sys
import unittest
from pathlib import Path

import nbformat
Expand All @@ -22,29 +21,22 @@ def _notebook_run(path):
kernel_name = 'python%d' % sys.version_info[0]
this_file_directory = os.path.dirname(__file__)
errors = []

with open(path) as f:
nb = nbformat.read(f, as_version=4)
nb.metadata.get('kernelspec', {})['name'] = kernel_name
ep = ExecutePreprocessor(kernel_name=kernel_name, timeout=300) #, allow_errors=True

try:
ep.preprocess(nb, {'metadata': {'path': this_file_directory}})

except CellExecutionError as e:
if "SKIP" in e.traceback:
print(str(e.traceback).split("\n")[-2])
else:
raise e

return nb, errors


class test_tasks(unittest.TestCase):

# No module named 'openmc_model'
def test_task_13(self):
for notebook in Path().rglob("tasks/task_13_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
def test_task_13():
for notebook in Path().rglob("tasks/task_13_*/*.ipynb"):
print(f'tests {notebook}')
nb, errors = _notebook_run(notebook)
assert errors == []
14 changes: 5 additions & 9 deletions tests/test_task_14.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import sys
import unittest
from pathlib import Path

import nbformat
Expand Down Expand Up @@ -40,11 +39,8 @@ def _notebook_run(path):
return nb, errors


class test_tasks(unittest.TestCase):

# No module named 'openmc_model'
def test_task_14(self):
for notebook in Path().rglob("tasks/task_14_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
def test_task_14():
for notebook in Path().rglob("tasks/task_14_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
14 changes: 5 additions & 9 deletions tests/test_task_15.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import sys
import unittest
from pathlib import Path

import nbformat
Expand Down Expand Up @@ -40,11 +39,8 @@ def _notebook_run(path):
return nb, errors


class test_tasks(unittest.TestCase):

# No module named 'openmc_model'
def test_task_14(self):
for notebook in Path().rglob("tasks/task_15_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
def test_task_14():
for notebook in Path().rglob("tasks/task_15_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
14 changes: 5 additions & 9 deletions tests/test_task_16.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import sys
import unittest
from pathlib import Path

import nbformat
Expand Down Expand Up @@ -40,11 +39,8 @@ def _notebook_run(path):
return nb, errors


class test_tasks(unittest.TestCase):

# No module named 'openmc_model'
def test_task_14(self):
for notebook in Path().rglob("tasks/task_16_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
def test_task_14():
for notebook in Path().rglob("tasks/task_16_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
13 changes: 5 additions & 8 deletions tests/test_task_17.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ def _notebook_run(path):
return nb, errors


class test_tasks(unittest.TestCase):

# No module named 'openmc_model'
def test_task_14(self):
for notebook in Path().rglob("tasks/task_17_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
def test_task_17():
for notebook in Path().rglob("tasks/task_17_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
14 changes: 5 additions & 9 deletions tests/test_task_18.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import sys
import unittest
from pathlib import Path

import nbformat
Expand Down Expand Up @@ -40,11 +39,8 @@ def _notebook_run(path):
return nb, errors


class test_tasks(unittest.TestCase):

# No module named 'openmc_model'
def test_task_14(self):
for notebook in Path().rglob("tasks/task_18_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
def test_task_18():
for notebook in Path().rglob("tasks/task_18_*/*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
Loading

0 comments on commit 78f6876

Please sign in to comment.