Skip to content

Commit 5c63e0d

Browse files
authored
Fix a few warnings, rename add_to_tallies_file (#3639)
1 parent 7815d3a commit 5c63e0d

File tree

17 files changed

+54
-56
lines changed

17 files changed

+54
-56
lines changed

docs/source/usersguide/random_ray.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ energy decomposition::
765765

766766
# Create a "tallies.xml" file for the MGXS Library
767767
tallies = openmc.Tallies()
768-
mgxs_lib.add_to_tallies_file(tallies, merge=True)
768+
mgxs_lib.add_to_tallies(tallies, merge=True)
769769

770770
# Export
771771
tallies.export_to_xml()

openmc/deplete/chain.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def form_matrix(self, rates, fission_yields=None):
630630

631631
n = len(self)
632632

633-
# we accumulate indices and value entries for everything and create the matrix
633+
# we accumulate indices and value entries for everything and create the matrix
634634
# in one step at the end to avoid expensive index checks scipy otherwise does.
635635
rows, cols, vals = [], [], []
636636
def setval(i, j, val):
@@ -716,14 +716,17 @@ def setval(i, j, val):
716716
return sp.csc_matrix((vals, (rows, cols)), shape=(n, n))
717717

718718
def add_redox_term(self, matrix, buffer, oxidation_states):
719-
"""Adds a redox term to the depletion matrix from data contained in
719+
r"""Adds a redox term to the depletion matrix from data contained in
720720
the matrix itself and a few user-inputs.
721721
722722
The redox term to add to the buffer nuclide :math:`N_j` can be written
723-
as: :math:`\frac{dN_j(t)}{dt} =
724-
\cdots - \frac{1}{OS_j}\sum_i N_i a_{ij} \cdot OS_i `
723+
as:
725724
726-
where :math:`OS` is the oxidation states vector and `a_{ij}` the
725+
.. math::
726+
\frac{dN_j(t)}{dt} = \cdots - \frac{1}{OS_j}\sum_i N_i a_{ij}
727+
\cdot OS_i
728+
729+
where :math:`OS` is the oxidation states vector and :math:`a_{ij}` the
727730
corresponding term in the Bateman matrix.
728731
729732
Parameters

openmc/mgxs/library.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,14 @@ def build_library(self):
556556

557557
self.all_mgxs[domain.id][mgxs_type] = mgxs
558558

559-
def add_to_tallies_file(self, tallies_file, merge=True):
560-
"""Add all tallies from all MGXS objects to a tallies file.
559+
def add_to_tallies(self, tallies, merge=True):
560+
"""Add tallies from all MGXS objects to a tallies object.
561561
562562
NOTE: This assumes that :meth:`Library.build_library` has been called
563563
564564
Parameters
565565
----------
566-
tallies_file : openmc.Tallies
566+
tallies : openmc.Tallies
567567
A Tallies collection to add each MGXS' tallies to generate a
568568
'tallies.xml' input file for OpenMC
569569
merge : bool
@@ -572,7 +572,7 @@ def add_to_tallies_file(self, tallies_file, merge=True):
572572
573573
"""
574574

575-
cv.check_type('tallies_file', tallies_file, openmc.Tallies)
575+
cv.check_type('tallies', tallies, openmc.Tallies)
576576

577577
# Add tallies from each MGXS for each domain and mgxs type
578578
for domain in self.domains:
@@ -587,7 +587,15 @@ def add_to_tallies_file(self, tallies_file, merge=True):
587587
= list(range(1, self.num_delayed_groups + 1))
588588

589589
for tally in mgxs.tallies.values():
590-
tallies_file.append(tally, merge=merge)
590+
tallies.append(tally, merge=merge)
591+
592+
def add_to_tallies_file(self, tallies_file, merge=True):
593+
warn(
594+
"The Library.add_to_tallies_file(...) method has been renamed to"
595+
"add_to_tallies(...) and will be removed in a future version of "
596+
"OpenMC.", FutureWarning
597+
)
598+
self.add_to_tallies(tallies_file, merge=merge)
591599

592600
def load_from_statepoint(self, statepoint):
593601
"""Extracts tallies in an OpenMC StatePoint with the data needed to

openmc/mgxs/mgxs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,8 +2127,8 @@ def get_pandas_dataframe(self, groups='all', nuclides='all',
21272127
df['std. dev.'] /= np.tile(densities, tile_factor)
21282128

21292129
# Replace NaNs by zeros (happens if nuclide density is zero)
2130-
df['mean'].replace(np.nan, 0.0, inplace=True)
2131-
df['std. dev.'].replace(np.nan, 0.0, inplace=True)
2130+
df['mean'] = df['mean'].replace(np.nan, 0.0)
2131+
df['std. dev.'] = df['std. dev.'].replace(np.nan, 0.0)
21322132

21332133
# Sort the dataframe by domain type id (e.g., distribcell id) and
21342134
# energy groups such that data is from fast to thermal

openmc/model/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,7 @@ def _generate_infinite_medium_mgxs(
17911791
mgxs_lib.build_library()
17921792

17931793
# Create a "tallies.xml" file for the MGXS Library
1794-
mgxs_lib.add_to_tallies_file(model.tallies, merge=True)
1794+
mgxs_lib.add_to_tallies(model.tallies, merge=True)
17951795

17961796
# Run
17971797
statepoint_filename = model.run(cwd=directory)
@@ -1980,7 +1980,7 @@ def _generate_stochastic_slab_mgxs(
19801980
mgxs_lib.build_library()
19811981

19821982
# Create a "tallies.xml" file for the MGXS Library
1983-
mgxs_lib.add_to_tallies_file(model.tallies, merge=True)
1983+
mgxs_lib.add_to_tallies(model.tallies, merge=True)
19841984

19851985
# Run
19861986
statepoint_filename = model.run(cwd=directory)
@@ -2075,7 +2075,7 @@ def _generate_material_wise_mgxs(
20752075
mgxs_lib.build_library()
20762076

20772077
# Create a "tallies.xml" file for the MGXS Library
2078-
mgxs_lib.add_to_tallies_file(model.tallies, merge=True)
2078+
mgxs_lib.add_to_tallies(model.tallies, merge=True)
20792079

20802080
# Run
20812081
statepoint_filename = model.run(cwd=directory)

openmc/tallies.py

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -738,13 +738,9 @@ def skewtest(self, alternative: str = "two-sided"):
738738
739739
Notes
740740
-----
741-
This test is based on D'Agostino and Pearson's test [1]_. The test
742-
requires at least 8 realizations to produce valid results.
743-
744-
References
745-
----------
746-
.. [1] D'Agostino, R. B. (1971), "An omnibus test of normality for
747-
moderate and large sample size", Biometrika, 58, 341-348
741+
This test is based on `D'Agostino and Pearson's test
742+
<https://doi.org/10.1093/biomet/60.3.613>`_. The test requires at least
743+
8 realizations to produce valid results.
748744
749745
"""
750746
n = self.num_realizations
@@ -788,8 +784,8 @@ def kurtosistest(self, alternative: str = "two-sided"):
788784
Parameters
789785
----------
790786
alternative : {'two-sided', 'less', 'greater'}, optional
791-
Defines the alternative hypothesis. Default is 'two-sided'.
792-
The following options are available:
787+
Defines the alternative hypothesis. Default is 'two-sided'. The
788+
following options are available:
793789
794790
* 'two-sided': the kurtosis of the distribution is different from
795791
that of the normal distribution
@@ -813,14 +809,9 @@ def kurtosistest(self, alternative: str = "two-sided"):
813809
814810
Notes
815811
-----
816-
This test is based on D'Agostino and Pearson's test [1]_. The test
817-
is typically recommended for at least 20 realizations to produce
818-
valid results.
819-
820-
References
821-
----------
822-
.. [1] D'Agostino, R. B. (1971), "An omnibus test of normality for
823-
moderate and large sample size", Biometrika, 58, 341-348
812+
This test is based on `D'Agostino and Pearson's test
813+
<https://doi.org/10.1093/biomet/60.3.613>`_. The test is typically
814+
recommended for at least 20 realizations to produce valid results.
824815
825816
"""
826817
n = self.num_realizations
@@ -855,9 +846,9 @@ def kurtosistest(self, alternative: str = "two-sided"):
855846
def normaltest(self, alternative: str = "two-sided"):
856847
"""Perform D'Agostino and Pearson's omnibus test for normality.
857848
858-
This method tests the null hypothesis that a sample comes from a
859-
normal distribution. It combines skewness and kurtosis to produce an
860-
omnibus test of normality.
849+
This method tests the null hypothesis that a sample comes from a normal
850+
distribution. It combines skewness and kurtosis to produce an omnibus
851+
test of normality.
861852
862853
Parameters
863854
----------
@@ -886,23 +877,19 @@ def normaltest(self, alternative: str = "two-sided"):
886877
Notes
887878
-----
888879
This test combines a test for skewness and a test for kurtosis to
889-
produce an omnibus test [1]_. The test statistic is:
880+
produce an `omnibus test <https://doi.org/10.1093/biomet/60.3.613>`_.
881+
The test statistic is:
890882
891883
.. math::
892884
893885
K^2 = Z_1^2 + Z_2^2
894886
895-
where :math:`Z_1` is the z-score from the skewness test and
896-
:math:`Z_2` is the z-score from the kurtosis test. This statistic
897-
follows a chi-square distribution with 2 degrees of freedom.
887+
where :math:`Z_1` is the z-score from the skewness test and :math:`Z_2`
888+
is the z-score from the kurtosis test. This statistic follows a
889+
chi-square distribution with 2 degrees of freedom.
898890
899891
The test requires at least 20 realizations to produce valid results.
900892
901-
References
902-
----------
903-
.. [1] D'Agostino, R. B. and Pearson, E. S. (1973), "Tests for
904-
departure from normality", Biometrika, 60, 613-622
905-
906893
"""
907894
n = self.num_realizations
908895
if n < 20:

tests/regression_tests/mgxs_library_ce_to_mg/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, *args, **kwargs):
2828
self.mgxs_lib.build_library()
2929

3030
# Initialize a tallies file
31-
self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False)
31+
self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False)
3232

3333
def _run_openmc(self):
3434
# Initial run

tests/regression_tests/mgxs_library_ce_to_mg_nuclides/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, *args, **kwargs):
2828
self.mgxs_lib.build_library()
2929

3030
# Initialize a tallies file
31-
self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False)
31+
self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False)
3232

3333
def _run_openmc(self):
3434
# Initial run

tests/regression_tests/mgxs_library_condense/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, *args, **kwargs):
3636
self.mgxs_lib.build_library()
3737

3838
# Add tallies
39-
self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False)
39+
self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False)
4040

4141
def _get_results(self, hash_output=False):
4242
"""Digest info in the statepoint and return as a string."""

tests/regression_tests/mgxs_library_correction/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, *args, **kwargs):
2929
self.mgxs_lib.build_library()
3030

3131
# Add tallies
32-
self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False)
32+
self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False)
3333

3434
def _get_results(self, hash_output=False):
3535
"""Digest info in the statepoint and return as a string."""

0 commit comments

Comments
 (0)