Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added check for openmc version #35

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
12 changes: 12 additions & 0 deletions src/openmc_source_plotter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@
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):

Check failure on line 25 in src/openmc_source_plotter/core.py

View workflow job for this annotation

GitHub Actions / Flake8

src/openmc_source_plotter/core.py#L25

Line too long (80 > 79 characters) (E501)

if isinstance(self, openmc.Model):

Expand Down Expand Up @@ -83,7 +95,7 @@
e_values = [particle.E for particle in data]

# Calculate pdf for source energies
probability, bin_edges = np.histogram(e_values, bins=energy_bins, density=True)

Check failure on line 98 in src/openmc_source_plotter/core.py

View workflow job for this annotation

GitHub Actions / Flake8

src/openmc_source_plotter/core.py#L98

Line too long (83 > 79 characters) (E501)

# scaling by strength
if isinstance(self, openmc.SourceBase):
Expand Down
Loading