From c74b67f35e649ae11fb38c4cdc4d3b3e490abffb Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 13 Feb 2024 11:16:47 +0000 Subject: [PATCH 1/3] added check for openmc version --- src/openmc_source_plotter/core.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/openmc_source_plotter/core.py b/src/openmc_source_plotter/core.py index a73196d..9603f24 100644 --- a/src/openmc_source_plotter/core.py +++ b/src/openmc_source_plotter/core.py @@ -9,6 +9,17 @@ import openmc.lib import plotly.graph_objects +import pkg_resources + +system_openmc_version = pkg_resources.parse_version(openmc.__version__) +min_openmc_version = pkg_resources.parse_version("0.14.0") +if system_openmc_version < min_openmc_version: + msg = ( + "openmc_source_plotter requires openmc version 0.14.0 or above. " + f"You have openmc version {system_openmc_version} installed. " + "Please update the version of openmc installed" + ) + raise ImportError(msg) def sample_initial_particles(self, n_samples: int = 1000, prn_seed: int = None): From 33d40eb269ec833fab597da7b3422ce6bfce4437 Mon Sep 17 00:00:00 2001 From: shimwell Date: Tue, 13 Feb 2024 11:19:01 +0000 Subject: [PATCH 2/3] [skip ci] Apply formatting changes --- src/openmc_source_plotter/core.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/openmc_source_plotter/core.py b/src/openmc_source_plotter/core.py index 9603f24..40dbb20 100644 --- a/src/openmc_source_plotter/core.py +++ b/src/openmc_source_plotter/core.py @@ -9,7 +9,7 @@ import openmc.lib import plotly.graph_objects -import pkg_resources +import pkg_resources system_openmc_version = pkg_resources.parse_version(openmc.__version__) min_openmc_version = pkg_resources.parse_version("0.14.0") @@ -17,10 +17,11 @@ msg = ( "openmc_source_plotter requires openmc version 0.14.0 or above. " f"You have openmc version {system_openmc_version} installed. " - "Please update the version of openmc installed" + "Please update the version of openmc installed" ) raise ImportError(msg) + def sample_initial_particles(self, n_samples: int = 1000, prn_seed: int = None): if isinstance(self, openmc.Model): From a3e66a49ae9da58e9d3ecea1adc094a8650bc62d Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 13 Feb 2024 11:19:18 +0000 Subject: [PATCH 3/3] added openmc version line --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f73ba65..9271b7c 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ A Python package for plotting the positions, directions or energy distributions # Installation +You will need to have OpenMC version 0.14.0 or newer installed first. + ```bash pip install openmc_source_plotter ```