Skip to content

Commit

Permalink
Merge branch 'main' into nuclideBaseAZSBug
Browse files Browse the repository at this point in the history
  • Loading branch information
albeanth committed Feb 3, 2025
2 parents bee8e49 + cf9106d commit bc68590
Show file tree
Hide file tree
Showing 30 changed files with 313 additions and 137 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ jobs:
git submodule init
git submodule update
make html
- name: deploy
make simplepdf
- name: Deploy
if: github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@v4.6.1
with:
Expand All @@ -46,10 +47,16 @@ jobs:
branch: main
folder: doc/_build/html
target-folder: armi
- name: Archive Docs from PR
- name: Archive HTML Docs
if: github.ref != 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: pr-docs
name: html-docs
path: doc/_build/html
retention-days: 5
- name: Archive PDF Docs
uses: actions/upload-artifact@v4
with:
name: pdf-docs
path: doc/_build/simplepdf/ARMI.pdf
retention-days: 5
62 changes: 61 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
# How to Contribute
# Contribution License Agreement

For information on how to contribute to ARMI, see [our official documenation](https://terrapower.github.io/armi/developer/first_time_contributors.html).

This Contribution License Agreement (**"Agreement"**) is agreed to by the party signing below (**"You"**), and conveys certain license rights to TerraPower, LLC and its affiliates (**"TerraPower"**) for Your contributions to TerraPower open source projects. This Agreement is effective as of the latest signature date below.

## 1. Definitions.

**"Code"** means the computer software code, whether in human-readable or machine-executable form, that is delivered by You to TerraPower under this Agreement.

**"Project"** means any of the projects owned or managed by TerraPower in which software is offered under a license approved by the Open Source Initiative (OSI) ([www.opensource.org](http://www.opensource.org)) and documentation offered under an OSI or a Creative Commons license (https://creativecommons.org/licenses).

**"Submit"** is the act of uploading, submitting, transmitting, or distributing code or other content to any Project, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of discussing and improving that Project, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Submission."

**"Submission"** means the Code and any other copyrightable material Submitted by You, including any associated comments and documentation.

## 2. Your Submission.

You must agree to the terms of this Agreement before making a Submission to any Project. This Agreement covers any and all Submissions that You, now or in the future (except as described in Section 4 below), Submit to any Project.

## 3. Originality of Work.

You represent that each of Your Submissions is entirely Your original work. Should You wish to Submit materials that are not Your original work, You may Submit them separately to the Project if You (a) retain all copyright and license information that was in the materials as You received them, (b) in the description accompanying Your Submission, include the phrase "Submission containing materials of a third party:" followed by the names of the third party and any licenses or other restrictions of which You are aware, and (c) follow any other instructions in the Project’s written guidelines concerning Submissions.

## 4. Your Employer.

References to "employer" in this Agreement include Your employer or anyone else for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your Submission is made in the course of Your work for an employer or Your employer has intellectual property rights in Your Submission by contract or applicable law, You must secure permission from Your employer to make the Submission before signing this Agreement. In that case, the term "You" in this Agreement will refer to You and the employer collectively. If You change employers in the future and desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement and secure permission from the new employer before Submitting those Submissions.

## 5. Licenses.

### a. Copyright License.

You grant TerraPower, and those who receive the Submission directly or indirectly from TerraPower, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license in the Submission to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute the Submission and such derivative works, and to sublicense any or all of the foregoing rights to third parties.

### b. Patent License.

You grant TerraPower, and those who receive the Submission directly or indirectly from TerraPower, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under Your patent claims that are necessarily infringed by the Submission or the combination of the Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and import or otherwise dispose of the Submission alone or with the Project.

### c. Other Rights Reserved.

Each party reserves all rights not expressly granted in this Agreement. No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are granted by implication, exhaustion, estoppel or otherwise.

## 6. Representations and Warranties.

You represent that You are legally entitled to grant the above licenses. You represent that each of Your Submissions is entirely Your original work (except as You may have disclosed under Section 3). You represent that You have secured permission from Your employer to make the Submission in cases where Your Submission is made in the course of Your work for Your employer or Your employer has intellectual property rights in Your Submission by contract or applicable law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You have the necessary authority to bind the listed employer to the obligations contained in this Agreement. You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES EXPRESSLY STATED IN SECTIONS 3, 4, AND 6, THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.

## 7. Notice to TerraPower.

You agree to notify TerraPower in writing of any facts or circumstances of which You later become aware that would make Your representations in this Agreement inaccurate in any respect.

## 8. Information about Submissions.

You agree that contributions to Projects and information about contributions may be maintained indefinitely and disclosed publicly, including Your name and other information that You submit with Your Submission.

## 9. Governing Law/Jurisdiction.

This Agreement is governed by the laws of the State of Washington, USA and the parties consent to exclusive jurisdiction and venue in the federal courts located in King County, Washington, USA unless no federal subject matter jurisdiction exists, in which case the parties consent to exclusive jurisdiction and venue in the Superior Court of King County, Washington, USA. The parties waive all defenses of lack of personal jurisdiction and forum non-conveniens.

## 10. Entire Agreement/Assignment.

This Agreement is the entire agreement between the parties, and supersedes any and all prior agreements, understandings or communications, written or oral, between the parties relating to the subject matter hereof. This Agreement may be assigned by TerraPower.

Please select one of the options below and sign as indicated. By signing, You accept and agree to the terms of this Contribution License Agreement for Your present and future Submissions to TerraPower.
9 changes: 0 additions & 9 deletions armi/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@
This module defines the :py:class:`App` class, which is used to configure the ARMI
Framework for a specific application. An ``App`` implements a simple interface for
customizing much of the Framework's behavior.
Notes
-----
Historical Fun Fact
This pattern is used by many frameworks as a way of encapsulating what would otherwise be global
state. The ARMI Framework has historically made heavy use of global state (e.g.,
:py:mod:`armi.nucDirectory.nuclideBases`), and it will take quite a bit of effort to refactor the
code to access such things through an App object.
"""
# ruff: noqa: E402
import collections
Expand Down
2 changes: 0 additions & 2 deletions armi/bookkeeping/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@

# re-export package components for easier import
from armi.bookkeeping.db.database import Database
from armi.bookkeeping.db.database3 import Database3
from armi.bookkeeping.db.databaseInterface import DatabaseInterface
from armi.bookkeeping.db.factory import databaseFactory

__all__ = [
"Database",
"Database3",
"DatabaseInterface",
"compareDatabases",
"databaseFactory",
Expand Down
22 changes: 12 additions & 10 deletions armi/bookkeeping/db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,16 +914,18 @@ def _compose(self, comps, cs, parent=None):

return comp

def _writeParams(self, h5group, comps) -> tuple:
def _getShape(arr: [np.ndarray, List, Tuple]):
"""Get the shape of a np.ndarray, list, or tuple."""
if isinstance(arr, np.ndarray):
return arr.shape
elif isinstance(arr, (list, tuple)):
return (len(arr),)
else:
return (1,)
@staticmethod
def _getArrayShape(arr: [np.ndarray, List, Tuple]):
"""Get the shape of a np.ndarray, list, or tuple."""
if isinstance(arr, np.ndarray):
return arr.shape
elif isinstance(arr, (list, tuple)):
return (len(arr),)
else:
# not a list, tuple, or array (likely int, float, or None)
return 1

def _writeParams(self, h5group, comps) -> tuple:
c = comps[0]
groupName = c.__class__.__name__
if groupName not in h5group:
Expand Down Expand Up @@ -969,7 +971,7 @@ def _getShape(arr: [np.ndarray, List, Tuple]):
else:
# check if temp is a jagged array
if any(isinstance(x, (np.ndarray, list)) for x in temp):
jagged = len(set([_getShape(x) for x in temp])) != 1
jagged = len(set([self._getArrayShape(x) for x in temp])) != 1
else:
jagged = False
data = (
Expand Down
27 changes: 0 additions & 27 deletions armi/bookkeeping/db/database3.py

This file was deleted.

1 change: 1 addition & 0 deletions armi/bookkeeping/db/passiveDBLoadPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class PassThroughYamlize(yamlize.Object):

@classmethod
def from_yaml(cls, loader, node, round_trip_data=None):
node.value = []
return yamlize.Object.from_yaml.__func__(
PassThroughYamlize, loader, node, round_trip_data
)
Expand Down
14 changes: 14 additions & 0 deletions armi/bookkeeping/db/tests/test_database3.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import numpy as np

from armi.bookkeeping.db import _getH5File, database, loadOperator
from armi.bookkeeping.db.database import Database
from armi.bookkeeping.db.databaseInterface import DatabaseInterface
from armi.bookkeeping.db.jaggedArray import JaggedArray
from armi.reactor import parameters
Expand Down Expand Up @@ -283,6 +284,19 @@ def _compareRoundTrip(self, data):
roundTrip = database.unpackSpecialData(packed, attrs, "testing")
self._compareArrays(data, roundTrip)

def test_getArrayShape(self):
"""Tests a helper method for ``_writeParams``."""
base = [1, 2, 3, 4]
self.assertEqual(Database._getArrayShape(base), (4,))
self.assertEqual(Database._getArrayShape(tuple(base)), (4,))
arr = np.array(base)
self.assertEqual(Database._getArrayShape(arr), (4,))
arr = np.array([base])
self.assertEqual(Database._getArrayShape(arr), (1, 4))
# not array type
self.assertEqual(Database._getArrayShape(1), 1)
self.assertEqual(Database._getArrayShape(None), 1)

def test_writeToDB(self):
"""Test writing to the database.
Expand Down
110 changes: 110 additions & 0 deletions armi/bookkeeping/db/tests/test_passiveDBLoadPlugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright 2025 TerraPower, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Provides functionality for testing the PassiveDBLoadPlugin."""
import unittest
from copy import deepcopy
from io import StringIO

from ruamel.yaml.cyaml import CLoader
from ruamel.yaml.nodes import MappingNode, ScalarNode

from armi import context, getApp
from armi.bookkeeping.db.passiveDBLoadPlugin import (
PassiveDBLoadPlugin,
PassThroughYamlize,
)
from armi.reactor.blocks import Block


class TestPassiveDBLoadPlugin(unittest.TestCase):
def setUp(self):
"""
Manipulate the standard App. We can't just configure our own, since the
pytest environment bleeds between tests.
"""
self.app = getApp()
self._backupApp = deepcopy(self.app)

def tearDown(self):
"""Restore the App to its original state."""
import armi

armi._app = self._backupApp
context.APP_NAME = "armi"

def test_passiveDBLoadPlugin(self):
plug = PassiveDBLoadPlugin()

# default case
bpSections = plug.defineBlueprintsSections()
self.assertEqual(len(bpSections), 0)
params = plug.defineParameters()
self.assertEqual(len(params), 0)

# non-empty cases
PassiveDBLoadPlugin.SKIP_BP_SECTIONS = ["hi", "mom"]
PassiveDBLoadPlugin.UNKNOWN_PARAMS = {Block: ["fake1", "fake2"]}
bpSections = plug.defineBlueprintsSections()
self.assertEqual(len(bpSections), 2)
self.assertTrue(type(bpSections[0]), tuple)
self.assertEqual(bpSections[0][0], "hi")
self.assertTrue(type(bpSections[1]), tuple)
self.assertEqual(bpSections[1][0], "mom")
params = plug.defineParameters()
self.assertEqual(len(params), 1)
self.assertIn(Block, params)


class TestPassThroughYamlize(unittest.TestCase):
def test_passThroughYamlizeExample1(self):
# create node from known BP-style YAML object
node = MappingNode(
"test_passThroughYamlizeExample1",
[
(
ScalarNode(tag="tag:yaml.org,2002:str", value="core-wide"),
MappingNode(
tag="tag:yaml.org,2002:map",
value=[
(
ScalarNode(
tag="tag:yaml.org,2002:str",
value="fuel axial expansion",
),
ScalarNode(tag="tag:yaml.org,2002:bool", value="False"),
),
(
ScalarNode(
tag="tag:yaml.org,2002:str",
value="grid plate radial expansion",
),
ScalarNode(tag="tag:yaml.org,2002:bool", value="True"),
),
],
),
)
],
)

# test that node is non-zero and has the "core-wide" section
self.assertEqual(node.value[0][0].value, "core-wide")

# pass the YAML string through the known YAML
pty = PassThroughYamlize()
loader = CLoader(StringIO(""))
_p = pty.from_yaml(loader, node)

# prove the section has been cleared
self.assertEqual(len(node.value), 0)
4 changes: 3 additions & 1 deletion armi/bookkeeping/report/reportingUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
Operator_WorkingDirectory = "Working Directory:"
Operator_CurrentUser = "Current User:"
Operator_PythonInterperter = "Python Interpreter:"
Operator_PythonExecutable = "Python Executable:"
Operator_ArmiCodebase = "ARMI Location:"
Operator_MasterMachine = "Master Machine:"
Operator_Date = "Date and Time:"
Expand All @@ -77,6 +78,7 @@ def _writeCaseInformation(o, cs):
(Operator_ArmiCodebase, context.ROOT),
(Operator_WorkingDirectory, os.getcwd()),
(Operator_PythonInterperter, sys.version),
(Operator_PythonExecutable, sys.executable),
(Operator_MasterMachine, getNodeName()),
(Operator_NumProcessors, context.MPI_SIZE),
(Operator_Date, context.START_TIME),
Expand Down Expand Up @@ -352,7 +354,7 @@ def _getSystemInfoLinux():
return ""

# get processor information
linuxProcCommands = ["cat /proc/cpuinfo", "lscpu", "lshw -class CPU"]
linuxProcCommands = ["lscpu", "cat /proc/cpuinfo", "lshw -class CPU"]
procInfo = ""
for cmd in linuxProcCommands:
procInfo = subprocess.run(
Expand Down
1 change: 1 addition & 0 deletions armi/bookkeeping/report/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def test_writeWelcomeHeaders(self):
self.assertIn("Case Info", mock.getStdout())
self.assertIn("Input File Info", mock.getStdout())
self.assertIn("crossSectionControl-DA", mock.getStdout())
self.assertIn("Python Executable", mock.getStdout())
self.assertIn(randoFile, mock.getStdout())


Expand Down
2 changes: 1 addition & 1 deletion armi/mpiActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def invokeHook(self):
actionResult = None
try:
action = mpiComm.scatter(self._actions, root=0)
# create a new communicator that only has these specific dudes running
# create a new communicator that only has these specific processes running
hasAction = action is not None
context.MPI_COMM = mpiComm.Split(int(hasAction))
context.MPI_RANK = context.MPI_COMM.Get_rank()
Expand Down
5 changes: 3 additions & 2 deletions armi/nuclearDataIO/cccc/isotxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,9 @@ def _getScatterMatrix(self, blockNumIndex):
"""
Get the scatter matrix for a particular blockNum.
Note: This is stupid and the logic should be combined with _setScatterMatrix.
Please recommend a better way to do it during code review.
Notes
-----
This logic could be combined with _setScatterMatrix.
"""
if blockNumIndex == self._getElasticScatterBlockNumIndex():
scatterMatrix = self._getMicros().elasticScatter
Expand Down
Loading

0 comments on commit bc68590

Please sign in to comment.