Skip to content

Commit

Permalink
added tests for coords
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Feb 10, 2023
1 parent bf1beee commit 0923121
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
41 changes: 41 additions & 0 deletions tests/test_coordinates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import os
import unittest
from pathlib import Path

import matplotlib.pyplot as plt
from dagmc_geometry_slice_plotter import get_slice_coordinates


class TestPlotSliceOfDagmcFile(unittest.TestCase):
"""Tests the neutronics utilities functionality and use cases"""

def setUp(self):
self.h5m_filename_smaller = "tests/dagmc.h5m"

def test_create_default_plot(self):
"""Tests returned object is a matplotlib plot"""

list_of_coords = get_slice_coordinates(
dagmc_file_or_trimesh_object=self.h5m_filename_smaller,
)

for xy in list_of_coords:
plt.plot(*xy, color="black", linewidth=1)

assert isinstance(list_of_coords, list)

def test_create_default_plot_file(self):
"""Tests output file creation"""

os.system("rm test_plot.png")

list_of_coords = get_slice_coordinates(
dagmc_file_or_trimesh_object=self.h5m_filename_smaller,
)

for xy in list_of_coords:
plt.plot(*xy, color="black", linewidth=1)


assert isinstance(list_of_coords, list)
# TODO consider making the function return lists of floats not a TrackedArray
12 changes: 5 additions & 7 deletions tests/test_plot_slice_of_dagmc_file.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import os
import tarfile
import unittest
import urllib.request
from pathlib import Path

import matplotlib.pyplot as plt
from dagmc_geometry_slice_plotter import plot_slice_of_dagmc_file
from dagmc_geometry_slice_plotter import plot_slice


class TestPlotSliceOfDagmcFile(unittest.TestCase):
Expand All @@ -17,8 +15,8 @@ def setUp(self):
def test_create_default_plot(self):
"""Tests returned object is a matplotlib plot"""

plot = plot_slice_of_dagmc_file(
dagmc_filename=self.h5m_filename_smaller,
plot = plot_slice(
dagmc_file_or_trimesh_object=self.h5m_filename_smaller,
)

assert isinstance(plot, type(plt))
Expand All @@ -28,8 +26,8 @@ def test_create_default_plot_file(self):

os.system("rm test_plot.png")

plot = plot_slice_of_dagmc_file(
dagmc_filename=self.h5m_filename_smaller,
plot = plot_slice(
dagmc_file_or_trimesh_object=self.h5m_filename_smaller,
)
plot.savefig("test_plot.png")

Expand Down

0 comments on commit 0923121

Please sign in to comment.