From dbe2294c04557bee9b734de99a16237c51634a82 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 17 Oct 2018 20:14:09 -0500 Subject: [PATCH 1/3] Support from_hdf5 for older format neutron files without redundant --- openmc/data/reaction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/data/reaction.py b/openmc/data/reaction.py index 547208dae..11807cadc 100644 --- a/openmc/data/reaction.py +++ b/openmc/data/reaction.py @@ -924,7 +924,7 @@ class Reaction(EqualityMixin): rx = cls(mt) rx.q_value = group.attrs['Q_value'] rx.center_of_mass = bool(group.attrs['center_of_mass']) - rx.redundant = bool(group.attrs['redundant']) + rx.redundant = bool(group.attrs.get('redundant', False)) # Read cross section at each temperature for T, Tgroup in group.items(): From 5b35714783b9b5cf1516b2f5e3e17e2c1384215d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 18 Oct 2018 05:44:26 -0500 Subject: [PATCH 2/3] Change pandas.DataFrame.as_matrix() -> .values --- examples/jupyter/mgxs-part-ii.ipynb | 4 ++-- openmc/data/photon.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/jupyter/mgxs-part-ii.ipynb b/examples/jupyter/mgxs-part-ii.ipynb index c10f55956..1058b7134 100644 --- a/examples/jupyter/mgxs-part-ii.ipynb +++ b/examples/jupyter/mgxs-part-ii.ipynb @@ -2048,8 +2048,8 @@ "o16 = df[df['nuclide'] == 'O16']['mean']\n", "\n", "# Cast DataFrames as NumPy arrays\n", - "h1 = h1.as_matrix()\n", - "o16 = o16.as_matrix()\n", + "h1 = h1.values\n", + "o16 = o16.values\n", "\n", "# Reshape arrays to 2D matrix for plotting\n", "h1.shape = (fine_groups.num_groups, fine_groups.num_groups)\n", diff --git a/openmc/data/photon.py b/openmc/data/photon.py index 61c903158..5f932b185 100644 --- a/openmc/data/photon.py +++ b/openmc/data/photon.py @@ -740,7 +740,7 @@ class IncidentPhoton(EqualityMixin): shell_values.insert(0, None) df = relax.transitions[shell].replace( shell_values, range(len(shell_values))) - sub_group.create_dataset('transitions', data=df.as_matrix()) + sub_group.create_dataset('transitions', data=df.values) # Determine threshold threshold = rx.xs.x[0] From 50aa7be701a14248c3df8903da2ac668d51e0133 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 18 Oct 2018 05:54:36 -0500 Subject: [PATCH 3/3] Make sure ABCs come from collections.abc --- openmc/arithmetic.py | 2 +- openmc/data/photon.py | 3 ++- openmc/data/resonance_covariance.py | 2 +- openmc/filter.py | 3 ++- openmc/mesh.py | 2 +- openmc/mgxs/groups.py | 2 +- openmc/universe.py | 3 ++- tests/unit_tests/test_data_decay.py | 2 +- tests/unit_tests/test_data_misc.py | 2 +- tests/unit_tests/test_data_neutron.py | 2 +- tests/unit_tests/test_data_photon.py | 2 +- tests/unit_tests/test_data_thermal.py | 2 +- 12 files changed, 15 insertions(+), 12 deletions(-) diff --git a/openmc/arithmetic.py b/openmc/arithmetic.py index 4a5e7486a..91e2f1ed4 100644 --- a/openmc/arithmetic.py +++ b/openmc/arithmetic.py @@ -1,6 +1,6 @@ import sys import copy -from collections import Iterable +from collections.abc import Iterable import numpy as np import pandas as pd diff --git a/openmc/data/photon.py b/openmc/data/photon.py index 5f932b185..e0f71d5ce 100644 --- a/openmc/data/photon.py +++ b/openmc/data/photon.py @@ -1,4 +1,5 @@ -from collections import OrderedDict, Mapping, Callable +from collections import OrderedDict +from collections.abc import Mapping, Callable from copy import deepcopy from io import StringIO from numbers import Integral, Real diff --git a/openmc/data/resonance_covariance.py b/openmc/data/resonance_covariance.py index 300e6dbf6..9e80e52f2 100644 --- a/openmc/data/resonance_covariance.py +++ b/openmc/data/resonance_covariance.py @@ -1,4 +1,4 @@ -from collections import MutableSequence +from collections.abc import MutableSequence import warnings import io import copy diff --git a/openmc/filter.py b/openmc/filter.py index 6c904e61d..ef68a4961 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -1,5 +1,6 @@ from abc import ABCMeta -from collections import Iterable, OrderedDict +from collections import OrderedDict +from collections.abc import Iterable import copy import hashlib from itertools import product diff --git a/openmc/mesh.py b/openmc/mesh.py index f7cba22f8..f454a6f88 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -1,4 +1,4 @@ -from collections import Iterable +from collections.abc import Iterable from numbers import Real, Integral from xml.etree import ElementTree as ET import sys diff --git a/openmc/mgxs/groups.py b/openmc/mgxs/groups.py index 6dd56e8e7..338bc4b00 100644 --- a/openmc/mgxs/groups.py +++ b/openmc/mgxs/groups.py @@ -1,4 +1,4 @@ -from collections import Iterable +from collections.abc import Iterable from numbers import Real import copy import sys diff --git a/openmc/universe.py b/openmc/universe.py index 294b114dd..044da12e3 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -1,4 +1,5 @@ -from collections import OrderedDict, Iterable +from collections import OrderedDict +from collections.abc import Iterable from copy import copy, deepcopy from numbers import Integral, Real import random diff --git a/tests/unit_tests/test_data_decay.py b/tests/unit_tests/test_data_decay.py index be8ad7d64..b925506df 100644 --- a/tests/unit_tests/test_data_decay.py +++ b/tests/unit_tests/test_data_decay.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from collections import Mapping +from collections.abc import Mapping import os from math import log diff --git a/tests/unit_tests/test_data_misc.py b/tests/unit_tests/test_data_misc.py index 34686b567..46a9dbd02 100644 --- a/tests/unit_tests/test_data_misc.py +++ b/tests/unit_tests/test_data_misc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from collections import Mapping +from collections.abc import Mapping import os import numpy as np diff --git a/tests/unit_tests/test_data_neutron.py b/tests/unit_tests/test_data_neutron.py index bbebcb34a..3cf036aa2 100644 --- a/tests/unit_tests/test_data_neutron.py +++ b/tests/unit_tests/test_data_neutron.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from collections import Mapping, Callable +from collections.abc import Mapping, Callable import os import numpy as np diff --git a/tests/unit_tests/test_data_photon.py b/tests/unit_tests/test_data_photon.py index eecef73c4..5036d08fd 100644 --- a/tests/unit_tests/test_data_photon.py +++ b/tests/unit_tests/test_data_photon.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from collections import Mapping, Callable +from collections.abc import Mapping, Callable import os import numpy as np diff --git a/tests/unit_tests/test_data_thermal.py b/tests/unit_tests/test_data_thermal.py index 9def78b38..7d7d4e964 100644 --- a/tests/unit_tests/test_data_thermal.py +++ b/tests/unit_tests/test_data_thermal.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from collections import Callable +from collections.abc import Callable import os import numpy as np