diff --git a/.github/workflows/validatemanifest.py b/.github/workflows/validatemanifest.py index 2e1fd901a..cb2978e46 100644 --- a/.github/workflows/validatemanifest.py +++ b/.github/workflows/validatemanifest.py @@ -18,8 +18,9 @@ Validate that we aren't trying to include files that don't exist. """ -from glob import glob import os +from glob import glob + import toml # CONSTANTS diff --git a/armi/__init__.py b/armi/__init__.py index 7a3eadc52..874ddf84f 100644 --- a/armi/__init__.py +++ b/armi/__init__.py @@ -51,8 +51,10 @@ import subprocess import sys import traceback -from typing import Optional, List, Type import warnings +from typing import List, Optional, Type + +import __main__ as main # The _bootstrap module performs operations that may need to occur before it is # necessarily safe to import the rest of the ARMI system. Things like: @@ -60,35 +62,26 @@ # - detect the nature of interaction with the user (terminal UI, GUI, unsupervized, etc) # - Initialize the nuclide database import armi._bootstrap -from armi import context +from armi import apps, cli, context, pluginManager, plugins, runLog from armi.context import ( - ROOT, - RES, - DOC, - USER, - START_TIME, + APP_DATA, CURRENT_MODE, + DOC, MPI_COMM, - MPI_RANK, + MPI_DISTRIBUTABLE, MPI_NODENAME, MPI_NODENAMES, - MPI_DISTRIBUTABLE, + MPI_RANK, MPI_SIZE, - APP_DATA, + RES, + ROOT, + START_TIME, + USER, + Mode, ) -from armi.context import Mode - -from armi import cli from armi.meta import __version__ -from armi import apps -from armi import pluginManager -from armi import plugins -from armi import runLog -from armi.reactor import flags -from armi.reactor import parameters from armi.nucDirectory import nuclideBases - -import __main__ as main +from armi.reactor import flags, parameters # ARMI does not configure its own application by default. This is mostly to catch issues # involving calling code that requires the framework to be configured before that has @@ -151,8 +144,7 @@ def init(choice=None, fName=None, cs=None, skipInspection=False): -------- >>> o = armi.init() """ - from armi import cases - from armi import settings + from armi import cases, settings if cs is None: if fName is None: @@ -178,12 +170,8 @@ def getDefaultPlugins() -> List[Type[plugins.ArmiPlugin]]: This is useful for an application to fold all of the ARMI Framework's capabilities into its own set of plugins. """ - from armi import cli - from armi import bookkeeping - from armi.physics import fuelCycle - from armi.physics import neutronics - from armi.physics import safety - from armi import reactor + from armi import bookkeeping, cli, reactor + from armi.physics import fuelCycle, neutronics, safety defaultPlugins = [ cli.EntryPointsPlugin, diff --git a/armi/__main__.py b/armi/__main__.py index 3389d548e..0a9c379f1 100644 --- a/armi/__main__.py +++ b/armi/__main__.py @@ -20,9 +20,7 @@ """ import sys -from armi import apps -from armi import configure, isConfigured -from armi import context +from armi import apps, configure, context, isConfigured from armi.cli import ArmiCLI diff --git a/armi/apps.py b/armi/apps.py index 22b620239..7d6263868 100644 --- a/armi/apps.py +++ b/armi/apps.py @@ -29,16 +29,15 @@ code to access such things through an App object. """ # ruff: noqa: E402 -from typing import Dict, Optional, Tuple, List import collections import importlib import sys +from typing import Dict, List, Optional, Tuple -from armi import context, plugins, pluginManager, meta, settings +from armi import context, meta, pluginManager, plugins, settings from armi.reactor import parameters from armi.reactor.flags import Flags -from armi.settings import fwSettings -from armi.settings import Setting +from armi.settings import Setting, fwSettings class App: @@ -85,14 +84,14 @@ def __init__(self): self.__initNewPlugins() def __initNewPlugins(self): - from armi import cli - from armi import bookkeeping - from armi.physics import fuelCycle - from armi.physics import fuelPerformance - from armi.physics import neutronics - from armi.physics import safety - from armi.physics import thermalHydraulics - from armi import reactor + from armi import bookkeeping, cli, reactor + from armi.physics import ( + fuelCycle, + fuelPerformance, + neutronics, + safety, + thermalHydraulics, + ) self._pm = plugins.getNewPluginManager() for plugin in ( diff --git a/armi/bookkeeping/__init__.py b/armi/bookkeeping/__init__.py index 00c8f149d..4a1b0bf7d 100644 --- a/armi/bookkeeping/__init__.py +++ b/armi/bookkeeping/__init__.py @@ -20,11 +20,13 @@ class BookkeepingPlugin(plugins.ArmiPlugin): @staticmethod @plugins.HOOKIMPL def exposeInterfaces(cs): + from armi.bookkeeping import ( + historyTracker, + mainInterface, + memoryProfiler, + snapshotInterface, + ) from armi.bookkeeping.db import databaseInterface - from armi.bookkeeping import historyTracker - from armi.bookkeeping import memoryProfiler - from armi.bookkeeping import mainInterface - from armi.bookkeeping import snapshotInterface from armi.bookkeeping.report import reportInterface interfaceInfo = [] @@ -75,8 +77,8 @@ def mpiActionRequiresReset(cmd) -> bool: -------- armi.operators.operatorMPI.OperatorMPI.workerOperate """ - from armi.bookkeeping import memoryProfiler from armi import mpiActions + from armi.bookkeeping import memoryProfiler if isinstance(cmd, mpiActions.MpiAction): for donotReset in ( diff --git a/armi/bookkeeping/db/__init__.py b/armi/bookkeeping/db/__init__.py index efc5f734a..5e2b9f421 100644 --- a/armi/bookkeeping/db/__init__.py +++ b/armi/bookkeeping/db/__init__.py @@ -62,15 +62,14 @@ import os from armi import runLog +from armi.bookkeeping.db.compareDB3 import compareDatabases # 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.compareDB3 import compareDatabases from armi.bookkeeping.db.factory import databaseFactory - __all__ = [ "Database", "Database3", diff --git a/armi/bookkeeping/db/compareDB3.py b/armi/bookkeeping/db/compareDB3.py index e71e4167e..ec64cab72 100644 --- a/armi/bookkeeping/db/compareDB3.py +++ b/armi/bookkeeping/db/compareDB3.py @@ -43,11 +43,11 @@ even if the code hasn't changed. """ -from typing import Sequence, Optional, Pattern, Tuple import collections import os import re import traceback +from typing import Optional, Pattern, Sequence, Tuple import h5py import numpy as np diff --git a/armi/bookkeeping/db/databaseInterface.py b/armi/bookkeeping/db/databaseInterface.py index 5e1e73ce9..fd5ebbd2b 100644 --- a/armi/bookkeeping/db/databaseInterface.py +++ b/armi/bookkeeping/db/databaseInterface.py @@ -21,25 +21,22 @@ import pathlib import time from typing import ( + MutableSequence, Optional, - Tuple, Sequence, - MutableSequence, + Tuple, ) -from armi import context -from armi import interfaces -from armi import runLog +from armi import context, interfaces, runLog from armi.bookkeeping.db.database import Database, getH5GroupName -from armi.reactor.parameters import parameterDefinitions +from armi.bookkeeping.db.typedefs import Histories, History from armi.reactor.composites import ArmiObject -from armi.bookkeeping.db.typedefs import History, Histories -from armi.utils import getPreviousTimeNode, getStepLengths +from armi.reactor.parameters import parameterDefinitions from armi.settings.fwSettings.databaseSettings import ( - CONF_SYNC_AFTER_WRITE, CONF_FORCE_DB_PARAMS, + CONF_SYNC_AFTER_WRITE, ) - +from armi.utils import getPreviousTimeNode, getStepLengths ORDER = interfaces.STACK_ORDER.BOOKKEEPING diff --git a/armi/bookkeeping/db/factory.py b/armi/bookkeeping/db/factory.py index 386e327a7..50cc51346 100644 --- a/armi/bookkeeping/db/factory.py +++ b/armi/bookkeeping/db/factory.py @@ -17,8 +17,8 @@ import h5py -from armi.bookkeeping.db.database import Database from armi.bookkeeping.db import permissions +from armi.bookkeeping.db.database import Database def databaseFactory(dbName: str, permission: str, version: Optional[str] = None): diff --git a/armi/bookkeeping/db/layout.py b/armi/bookkeeping/db/layout.py index e36cd0630..ff0671729 100644 --- a/armi/bookkeeping/db/layout.py +++ b/armi/bookkeeping/db/layout.py @@ -26,12 +26,12 @@ import collections from typing import ( + Any, + Dict, + List, Optional, Tuple, Type, - Dict, - Any, - List, ) import numpy as np @@ -41,8 +41,7 @@ from armi.reactor.components import Component from armi.reactor.composites import ArmiObject from armi.reactor.excoreStructure import ExcoreStructure -from armi.reactor.reactors import Core -from armi.reactor.reactors import Reactor +from armi.reactor.reactors import Core, Reactor # Here we store the Database version information. DB_MAJOR = 3 diff --git a/armi/bookkeeping/db/tests/test_comparedb3.py b/armi/bookkeeping/db/tests/test_comparedb3.py index 4eb5531d8..4bcb18fe2 100644 --- a/armi/bookkeeping/db/tests/test_comparedb3.py +++ b/armi/bookkeeping/db/tests/test_comparedb3.py @@ -19,17 +19,17 @@ import numpy as np from armi.bookkeeping.db.compareDB3 import ( - _compareSets, + DiffResults, + OutputWriter, _compareAuxData, + _compareSets, _diffSimpleData, _diffSpecialData, compareDatabases, - DiffResults, - OutputWriter, ) from armi.bookkeeping.db.databaseInterface import DatabaseInterface from armi.reactor.tests import test_reactors -from armi.tests import mockRunLogs, TEST_ROOT +from armi.tests import TEST_ROOT, mockRunLogs from armi.utils.directoryChangers import TemporaryDirectoryChanger diff --git a/armi/bookkeeping/db/tests/test_databaseInterface.py b/armi/bookkeeping/db/tests/test_databaseInterface.py index b65239237..a4c12ded4 100644 --- a/armi/bookkeeping/db/tests/test_databaseInterface.py +++ b/armi/bookkeeping/db/tests/test_databaseInterface.py @@ -21,9 +21,7 @@ from numpy.testing import assert_allclose, assert_equal from armi import __version__ as version -from armi import interfaces -from armi import runLog -from armi import settings +from armi import interfaces, runLog, settings from armi.bookkeeping.db.database import Database from armi.bookkeeping.db.databaseInterface import DatabaseInterface from armi.cases import case diff --git a/armi/bookkeeping/db/tests/test_layout.py b/armi/bookkeeping/db/tests/test_layout.py index 3769351d0..5acf5e4ed 100644 --- a/armi/bookkeeping/db/tests/test_layout.py +++ b/armi/bookkeeping/db/tests/test_layout.py @@ -16,8 +16,7 @@ import unittest from armi import context -from armi.bookkeeping.db import database -from armi.bookkeeping.db import layout +from armi.bookkeeping.db import database, layout from armi.reactor import grids from armi.utils.directoryChangers import TemporaryDirectoryChanger diff --git a/armi/bookkeeping/db/typedefs.py b/armi/bookkeeping/db/typedefs.py index a8cf505cd..e1ffd8990 100644 --- a/armi/bookkeeping/db/typedefs.py +++ b/armi/bookkeeping/db/typedefs.py @@ -12,12 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Dict, Tuple, Any +from typing import Any, Dict, Tuple from armi.reactor.composites import ArmiObject from armi.reactor.grids import LocationBase - # Return type for the getHistories() method # param time node value History = Dict[str, Dict[Tuple[int, int], Any]] diff --git a/armi/bookkeeping/historyTracker.py b/armi/bookkeeping/historyTracker.py index 4f5a6e752..0bf34e347 100644 --- a/armi/bookkeeping/historyTracker.py +++ b/armi/bookkeeping/historyTracker.py @@ -67,21 +67,19 @@ def getHistoryParams(self): See :ref:`detail-assems`. """ -from typing import TYPE_CHECKING import traceback +from typing import TYPE_CHECKING -from armi import interfaces -from armi import runLog -from armi import operators -from armi.reactor.flags import Flags +from armi import interfaces, operators, runLog from armi.reactor import grids +from armi.reactor.flags import Flags from armi.utils import tabulate ORDER = 2 * interfaces.STACK_ORDER.BEFORE + interfaces.STACK_ORDER.BOOKKEEPING if TYPE_CHECKING: - from armi.reactor.blocks import Block from armi.reactor.assemblies import Assembly + from armi.reactor.blocks import Block def describeInterfaces(cs): diff --git a/armi/bookkeeping/mainInterface.py b/armi/bookkeeping/mainInterface.py index 3689ec038..67b26e886 100644 --- a/armi/bookkeeping/mainInterface.py +++ b/armi/bookkeeping/mainInterface.py @@ -22,18 +22,15 @@ import os import re -from armi import context -from armi import interfaces -from armi import operators -from armi import runLog -from armi import utils +from armi import context, interfaces, operators, runLog, utils from armi.bookkeeping.db.database import Database -from armi.settings.fwSettings.globalSettings import CONF_COPY_FILES_FROM -from armi.settings.fwSettings.globalSettings import CONF_COPY_FILES_TO +from armi.settings.fwSettings.globalSettings import ( + CONF_COPY_FILES_FROM, + CONF_COPY_FILES_TO, +) from armi.utils import pathTools from armi.utils.customExceptions import InputError - ORDER = interfaces.STACK_ORDER.PREPROCESSING diff --git a/armi/bookkeeping/memoryProfiler.py b/armi/bookkeeping/memoryProfiler.py index f3b6106d4..302f2d462 100644 --- a/armi/bookkeeping/memoryProfiler.py +++ b/armi/bookkeeping/memoryProfiler.py @@ -36,15 +36,12 @@ https://pythonhosted.org/psutil/ https://docs.python.org/3/library/gc.html#gc.garbage """ -from os import cpu_count -from typing import Optional import gc import sys +from os import cpu_count +from typing import Optional -from armi import context -from armi import interfaces -from armi import mpiActions -from armi import runLog +from armi import context, interfaces, mpiActions, runLog from armi.reactor.composites import ArmiObject from armi.utils import tabulate from armi.utils.customExceptions import NonexistentSetting diff --git a/armi/bookkeeping/report/newReportUtils.py b/armi/bookkeeping/report/newReportUtils.py index 98c14bf92..e7f2adb45 100644 --- a/armi/bookkeeping/report/newReportUtils.py +++ b/armi/bookkeeping/report/newReportUtils.py @@ -13,6 +13,7 @@ # limitations under the License. import collections import os + import numpy as np from armi import runLog @@ -22,12 +23,12 @@ from armi.reactor.components import component from armi.reactor.flags import Flags from armi.utils import ( - units, - plotting, - iterables, getAvailabilityFactors, getCycleLengths, getStepLengths, + iterables, + plotting, + units, ) @@ -294,8 +295,7 @@ def _setGeneralCoreParametersData(core, cs, coreDesignTable): def _setGeneralSimulationData(core, cs, coreDesignTable): - from armi.physics.neutronics.settings import CONF_GEN_XS - from armi.physics.neutronics.settings import CONF_GLOBAL_FLUX_ACTIVE + from armi.physics.neutronics.settings import CONF_GEN_XS, CONF_GLOBAL_FLUX_ACTIVE coreDesignTable.addRow([" ", ""]) coreDesignTable.addRow(["Full Core Model", "{}".format(core.isFullCore)]) @@ -411,8 +411,7 @@ def insertSettingsData(cs, report): report: ReportContent The report to be added to """ - from armi.physics.neutronics.settings import CONF_GEN_XS - from armi.physics.neutronics.settings import CONF_NEUTRONICS_KERNEL + from armi.physics.neutronics.settings import CONF_GEN_XS, CONF_NEUTRONICS_KERNEL report[COMPREHENSIVE_REPORT][CASE_PARAMETERS] = newReports.Table("Case Parameters") report[COMPREHENSIVE_REPORT][REACTOR_PARAMS] = newReports.Table( diff --git a/armi/bookkeeping/report/reportInterface.py b/armi/bookkeeping/report/reportInterface.py index 0105f70bb..46940fb12 100644 --- a/armi/bookkeeping/report/reportInterface.py +++ b/armi/bookkeeping/report/reportInterface.py @@ -20,16 +20,13 @@ """ import re -from armi import interfaces -from armi import runLog +from armi import interfaces, runLog from armi.bookkeeping import report from armi.bookkeeping.report import reportingUtils from armi.physics import neutronics from armi.physics.neutronics.settings import CONF_NEUTRONICS_TYPE from armi.reactor.flags import Flags -from armi.utils import directoryChangers -from armi.utils import reportPlotting -from armi.utils import units +from armi.utils import directoryChangers, reportPlotting, units ORDER = interfaces.STACK_ORDER.BEFORE + interfaces.STACK_ORDER.BOOKKEEPING diff --git a/armi/bookkeeping/report/reportingUtils.py b/armi/bookkeeping/report/reportingUtils.py index 9ac13287c..1378efdf7 100644 --- a/armi/bookkeeping/report/reportingUtils.py +++ b/armi/bookkeeping/report/reportingUtils.py @@ -16,7 +16,6 @@ A collection of miscellaneous functions used by ReportInterface to generate various reports. """ -from copy import copy import collections import os import pathlib @@ -25,23 +24,23 @@ import sys import textwrap import time +from copy import copy import numpy as np -from armi import context -from armi import interfaces -from armi import runLog +from armi import context, interfaces, runLog from armi.bookkeeping import report from armi.operators import RunTypes from armi.reactor.components import ComponentType from armi.reactor.flags import Flags -from armi.utils import getFileSHA1Hash -from armi.utils import iterables -from armi.utils import plotting -from armi.utils import tabulate -from armi.utils import textProcessors -from armi.utils import units - +from armi.utils import ( + getFileSHA1Hash, + iterables, + plotting, + tabulate, + textProcessors, + units, +) # Set to prevent the image and text from being too small to read. MAX_ASSEMS_PER_ASSEM_PLOT = 6 @@ -970,8 +969,7 @@ def _setGeneralCoreParametersData(core, cs, coreDesignTable): def _setGeneralSimulationData(core, cs, coreDesignTable): - from armi.physics.neutronics.settings import CONF_GEN_XS - from armi.physics.neutronics.settings import CONF_GLOBAL_FLUX_ACTIVE + from armi.physics.neutronics.settings import CONF_GEN_XS, CONF_GLOBAL_FLUX_ACTIVE report.setData(" ", "", coreDesignTable, report.DESIGN) report.setData( diff --git a/armi/bookkeeping/report/tests/test_newReport.py b/armi/bookkeeping/report/tests/test_newReport.py index bf11ecf2c..3337cc351 100644 --- a/armi/bookkeeping/report/tests/test_newReport.py +++ b/armi/bookkeeping/report/tests/test_newReport.py @@ -20,12 +20,10 @@ import htmltree from armi import getPluginManagerOrFail -from armi.bookkeeping.report import data -from armi.bookkeeping.report import newReports +from armi.bookkeeping.report import data, newReports from armi.physics.neutronics.reports import neutronicsPlotting from armi.reactor.tests import test_reactors -from armi.tests import mockRunLogs -from armi.tests import TEST_ROOT +from armi.tests import TEST_ROOT, mockRunLogs from armi.utils.directoryChangers import TemporaryDirectoryChanger diff --git a/armi/bookkeeping/report/tests/test_report.py b/armi/bookkeeping/report/tests/test_report.py index 7499cd8a8..b395781d6 100644 --- a/armi/bookkeeping/report/tests/test_report.py +++ b/armi/bookkeeping/report/tests/test_report.py @@ -13,13 +13,13 @@ # limitations under the License. """Really basic tests of the report Utils.""" -from glob import glob -from unittest.mock import patch import logging import os import subprocess import sys import unittest +from glob import glob +from unittest.mock import patch from armi import runLog, settings from armi.bookkeeping import report diff --git a/armi/bookkeeping/snapshotInterface.py b/armi/bookkeeping/snapshotInterface.py index 087c0a6b9..1ef75c8a8 100644 --- a/armi/bookkeeping/snapshotInterface.py +++ b/armi/bookkeeping/snapshotInterface.py @@ -27,12 +27,9 @@ Snapshots can be requested through the settings: ``dumpSnapshot`` and/or ``defaultSnapshots``. """ -from armi import interfaces -from armi import operators -from armi import runLog +from armi import interfaces, operators, runLog from armi.utils import getStepLengths - ORDER = interfaces.STACK_ORDER.POSTPROCESSING diff --git a/armi/bookkeeping/tests/_constants.py b/armi/bookkeeping/tests/_constants.py index 8002d27ec..28f28041e 100644 --- a/armi/bookkeeping/tests/_constants.py +++ b/armi/bookkeeping/tests/_constants.py @@ -22,7 +22,6 @@ from armi.tests import TEST_ROOT - # These files are needed to run the data_model ipython notebook, which is done in # test_historyTracker, and when building the docs. TUTORIAL_FILES = [ diff --git a/armi/bookkeeping/tests/test_historyTracker.py b/armi/bookkeeping/tests/test_historyTracker.py index e27a92395..a9d5afdc6 100644 --- a/armi/bookkeeping/tests/test_historyTracker.py +++ b/armi/bookkeeping/tests/test_historyTracker.py @@ -24,14 +24,12 @@ import shutil import unittest -from armi import settings -from armi import utils +from armi import settings, utils from armi.bookkeeping import historyTracker from armi.bookkeeping.tests._constants import TUTORIAL_FILES from armi.cases import case from armi.context import ROOT -from armi.reactor import blocks -from armi.reactor import grids +from armi.reactor import blocks, grids from armi.reactor.flags import Flags from armi.tests import ArmiTestHelper from armi.utils.directoryChangers import TemporaryDirectoryChanger diff --git a/armi/bookkeeping/tests/test_memoryProfiler.py b/armi/bookkeeping/tests/test_memoryProfiler.py index 497fb3a64..d32adf185 100644 --- a/armi/bookkeeping/tests/test_memoryProfiler.py +++ b/armi/bookkeeping/tests/test_memoryProfiler.py @@ -13,9 +13,9 @@ # limitations under the License. """Tests for memoryProfiler.""" -from unittest.mock import MagicMock, patch import logging import unittest +from unittest.mock import MagicMock, patch from armi import runLog from armi.bookkeeping import memoryProfiler @@ -24,7 +24,7 @@ getTotalJobMemory, ) from armi.reactor.tests import test_reactors -from armi.tests import mockRunLogs, TEST_ROOT +from armi.tests import TEST_ROOT, mockRunLogs class TestMemoryProfiler(unittest.TestCase): diff --git a/armi/bookkeeping/visualization/entryPoint.py b/armi/bookkeeping/visualization/entryPoint.py index 13d919951..7a677721e 100644 --- a/armi/bookkeeping/visualization/entryPoint.py +++ b/armi/bookkeeping/visualization/entryPoint.py @@ -127,9 +127,8 @@ def parse(self, args): def invoke(self): # late imports so that we dont have to import the world to do anything - from armi.bookkeeping.visualization import vtk - from armi.bookkeeping.visualization import xdmf from armi.bookkeeping.db import databaseFactory + from armi.bookkeeping.visualization import vtk, xdmf # a little baroque, but easy to extend with future formats formatMap = { diff --git a/armi/bookkeeping/visualization/tests/test_vis.py b/armi/bookkeeping/visualization/tests/test_vis.py index c53dae864..050357280 100644 --- a/armi/bookkeeping/visualization/tests/test_vis.py +++ b/armi/bookkeeping/visualization/tests/test_vis.py @@ -20,11 +20,8 @@ from armi import settings from armi.bookkeeping.db import Database -from armi.bookkeeping.visualization import utils -from armi.bookkeeping.visualization import vtk -from armi.bookkeeping.visualization import xdmf -from armi.reactor import blocks -from armi.reactor import components +from armi.bookkeeping.visualization import utils, vtk, xdmf +from armi.reactor import blocks, components from armi.reactor.tests import test_reactors from armi.utils.directoryChangers import TemporaryDirectoryChanger diff --git a/armi/bookkeeping/visualization/utils.py b/armi/bookkeeping/visualization/utils.py index c692afeeb..eabafd020 100644 --- a/armi/bookkeeping/visualization/utils.py +++ b/armi/bookkeeping/visualization/utils.py @@ -26,12 +26,9 @@ from pyevtk.hl import unstructuredGridToVTK from pyevtk.vtk import VtkHexahedron, VtkQuadraticHexahedron -from armi.reactor import assemblies -from armi.reactor import reactors -from armi.reactor import blocks +from armi.reactor import assemblies, blocks, reactors from armi.utils import hexagon - # The hex prism cell type is not very well-documented, and so is not described in # pyevtk. Digging into the header reveals that `16` does the trick. _HEX_PRISM_TID = 16 diff --git a/armi/bookkeeping/visualization/vtk.py b/armi/bookkeeping/visualization/vtk.py index f5b382f66..5a4a30013 100644 --- a/armi/bookkeeping/visualization/vtk.py +++ b/armi/bookkeeping/visualization/vtk.py @@ -28,20 +28,15 @@ wouldn't be too difficult to do here either. Also future work, but probably not super important unless dealing with really big meshes. """ -from typing import Dict, Any, List, Optional, Set, Tuple +from typing import Any, Dict, List, Optional, Set, Tuple import numpy as np from pyevtk.vtk import VtkGroup from armi import runLog from armi.bookkeeping.db import database -from armi.bookkeeping.visualization import dumper -from armi.bookkeeping.visualization import utils -from armi.reactor import assemblies -from armi.reactor import blocks -from armi.reactor import composites -from armi.reactor import parameters -from armi.reactor import reactors +from armi.bookkeeping.visualization import dumper, utils +from armi.reactor import assemblies, blocks, composites, parameters, reactors class VtkDumper(dumper.VisFileDumper): diff --git a/armi/bookkeeping/visualization/xdmf.py b/armi/bookkeeping/visualization/xdmf.py index c912bba21..566816952 100644 --- a/armi/bookkeeping/visualization/xdmf.py +++ b/armi/bookkeeping/visualization/xdmf.py @@ -39,22 +39,17 @@ import io import math import pathlib -from typing import Optional, Set, List, Tuple, Dict -import xml.etree.ElementTree as ET import xml.dom.minidom +import xml.etree.ElementTree as ET +from typing import Dict, List, Optional, Set, Tuple -import numpy as np import h5py +import numpy as np from armi import runLog -from armi.reactor import assemblies -from armi.reactor import composites -from armi.reactor import reactors -from armi.reactor import blocks from armi.bookkeeping.db import database -from armi.bookkeeping.visualization import dumper -from armi.bookkeeping.visualization import utils - +from armi.bookkeeping.visualization import dumper, utils +from armi.reactor import assemblies, blocks, composites, reactors _VTK_TO_XDMF_CELLS = {16: 16} diff --git a/armi/cases/case.py b/armi/cases/case.py index 588b020c4..05eeb3ce1 100644 --- a/armi/cases/case.py +++ b/armi/cases/case.py @@ -24,7 +24,6 @@ -------- armi.cases.suite : A collection of Cases """ -from typing import Dict, Optional, Sequence, Set, Union import ast import cProfile import glob @@ -37,28 +36,22 @@ import textwrap import time import trace +from typing import Dict, Optional, Sequence, Set, Union import coverage -from armi import context -from armi import getPluginManager -from armi import interfaces -from armi import operators -from armi import runLog -from armi import settings +from armi import context, getPluginManager, interfaces, operators, runLog, settings from armi.bookkeeping.db import compareDatabases from armi.cli import reportsEntryPoint from armi.nucDirectory import nuclideBases from armi.physics.neutronics.settings import CONF_LOADING_FILE -from armi.reactor import blueprints -from armi.reactor import reactors -from armi.reactor import systemLayoutInput -from armi.utils import pathTools -from armi.utils import tabulate -from armi.utils import textProcessors +from armi.reactor import blueprints, reactors, systemLayoutInput +from armi.utils import pathTools, tabulate, textProcessors from armi.utils.customExceptions import NonexistentSetting -from armi.utils.directoryChangers import DirectoryChanger -from armi.utils.directoryChangers import ForcedCreationDirectoryChanger +from armi.utils.directoryChangers import ( + DirectoryChanger, + ForcedCreationDirectoryChanger, +) # Change from default .coverage to help with Windows dotfile issues. # Must correspond with data_file entry in `pyproject.toml`! diff --git a/armi/cases/inputModifiers/tests/test_inputModifiers.py b/armi/cases/inputModifiers/tests/test_inputModifiers.py index d711275aa..cb03835a4 100644 --- a/armi/cases/inputModifiers/tests/test_inputModifiers.py +++ b/armi/cases/inputModifiers/tests/test_inputModifiers.py @@ -12,20 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. """Unit tests for input modifiers.""" -from ruamel import yaml import io import os import unittest -from armi import cases -from armi import settings +from ruamel import yaml + +from armi import cases, settings from armi.cases import suiteBuilder -from armi.reactor import blueprints -from armi.reactor import systemLayoutInput -from armi.utils import directoryChangers from armi.cases.inputModifiers import ( - neutronicsModifiers, inputModifiers, + neutronicsModifiers, pinTypeInputModifiers, ) from armi.physics.neutronics.fissionProductModel.fissionProductModelSettings import ( @@ -36,7 +33,9 @@ CONF_EPS_FSAVG, CONF_EPS_FSPOINT, ) +from armi.reactor import blueprints, systemLayoutInput from armi.reactor.tests import test_reactors +from armi.utils import directoryChangers class MockGeom: diff --git a/armi/cases/suite.py b/armi/cases/suite.py index 222e2397c..6b580e9ec 100644 --- a/armi/cases/suite.py +++ b/armi/cases/suite.py @@ -28,14 +28,12 @@ armi.cases.case : An individual item of a case suite. """ import os -from typing import Optional, Sequence import traceback +from typing import Optional, Sequence -from armi import runLog -from armi import settings +from armi import runLog, settings from armi.cases import case as armicase -from armi.utils import directoryChangers -from armi.utils import tabulate +from armi.utils import directoryChangers, tabulate class CaseSuite: diff --git a/armi/cases/suiteBuilder.py b/armi/cases/suiteBuilder.py index fd846086d..47d475bd1 100644 --- a/armi/cases/suiteBuilder.py +++ b/armi/cases/suiteBuilder.py @@ -25,12 +25,13 @@ of how you can modify inputs for parameter sweeping. Power-users will generally make their own ``Modifier``\ s that are design-specific. """ -from collections import Counter -from pyDOE import lhs -from typing import List import copy import os import random +from collections import Counter +from typing import List + +from pyDOE import lhs from armi.cases import suite diff --git a/armi/cases/tests/test_cases.py b/armi/cases/tests/test_cases.py index b04c9fcdd..9347e1616 100644 --- a/armi/cases/tests/test_cases.py +++ b/armi/cases/tests/test_cases.py @@ -22,24 +22,14 @@ import h5py -from armi import cases -from armi import context -from armi import getApp -from armi import interfaces -from armi import plugins -from armi import runLog -from armi import settings +from armi import cases, context, getApp, interfaces, plugins, runLog, settings from armi.bookkeeping.db.databaseInterface import DatabaseInterface from armi.physics.fuelCycle.settings import CONF_SHUFFLE_LOGIC -from armi.reactor import blueprints -from armi.reactor import systemLayoutInput +from armi.reactor import blueprints, systemLayoutInput from armi.reactor.tests import test_reactors -from armi.tests import ARMI_RUN_PATH -from armi.tests import mockRunLogs -from armi.tests import TEST_ROOT +from armi.tests import ARMI_RUN_PATH, TEST_ROOT, mockRunLogs from armi.utils import directoryChangers - GEOM_INPUT = """ diff --git a/armi/cases/tests/test_suiteBuilder.py b/armi/cases/tests/test_suiteBuilder.py index 81c94c639..eab1f618c 100644 --- a/armi/cases/tests/test_suiteBuilder.py +++ b/armi/cases/tests/test_suiteBuilder.py @@ -18,12 +18,12 @@ from armi import cases, settings from armi.cases.inputModifiers.inputModifiers import ( - SamplingInputModifier, InputModifier, + SamplingInputModifier, ) from armi.cases.suiteBuilder import ( - LatinHyperCubeSuiteBuilder, FullFactorialSuiteBuilder, + LatinHyperCubeSuiteBuilder, SeparateEffectsSuiteBuilder, ) diff --git a/armi/cli/__init__.py b/armi/cli/__init__.py index dd46f65c2..2e496f413 100644 --- a/armi/cli/__init__.py +++ b/armi/cli/__init__.py @@ -45,10 +45,7 @@ import textwrap from typing import Optional -from armi import context -from armi import meta -from armi import plugins -from armi import runLog +from armi import context, meta, plugins, runLog class EntryPointsPlugin(plugins.ArmiPlugin): @@ -57,16 +54,16 @@ class EntryPointsPlugin(plugins.ArmiPlugin): def defineEntryPoints(): from armi.cli import ( checkInputs, + # testing + cleanTemps, clone, compareCases, + gridGui, migrateInputs, modify, + reportsEntryPoint, run, - gridGui, - # testing - cleanTemps, runSuite, - reportsEntryPoint, ) entryPoints = [] diff --git a/armi/cli/database.py b/armi/cli/database.py index bf33e20ee..df55db474 100644 --- a/armi/cli/database.py +++ b/armi/cli/database.py @@ -16,8 +16,7 @@ import os import pathlib -from armi import context -from armi import runLog +from armi import context, runLog from armi.cli.entryPoint import EntryPoint from armi.utils.textProcessors import resolveMarkupInclusions diff --git a/armi/cli/gridGui.py b/armi/cli/gridGui.py index e99c82e6c..d02c5dd13 100644 --- a/armi/cli/gridGui.py +++ b/armi/cli/gridGui.py @@ -38,6 +38,7 @@ def invoke(self): # invoking the entry point try: import wx + from armi.utils import gridEditor except ImportError: raise RuntimeError( diff --git a/armi/cli/modify.py b/armi/cli/modify.py index 197f9f8bf..e1ed6bdaf 100644 --- a/armi/cli/modify.py +++ b/armi/cli/modify.py @@ -17,9 +17,7 @@ file(s). All valid settings may be used as keyword arguments. """ -from armi import operators -from armi import runLog -from armi import settings +from armi import operators, runLog, settings from armi.cli.entryPoint import EntryPoint diff --git a/armi/cli/reportsEntryPoint.py b/armi/cli/reportsEntryPoint.py index efb2802fc..12ca7eb25 100644 --- a/armi/cli/reportsEntryPoint.py +++ b/armi/cli/reportsEntryPoint.py @@ -17,8 +17,7 @@ from armi.bookkeeping.db import databaseFactory from armi.bookkeeping.report import newReports as reports from armi.cli import entryPoint -from armi.reactor import blueprints -from armi.reactor import reactors +from armi.reactor import blueprints, reactors from armi.utils.directoryChangers import ForcedCreationDirectoryChanger diff --git a/armi/cli/runSuite.py b/armi/cli/runSuite.py index 6df7d1e84..7bd38201e 100644 --- a/armi/cli/runSuite.py +++ b/armi/cli/runSuite.py @@ -15,8 +15,8 @@ """Run multiple ARMI cases one after the other on the local machine.""" import os -from armi.cli.run import RunEntryPoint from armi import cases +from armi.cli.run import RunEntryPoint from armi.utils import directoryChangers diff --git a/armi/cli/tests/test_runEntryPoint.py b/armi/cli/tests/test_runEntryPoint.py index 088937d2e..2094f6222 100644 --- a/armi/cli/tests/test_runEntryPoint.py +++ b/armi/cli/tests/test_runEntryPoint.py @@ -12,12 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. """Test for run cli entry point.""" -from glob import glob -from shutil import copyfile import logging import os import sys import unittest +from glob import glob +from shutil import copyfile from armi import runLog from armi.__main__ import main @@ -35,7 +35,7 @@ from armi.cli.runSuite import RunSuiteCommand from armi.physics.neutronics.diffIsotxs import CompareIsotxsLibraries from armi.testing import loadTestReactor, reduceTestReactorRings -from armi.tests import mockRunLogs, TEST_ROOT, ARMI_RUN_PATH +from armi.tests import ARMI_RUN_PATH, TEST_ROOT, mockRunLogs from armi.utils.directoryChangers import TemporaryDirectoryChanger from armi.utils.dynamicImporter import getEntireFamilyTree diff --git a/armi/context.py b/armi/context.py index dd959e350..8436ceae5 100644 --- a/armi/context.py +++ b/armi/context.py @@ -18,7 +18,6 @@ ARMI's global state information: operating system information, environment data, user data, memory parallelism, temporary storage locations, and if operational mode (interactive, gui, or batch). """ -from logging import DEBUG import datetime import enum import gc @@ -26,6 +25,7 @@ import os import sys import time +from logging import DEBUG # h5py needs to be imported here, so that the disconnectAllHdfDBs() call that gets bound to atexit # below doesn't lead to a segfault on python exit. @@ -38,10 +38,8 @@ # >>> import h5py # # >>> atexit.register(willSegFault) - import h5py # noqa: F401 - BLUEPRINTS_IMPORTED = False BLUEPRINTS_IMPORT_CONTEXT = "" diff --git a/armi/interfaces.py b/armi/interfaces.py index ee1c360ea..8f103ea43 100644 --- a/armi/interfaces.py +++ b/armi/interfaces.py @@ -24,16 +24,12 @@ armi.plugins : Register various interfaces """ import copy -from typing import Union -from typing import NamedTuple -from typing import List -from typing import Dict +from typing import Dict, List, NamedTuple, Union import numpy as np from numpy.linalg import norm -from armi import getPluginManagerOrFail, settings, utils -from armi import runLog +from armi import getPluginManagerOrFail, runLog, settings, utils from armi.reactor import parameters from armi.utils import textProcessors diff --git a/armi/materials/__init__.py b/armi/materials/__init__.py index e8f86261d..1078ade88 100644 --- a/armi/materials/__init__.py +++ b/armi/materials/__init__.py @@ -32,10 +32,10 @@ The base class for all materials is in :py:mod:`armi.materials.material`. """ -from typing import List import importlib import inspect import pkgutil +from typing import List from armi.materials.material import Material diff --git a/armi/materials/air.py b/armi/materials/air.py index 643a1d239..53a339bb3 100644 --- a/armi/materials/air.py +++ b/armi/materials/air.py @@ -14,7 +14,7 @@ """Simple air material.""" from armi.materials import material -from armi.utils.units import getTk, G_PER_CM3_TO_KG_PER_M3 +from armi.utils.units import G_PER_CM3_TO_KG_PER_M3, getTk class Air(material.Fluid): diff --git a/armi/materials/be9.py b/armi/materials/be9.py index 1467064b9..8b7122588 100644 --- a/armi/materials/be9.py +++ b/armi/materials/be9.py @@ -18,10 +18,10 @@ It has a nice (n,2n) reaction and is an inhalation hazard. """ -from armi.utils.units import getTk from armi.materials.material import Material -from armi.nucDirectory import thermalScattering as tsl from armi.nucDirectory import nuclideBases as nb +from armi.nucDirectory import thermalScattering as tsl +from armi.utils.units import getTk class Be9(Material): diff --git a/armi/materials/copper.py b/armi/materials/copper.py index 8ffb62217..c44815d29 100644 --- a/armi/materials/copper.py +++ b/armi/materials/copper.py @@ -14,8 +14,8 @@ """Copper metal.""" -from armi.utils.units import getTk from armi.materials.material import Material +from armi.utils.units import getTk class Cu(Material): diff --git a/armi/materials/graphite.py b/armi/materials/graphite.py index b7ac48141..0e7ec764f 100644 --- a/armi/materials/graphite.py +++ b/armi/materials/graphite.py @@ -15,9 +15,9 @@ """Graphite is often used as a moderator in gas-cooled nuclear reactors.""" from armi.materials.material import Material -from armi.utils import units -from armi.nucDirectory import thermalScattering as tsl from armi.nucDirectory import nuclideBases as nb +from armi.nucDirectory import thermalScattering as tsl +from armi.utils import units class Graphite(Material): diff --git a/armi/materials/hafnium.py b/armi/materials/hafnium.py index 709ec39d0..1694c1c57 100644 --- a/armi/materials/hafnium.py +++ b/armi/materials/hafnium.py @@ -14,8 +14,8 @@ """Hafnium is an element that has high capture cross section across multiple isotopes.""" -from armi.nucDirectory import nucDir from armi.materials.material import SimpleSolid +from armi.nucDirectory import nucDir class Hafnium(SimpleSolid): diff --git a/armi/materials/hastelloyN.py b/armi/materials/hastelloyN.py index fbbe1b2ce..dd60db465 100644 --- a/armi/materials/hastelloyN.py +++ b/armi/materials/hastelloyN.py @@ -15,7 +15,7 @@ """Hastelloy-N is a high-nickel structural material invented by ORNL for handling molten fluoride salts.""" from armi.materials.material import Material -from armi.utils.units import getTk, getTc +from armi.utils.units import getTc, getTk class HastelloyN(Material): diff --git a/armi/materials/material.py b/armi/materials/material.py index 362b66ece..06593dbe8 100644 --- a/armi/materials/material.py +++ b/armi/materials/material.py @@ -21,14 +21,14 @@ import traceback import warnings -from scipy.optimize import fsolve import numpy as np +from scipy.optimize import fsolve from armi import runLog from armi.nucDirectory import nuclideBases from armi.reactor.flags import TypeSpec from armi.utils import densityTools -from armi.utils.units import getTk, getTc +from armi.utils.units import getTc, getTk # globals FAIL_ON_RANGE = False diff --git a/armi/materials/mox.py b/armi/materials/mox.py index b2ab41700..61631a412 100644 --- a/armi/materials/mox.py +++ b/armi/materials/mox.py @@ -23,8 +23,8 @@ """ from armi import runLog -from armi.materials.uraniumOxide import UraniumOxide from armi.materials import material +from armi.materials.uraniumOxide import UraniumOxide from armi.nucDirectory import nucDir diff --git a/armi/materials/tests/test_materials.py b/armi/materials/tests/test_materials.py index 1b27df200..22b125f79 100644 --- a/armi/materials/tests/test_materials.py +++ b/armi/materials/tests/test_materials.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. """Tests materials.py.""" -from copy import deepcopy import math import pickle import unittest +from copy import deepcopy from numpy import testing diff --git a/armi/materials/tests/test_uZr.py b/armi/materials/tests/test_uZr.py index e2b4eb270..ddd5e67e1 100644 --- a/armi/materials/tests/test_uZr.py +++ b/armi/materials/tests/test_uZr.py @@ -13,8 +13,8 @@ # limitations under the License. """Tests for simplified UZr material.""" -from unittest import TestCase import pickle +from unittest import TestCase from armi.materials.uZr import UZr diff --git a/armi/materials/tests/test_water.py b/armi/materials/tests/test_water.py index d62c190c4..2756e433a 100644 --- a/armi/materials/tests/test_water.py +++ b/armi/materials/tests/test_water.py @@ -15,7 +15,7 @@ """Unit tests for water materials.""" import unittest -from armi.materials.water import SaturatedWater, SaturatedSteam, Water +from armi.materials.water import SaturatedSteam, SaturatedWater, Water class Test_Water(unittest.TestCase): diff --git a/armi/materials/thoriumOxide.py b/armi/materials/thoriumOxide.py index af5177c5b..28730a7c7 100644 --- a/armi/materials/thoriumOxide.py +++ b/armi/materials/thoriumOxide.py @@ -21,8 +21,8 @@ https://www-pub.iaea.org/mtcd/publications/pdf/te_1450_web.pdf """ from armi import runLog +from armi.materials.material import FuelMaterial, Material, SimpleSolid from armi.utils.units import getTk -from armi.materials.material import Material, FuelMaterial, SimpleSolid class ThoriumOxide(FuelMaterial, SimpleSolid): diff --git a/armi/materials/uThZr.py b/armi/materials/uThZr.py index 4e60c132c..0aaf27719 100644 --- a/armi/materials/uThZr.py +++ b/armi/materials/uThZr.py @@ -13,9 +13,9 @@ # limitations under the License. """Uranium Thorium Zirconium alloy metal.""" -from armi.utils.units import getTk -from armi.materials.material import FuelMaterial from armi import runLog +from armi.materials.material import FuelMaterial +from armi.utils.units import getTk class UThZr(FuelMaterial): diff --git a/armi/materials/uraniumOxide.py b/armi/materials/uraniumOxide.py index 64ce7f1b0..4d899df9b 100644 --- a/armi/materials/uraniumOxide.py +++ b/armi/materials/uraniumOxide.py @@ -32,7 +32,6 @@ from armi.nucDirectory import thermalScattering as tsl from armi.utils.units import getTk - HeatCapacityConstants = collections.namedtuple( "HeatCapacityConstants", ["c1", "c2", "c3", "theta", "Ea"] ) diff --git a/armi/migration/m0_1_3.py b/armi/migration/m0_1_3.py index 4e7f4ed49..10ce88910 100644 --- a/armi/migration/m0_1_3.py +++ b/armi/migration/m0_1_3.py @@ -15,8 +15,8 @@ import io import re -from armi.migration.base import BlueprintsMigration from armi import runLog +from armi.migration.base import BlueprintsMigration class RemoveCentersFromBlueprints(BlueprintsMigration): diff --git a/armi/migration/m0_1_6.py b/armi/migration/m0_1_6.py index 371dd2d65..0f19099ad 100644 --- a/armi/migration/m0_1_6.py +++ b/armi/migration/m0_1_6.py @@ -17,9 +17,8 @@ import re from armi import runLog -from armi.settings import caseSettings from armi.migration.base import SettingsMigration -from armi.settings import settingsIO +from armi.settings import caseSettings, settingsIO from armi.utils.units import ASCII_LETTER_A, ASCII_ZERO AXIAL_CHARS = [ diff --git a/armi/migration/tests/test_m0_1_6.py b/armi/migration/tests/test_m0_1_6.py index bb0931fdd..94df94c1e 100644 --- a/armi/migration/tests/test_m0_1_6.py +++ b/armi/migration/tests/test_m0_1_6.py @@ -17,7 +17,7 @@ from armi.migration.m0_1_6 import ConvertAlphanumLocationSettingsToNum from armi.settings import caseSettings -from armi.settings.settingsIO import SettingsWriter, SettingsReader +from armi.settings.settingsIO import SettingsReader, SettingsWriter class TestMigration(unittest.TestCase): diff --git a/armi/migration/tests/test_migration_base.py b/armi/migration/tests/test_migration_base.py index 67bffcc81..4fb532eac 100644 --- a/armi/migration/tests/test_migration_base.py +++ b/armi/migration/tests/test_migration_base.py @@ -15,8 +15,7 @@ import os import unittest -from armi.migration.base import Migration -from armi.migration.base import SettingsMigration +from armi.migration.base import Migration, SettingsMigration from armi.tests import TEST_ROOT diff --git a/armi/mpiActions.py b/armi/mpiActions.py index ca3fc9ca3..dbf0171cf 100644 --- a/armi/mpiActions.py +++ b/armi/mpiActions.py @@ -59,15 +59,10 @@ import pickle import timeit -from armi import context -from armi import interfaces -from armi import runLog -from armi import settings -from armi import utils +from armi import context, interfaces, runLog, settings, utils from armi.reactor import reactors from armi.reactor.parameters import parameterDefinitions -from armi.utils import iterables -from armi.utils import tabulate +from armi.utils import iterables, tabulate class MpiAction: diff --git a/armi/nucDirectory/elements.py b/armi/nucDirectory/elements.py index 35b33794c..a7669f5a2 100644 --- a/armi/nucDirectory/elements.py +++ b/armi/nucDirectory/elements.py @@ -130,8 +130,8 @@ def getAttributes(element): """ import os -from typing import List from enum import Enum +from typing import List from armi import context from armi.utils.units import HEAVY_METAL_CUTOFF_Z diff --git a/armi/nucDirectory/nuclideBases.py b/armi/nucDirectory/nuclideBases.py index 60490c3b9..d9e1130fc 100644 --- a/armi/nucDirectory/nuclideBases.py +++ b/armi/nucDirectory/nuclideBases.py @@ -97,11 +97,10 @@ class which is used to organize and store metadata about each nuclide. The import os -from ruamel.yaml import YAML import numpy as np +from ruamel.yaml import YAML -from armi import context -from armi import runLog +from armi import context, runLog from armi.nucDirectory import transmutations from armi.utils.units import HEAVY_METAL_CUTOFF_Z @@ -116,7 +115,6 @@ class which is used to organize and store metadata about each nuclide. The # together to maintain self-consistency. from armi.nucDirectory import elements # noqa: E402 - # Dictionary of INuclides by the INuclide.name for fast indexing byName = {} byDBName = {} diff --git a/armi/nucDirectory/tests/test_nuclideBases.py b/armi/nucDirectory/tests/test_nuclideBases.py index 0bfcafbb8..1ef1b5900 100644 --- a/armi/nucDirectory/tests/test_nuclideBases.py +++ b/armi/nucDirectory/tests/test_nuclideBases.py @@ -23,7 +23,7 @@ from armi.context import RES from armi.nucDirectory import nuclideBases from armi.nucDirectory.tests import NUCDIRECTORY_TESTS_DEFAULT_DIR_PATH -from armi.utils.units import SECONDS_PER_HOUR, AVOGADROS_NUMBER, CURIE_PER_BECQUEREL +from armi.utils.units import AVOGADROS_NUMBER, CURIE_PER_BECQUEREL, SECONDS_PER_HOUR class TestNuclide(unittest.TestCase): diff --git a/armi/nucDirectory/tests/test_thermalScattering.py b/armi/nucDirectory/tests/test_thermalScattering.py index e6e4d9291..a3b676365 100644 --- a/armi/nucDirectory/tests/test_thermalScattering.py +++ b/armi/nucDirectory/tests/test_thermalScattering.py @@ -16,8 +16,7 @@ from armi.nucDirectory import nuclideBases as nb from armi.nucDirectory import thermalScattering as ts -from armi.reactor import blocks -from armi.reactor import components +from armi.reactor import blocks, components def buildBlockWithTSL(): diff --git a/armi/nucDirectory/thermalScattering.py b/armi/nucDirectory/thermalScattering.py index ed0857f05..e53f4f9f3 100644 --- a/armi/nucDirectory/thermalScattering.py +++ b/armi/nucDirectory/thermalScattering.py @@ -55,9 +55,8 @@ """ from typing import Tuple, Union -from armi.nucDirectory import nuclideBases as nb from armi.nucDirectory import elements - +from armi.nucDirectory import nuclideBases as nb BE_METAL = "Be-metal" BEO = "BeO" diff --git a/armi/nuclearDataIO/__init__.py b/armi/nuclearDataIO/__init__.py index 89a2ca925..643cb9a2e 100644 --- a/armi/nuclearDataIO/__init__.py +++ b/armi/nuclearDataIO/__init__.py @@ -15,8 +15,6 @@ """Read and/or write data files associated with nuclear data and reactor physics data.""" # ruff: noqa: F401 -from armi.physics import neutronics - # export the cccc modules here to keep external clients happy, # though prefer full imports in new code from armi.nuclearDataIO.cccc import ( @@ -34,6 +32,7 @@ rtflux, rzflux, ) +from armi.physics import neutronics def getExpectedISOTXSFileName(cycle=None, node=None, suffix=None, xsID=None): diff --git a/armi/nuclearDataIO/cccc/compxs.py b/armi/nuclearDataIO/cccc/compxs.py index 99bf03114..0a65049f7 100644 --- a/armi/nuclearDataIO/cccc/compxs.py +++ b/armi/nuclearDataIO/cccc/compxs.py @@ -74,18 +74,18 @@ """ from traceback import format_exc -from scipy.sparse import csc_matrix import numpy as np +from scipy.sparse import csc_matrix from armi import runLog from armi.nuclearDataIO import cccc -from armi.nuclearDataIO.xsCollections import XSCollection from armi.nuclearDataIO.nuclearFileMetadata import ( - RegionXSMetadata, COMPXS_POWER_CONVERSION_FACTORS, REGIONXS_POWER_CONVERT_DIRECTIONAL_DIFF, + RegionXSMetadata, ) -from armi.utils.properties import unlockImmutableProperties, lockImmutableProperties +from armi.nuclearDataIO.xsCollections import XSCollection +from armi.utils.properties import lockImmutableProperties, unlockImmutableProperties def _getRegionIO(): diff --git a/armi/nuclearDataIO/cccc/dif3d.py b/armi/nuclearDataIO/cccc/dif3d.py index e5d8443ee..1ad9e14dd 100644 --- a/armi/nuclearDataIO/cccc/dif3d.py +++ b/armi/nuclearDataIO/cccc/dif3d.py @@ -20,7 +20,6 @@ from armi import runLog from armi.nuclearDataIO import cccc - FILE_SPEC_2D_PARAMS = ( [ "IPROBT", diff --git a/armi/nuclearDataIO/cccc/dlayxs.py b/armi/nuclearDataIO/cccc/dlayxs.py index 4364b92b1..58471bbc4 100644 --- a/armi/nuclearDataIO/cccc/dlayxs.py +++ b/armi/nuclearDataIO/cccc/dlayxs.py @@ -27,9 +27,7 @@ from armi import runLog from armi.nucDirectory import nuclideBases -from armi.nuclearDataIO import cccc -from armi.nuclearDataIO import nuclearFileMetadata - +from armi.nuclearDataIO import cccc, nuclearFileMetadata ALLOWED_NUCLIDE_CONTRIBUTION_ERROR = 1e-5 diff --git a/armi/nuclearDataIO/cccc/gamiso.py b/armi/nuclearDataIO/cccc/gamiso.py index 5c0b4132a..c203c244d 100644 --- a/armi/nuclearDataIO/cccc/gamiso.py +++ b/armi/nuclearDataIO/cccc/gamiso.py @@ -37,9 +37,8 @@ """ from armi import runLog +from armi.nuclearDataIO import xsLibraries, xsNuclides from armi.nuclearDataIO.cccc import isotxs -from armi.nuclearDataIO import xsLibraries -from armi.nuclearDataIO import xsNuclides def compare(lib1, lib2): diff --git a/armi/nuclearDataIO/cccc/isotxs.py b/armi/nuclearDataIO/cccc/isotxs.py index 69c7747a7..fd3a5f9ba 100644 --- a/armi/nuclearDataIO/cccc/isotxs.py +++ b/armi/nuclearDataIO/cccc/isotxs.py @@ -37,16 +37,14 @@ """ -import traceback import itertools +import traceback import numpy as np from scipy import sparse from armi import runLog -from armi.nuclearDataIO import cccc -from armi.nuclearDataIO import xsNuclides -from armi.nuclearDataIO import xsLibraries +from armi.nuclearDataIO import cccc, xsLibraries, xsNuclides from armi.utils import properties # scattering block definitions from ISOTXS diff --git a/armi/nuclearDataIO/cccc/pmatrx.py b/armi/nuclearDataIO/cccc/pmatrx.py index 2ae73ceff..de9cdee69 100644 --- a/armi/nuclearDataIO/cccc/pmatrx.py +++ b/armi/nuclearDataIO/cccc/pmatrx.py @@ -26,9 +26,7 @@ import traceback from armi import runLog -from armi.nuclearDataIO import cccc -from armi.nuclearDataIO import xsNuclides -from armi.nuclearDataIO import xsLibraries +from armi.nuclearDataIO import cccc, xsLibraries, xsNuclides from armi.utils import properties diff --git a/armi/nuclearDataIO/cccc/tests/test_fixsrc.py b/armi/nuclearDataIO/cccc/tests/test_fixsrc.py index 531b3036f..739a54d70 100644 --- a/armi/nuclearDataIO/cccc/tests/test_fixsrc.py +++ b/armi/nuclearDataIO/cccc/tests/test_fixsrc.py @@ -13,10 +13,11 @@ # limitations under the License. """Test the reading and writing of the DIF3D FIXSRC file format.""" -import numpy as np import os import unittest +import numpy as np + from armi.nuclearDataIO.cccc import fixsrc from armi.utils.directoryChangers import TemporaryDirectoryChanger diff --git a/armi/nuclearDataIO/cccc/tests/test_gamiso.py b/armi/nuclearDataIO/cccc/tests/test_gamiso.py index 6fd45bfa3..473b5a0b5 100644 --- a/armi/nuclearDataIO/cccc/tests/test_gamiso.py +++ b/armi/nuclearDataIO/cccc/tests/test_gamiso.py @@ -13,9 +13,9 @@ # limitations under the License. """Test GAMISO reading and writing.""" -from copy import deepcopy import os import unittest +from copy import deepcopy from armi.nuclearDataIO import xsLibraries from armi.nuclearDataIO.cccc import gamiso diff --git a/armi/nuclearDataIO/nuclearFileMetadata.py b/armi/nuclearDataIO/nuclearFileMetadata.py index 2e1ddb89a..be894c79b 100644 --- a/armi/nuclearDataIO/nuclearFileMetadata.py +++ b/armi/nuclearDataIO/nuclearFileMetadata.py @@ -24,7 +24,6 @@ from armi import runLog from armi.utils import properties - COMPXS_POWER_CONVERSION_FACTORS = ["fissionWattSeconds", "captureWattSeconds"] REGIONXS_POWER_CONVERT_DIRECTIONAL_DIFF = [ "powerConvMult", diff --git a/armi/nuclearDataIO/tests/test_xsCollections.py b/armi/nuclearDataIO/tests/test_xsCollections.py index 6a85e1734..a039c8bef 100644 --- a/armi/nuclearDataIO/tests/test_xsCollections.py +++ b/armi/nuclearDataIO/tests/test_xsCollections.py @@ -17,9 +17,8 @@ import unittest from armi import settings +from armi.nuclearDataIO import isotxs, xsCollections from armi.reactor.blocks import HexBlock -from armi.nuclearDataIO import isotxs -from armi.nuclearDataIO import xsCollections from armi.tests import ISOAA_PATH from armi.utils.directoryChangers import TemporaryDirectoryChanger from armi.utils.plotting import plotNucXs diff --git a/armi/nuclearDataIO/tests/test_xsNuclides.py b/armi/nuclearDataIO/tests/test_xsNuclides.py index 91109e5c2..2985d6e70 100644 --- a/armi/nuclearDataIO/tests/test_xsNuclides.py +++ b/armi/nuclearDataIO/tests/test_xsNuclides.py @@ -16,11 +16,8 @@ import unittest from armi.nucDirectory import nuclideBases -from armi.nuclearDataIO import isotxs -from armi.nuclearDataIO import xsLibraries -from armi.nuclearDataIO import xsNuclides -from armi.tests import ISOAA_PATH -from armi.tests import mockRunLogs +from armi.nuclearDataIO import isotxs, xsLibraries, xsNuclides +from armi.tests import ISOAA_PATH, mockRunLogs class NuclideTests(unittest.TestCase): diff --git a/armi/nuclearDataIO/xsCollections.py b/armi/nuclearDataIO/xsCollections.py index 913032aef..c2d873b5c 100644 --- a/armi/nuclearDataIO/xsCollections.py +++ b/armi/nuclearDataIO/xsCollections.py @@ -42,8 +42,7 @@ from scipy import sparse from armi import runLog -from armi.utils import properties -from armi.utils import units +from armi.utils import properties, units # Basic cross-section types that are represented by a 1-D vector in the multigroup approximation # No one is particularly proud of these names...we can claim diff --git a/armi/nuclearDataIO/xsLibraries.py b/armi/nuclearDataIO/xsLibraries.py index f38bbaa65..a60d4e5e8 100644 --- a/armi/nuclearDataIO/xsLibraries.py +++ b/armi/nuclearDataIO/xsLibraries.py @@ -31,9 +31,7 @@ def compare(lib1, lib2): """Compare two XSLibraries, and return True if equal, or False if not.""" - from armi.nuclearDataIO.cccc import isotxs - from armi.nuclearDataIO.cccc import gamiso - from armi.nuclearDataIO.cccc import pmatrx + from armi.nuclearDataIO.cccc import gamiso, isotxs, pmatrx equal = True # check the nuclides @@ -177,10 +175,8 @@ def mergeXSLibrariesInWorkingDirectory( An alternate directory in which to search for files other than the working directory. The main purpose of this is for testing, but it could also be useful to users. """ - from armi.nuclearDataIO.cccc import isotxs - from armi.nuclearDataIO.cccc import gamiso - from armi.nuclearDataIO.cccc import pmatrx from armi import nuclearDataIO + from armi.nuclearDataIO.cccc import gamiso, isotxs, pmatrx baseDir = alternateDirectory or os.getcwd() globPath = os.path.join(baseDir, _ISOTXS_EXT + "*") diff --git a/armi/nuclearDataIO/xsNuclides.py b/armi/nuclearDataIO/xsNuclides.py index c2c976af4..d59b85daf 100644 --- a/armi/nuclearDataIO/xsNuclides.py +++ b/armi/nuclearDataIO/xsNuclides.py @@ -26,9 +26,7 @@ index (i.e. "PU39AA"). """ from armi.nucDirectory import nuclideBases -from armi.nuclearDataIO import xsCollections -from armi.nuclearDataIO import xsLibraries -from armi.nuclearDataIO import nuclearFileMetadata +from armi.nuclearDataIO import nuclearFileMetadata, xsCollections, xsLibraries from armi.utils.customExceptions import warn_when_root diff --git a/armi/operators/__init__.py b/armi/operators/__init__.py index 6eb5ca3cc..7efe833a3 100644 --- a/armi/operators/__init__.py +++ b/armi/operators/__init__.py @@ -39,8 +39,8 @@ math on the reactor model """ -from armi import context -from armi import getPluginManagerOrFail +# ruff: noqa: I001 +from armi import context, getPluginManagerOrFail from armi.operators.runTypes import RunTypes from armi.operators.operator import Operator from armi.operators.operatorMPI import OperatorMPI diff --git a/armi/operators/operatorMPI.py b/armi/operators/operatorMPI.py index bb9761653..dcd5a9538 100644 --- a/armi/operators/operatorMPI.py +++ b/armi/operators/operatorMPI.py @@ -41,10 +41,7 @@ import time import traceback -from armi import context -from armi import getPluginManager -from armi import mpiActions -from armi import runLog +from armi import context, getPluginManager, mpiActions, runLog from armi.operators.operator import Operator from armi.reactor import reactors diff --git a/armi/operators/settingsValidation.py b/armi/operators/settingsValidation.py index 949b0e09b..ec9446b1c 100644 --- a/armi/operators/settingsValidation.py +++ b/armi/operators/settingsValidation.py @@ -24,6 +24,8 @@ """ # ruff: noqa: F401 -from armi.settings.settingsValidation import createQueryRevertBadPathToDefault -from armi.settings.settingsValidation import Inspector -from armi.settings.settingsValidation import Query +from armi.settings.settingsValidation import ( + Inspector, + Query, + createQueryRevertBadPathToDefault, +) diff --git a/armi/operators/snapshots.py b/armi/operators/snapshots.py index 575c8b606..4ce4d2655 100644 --- a/armi/operators/snapshots.py +++ b/armi/operators/snapshots.py @@ -14,8 +14,8 @@ """Snapshot Operator.""" -from armi.operators import operatorMPI from armi import runLog +from armi.operators import operatorMPI class OperatorSnapshots(operatorMPI.OperatorMPI): diff --git a/armi/operators/tests/test_operators.py b/armi/operators/tests/test_operators.py index 54199a5b9..878324123 100644 --- a/armi/operators/tests/test_operators.py +++ b/armi/operators/tests/test_operators.py @@ -13,12 +13,12 @@ # limitations under the License. """Tests for operators.""" -from unittest.mock import patch import collections import io import os import sys import unittest +from unittest.mock import patch from armi import settings from armi.bookkeeping.db.databaseInterface import DatabaseInterface @@ -27,16 +27,16 @@ from armi.physics.neutronics.globalFlux.globalFluxInterface import ( GlobalFluxInterfaceUsingExecuters, ) -from armi.reactor.reactors import Reactor, Core +from armi.reactor.reactors import Core, Reactor from armi.reactor.tests import test_reactors from armi.settings.caseSettings import Settings from armi.settings.fwSettings.globalSettings import ( - CONF_RUN_TYPE, - CONF_TIGHT_COUPLING, CONF_CYCLES_SKIP_TIGHT_COUPLING_INTERACTION, - CONF_TIGHT_COUPLING_SETTINGS, CONF_DEFERRED_INTERFACE_NAMES, CONF_DEFERRED_INTERFACES_CYCLE, + CONF_RUN_TYPE, + CONF_TIGHT_COUPLING, + CONF_TIGHT_COUPLING_SETTINGS, ) from armi.tests import mockRunLogs from armi.utils import directoryChangers diff --git a/armi/physics/executers.py b/armi/physics/executers.py index d99c11c6d..b8deaaca2 100644 --- a/armi/physics/executers.py +++ b/armi/physics/executers.py @@ -21,7 +21,7 @@ import os from armi import runLog -from armi.context import getFastPath, MPI_RANK +from armi.context import MPI_RANK, getFastPath from armi.utils import directoryChangers, pathTools diff --git a/armi/physics/fuelCycle/__init__.py b/armi/physics/fuelCycle/__init__.py index 95f4e96d8..384d73f16 100644 --- a/armi/physics/fuelCycle/__init__.py +++ b/armi/physics/fuelCycle/__init__.py @@ -28,12 +28,9 @@ The fuel handler plugin moves fuel around in a reactor. """ -from armi import interfaces -from armi import operators -from armi import plugins +from armi import interfaces, operators, plugins from armi.operators import RunTypes -from armi.physics.fuelCycle import fuelHandlers -from armi.physics.fuelCycle import settings +from armi.physics.fuelCycle import fuelHandlers, settings ORDER = interfaces.STACK_ORDER.FUEL_MANAGEMENT diff --git a/armi/physics/fuelCycle/fuelHandlerFactory.py b/armi/physics/fuelCycle/fuelHandlerFactory.py index c6068f62e..babc59ed7 100644 --- a/armi/physics/fuelCycle/fuelHandlerFactory.py +++ b/armi/physics/fuelCycle/fuelHandlerFactory.py @@ -14,8 +14,7 @@ """factory for the FuelHandler.""" from armi.physics.fuelCycle import fuelHandlers -from armi.physics.fuelCycle.settings import CONF_FUEL_HANDLER_NAME -from armi.physics.fuelCycle.settings import CONF_SHUFFLE_LOGIC +from armi.physics.fuelCycle.settings import CONF_FUEL_HANDLER_NAME, CONF_SHUFFLE_LOGIC from armi.utils import directoryChangers, pathTools diff --git a/armi/physics/fuelCycle/fuelHandlerInterface.py b/armi/physics/fuelCycle/fuelHandlerInterface.py index 0425cdec9..85bd52655 100644 --- a/armi/physics/fuelCycle/fuelHandlerInterface.py +++ b/armi/physics/fuelCycle/fuelHandlerInterface.py @@ -14,12 +14,13 @@ """A place for the FuelHandler's Interface.""" -from armi import interfaces -from armi import runLog +from armi import interfaces, runLog from armi.physics.fuelCycle import fuelHandlerFactory -from armi.physics.fuelCycle.settings import CONF_PLOT_SHUFFLE_ARROWS -from armi.physics.fuelCycle.settings import CONF_RUN_LATTICE_BEFORE_SHUFFLING -from armi.physics.fuelCycle.settings import CONF_SHUFFLE_LOGIC +from armi.physics.fuelCycle.settings import ( + CONF_PLOT_SHUFFLE_ARROWS, + CONF_RUN_LATTICE_BEFORE_SHUFFLING, + CONF_SHUFFLE_LOGIC, +) from armi.utils import plotting diff --git a/armi/physics/fuelCycle/fuelHandlers.py b/armi/physics/fuelCycle/fuelHandlers.py index 9f99d5a8f..74697cd63 100644 --- a/armi/physics/fuelCycle/fuelHandlers.py +++ b/armi/physics/fuelCycle/fuelHandlers.py @@ -37,8 +37,8 @@ from armi.physics.fuelCycle.fuelHandlerInterface import FuelHandlerInterface from armi.physics.fuelCycle.settings import CONF_ASSEMBLY_ROTATION_ALG from armi.reactor.flags import Flags -from armi.utils.customExceptions import InputError from armi.reactor.parameters import ParamLocation +from armi.utils.customExceptions import InputError class FuelHandler: diff --git a/armi/physics/fuelCycle/settings.py b/armi/physics/fuelCycle/settings.py index 647a279ae..fd50301c3 100644 --- a/armi/physics/fuelCycle/settings.py +++ b/armi/physics/fuelCycle/settings.py @@ -12,8 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """Settings for generic fuel cycle code.""" -from armi.settings import setting -from armi.settings import settingsValidation +from armi.settings import setting, settingsValidation CONF_ASSEM_ROTATION_STATIONARY = "assemblyRotationStationary" CONF_ASSEMBLY_ROTATION_ALG = "assemblyRotationAlgorithm" diff --git a/armi/physics/fuelCycle/tests/test_fuelHandlers.py b/armi/physics/fuelCycle/tests/test_fuelHandlers.py index b6bbc14a0..2ea5e57d6 100644 --- a/armi/physics/fuelCycle/tests/test_fuelHandlers.py +++ b/armi/physics/fuelCycle/tests/test_fuelHandlers.py @@ -38,12 +38,12 @@ ) from armi.reactor import assemblies, blocks, components, grids from armi.reactor.flags import Flags +from armi.reactor.parameters import ParamLocation from armi.reactor.tests import test_reactors from armi.reactor.zones import Zone from armi.settings import caseSettings from armi.tests import TEST_ROOT, ArmiTestHelper, mockRunLogs from armi.utils import directoryChangers -from armi.reactor.parameters import ParamLocation class FuelHandlerTestHelper(ArmiTestHelper): diff --git a/armi/physics/fuelPerformance/executers.py b/armi/physics/fuelPerformance/executers.py index 7cc0af2fb..2bd92fac4 100644 --- a/armi/physics/fuelPerformance/executers.py +++ b/armi/physics/fuelPerformance/executers.py @@ -22,15 +22,14 @@ """ from armi.physics import executers - from armi.physics.fuelPerformance.settings import ( - CONF_FUEL_PERFORMANCE_ENGINE, CONF_AXIAL_EXPANSION, CONF_BOND_REMOVAL, - CONF_FGR_REMOVAL, - CONF_CLADDING_WASTAGE, CONF_CLADDING_STRAIN, + CONF_CLADDING_WASTAGE, + CONF_FGR_REMOVAL, CONF_FGYF, + CONF_FUEL_PERFORMANCE_ENGINE, ) diff --git a/armi/physics/fuelPerformance/parameters.py b/armi/physics/fuelPerformance/parameters.py index 604a37015..47d09f32a 100644 --- a/armi/physics/fuelPerformance/parameters.py +++ b/armi/physics/fuelPerformance/parameters.py @@ -13,8 +13,8 @@ # limitations under the License. """Parameter definitions for fuel performance plugins.""" from armi.reactor import parameters -from armi.reactor.parameters import ParamLocation from armi.reactor.blocks import Block +from armi.reactor.parameters import ParamLocation from armi.utils import units diff --git a/armi/physics/fuelPerformance/plugin.py b/armi/physics/fuelPerformance/plugin.py index 9e82f7f50..60bdbf07f 100644 --- a/armi/physics/fuelPerformance/plugin.py +++ b/armi/physics/fuelPerformance/plugin.py @@ -14,11 +14,9 @@ """Generic Fuel Performance Plugin.""" -from armi import plugins -from armi import interfaces +from armi import interfaces, plugins from armi.physics.fuelPerformance import settings - ORDER = interfaces.STACK_ORDER.CROSS_SECTIONS diff --git a/armi/physics/fuelPerformance/settings.py b/armi/physics/fuelPerformance/settings.py index edef934f2..91f190637 100644 --- a/armi/physics/fuelPerformance/settings.py +++ b/armi/physics/fuelPerformance/settings.py @@ -17,7 +17,6 @@ from armi.settings import setting from armi.settings.settingsValidation import Query - CONF_AXIAL_EXPANSION = "axialExpansion" CONF_BOND_REMOVAL = "bondRemoval" CONF_CLADDING_STRAIN = "claddingStrain" diff --git a/armi/physics/neutronics/crossSectionSettings.py b/armi/physics/neutronics/crossSectionSettings.py index a683f7d7f..b1d0d0b40 100644 --- a/armi/physics/neutronics/crossSectionSettings.py +++ b/armi/physics/neutronics/crossSectionSettings.py @@ -31,8 +31,7 @@ import voluptuous as vol -from armi import context -from armi import runLog +from armi import context, runLog from armi.physics.neutronics import crossSectionGroupManager from armi.physics.neutronics.crossSectionGroupManager import BLOCK_COLLECTIONS from armi.settings import Setting diff --git a/armi/physics/neutronics/diffIsotxs.py b/armi/physics/neutronics/diffIsotxs.py index 5ac4c1e59..d94baa195 100644 --- a/armi/physics/neutronics/diffIsotxs.py +++ b/armi/physics/neutronics/diffIsotxs.py @@ -52,8 +52,7 @@ def addOptions(self): ) def invoke(self): - from armi.nuclearDataIO import isotxs - from armi.nuclearDataIO import xsLibraries + from armi.nuclearDataIO import isotxs, xsLibraries runLog.setVerbosity(0) refIsotxs = isotxs.readBinary(self.args.reference) diff --git a/armi/physics/neutronics/energyGroups.py b/armi/physics/neutronics/energyGroups.py index 5da90636d..4482f4a29 100644 --- a/armi/physics/neutronics/energyGroups.py +++ b/armi/physics/neutronics/energyGroups.py @@ -20,13 +20,13 @@ import numpy as np from armi import runLog -from armi.utils.mathematics import findNearestValue from armi.physics.neutronics.const import ( FAST_FLUX_THRESHOLD_EV, + HIGH_ENERGY_EV, MAXIMUM_XS_LIBRARY_ENERGY, ULTRA_FINE_GROUP_LETHARGY_WIDTH, - HIGH_ENERGY_EV, ) +from armi.utils.mathematics import findNearestValue def getFastFluxGroupCutoff(eGrpStruc): diff --git a/armi/physics/neutronics/fissionProductModel/__init__.py b/armi/physics/neutronics/fissionProductModel/__init__.py index 1a9a15347..014243375 100644 --- a/armi/physics/neutronics/fissionProductModel/__init__.py +++ b/armi/physics/neutronics/fissionProductModel/__init__.py @@ -15,6 +15,7 @@ """The Fission product model subpackage.""" import os + from armi.context import RES REFERENCE_LUMPED_FISSION_PRODUCT_FILE = os.path.join( diff --git a/armi/physics/neutronics/fissionProductModel/fissionProductModel.py b/armi/physics/neutronics/fissionProductModel/fissionProductModel.py index 73b998fa7..218ae3f2d 100644 --- a/armi/physics/neutronics/fissionProductModel/fissionProductModel.py +++ b/armi/physics/neutronics/fissionProductModel/fissionProductModel.py @@ -96,15 +96,13 @@ is initialized and may not be an out-of-the-box general solution. """ -from armi import runLog -from armi import interfaces -from armi.reactor.flags import Flags +from armi import interfaces, runLog from armi.physics.neutronics.fissionProductModel import lumpedFissionProduct from armi.physics.neutronics.fissionProductModel.fissionProductModelSettings import ( CONF_FP_MODEL, CONF_MAKE_ALL_BLOCK_LFPS_INDEPENDENT, ) - +from armi.reactor.flags import Flags NUM_FISSION_PRODUCTS_PER_LFP = 2.0 diff --git a/armi/physics/neutronics/fissionProductModel/fissionProductModelSettings.py b/armi/physics/neutronics/fissionProductModel/fissionProductModelSettings.py index d23e1b142..e9c48c12d 100644 --- a/armi/physics/neutronics/fissionProductModel/fissionProductModelSettings.py +++ b/armi/physics/neutronics/fissionProductModel/fissionProductModelSettings.py @@ -14,8 +14,8 @@ """Settings related to the fission product model.""" -from armi.settings import setting from armi.physics.neutronics import fissionProductModel +from armi.settings import setting CONF_FP_MODEL = "fpModel" CONF_MAKE_ALL_BLOCK_LFPS_INDEPENDENT = "makeAllBlockLFPsIndependent" diff --git a/armi/physics/neutronics/fissionProductModel/lumpedFissionProduct.py b/armi/physics/neutronics/fissionProductModel/lumpedFissionProduct.py index 4a5c1ce75..3aa8e3e56 100644 --- a/armi/physics/neutronics/fissionProductModel/lumpedFissionProduct.py +++ b/armi/physics/neutronics/fissionProductModel/lumpedFissionProduct.py @@ -20,13 +20,11 @@ """ import os -from armi.nucDirectory import nuclideBases from armi import runLog -from armi.nucDirectory import elements - +from armi.nucDirectory import elements, nuclideBases from armi.physics.neutronics.fissionProductModel.fissionProductModelSettings import ( - CONF_LFP_COMPOSITION_FILE_PATH, CONF_FP_MODEL, + CONF_LFP_COMPOSITION_FILE_PATH, ) diff --git a/armi/physics/neutronics/fissionProductModel/tests/test_fissionProductModel.py b/armi/physics/neutronics/fissionProductModel/tests/test_fissionProductModel.py index a21b5abd9..0ec9dd6f7 100644 --- a/armi/physics/neutronics/fissionProductModel/tests/test_fissionProductModel.py +++ b/armi/physics/neutronics/fissionProductModel/tests/test_fissionProductModel.py @@ -16,14 +16,14 @@ from armi import nuclideBases from armi.physics.neutronics.fissionProductModel import fissionProductModel +from armi.physics.neutronics.fissionProductModel.fissionProductModelSettings import ( + CONF_FISSION_PRODUCT_LIBRARY_NAME, + CONF_FP_MODEL, +) from armi.physics.neutronics.fissionProductModel.tests import test_lumpedFissionProduct from armi.physics.neutronics.isotopicDepletion.isotopicDepletionInterface import ( isDepletable, ) -from armi.physics.neutronics.fissionProductModel.fissionProductModelSettings import ( - CONF_FP_MODEL, - CONF_FISSION_PRODUCT_LIBRARY_NAME, -) from armi.reactor.flags import Flags from armi.reactor.tests.test_reactors import ( buildOperatorOfEmptyHexBlocks, diff --git a/armi/physics/neutronics/fissionProductModel/tests/test_lumpedFissionProduct.py b/armi/physics/neutronics/fissionProductModel/tests/test_lumpedFissionProduct.py index 9d5f7f796..2197060ec 100644 --- a/armi/physics/neutronics/fissionProductModel/tests/test_lumpedFissionProduct.py +++ b/armi/physics/neutronics/fissionProductModel/tests/test_lumpedFissionProduct.py @@ -13,24 +13,24 @@ # limitations under the License. """Tests for lumpedFissionProduce module.""" -import unittest import io import math import os +import unittest +from armi.context import RES +from armi.nucDirectory import nuclideBases from armi.physics.neutronics.fissionProductModel import ( - lumpedFissionProduct, REFERENCE_LUMPED_FISSION_PRODUCT_FILE, + lumpedFissionProduct, ) -from armi.context import RES -from armi.settings import Settings -from armi.reactor.tests.test_reactors import buildOperatorOfEmptyHexBlocks -from armi.reactor.flags import Flags -from armi.nucDirectory import nuclideBases from armi.physics.neutronics.fissionProductModel.fissionProductModelSettings import ( CONF_FP_MODEL, CONF_LFP_COMPOSITION_FILE_PATH, ) +from armi.reactor.flags import Flags +from armi.reactor.tests.test_reactors import buildOperatorOfEmptyHexBlocks +from armi.settings import Settings LFP_TEXT = """LFP35 GE73 5.9000E-06 LFP35 GE74 1.4000E-05 diff --git a/armi/physics/neutronics/globalFlux/globalFluxInterface.py b/armi/physics/neutronics/globalFlux/globalFluxInterface.py index 9e51adab5..aef9d2800 100644 --- a/armi/physics/neutronics/globalFlux/globalFluxInterface.py +++ b/armi/physics/neutronics/globalFlux/globalFluxInterface.py @@ -20,20 +20,15 @@ import numpy as np -from armi import interfaces -from armi import runLog -from armi.physics import constants -from armi.physics import executers -from armi.physics import neutronics -from armi.reactor import geometry -from armi.reactor import reactors -from armi.physics.neutronics.globalFlux import RX_PARAM_NAMES, RX_ABS_MICRO_LABELS +from armi import interfaces, runLog +from armi.physics import constants, executers, neutronics +from armi.physics.neutronics.globalFlux import RX_ABS_MICRO_LABELS, RX_PARAM_NAMES +from armi.reactor import geometry, reactors from armi.reactor.blocks import Block -from armi.reactor.converters import geometryConverters -from armi.reactor.converters import uniformMesh +from armi.reactor.converters import geometryConverters, uniformMesh from armi.reactor.flags import Flags from armi.settings.caseSettings import Settings -from armi.utils import units, codeTiming, getMaxBurnSteps, getBurnSteps +from armi.utils import codeTiming, getBurnSteps, getMaxBurnSteps, units ORDER = interfaces.STACK_ORDER.FLUX @@ -496,9 +491,9 @@ def fromUserSettings(self, cs: Settings): CONF_XS_KERNEL, ) from armi.settings.fwSettings.globalSettings import ( - CONF_PHYSICS_FILES, - CONF_NON_UNIFORM_ASSEM_FLAGS, CONF_DETAILED_AXIAL_EXPANSION, + CONF_NON_UNIFORM_ASSEM_FLAGS, + CONF_PHYSICS_FILES, ) self.kernelName = cs[CONF_NEUTRONICS_KERNEL] diff --git a/armi/physics/neutronics/globalFlux/tests/test_globalFluxInterface.py b/armi/physics/neutronics/globalFlux/tests/test_globalFluxInterface.py index 09adacaf8..e7a79d909 100644 --- a/armi/physics/neutronics/globalFlux/tests/test_globalFluxInterface.py +++ b/armi/physics/neutronics/globalFlux/tests/test_globalFluxInterface.py @@ -27,8 +27,7 @@ from armi.reactor import geometry from armi.reactor.blocks import HexBlock from armi.reactor.flags import Flags -from armi.reactor.tests import test_blocks -from armi.reactor.tests import test_reactors +from armi.reactor.tests import test_blocks, test_reactors from armi.tests import ISOAA_PATH diff --git a/armi/physics/neutronics/latticePhysics/__init__.py b/armi/physics/neutronics/latticePhysics/__init__.py index 1d94e02b7..b66824141 100644 --- a/armi/physics/neutronics/latticePhysics/__init__.py +++ b/armi/physics/neutronics/latticePhysics/__init__.py @@ -16,8 +16,7 @@ # ruff: noqa: F401 import os -from armi import interfaces -from armi import settings +from armi import interfaces, settings from armi.physics import neutronics from armi.utils import pathTools diff --git a/armi/physics/neutronics/latticePhysics/latticePhysicsWriter.py b/armi/physics/neutronics/latticePhysics/latticePhysicsWriter.py index c52ed664a..09f636f2e 100644 --- a/armi/physics/neutronics/latticePhysics/latticePhysicsWriter.py +++ b/armi/physics/neutronics/latticePhysics/latticePhysicsWriter.py @@ -21,30 +21,28 @@ physics codes. """ -import math import collections +import math import numpy as np import ordered_set -from armi import runLog -from armi import interfaces -from armi.physics import neutronics -from armi.reactor import components +from armi import interfaces, runLog from armi.nucDirectory import nuclideBases -from armi.reactor.flags import Flags -from armi.utils.customExceptions import warn_when_root +from armi.physics import neutronics from armi.physics.neutronics.const import CONF_CROSS_SECTION from armi.physics.neutronics.fissionProductModel.fissionProductModelSettings import ( CONF_FP_MODEL, ) from armi.physics.neutronics.settings import ( + CONF_GEN_XS, CONF_MINIMUM_FISSILE_FRACTION, CONF_MINIMUM_NUCLIDE_DENSITY, ) -from armi.physics.neutronics.settings import CONF_GEN_XS +from armi.reactor import components +from armi.reactor.flags import Flags from armi.settings.fwSettings.globalSettings import CONF_DETAILED_AXIAL_EXPANSION - +from armi.utils.customExceptions import warn_when_root # number of decimal places to round temperatures to in _groupNuclidesByTemperature _NUM_DIGITS_ROUND_TEMPERATURE = 3 diff --git a/armi/physics/neutronics/latticePhysics/tests/test_latticeInterface.py b/armi/physics/neutronics/latticePhysics/tests/test_latticeInterface.py index 63a4bfd38..11e4cdd57 100644 --- a/armi/physics/neutronics/latticePhysics/tests/test_latticeInterface.py +++ b/armi/physics/neutronics/latticePhysics/tests/test_latticeInterface.py @@ -13,27 +13,26 @@ # limitations under the License. """Test the Lattice Interface.""" -from collections import OrderedDict import unittest +from collections import OrderedDict -from armi.physics.neutronics.latticePhysics.latticePhysicsInterface import ( - LatticePhysicsInterface, -) from armi import settings from armi.nuclearDataIO.cccc import isotxs from armi.operators.operator import Operator from armi.physics.neutronics import LatticePhysicsFrequency from armi.physics.neutronics.crossSectionGroupManager import CrossSectionGroupManager -from armi.physics.neutronics.settings import CONF_GEN_XS -from armi.physics.neutronics.settings import CONF_GLOBAL_FLUX_ACTIVE -from armi.reactor.reactors import Reactor, Core -from armi.reactor.tests.test_blocks import buildSimpleFuelBlock -from armi.tests import mockRunLogs +from armi.physics.neutronics.latticePhysics.latticePhysicsInterface import ( + LatticePhysicsInterface, +) +from armi.physics.neutronics.settings import CONF_GEN_XS, CONF_GLOBAL_FLUX_ACTIVE from armi.reactor.assemblies import ( HexAssembly, grids, ) -from armi.tests import ISOAA_PATH +from armi.reactor.reactors import Core, Reactor +from armi.reactor.tests.test_blocks import buildSimpleFuelBlock +from armi.tests import ISOAA_PATH, mockRunLogs + # As an interface, LatticePhysicsInterface must be subclassed to be used class LatticeInterfaceTester(LatticePhysicsInterface): diff --git a/armi/physics/neutronics/latticePhysics/tests/test_latticeWriter.py b/armi/physics/neutronics/latticePhysics/tests/test_latticeWriter.py index 7b4056c50..89f1b1225 100644 --- a/armi/physics/neutronics/latticePhysics/tests/test_latticeWriter.py +++ b/armi/physics/neutronics/latticePhysics/tests/test_latticeWriter.py @@ -13,8 +13,8 @@ # limitations under the License. """Test the Lattice Physics Writer.""" -from collections import defaultdict import unittest +from collections import defaultdict from armi.physics.neutronics.const import CONF_CROSS_SECTION from armi.physics.neutronics.fissionProductModel.fissionProductModelSettings import ( @@ -27,8 +27,8 @@ LatticePhysicsWriter, ) from armi.physics.neutronics.settings import ( - CONF_XS_BLOCK_REPRESENTATION, CONF_DISABLE_BLOCK_TYPE_EXCLUSION_IN_XS_GENERATION, + CONF_XS_BLOCK_REPRESENTATION, ) from armi.testing import loadTestReactor from armi.tests import TEST_ROOT diff --git a/armi/physics/neutronics/macroXSGenerationInterface.py b/armi/physics/neutronics/macroXSGenerationInterface.py index 2665b82cc..99928d9dc 100644 --- a/armi/physics/neutronics/macroXSGenerationInterface.py +++ b/armi/physics/neutronics/macroXSGenerationInterface.py @@ -20,10 +20,7 @@ \Sigma_i = N_i \sigma_i """ -from armi import context -from armi import interfaces -from armi import mpiActions -from armi import runLog +from armi import context, interfaces, mpiActions, runLog from armi.nuclearDataIO import xsCollections from armi.physics.neutronics.settings import CONF_MINIMUM_NUCLIDE_DENSITY from armi.utils import getBurnSteps, iterables diff --git a/armi/physics/neutronics/reports.py b/armi/physics/neutronics/reports.py index 5989fbeb1..e0623df3e 100644 --- a/armi/physics/neutronics/reports.py +++ b/armi/physics/neutronics/reports.py @@ -14,9 +14,7 @@ from collections import defaultdict -from armi.bookkeeping.report import newReportUtils -from armi.bookkeeping.report import newReports -from armi.reactor.flags import Flags +from armi.bookkeeping.report import newReports, newReportUtils from armi.physics.neutronics.fissionProductModel.fissionProductModelSettings import ( CONF_FP_MODEL, ) @@ -25,6 +23,7 @@ CONF_NEUTRONICS_KERNEL, CONF_NEUTRONICS_TYPE, ) +from armi.reactor.flags import Flags def insertNeutronicsReport(r, cs, report, stage): diff --git a/armi/physics/neutronics/settings.py b/armi/physics/neutronics/settings.py index d6aaa42bb..1677096d3 100644 --- a/armi/physics/neutronics/settings.py +++ b/armi/physics/neutronics/settings.py @@ -19,15 +19,13 @@ from armi.physics.neutronics import LatticePhysicsFrequency from armi.physics.neutronics.const import NEUTRON from armi.physics.neutronics.energyGroups import GROUP_STRUCTURE -from armi.settings import setting -from armi.settings import settingsValidation -from armi.utils import directoryChangers +from armi.settings import setting, settingsValidation from armi.settings.fwSettings.globalSettings import ( CONF_DETAILED_AXIAL_EXPANSION, CONF_NON_UNIFORM_ASSEM_FLAGS, CONF_RUN_TYPE, ) - +from armi.utils import directoryChangers CONF_BC_COEFFICIENT = "bcCoefficient" CONF_BOUNDARIES = "boundaries" diff --git a/armi/physics/neutronics/tests/test_crossSectionSettings.py b/armi/physics/neutronics/tests/test_crossSectionSettings.py index 17499e806..b2882656d 100644 --- a/armi/physics/neutronics/tests/test_crossSectionSettings.py +++ b/armi/physics/neutronics/tests/test_crossSectionSettings.py @@ -15,22 +15,24 @@ import io import unittest -from ruamel.yaml import YAML import voluptuous as vol +from ruamel.yaml import YAML from armi import settings from armi.physics.neutronics.const import CONF_CROSS_SECTION -from armi.physics.neutronics.crossSectionSettings import CONF_BLOCK_REPRESENTATION -from armi.physics.neutronics.crossSectionSettings import CONF_GEOM -from armi.physics.neutronics.crossSectionSettings import XSModelingOptions -from armi.physics.neutronics.crossSectionSettings import XSSettingDef -from armi.physics.neutronics.crossSectionSettings import XSSettings -from armi.physics.neutronics.crossSectionSettings import xsSettingsValidator -from armi.physics.neutronics.tests.test_neutronicsPlugin import XS_EXAMPLE +from armi.physics.neutronics.crossSectionSettings import ( + CONF_BLOCK_REPRESENTATION, + CONF_GEOM, + XSModelingOptions, + XSSettingDef, + XSSettings, + xsSettingsValidator, +) from armi.physics.neutronics.settings import ( - CONF_XS_BLOCK_REPRESENTATION, CONF_DISABLE_BLOCK_TYPE_EXCLUSION_IN_XS_GENERATION, + CONF_XS_BLOCK_REPRESENTATION, ) +from armi.physics.neutronics.tests.test_neutronicsPlugin import XS_EXAMPLE from armi.settings import caseSettings diff --git a/armi/physics/neutronics/tests/test_crossSectionTable.py b/armi/physics/neutronics/tests/test_crossSectionTable.py index 9c9abe5b7..a961be50e 100644 --- a/armi/physics/neutronics/tests/test_crossSectionTable.py +++ b/armi/physics/neutronics/tests/test_crossSectionTable.py @@ -17,6 +17,8 @@ from armi.nuclearDataIO.cccc import isotxs from armi.physics.neutronics.isotopicDepletion import ( crossSectionTable, +) +from armi.physics.neutronics.isotopicDepletion import ( isotopicDepletionInterface as idi, ) from armi.physics.neutronics.latticePhysics import ORDER diff --git a/armi/physics/neutronics/tests/test_neutronicsPlugin.py b/armi/physics/neutronics/tests/test_neutronicsPlugin.py index 00c855ada..ca93f62c7 100644 --- a/armi/physics/neutronics/tests/test_neutronicsPlugin.py +++ b/armi/physics/neutronics/tests/test_neutronicsPlugin.py @@ -22,26 +22,23 @@ from armi.physics import neutronics from armi.physics.neutronics.const import CONF_CROSS_SECTION from armi.physics.neutronics.settings import ( + CONF_BOUNDARIES, + CONF_DPA_XS_SET, CONF_GEN_XS, CONF_GLOBAL_FLUX_ACTIVE, + CONF_GRID_PLATE_DPA_XS_SET, CONF_GROUP_STRUCTURE, - CONF_DPA_XS_SET, - CONF_OUTERS_, CONF_INNERS_, - CONF_NEUTRONICS_KERNEL, CONF_LATTICE_PHYSICS_FREQUENCY, + CONF_NEUTRONICS_KERNEL, + CONF_OUTERS_, getNeutronicsSettingValidators, ) -from armi.settings import caseSettings -from armi.settings import settingsValidation +from armi.settings import caseSettings, settingsValidation from armi.settings.fwSettings.globalSettings import CONF_RUN_TYPE from armi.tests import TEST_ROOT from armi.tests.test_plugins import TestPlugin from armi.utils import directoryChangers -from armi.physics.neutronics.settings import ( - CONF_BOUNDARIES, - CONF_GRID_PLATE_DPA_XS_SET, -) XS_EXAMPLE = """AA: geometry: 0D diff --git a/armi/physics/thermalHydraulics/parameters.py b/armi/physics/thermalHydraulics/parameters.py index a6af2c1ba..8939abf61 100644 --- a/armi/physics/thermalHydraulics/parameters.py +++ b/armi/physics/thermalHydraulics/parameters.py @@ -13,8 +13,8 @@ # limitations under the License. """Parameter definitions for thermal hydraulic plugins.""" from armi.reactor import parameters -from armi.reactor.parameters import ParamLocation from armi.reactor.blocks import Block +from armi.reactor.parameters import ParamLocation from armi.utils import units diff --git a/armi/physics/thermalHydraulics/plugin.py b/armi/physics/thermalHydraulics/plugin.py index 0d675a054..562dc880b 100644 --- a/armi/physics/thermalHydraulics/plugin.py +++ b/armi/physics/thermalHydraulics/plugin.py @@ -20,10 +20,8 @@ """ -from armi import plugins +from armi import interfaces, plugins from armi.physics.thermalHydraulics import settings -from armi import interfaces - ORDER = interfaces.STACK_ORDER.THERMAL_HYDRAULICS diff --git a/armi/plugins.py b/armi/plugins.py index fdeb4cd66..d5fd810a6 100644 --- a/armi/plugins.py +++ b/armi/plugins.py @@ -118,7 +118,7 @@ replaced with plugin-based fuel handler logic. """ -from typing import Callable, Dict, List, Union, TYPE_CHECKING +from typing import TYPE_CHECKING, Callable, Dict, List, Union import pluggy diff --git a/armi/reactor/__init__.py b/armi/reactor/__init__.py index c7c3981d0..3536b698c 100644 --- a/armi/reactor/__init__.py +++ b/armi/reactor/__init__.py @@ -49,14 +49,13 @@ See :doc:`/developer/index`. """ -from typing import Dict, Callable, Union, TYPE_CHECKING +from typing import TYPE_CHECKING, Callable, Dict, Union -from armi import materials -from armi import plugins +from armi import materials, plugins if TYPE_CHECKING: - from armi.reactor.reactors import Core from armi.reactor.excoreStructure import ExcoreStructure + from armi.reactor.reactors import Core from armi.reactor.spentFuelPool import SpentFuelPool @@ -79,9 +78,9 @@ def beforeReactorConstruction(cs) -> None: @staticmethod @plugins.HOOKIMPL def defineBlockTypes(): - from armi.reactor.components.basicShapes import Rectangle, Hexagon - from armi.reactor.components.volumetricShapes import RadialSegment from armi.reactor import blocks + from armi.reactor.components.basicShapes import Hexagon, Rectangle + from armi.reactor.components.volumetricShapes import RadialSegment return [ (Rectangle, blocks.CartesianBlock), @@ -92,8 +91,8 @@ def defineBlockTypes(): @staticmethod @plugins.HOOKIMPL def defineAssemblyTypes(): - from armi.reactor.blocks import HexBlock, CartesianBlock, ThRZBlock - from armi.reactor.assemblies import HexAssembly, CartesianAssembly, ThRZAssembly + from armi.reactor.assemblies import CartesianAssembly, HexAssembly, ThRZAssembly + from armi.reactor.blocks import CartesianBlock, HexBlock, ThRZBlock return [ (HexBlock, HexAssembly), @@ -106,9 +105,9 @@ def defineAssemblyTypes(): def defineSystemBuilders() -> Dict[ str, Callable[[str], Union["Core", "ExcoreStructure", "SpentFuelPool"]] ]: - from armi.reactor.spentFuelPool import SpentFuelPool from armi.reactor.excoreStructure import ExcoreStructure from armi.reactor.reactors import Core + from armi.reactor.spentFuelPool import SpentFuelPool return { "core": Core, diff --git a/armi/reactor/assemblies.py b/armi/reactor/assemblies.py index da55c7694..149c04690 100644 --- a/armi/reactor/assemblies.py +++ b/armi/reactor/assemblies.py @@ -20,19 +20,16 @@ import copy import math import pickle +from collections.abc import Iterable from random import randint from typing import ClassVar, Optional, Type -from collections.abc import Iterable import numpy as np from scipy import interpolate from armi import runLog from armi.materials.material import Fluid -from armi.reactor import assemblyParameters -from armi.reactor import blocks -from armi.reactor import composites -from armi.reactor import grids +from armi.reactor import assemblyParameters, blocks, composites, grids from armi.reactor.flags import Flags from armi.reactor.parameters import ParamLocation from armi.reactor.spentFuelPool import SpentFuelPool diff --git a/armi/reactor/blocks.py b/armi/reactor/blocks.py index 023e86361..aebf3893d 100644 --- a/armi/reactor/blocks.py +++ b/armi/reactor/blocks.py @@ -18,35 +18,32 @@ Assemblies are made of blocks. Blocks are made of components. """ -from typing import Optional, Type, Tuple, ClassVar import collections import copy import functools import math +from typing import ClassVar, Optional, Tuple, Type import numpy as np -from armi import nuclideBases -from armi import runLog +from armi import nuclideBases, runLog from armi.bookkeeping import report from armi.nuclearDataIO import xsCollections -from armi.physics.neutronics import GAMMA -from armi.physics.neutronics import NEUTRON -from armi.reactor import blockParameters -from armi.reactor import components -from armi.reactor import composites -from armi.reactor import geometry -from armi.reactor import grids -from armi.reactor import parameters +from armi.physics.neutronics import GAMMA, NEUTRON +from armi.reactor import ( + blockParameters, + components, + composites, + geometry, + grids, + parameters, +) from armi.reactor.components import basicShapes -from armi.reactor.components.basicShapes import Hexagon, Circle +from armi.reactor.components.basicShapes import Circle, Hexagon from armi.reactor.components.complexShapes import Helix from armi.reactor.flags import Flags from armi.reactor.parameters import ParamLocation -from armi.utils import densityTools -from armi.utils import hexagon -from armi.utils import iterables -from armi.utils import units +from armi.utils import densityTools, hexagon, iterables, units from armi.utils.plotting import plotBlockFlux from armi.utils.units import TRACE_NUMBER_DENSITY diff --git a/armi/reactor/blueprints/__init__.py b/armi/reactor/blueprints/__init__.py index 48532ed58..aa31dddde 100644 --- a/armi/reactor/blueprints/__init__.py +++ b/armi/reactor/blueprints/__init__.py @@ -69,40 +69,42 @@ import traceback import typing -from ruamel.yaml import CLoader, RoundTripLoader import ordered_set import yamlize import yamlize.objects +from ruamel.yaml import CLoader, RoundTripLoader -from armi import context -from armi import getPluginManager, getPluginManagerOrFail -from armi import migration -from armi import plugins -from armi import runLog +from armi import ( + context, + getPluginManager, + getPluginManagerOrFail, + migration, + plugins, + runLog, +) from armi.nucDirectory import nuclideBases from armi.physics.neutronics.settings import CONF_LOADING_FILE -from armi.reactor import assemblies -from armi.reactor import geometry -from armi.reactor import systemLayoutInput +from armi.reactor import assemblies, geometry, systemLayoutInput from armi.reactor.blueprints import isotopicOptions from armi.reactor.blueprints.assemblyBlueprint import AssemblyKeyedList from armi.reactor.blueprints.blockBlueprint import BlockKeyedList -from armi.reactor.blueprints.componentBlueprint import ComponentGroups -from armi.reactor.blueprints.componentBlueprint import ComponentKeyedList +from armi.reactor.blueprints.componentBlueprint import ( + ComponentGroups, + ComponentKeyedList, +) from armi.reactor.blueprints.gridBlueprint import Grids, Triplet -from armi.reactor.blueprints.reactorBlueprint import Systems, SystemBlueprint +from armi.reactor.blueprints.reactorBlueprint import SystemBlueprint, Systems from armi.reactor.converters import axialExpansionChanger from armi.reactor.flags import Flags from armi.settings.fwSettings.globalSettings import ( - CONF_DETAILED_AXIAL_EXPANSION, + CONF_ACCEPTABLE_BLOCK_AREA_ERROR, CONF_ASSEM_FLAGS_SKIP_AXIAL_EXP, + CONF_DETAILED_AXIAL_EXPANSION, + CONF_GEOM_FILE, CONF_INPUT_HEIGHTS_HOT, CONF_NON_UNIFORM_ASSEM_FLAGS, - CONF_ACCEPTABLE_BLOCK_AREA_ERROR, - CONF_GEOM_FILE, ) -from armi.utils import tabulate -from armi.utils import textProcessors +from armi.utils import tabulate, textProcessors from armi.utils.customExceptions import InputError context.BLUEPRINTS_IMPORTED = True diff --git a/armi/reactor/blueprints/assemblyBlueprint.py b/armi/reactor/blueprints/assemblyBlueprint.py index 6ef7c420f..083c42c8f 100644 --- a/armi/reactor/blueprints/assemblyBlueprint.py +++ b/armi/reactor/blueprints/assemblyBlueprint.py @@ -22,11 +22,8 @@ """ import yamlize -from armi import getPluginManagerOrFail -from armi import runLog -from armi.reactor import assemblies -from armi.reactor import grids -from armi.reactor import parameters +from armi import getPluginManagerOrFail, runLog +from armi.reactor import assemblies, grids, parameters from armi.reactor.blueprints import blockBlueprint from armi.reactor.flags import Flags from armi.settings.fwSettings.globalSettings import CONF_INPUT_HEIGHTS_HOT diff --git a/armi/reactor/blueprints/blockBlueprint.py b/armi/reactor/blueprints/blockBlueprint.py index a1e7a5543..fe358c561 100644 --- a/armi/reactor/blueprints/blockBlueprint.py +++ b/armi/reactor/blueprints/blockBlueprint.py @@ -15,14 +15,13 @@ """This module defines the ARMI input for a block definition, and code for constructing an ARMI ``Block``.""" import collections from inspect import signature -from typing import Iterable, Set, Iterator +from typing import Iterable, Iterator, Set import yamlize from armi import getPluginManagerOrFail, runLog from armi.materials.material import Material -from armi.reactor import blocks -from armi.reactor import parameters +from armi.reactor import blocks, parameters from armi.reactor.blueprints import componentBlueprint from armi.reactor.components.component import Component from armi.reactor.composites import Composite diff --git a/armi/reactor/blueprints/componentBlueprint.py b/armi/reactor/blueprints/componentBlueprint.py index 289a0de8f..c871d8ca5 100644 --- a/armi/reactor/blueprints/componentBlueprint.py +++ b/armi/reactor/blueprints/componentBlueprint.py @@ -20,13 +20,11 @@ """ import yamlize -from armi import runLog -from armi import materials -from armi.reactor import components -from armi.reactor import composites +from armi import materials, runLog +from armi.nucDirectory import nuclideBases +from armi.reactor import components, composites from armi.reactor.flags import Flags from armi.utils import densityTools -from armi.nucDirectory import nuclideBases COMPONENT_GROUP_SHAPE = "group" diff --git a/armi/reactor/blueprints/gridBlueprint.py b/armi/reactor/blueprints/gridBlueprint.py index 2c1341fdd..c05a8ed7b 100644 --- a/armi/reactor/blueprints/gridBlueprint.py +++ b/armi/reactor/blueprints/gridBlueprint.py @@ -100,18 +100,17 @@ IC IC MC PC RR SH """ -from io import StringIO -from typing import Tuple import copy import itertools +from io import StringIO +from typing import Tuple import numpy as np import yamlize from ruamel.yaml import scalarstring from armi import runLog -from armi.reactor import blueprints -from armi.reactor import geometry, grids +from armi.reactor import blueprints, geometry, grids from armi.utils import asciimaps from armi.utils.customExceptions import InputError from armi.utils.mathematics import isMonotonic diff --git a/armi/reactor/blueprints/isotopicOptions.py b/armi/reactor/blueprints/isotopicOptions.py index e8b2b3544..f2e92866b 100644 --- a/armi/reactor/blueprints/isotopicOptions.py +++ b/armi/reactor/blueprints/isotopicOptions.py @@ -20,23 +20,19 @@ """ import yamlize -from armi import materials -from armi import runLog -from armi.nucDirectory import elements -from armi.nucDirectory import nucDir -from armi.nucDirectory import nuclideBases -from armi.utils import densityTools -from armi.utils import units -from armi.utils.customExceptions import InputError +from armi import materials, runLog +from armi.nucDirectory import elements, nucDir, nuclideBases from armi.physics.neutronics.fissionProductModel.fissionProductModelSettings import ( - CONF_FP_MODEL, CONF_FISSION_PRODUCT_LIBRARY_NAME, + CONF_FP_MODEL, ) from armi.physics.neutronics.settings import ( CONF_MCNP_LIB_BASE, CONF_NEUTRONICS_KERNEL, CONF_XS_KERNEL, ) +from armi.utils import densityTools, units +from armi.utils.customExceptions import InputError ALLOWED_KEYS = set(nuclideBases.byName.keys()) | set(elements.bySymbol.keys()) diff --git a/armi/reactor/blueprints/reactorBlueprint.py b/armi/reactor/blueprints/reactorBlueprint.py index 75b363a64..ff7a4e8fb 100644 --- a/armi/reactor/blueprints/reactorBlueprint.py +++ b/armi/reactor/blueprints/reactorBlueprint.py @@ -35,11 +35,8 @@ """ import yamlize -from armi import context -from armi import getPluginManagerOrFail -from armi import runLog -from armi.reactor import geometry -from armi.reactor import grids +from armi import context, getPluginManagerOrFail, runLog +from armi.reactor import geometry, grids from armi.reactor.blueprints.gridBlueprint import Triplet from armi.utils import tabulate @@ -236,7 +233,7 @@ def _modifyGeometry(self, container, gridDesign): # all cases should have no edge assemblies. They are added ephemerally when needed from armi.reactor.converters import ( geometryConverters, - ) # preventing circular imports + ) runLog.header("=========== Applying Geometry Modifications ===========") converter = geometryConverters.EdgeAssemblyChanger() diff --git a/armi/reactor/blueprints/tests/test_blueprints.py b/armi/reactor/blueprints/tests/test_blueprints.py index 7827dd5e1..95811561c 100644 --- a/armi/reactor/blueprints/tests/test_blueprints.py +++ b/armi/reactor/blueprints/tests/test_blueprints.py @@ -23,16 +23,14 @@ from armi import settings from armi.nucDirectory.elements import bySymbol from armi.physics.neutronics.settings import CONF_XS_KERNEL -from armi.reactor import blueprints -from armi.reactor import parameters +from armi.reactor import blueprints, parameters from armi.reactor.blueprints.componentBlueprint import ComponentBlueprint -from armi.reactor.blueprints.isotopicOptions import NuclideFlags, CustomIsotopics -from armi.reactor.flags import Flags -from armi.tests import TEST_ROOT -from armi.utils import directoryChangers -from armi.utils import textProcessors from armi.reactor.blueprints.gridBlueprint import saveToStream +from armi.reactor.blueprints.isotopicOptions import CustomIsotopics, NuclideFlags +from armi.reactor.flags import Flags from armi.settings.fwSettings.globalSettings import CONF_INPUT_HEIGHTS_HOT +from armi.tests import TEST_ROOT +from armi.utils import directoryChangers, textProcessors class TestBlueprints(unittest.TestCase): diff --git a/armi/reactor/blueprints/tests/test_customIsotopics.py b/armi/reactor/blueprints/tests/test_customIsotopics.py index d971cb658..27ce95edc 100644 --- a/armi/reactor/blueprints/tests/test_customIsotopics.py +++ b/armi/reactor/blueprints/tests/test_customIsotopics.py @@ -18,11 +18,12 @@ import yamlize -from armi import runLog -from armi import settings -from armi.physics.neutronics.settings import CONF_MCNP_LIB_BASE -from armi.physics.neutronics.settings import CONF_NEUTRONICS_KERNEL -from armi.physics.neutronics.settings import CONF_XS_KERNEL +from armi import runLog, settings +from armi.physics.neutronics.settings import ( + CONF_MCNP_LIB_BASE, + CONF_NEUTRONICS_KERNEL, + CONF_XS_KERNEL, +) from armi.reactor import blueprints from armi.reactor.blueprints import isotopicOptions from armi.reactor.flags import Flags diff --git a/armi/reactor/blueprints/tests/test_gridBlueprints.py b/armi/reactor/blueprints/tests/test_gridBlueprints.py index 076a68186..16e38cd50 100644 --- a/armi/reactor/blueprints/tests/test_gridBlueprints.py +++ b/armi/reactor/blueprints/tests/test_gridBlueprints.py @@ -25,7 +25,6 @@ from armi.reactor.blueprints.gridBlueprint import Grids, saveToStream from armi.utils.directoryChangers import TemporaryDirectoryChanger - LATTICE_BLUEPRINT = """ control: geom: hex_corners_up diff --git a/armi/reactor/blueprints/tests/test_materialModifications.py b/armi/reactor/blueprints/tests/test_materialModifications.py index a6487f903..52ada251e 100644 --- a/armi/reactor/blueprints/tests/test_materialModifications.py +++ b/armi/reactor/blueprints/tests/test_materialModifications.py @@ -16,8 +16,7 @@ from numpy.testing import assert_allclose -from armi import materials -from armi import settings +from armi import materials, settings from armi.reactor import blueprints from armi.reactor.blueprints.blockBlueprint import BlockBlueprint diff --git a/armi/reactor/blueprints/tests/test_reactorBlueprints.py b/armi/reactor/blueprints/tests/test_reactorBlueprints.py index 411d6fcfa..2e107517e 100644 --- a/armi/reactor/blueprints/tests/test_reactorBlueprints.py +++ b/armi/reactor/blueprints/tests/test_reactorBlueprints.py @@ -17,10 +17,8 @@ import unittest from armi import settings -from armi.reactor import blueprints -from armi.reactor import reactors -from armi.reactor.blueprints import gridBlueprint -from armi.reactor.blueprints import reactorBlueprint +from armi.reactor import blueprints, reactors +from armi.reactor.blueprints import gridBlueprint, reactorBlueprint from armi.reactor.blueprints.tests import test_customIsotopics from armi.reactor.composites import Composite from armi.reactor.excoreStructure import ExcoreStructure diff --git a/armi/reactor/components/__init__.py b/armi/reactor/components/__init__.py index 516cdae81..953d12d22 100644 --- a/armi/reactor/components/__init__.py +++ b/armi/reactor/components/__init__.py @@ -26,7 +26,7 @@ Class inheritance diagram for :py:mod:`armi.reactor.components`. """ -# ruff: noqa: F405 +# ruff: noqa: F405, I001 import math import numpy as np diff --git a/armi/reactor/components/basicShapes.py b/armi/reactor/components/basicShapes.py index 4e395009b..2edc20a9a 100644 --- a/armi/reactor/components/basicShapes.py +++ b/armi/reactor/components/basicShapes.py @@ -20,8 +20,7 @@ """ import math -from armi.reactor.components import ShapedComponent -from armi.reactor.components import componentParameters +from armi.reactor.components import ShapedComponent, componentParameters class Circle(ShapedComponent): diff --git a/armi/reactor/components/complexShapes.py b/armi/reactor/components/complexShapes.py index 2f1ff9f6f..247447ab7 100644 --- a/armi/reactor/components/complexShapes.py +++ b/armi/reactor/components/complexShapes.py @@ -16,9 +16,7 @@ import math -from armi.reactor.components import ShapedComponent -from armi.reactor.components import componentParameters -from armi.reactor.components import basicShapes +from armi.reactor.components import ShapedComponent, basicShapes, componentParameters class HoledHexagon(basicShapes.Hexagon): diff --git a/armi/reactor/components/component.py b/armi/reactor/components/component.py index 5a4da2f3b..979d6471d 100644 --- a/armi/reactor/components/component.py +++ b/armi/reactor/components/component.py @@ -19,21 +19,15 @@ """ import copy import re +from typing import Optional import numpy as np -from typing import Optional -from armi import materials -from armi import runLog +from armi import materials, runLog from armi.bookkeeping import report -from armi.materials import custom -from armi.materials import material -from armi.materials import void +from armi.materials import custom, material, void from armi.nucDirectory import nuclideBases -from armi.reactor import composites -from armi.reactor import flags -from armi.reactor import grids -from armi.reactor import parameters +from armi.reactor import composites, flags, grids, parameters from armi.reactor.components import componentParameters from armi.utils import densityTools from armi.utils.units import C_TO_K diff --git a/armi/reactor/components/volumetricShapes.py b/armi/reactor/components/volumetricShapes.py index 329c537b1..27d2bee51 100644 --- a/armi/reactor/components/volumetricShapes.py +++ b/armi/reactor/components/volumetricShapes.py @@ -16,8 +16,7 @@ import math -from armi.reactor.components import componentParameters -from armi.reactor.components import ShapedComponent +from armi.reactor.components import ShapedComponent, componentParameters class Sphere(ShapedComponent): diff --git a/armi/reactor/composites.py b/armi/reactor/composites.py index 1b2bad687..e6cd581c6 100644 --- a/armi/reactor/composites.py +++ b/armi/reactor/composites.py @@ -46,9 +46,7 @@ from armi.reactor import grids, parameters from armi.reactor.flags import Flags, TypeSpec from armi.reactor.parameters import resolveCollections -from armi.utils import densityTools -from armi.utils import tabulate -from armi.utils import units +from armi.utils import densityTools, tabulate, units from armi.utils.densityTools import calculateNumberDensity from armi.utils.flags import auto diff --git a/armi/reactor/converters/axialExpansionChanger/__init__.py b/armi/reactor/converters/axialExpansionChanger/__init__.py index 9676af29d..eb7454eac 100644 --- a/armi/reactor/converters/axialExpansionChanger/__init__.py +++ b/armi/reactor/converters/axialExpansionChanger/__init__.py @@ -19,12 +19,10 @@ ) from armi.reactor.converters.axialExpansionChanger.axialExpansionChanger import ( AxialExpansionChanger, -) -from armi.reactor.converters.axialExpansionChanger.axialExpansionChanger import ( makeAssemsAbleToSnapToUniformMesh, ) -from armi.reactor.converters.axialExpansionChanger.expansionData import ExpansionData from armi.reactor.converters.axialExpansionChanger.expansionData import ( + ExpansionData, getSolidComponents, iterSolidComponents, ) diff --git a/armi/reactor/converters/axialExpansionChanger/assemblyAxialLinkage.py b/armi/reactor/converters/axialExpansionChanger/assemblyAxialLinkage.py index ae546b51e..c41977d63 100644 --- a/armi/reactor/converters/axialExpansionChanger/assemblyAxialLinkage.py +++ b/armi/reactor/converters/axialExpansionChanger/assemblyAxialLinkage.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import typing import dataclasses import functools import itertools +import typing from armi import runLog from armi.reactor.blocks import Block @@ -24,7 +24,6 @@ iterSolidComponents, ) - if typing.TYPE_CHECKING: from armi.reactor.assemblies import Assembly diff --git a/armi/reactor/converters/axialExpansionChanger/expansionData.py b/armi/reactor/converters/axialExpansionChanger/expansionData.py index 39d4dacaa..b3aa73aed 100644 --- a/armi/reactor/converters/axialExpansionChanger/expansionData.py +++ b/armi/reactor/converters/axialExpansionChanger/expansionData.py @@ -14,7 +14,7 @@ """Data container for axial expansion.""" from statistics import mean -from typing import TYPE_CHECKING, Optional, Iterable +from typing import TYPE_CHECKING, Iterable, Optional from armi import runLog from armi.materials import material @@ -29,9 +29,9 @@ ] if TYPE_CHECKING: - from armi.reactor.components import Component - from armi.reactor.blocks import Block from armi.reactor.assemblies import Assembly + from armi.reactor.blocks import Block + from armi.reactor.components import Component def iterSolidComponents(b: "Block") -> Iterable["Component"]: diff --git a/armi/reactor/converters/geometryConverters.py b/armi/reactor/converters/geometryConverters.py index e035c4e9a..8006a917f 100644 --- a/armi/reactor/converters/geometryConverters.py +++ b/armi/reactor/converters/geometryConverters.py @@ -35,26 +35,26 @@ import matplotlib.pyplot as plt import numpy as np -from armi import materials -from armi import runLog +from armi import materials, runLog from armi.physics.neutronics.fissionProductModel import lumpedFissionProduct -from armi.reactor import assemblies -from armi.reactor import blocks -from armi.reactor import components -from armi.reactor import geometry -from armi.reactor import grids -from armi.reactor import parameters -from armi.reactor import reactors -from armi.reactor.converters import blockConverters -from armi.reactor.converters import meshConverters +from armi.reactor import ( + assemblies, + blocks, + components, + geometry, + grids, + parameters, + reactors, +) +from armi.reactor.converters import blockConverters, meshConverters from armi.reactor.flags import Flags -from armi.reactor.parameters import Category -from armi.reactor.parameters import NEVER -from armi.reactor.parameters import ParamLocation -from armi.reactor.parameters import SINCE_LAST_GEOMETRY_TRANSFORMATION -from armi.utils import hexagon -from armi.utils import plotting -from armi.utils import units +from armi.reactor.parameters import ( + NEVER, + SINCE_LAST_GEOMETRY_TRANSFORMATION, + Category, + ParamLocation, +) +from armi.utils import hexagon, plotting, units BLOCK_AXIAL_MESH_SPACING = ( 20 # Block axial mesh spacing set for nodal diffusion calculation (cm) diff --git a/armi/reactor/converters/meshConverters.py b/armi/reactor/converters/meshConverters.py index 769770e63..ef89eedaa 100644 --- a/armi/reactor/converters/meshConverters.py +++ b/armi/reactor/converters/meshConverters.py @@ -15,8 +15,8 @@ """Mesh specifiers update the mesh structure of a reactor by increasing or decreasing the number of mesh coordinates.""" import collections -import math import itertools +import math import numpy as np diff --git a/armi/reactor/converters/parameterSweeps/generalParameterSweepConverters.py b/armi/reactor/converters/parameterSweeps/generalParameterSweepConverters.py index 11248e3b8..a5d6a0bc0 100644 --- a/armi/reactor/converters/parameterSweeps/generalParameterSweepConverters.py +++ b/armi/reactor/converters/parameterSweeps/generalParameterSweepConverters.py @@ -13,12 +13,12 @@ # limitations under the License. """Module for general core parameter sweeps.""" -from armi.reactor.converters.geometryConverters import GeometryConverter from armi.physics.neutronics.settings import ( CONF_EPS_EIG, CONF_EPS_FSAVG, CONF_EPS_FSPOINT, ) +from armi.reactor.converters.geometryConverters import GeometryConverter class ParameterSweepConverter(GeometryConverter): diff --git a/armi/reactor/converters/parameterSweeps/tests/test_paramSweepConverters.py b/armi/reactor/converters/parameterSweeps/tests/test_paramSweepConverters.py index 8222ec533..af7d0dd6f 100644 --- a/armi/reactor/converters/parameterSweeps/tests/test_paramSweepConverters.py +++ b/armi/reactor/converters/parameterSweeps/tests/test_paramSweepConverters.py @@ -25,7 +25,6 @@ from armi.testing import loadTestReactor from armi.tests import TEST_ROOT - THIS_DIR = os.path.dirname(__file__) diff --git a/armi/reactor/converters/pinTypeBlockConverters.py b/armi/reactor/converters/pinTypeBlockConverters.py index 59864ae35..ab36abbfe 100644 --- a/armi/reactor/converters/pinTypeBlockConverters.py +++ b/armi/reactor/converters/pinTypeBlockConverters.py @@ -28,8 +28,8 @@ """ import math -from armi.reactor.flags import Flags from armi import runLog +from armi.reactor.flags import Flags def adjustSmearDensity(obj, value, bolBlock=None): diff --git a/armi/reactor/converters/tests/test_blockConverter.py b/armi/reactor/converters/tests/test_blockConverter.py index c2ada65cf..702b8eb38 100644 --- a/armi/reactor/converters/tests/test_blockConverter.py +++ b/armi/reactor/converters/tests/test_blockConverter.py @@ -13,10 +13,10 @@ # limitations under the License. """Test block conversions.""" +import math import os import unittest -import math import numpy as np from armi.physics.neutronics.isotopicDepletion.isotopicDepletionInterface import ( diff --git a/armi/reactor/converters/tests/test_geometryConverters.py b/armi/reactor/converters/tests/test_geometryConverters.py index 5a9c18dde..5746a18bb 100644 --- a/armi/reactor/converters/tests/test_geometryConverters.py +++ b/armi/reactor/converters/tests/test_geometryConverters.py @@ -16,20 +16,17 @@ import math import os import unittest + from numpy.testing import assert_allclose from armi import runLog -from armi.reactor import blocks -from armi.reactor import geometry -from armi.reactor import grids -from armi.reactor.converters import geometryConverters -from armi.reactor.converters import uniformMesh +from armi.reactor import blocks, geometry, grids +from armi.reactor.converters import geometryConverters, uniformMesh from armi.reactor.flags import Flags from armi.testing import loadTestReactor, reduceTestReactorRings from armi.tests import TEST_ROOT, mockRunLogs from armi.utils import directoryChangers - THIS_DIR = os.path.dirname(__file__) diff --git a/armi/reactor/converters/tests/test_meshConverters.py b/armi/reactor/converters/tests/test_meshConverters.py index e3630fc28..14f102139 100644 --- a/armi/reactor/converters/tests/test_meshConverters.py +++ b/armi/reactor/converters/tests/test_meshConverters.py @@ -16,7 +16,7 @@ import math import unittest -from armi.reactor.converters import meshConverters, geometryConverters +from armi.reactor.converters import geometryConverters, meshConverters from armi.testing import loadTestReactor from armi.tests import TEST_ROOT diff --git a/armi/reactor/converters/tests/test_pinTypeBlockConverters.py b/armi/reactor/converters/tests/test_pinTypeBlockConverters.py index 2574aa969..4760d9f7b 100644 --- a/armi/reactor/converters/tests/test_pinTypeBlockConverters.py +++ b/armi/reactor/converters/tests/test_pinTypeBlockConverters.py @@ -15,14 +15,13 @@ import copy import unittest -from armi.reactor.flags import Flags - -from armi.reactor.tests.test_blocks import loadTestBlock, buildSimpleFuelBlock from armi.reactor.converters.pinTypeBlockConverters import ( - adjustCladThicknessByOD, adjustCladThicknessByID, + adjustCladThicknessByOD, adjustSmearDensity, ) +from armi.reactor.flags import Flags +from armi.reactor.tests.test_blocks import buildSimpleFuelBlock, loadTestBlock class TestPinTypeConverters(unittest.TestCase): diff --git a/armi/reactor/converters/tests/test_uniformMesh.py b/armi/reactor/converters/tests/test_uniformMesh.py index 1f4f404da..d5d386f56 100644 --- a/armi/reactor/converters/tests/test_uniformMesh.py +++ b/armi/reactor/converters/tests/test_uniformMesh.py @@ -13,20 +13,19 @@ # limitations under the License. """Tests for the uniform mesh geometry converter.""" import collections +import copy import os import random import unittest -import copy from armi.nuclearDataIO.cccc import isotxs from armi.physics.neutronics.settings import CONF_XS_KERNEL -from armi.settings.fwSettings.globalSettings import CONF_UNIFORM_MESH_MINIMUM_SIZE from armi.reactor.converters import uniformMesh from armi.reactor.flags import Flags -from armi.reactor.tests import test_assemblies -from armi.reactor.tests import test_blocks +from armi.reactor.tests import test_assemblies, test_blocks +from armi.settings.fwSettings.globalSettings import CONF_UNIFORM_MESH_MINIMUM_SIZE from armi.testing import loadTestReactor, reduceTestReactorRings -from armi.tests import TEST_ROOT, ISOAA_PATH +from armi.tests import ISOAA_PATH, TEST_ROOT class DummyFluxOptions: diff --git a/armi/reactor/converters/uniformMesh.py b/armi/reactor/converters/uniformMesh.py index 8bb949771..af7fcda70 100644 --- a/armi/reactor/converters/uniformMesh.py +++ b/armi/reactor/converters/uniformMesh.py @@ -52,28 +52,24 @@ .. figure:: /.static/axial_homogenization.png """ -import re -import glob -import copy import collections +import copy +import glob +import re from timeit import default_timer as timer import numpy as np import armi from armi import runLog -from armi.utils.mathematics import average1DWithinTolerance -from armi.utils import iterables -from armi.utils import plotting -from armi.reactor import grids -from armi.reactor.reactors import Core -from armi.reactor.flags import Flags +from armi.physics.neutronics.globalFlux import RX_ABS_MICRO_LABELS, RX_PARAM_NAMES +from armi.reactor import grids, parameters from armi.reactor.converters.geometryConverters import GeometryConverter -from armi.reactor import parameters -from armi.reactor.reactors import Reactor +from armi.reactor.flags import Flags +from armi.reactor.reactors import Core, Reactor from armi.settings.fwSettings.globalSettings import CONF_UNIFORM_MESH_MINIMUM_SIZE -from armi.physics.neutronics.globalFlux import RX_PARAM_NAMES, RX_ABS_MICRO_LABELS - +from armi.utils import iterables, plotting +from armi.utils.mathematics import average1DWithinTolerance HEAVY_METAL_PARAMS = ["molesHmBOL", "massHmBOL"] diff --git a/armi/reactor/cores.py b/armi/reactor/cores.py index 00ce8d47d..830a8fd5a 100644 --- a/armi/reactor/cores.py +++ b/armi/reactor/cores.py @@ -18,24 +18,25 @@ A Core frequently contain assemblies which in turn contain more refinement in representing the physical reactor. """ -from typing import Optional import collections import copy import itertools import os import time +from typing import Optional import numpy as np -from armi import getPluginManagerOrFail, nuclearDataIO -from armi import runLog +from armi import getPluginManagerOrFail, nuclearDataIO, runLog from armi.nuclearDataIO import xsLibraries -from armi.reactor import composites -from armi.reactor import geometry -from armi.reactor import grids -from armi.reactor import parameters -from armi.reactor import reactorParameters -from armi.reactor import zones +from armi.reactor import ( + composites, + geometry, + grids, + parameters, + reactorParameters, + zones, +) from armi.reactor.flags import Flags from armi.settings.fwSettings.globalSettings import ( CONF_AUTOMATIC_VARIABLE_MESH, @@ -48,8 +49,7 @@ CONF_TRACK_ASSEMS, CONF_ZONE_DEFINITIONS, ) -from armi.utils import createFormattedStrWithDelimiter, units -from armi.utils import tabulate +from armi.utils import createFormattedStrWithDelimiter, tabulate, units from armi.utils.iterables import Sequence from armi.utils.mathematics import average1DWithinTolerance @@ -124,8 +124,8 @@ def __init__(self, name): def setOptionsFromCs(self, cs): from armi.physics.fuelCycle.settings import ( - CONF_JUMP_RING_NUM, CONF_CIRCULAR_RING_MODE, + CONF_JUMP_RING_NUM, ) # these are really "user modifiable modeling constants" diff --git a/armi/reactor/flags.py b/armi/reactor/flags.py index 190d58c7a..e311f6e4a 100644 --- a/armi/reactor/flags.py +++ b/armi/reactor/flags.py @@ -110,7 +110,6 @@ from armi.utils.flags import Flag, FlagType, auto - # Type alias used for passing type specifications to many of the composite methods. See # Composite::hasFlags() to understand the semantics for how TypeSpecs are interpreted. # Anything that interprets a TypeSpec should apply the same semantics. diff --git a/armi/reactor/geometry.py b/armi/reactor/geometry.py index 93a9d9fc5..7d1e3601e 100644 --- a/armi/reactor/geometry.py +++ b/armi/reactor/geometry.py @@ -17,7 +17,7 @@ geometry. """ import enum -from typing import Union, Optional +from typing import Optional, Union class GeomType(enum.Enum): diff --git a/armi/reactor/grids/__init__.py b/armi/reactor/grids/__init__.py index fa6fe3c07..541e1cd15 100644 --- a/armi/reactor/grids/__init__.py +++ b/armi/reactor/grids/__init__.py @@ -61,29 +61,27 @@ current grid. """ # ruff: noqa: F401 -from typing import Tuple, Optional +from typing import Optional, Tuple +from armi.reactor.grids.axial import AxialGrid +from armi.reactor.grids.cartesian import CartesianGrid from armi.reactor.grids.constants import ( - BOUNDARY_CENTER, BOUNDARY_0_DEGREES, - BOUNDARY_120_DEGREES, BOUNDARY_60_DEGREES, + BOUNDARY_120_DEGREES, + BOUNDARY_CENTER, ) - +from armi.reactor.grids.grid import Grid +from armi.reactor.grids.hexagonal import COS30, SIN30, TRIANGLES_IN_HEXAGON, HexGrid from armi.reactor.grids.locations import ( - LocationBase, + CoordinateLocation, IndexLocation, + LocationBase, MultiIndexLocation, - CoordinateLocation, addingIsValid, ) - -from armi.reactor.grids.grid import Grid -from armi.reactor.grids.structuredGrid import StructuredGrid, GridParameters, _tuplify -from armi.reactor.grids.axial import AxialGrid -from armi.reactor.grids.cartesian import CartesianGrid -from armi.reactor.grids.hexagonal import HexGrid, COS30, SIN30, TRIANGLES_IN_HEXAGON -from armi.reactor.grids.thetarz import ThetaRZGrid, TAU +from armi.reactor.grids.structuredGrid import GridParameters, StructuredGrid, _tuplify +from armi.reactor.grids.thetarz import TAU, ThetaRZGrid def locatorLabelToIndices(label: str) -> Tuple[int, int, Optional[int]]: diff --git a/armi/reactor/grids/axial.py b/armi/reactor/grids/axial.py index 4cde443f1..ffbb43a4a 100644 --- a/armi/reactor/grids/axial.py +++ b/armi/reactor/grids/axial.py @@ -11,7 +11,7 @@ # 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. -from typing import List, Optional, TYPE_CHECKING, NoReturn +from typing import TYPE_CHECKING, List, NoReturn, Optional import numpy as np diff --git a/armi/reactor/grids/cartesian.py b/armi/reactor/grids/cartesian.py index 4971e8ee0..adb83c08e 100644 --- a/armi/reactor/grids/cartesian.py +++ b/armi/reactor/grids/cartesian.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import itertools -from typing import Optional, NoReturn, Tuple +from typing import NoReturn, Optional, Tuple import numpy as np diff --git a/armi/reactor/grids/grid.py b/armi/reactor/grids/grid.py index fac584260..14ab823c2 100644 --- a/armi/reactor/grids/grid.py +++ b/armi/reactor/grids/grid.py @@ -12,12 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. from abc import ABC, abstractmethod -from typing import Union, Optional, Hashable, TYPE_CHECKING, Dict, Iterable, Tuple, List +from typing import TYPE_CHECKING, Dict, Hashable, Iterable, List, Optional, Tuple, Union import numpy as np from armi.reactor import geometry -from armi.reactor.grids.locations import LocationBase, IndexLocation, IJType, IJKType +from armi.reactor.grids.locations import IJKType, IJType, IndexLocation, LocationBase if TYPE_CHECKING: from armi.reactor.composites import ArmiObject diff --git a/armi/reactor/grids/hexagonal.py b/armi/reactor/grids/hexagonal.py index df44d19ef..262307826 100644 --- a/armi/reactor/grids/hexagonal.py +++ b/armi/reactor/grids/hexagonal.py @@ -13,15 +13,15 @@ # limitations under the License. from collections import deque from math import sqrt -from typing import Tuple, List, Optional +from typing import List, Optional, Tuple import numpy as np from armi.reactor import geometry from armi.reactor.grids.constants import ( BOUNDARY_0_DEGREES, - BOUNDARY_120_DEGREES, BOUNDARY_60_DEGREES, + BOUNDARY_120_DEGREES, BOUNDARY_CENTER, ) from armi.reactor.grids.locations import IJKType, IJType, IndexLocation diff --git a/armi/reactor/grids/locations.py b/armi/reactor/grids/locations.py index 1d0320ee2..cc2a1aaf7 100644 --- a/armi/reactor/grids/locations.py +++ b/armi/reactor/grids/locations.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Optional, TYPE_CHECKING, Union, Hashable, Tuple, List, Iterator -from abc import ABC, abstractmethod import math +from abc import ABC, abstractmethod +from typing import TYPE_CHECKING, Hashable, Iterator, List, Optional, Tuple, Union import numpy as np diff --git a/armi/reactor/grids/structuredGrid.py b/armi/reactor/grids/structuredGrid.py index 07388338b..177120419 100644 --- a/armi/reactor/grids/structuredGrid.py +++ b/armi/reactor/grids/structuredGrid.py @@ -10,10 +10,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from abc import abstractmethod import collections import itertools -from typing import Tuple, Union, List, Iterable, Optional, Sequence +from abc import abstractmethod +from typing import Iterable, List, Optional, Sequence, Tuple, Union import numpy as np diff --git a/armi/reactor/grids/tests/test_grids.py b/armi/reactor/grids/tests/test_grids.py index 79502922d..8cfa5c492 100644 --- a/armi/reactor/grids/tests/test_grids.py +++ b/armi/reactor/grids/tests/test_grids.py @@ -13,17 +13,16 @@ # limitations under the License. """Tests for grids.""" -from io import BytesIO -from random import randint import math import pickle import unittest +from io import BytesIO +from random import randint import numpy as np from numpy.testing import assert_allclose, assert_array_equal -from armi.reactor import geometry -from armi.reactor import grids +from armi.reactor import geometry, grids from armi.utils import hexagon diff --git a/armi/reactor/grids/thetarz.py b/armi/reactor/grids/thetarz.py index 7f9582d4c..c3270c009 100644 --- a/armi/reactor/grids/thetarz.py +++ b/armi/reactor/grids/thetarz.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. import math -from typing import TYPE_CHECKING, Optional, NoReturn +from typing import TYPE_CHECKING, NoReturn, Optional import numpy as np -from armi.reactor.grids.locations import IJType, IJKType +from armi.reactor.grids.locations import IJKType, IJType from armi.reactor.grids.structuredGrid import StructuredGrid if TYPE_CHECKING: diff --git a/armi/reactor/parameters/__init__.py b/armi/reactor/parameters/__init__.py index 16bf2813b..62716923b 100644 --- a/armi/reactor/parameters/__init__.py +++ b/armi/reactor/parameters/__init__.py @@ -197,37 +197,32 @@ class instance to have a ``__dict__``. This saves memory when there are many .. _Meriam-Webster: http://www.merriam-webster.com/dictionary/parameter """ # ruff: noqa: F401 +from armi.reactor.parameters.exceptions import ( + ParameterDefinitionError, + ParameterError, + UnknownParameterError, +) from armi.reactor.parameters.parameterCollections import ( ParameterCollection, + applyAllParameters, collectPluginParameters, ) -from armi.reactor.parameters.parameterCollections import applyAllParameters -from armi.reactor.parameters.parameterDefinitions import ( - ParameterDefinitionCollection, - Parameter, -) - from armi.reactor.parameters.parameterDefinitions import ( + ALL_DEFINITIONS, + NEVER, + SINCE_ANYTHING, + SINCE_BACKUP, SINCE_INITIALIZATION, SINCE_LAST_DISTRIBUTE_STATE, SINCE_LAST_GEOMETRY_TRANSFORMATION, - SINCE_BACKUP, - SINCE_ANYTHING, - NEVER, - Serializer, Category, - ParamLocation, NoDefault, - ALL_DEFINITIONS, -) - -from armi.reactor.parameters.exceptions import ( - ParameterDefinitionError, - ParameterError, - UnknownParameterError, + Parameter, + ParameterDefinitionCollection, + ParamLocation, + Serializer, ) - forType = ALL_DEFINITIONS.forType inCategory = ALL_DEFINITIONS.inCategory byNameAndType = ALL_DEFINITIONS.byNameAndType diff --git a/armi/reactor/parameters/parameterCollections.py b/armi/reactor/parameters/parameterCollections.py index c588563cc..65f3c34fc 100644 --- a/armi/reactor/parameters/parameterCollections.py +++ b/armi/reactor/parameters/parameterCollections.py @@ -12,24 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Optional, List, Set, Iterator, Callable import copy import pickle import sys +from typing import Any, Callable, Iterator, List, Optional, Set import numpy as np from armi import runLog -from armi.reactor.parameters import parameterDefinitions, exceptions +from armi.reactor.parameters import exceptions, parameterDefinitions from armi.reactor.parameters.parameterDefinitions import ( - SINCE_LAST_DISTRIBUTE_STATE, - SINCE_BACKUP, - SINCE_ANYTHING, NEVER, + SINCE_ANYTHING, + SINCE_BACKUP, + SINCE_LAST_DISTRIBUTE_STATE, ) from armi.utils import units - GLOBAL_SERIAL_NUM = -1 """ The serial number for all ParameterCollections diff --git a/armi/reactor/parameters/parameterDefinitions.py b/armi/reactor/parameters/parameterDefinitions.py index 4063a2cf3..54b213782 100644 --- a/armi/reactor/parameters/parameterDefinitions.py +++ b/armi/reactor/parameters/parameterDefinitions.py @@ -25,15 +25,15 @@ -------- armi.reactor.parameters """ -from typing import Any, Dict, Optional, Sequence, Tuple, Type import enum import functools import re +from typing import Any, Dict, Optional, Sequence, Tuple, Type import numpy as np from armi.reactor.flags import Flags -from armi.reactor.parameters.exceptions import ParameterError, ParameterDefinitionError +from armi.reactor.parameters.exceptions import ParameterDefinitionError, ParameterError # bitwise masks for high-speed operations on the `assigned` attribute # see: https://web.archive.org/web/20120225043338/http://www.vipan.com/htdocs/bitwisehelp.html diff --git a/armi/reactor/reactors.py b/armi/reactor/reactors.py index 1c5b862d5..4354fe60b 100644 --- a/armi/reactor/reactors.py +++ b/armi/reactor/reactors.py @@ -16,16 +16,13 @@ Reactor objects represent the highest level in the hierarchy of structures that compose the system to be modeled. """ -from typing import Optional import copy +from typing import Optional -from armi import getPluginManagerOrFail -from armi import runLog -from armi.reactor import composites -from armi.reactor import reactorParameters +from armi import getPluginManagerOrFail, runLog +from armi.reactor import composites, reactorParameters from armi.reactor.cores import Core -from armi.reactor.excoreStructure import ExcoreCollection -from armi.reactor.excoreStructure import ExcoreStructure +from armi.reactor.excoreStructure import ExcoreCollection, ExcoreStructure from armi.reactor.systemLayoutInput import SystemLayoutInput from armi.settings.fwSettings.globalSettings import ( CONF_GEOM_FILE, diff --git a/armi/reactor/systemLayoutInput.py b/armi/reactor/systemLayoutInput.py index 38573b029..7b7cdb659 100644 --- a/armi/reactor/systemLayoutInput.py +++ b/armi/reactor/systemLayoutInput.py @@ -25,20 +25,18 @@ reactor.blueprints.gridBlueprint """ -from collections import OrderedDict -from copy import copy import os import sys import xml.etree.ElementTree as ET +from collections import OrderedDict +from copy import copy -from ruamel.yaml import YAML import voluptuous as vol +from ruamel.yaml import YAML from armi import runLog -from armi.reactor import geometry -from armi.reactor import grids -from armi.utils import asciimaps -from armi.utils import directoryChangers +from armi.reactor import geometry, grids +from armi.utils import asciimaps, directoryChangers INP_SYSTEMS = "reactor" INP_SYMMETRY = "symmetry" diff --git a/armi/reactor/tests/test_assemblies.py b/armi/reactor/tests/test_assemblies.py index 787dd129c..d32494725 100644 --- a/armi/reactor/tests/test_assemblies.py +++ b/armi/reactor/tests/test_assemblies.py @@ -21,31 +21,30 @@ import numpy as np from numpy.testing import assert_allclose -from armi import settings -from armi import tests +from armi import settings, tests from armi.physics.neutronics.settings import ( CONF_LOADING_FILE, CONF_XS_KERNEL, ) -from armi.reactor import assemblies -from armi.reactor import blocks -from armi.reactor import blueprints -from armi.reactor import components -from armi.reactor import geometry -from armi.reactor import parameters -from armi.reactor import reactors +from armi.reactor import ( + assemblies, + blocks, + blueprints, + components, + geometry, + parameters, + reactors, +) from armi.reactor.assemblies import ( - copy, Flags, - grids, HexAssembly, + copy, + grids, runLog, ) from armi.reactor.tests import test_reactors from armi.tests import TEST_ROOT, mockRunLogs -from armi.utils import directoryChangers -from armi.utils import textProcessors - +from armi.utils import directoryChangers, textProcessors NUM_BLOCKS = 3 diff --git a/armi/reactor/tests/test_blocks.py b/armi/reactor/tests/test_blocks.py index ff55fe517..aa6c914d4 100644 --- a/armi/reactor/tests/test_blocks.py +++ b/armi/reactor/tests/test_blocks.py @@ -39,11 +39,14 @@ from armi.reactor.tests.test_assemblies import makeTestAssembly from armi.testing import loadTestReactor from armi.tests import ISOAA_PATH, TEST_ROOT -from armi.utils import hexagon, units, densityTools +from armi.utils import densityTools, hexagon, units from armi.utils.directoryChangers import TemporaryDirectoryChanger -from armi.utils.units import ASCII_LETTER_A, ASCII_LETTER_Z, ASCII_LETTER_a -from armi.utils.units import MOLES_PER_CC_TO_ATOMS_PER_BARN_CM - +from armi.utils.units import ( + ASCII_LETTER_A, + ASCII_LETTER_Z, + MOLES_PER_CC_TO_ATOMS_PER_BARN_CM, + ASCII_LETTER_a, +) NUM_PINS_IN_TEST_BLOCK = 217 diff --git a/armi/reactor/tests/test_components.py b/armi/reactor/tests/test_components.py index 18e8a530e..ad32245e4 100644 --- a/armi/reactor/tests/test_components.py +++ b/armi/reactor/tests/test_components.py @@ -22,8 +22,7 @@ from armi.materials import air, alloy200 from armi.materials.material import Material -from armi.reactor import components -from armi.reactor import flags +from armi.reactor import components, flags from armi.reactor.blocks import Block from armi.reactor.components import ( Circle, diff --git a/armi/reactor/tests/test_composites.py b/armi/reactor/tests/test_composites.py index 96966a768..861faa80c 100644 --- a/armi/reactor/tests/test_composites.py +++ b/armi/reactor/tests/test_composites.py @@ -13,31 +13,23 @@ # limitations under the License. """Tests for the composite pattern.""" -from copy import deepcopy import logging import unittest +from copy import deepcopy -from armi import nuclearDataIO -from armi import runLog -from armi import settings -from armi import utils +from armi import nuclearDataIO, runLog, settings, utils from armi.nucDirectory import nucDir, nuclideBases from armi.physics.neutronics.fissionProductModel.tests.test_lumpedFissionProduct import ( getDummyLFPFile, ) -from armi.reactor import assemblies -from armi.reactor import components -from armi.reactor import composites -from armi.reactor import grids -from armi.reactor import parameters +from armi.reactor import assemblies, components, composites, grids, parameters from armi.reactor.blueprints import assemblyBlueprint from armi.reactor.components import basicShapes from armi.reactor.composites import getReactionRateDict from armi.reactor.flags import Flags, TypeSpec from armi.reactor.tests.test_blocks import loadTestBlock from armi.testing import loadTestReactor -from armi.tests import ISOAA_PATH -from armi.tests import mockRunLogs +from armi.tests import ISOAA_PATH, mockRunLogs class MockBP: diff --git a/armi/reactor/tests/test_hexBlockRotate.py b/armi/reactor/tests/test_hexBlockRotate.py index 610286c2e..d0bac628b 100644 --- a/armi/reactor/tests/test_hexBlockRotate.py +++ b/armi/reactor/tests/test_hexBlockRotate.py @@ -22,12 +22,12 @@ from armi.reactor.blocks import HexBlock from armi.reactor.components import Component from armi.reactor.grids import ( - MultiIndexLocation, CoordinateLocation, - IndexLocation, HexGrid, + IndexLocation, + MultiIndexLocation, ) -from armi.reactor.tests.test_blocks import loadTestBlock, NUM_PINS_IN_TEST_BLOCK +from armi.reactor.tests.test_blocks import NUM_PINS_IN_TEST_BLOCK, loadTestBlock from armi.utils import iterables diff --git a/armi/reactor/tests/test_parameters.py b/armi/reactor/tests/test_parameters.py index 8a324f635..9f1a5e018 100644 --- a/armi/reactor/tests/test_parameters.py +++ b/armi/reactor/tests/test_parameters.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. """Tests for assorted Parameters tools.""" -from glob import glob -from shutil import copyfile import copy import os import unittest +from glob import glob +from shutil import copyfile from armi.reactor import parameters from armi.reactor.reactorParameters import makeParametersReadOnly diff --git a/armi/reactor/tests/test_reactors.py b/armi/reactor/tests/test_reactors.py index 89ad36038..561c55247 100644 --- a/armi/reactor/tests/test_reactors.py +++ b/armi/reactor/tests/test_reactors.py @@ -22,27 +22,22 @@ from numpy.testing import assert_allclose, assert_equal -from armi import operators -from armi import runLog -from armi import settings -from armi import tests +from armi import operators, runLog, settings, tests from armi.materials import uZr from armi.physics.neutronics.settings import CONF_XS_KERNEL -from armi.reactor import assemblies -from armi.reactor import blocks -from armi.reactor import geometry -from armi.reactor import grids -from armi.reactor import reactors +from armi.reactor import assemblies, blocks, geometry, grids, reactors from armi.reactor.components import Hexagon, Rectangle from armi.reactor.composites import Composite from armi.reactor.converters import geometryConverters from armi.reactor.converters.axialExpansionChanger import AxialExpansionChanger from armi.reactor.flags import Flags from armi.reactor.spentFuelPool import SpentFuelPool -from armi.settings.fwSettings.globalSettings import CONF_ASSEM_FLAGS_SKIP_AXIAL_EXP -from armi.settings.fwSettings.globalSettings import CONF_SORT_REACTOR +from armi.settings.fwSettings.globalSettings import ( + CONF_ASSEM_FLAGS_SKIP_AXIAL_EXP, + CONF_SORT_REACTOR, +) from armi.testing import loadTestReactor, reduceTestReactorRings # noqa: F401 -from armi.tests import mockRunLogs, TEST_ROOT +from armi.tests import TEST_ROOT, mockRunLogs from armi.utils import directoryChangers _THIS_DIR = os.path.dirname(__file__) diff --git a/armi/reactor/tests/test_zones.py b/armi/reactor/tests/test_zones.py index 4ded16430..9ac40a6d3 100644 --- a/armi/reactor/tests/test_zones.py +++ b/armi/reactor/tests/test_zones.py @@ -18,13 +18,15 @@ import unittest from armi import runLog -from armi.reactor import assemblies -from armi.reactor import blocks -from armi.reactor import blueprints -from armi.reactor import geometry -from armi.reactor import grids -from armi.reactor import reactors -from armi.reactor import zones +from armi.reactor import ( + assemblies, + blocks, + blueprints, + geometry, + grids, + reactors, + zones, +) from armi.reactor.tests import test_reactors from armi.tests import mockRunLogs diff --git a/armi/settings/__init__.py b/armi/settings/__init__.py index 258864bde..31bc31307 100644 --- a/armi/settings/__init__.py +++ b/armi/settings/__init__.py @@ -20,21 +20,22 @@ availability fraction and things like that. The ARMI Framework itself has many settings of its own, and plugins typically register some of their own settings as well. """ -from typing import List import fnmatch import glob import os +from typing import List from ruamel import yaml from armi import runLog from armi.settings.caseSettings import Settings -from armi.settings.setting import Default # noqa: F401 -from armi.settings.setting import Option # noqa: F401 -from armi.settings.setting import Setting +from armi.settings.setting import ( + Default, # noqa: F401 + Option, # noqa: F401 + Setting, +) from armi.utils.customExceptions import InvalidSettingsFileError - NOT_ENABLED = "" # An empty setting value implies that the feature diff --git a/armi/settings/caseSettings.py b/armi/settings/caseSettings.py index 165359fd5..76a2d2f0b 100644 --- a/armi/settings/caseSettings.py +++ b/armi/settings/caseSettings.py @@ -25,10 +25,10 @@ import logging import os from copy import copy, deepcopy + from ruamel.yaml import YAML -from armi import context -from armi import runLog +from armi import context, runLog from armi.settings import settingsIO from armi.settings.setting import Setting from armi.utils import pathTools diff --git a/armi/settings/fwSettings/__init__.py b/armi/settings/fwSettings/__init__.py index a7caffdb4..22e96f542 100644 --- a/armi/settings/fwSettings/__init__.py +++ b/armi/settings/fwSettings/__init__.py @@ -16,9 +16,7 @@ from typing import List from armi.settings import setting -from armi.settings.fwSettings import globalSettings -from armi.settings.fwSettings import databaseSettings -from armi.settings.fwSettings import reportSettings +from armi.settings.fwSettings import databaseSettings, globalSettings, reportSettings def getFrameworkSettings() -> List[setting.Setting]: diff --git a/armi/settings/fwSettings/globalSettings.py b/armi/settings/fwSettings/globalSettings.py index 353a0cc79..cb07e9b33 100644 --- a/armi/settings/fwSettings/globalSettings.py +++ b/armi/settings/fwSettings/globalSettings.py @@ -29,7 +29,6 @@ from armi.settings.fwSettings import tightCouplingSettings from armi.utils.mathematics import isMonotonic - # Framework settings CONF_ACCEPTABLE_BLOCK_AREA_ERROR = "acceptableBlockAreaError" CONF_ASSEM_FLAGS_SKIP_AXIAL_EXP = "assemFlagsToSkipAxialExpansion" diff --git a/armi/settings/fwSettings/reportSettings.py b/armi/settings/fwSettings/reportSettings.py index 67c5a8322..5cb16c5a4 100644 --- a/armi/settings/fwSettings/reportSettings.py +++ b/armi/settings/fwSettings/reportSettings.py @@ -18,7 +18,6 @@ from armi.settings import setting - CONF_GEN_REPORTS = "genReports" CONF_ASSEM_POW_SUMMARY = "assemPowSummary" CONF_SUMMARIZE_ASSEM_DESIGN = "summarizeAssemDesign" diff --git a/armi/settings/fwSettings/tests/test_tightCouplingSettings.py b/armi/settings/fwSettings/tests/test_tightCouplingSettings.py index 7336ba713..451617b8b 100644 --- a/armi/settings/fwSettings/tests/test_tightCouplingSettings.py +++ b/armi/settings/fwSettings/tests/test_tightCouplingSettings.py @@ -21,11 +21,11 @@ import io import unittest -from ruamel.yaml import YAML import voluptuous as vol +from ruamel.yaml import YAML -from armi.settings.fwSettings.tightCouplingSettings import TightCouplingSettingDef from armi.settings.fwSettings.tightCouplingSettings import ( + TightCouplingSettingDef, tightCouplingSettingsValidator, ) diff --git a/armi/settings/setting.py b/armi/settings/setting.py index 1d83cccc7..c4d901d0f 100644 --- a/armi/settings/setting.py +++ b/armi/settings/setting.py @@ -23,17 +23,16 @@ complex schema validation for settings that are more complex dictionaries (e.g. XS, rx coeffs). """ -from collections import namedtuple -from typing import List, Optional, Tuple import copy import datetime +from collections import namedtuple +from typing import List, Optional, Tuple import voluptuous as vol from armi import runLog from armi.reactor.flags import Flags - # Options are used to imbue existing settings with new Options. This allows a setting # like `neutronicsKernel` to strictly enforce options, even though the plugin that # defines it does not know all possible options, which may be provided from other diff --git a/armi/settings/settingsIO.py b/armi/settings/settingsIO.py index 516b5f238..d1171dfb6 100644 --- a/armi/settings/settingsIO.py +++ b/armi/settings/settingsIO.py @@ -16,19 +16,18 @@ :py:class:`~armi.settings.caseSettings.Settings`, and the contained :py:class:`~armi.settings.setting.Setting`. """ -from typing import Dict, Tuple, Set import collections import datetime import enum import os import sys +from typing import Dict, Set, Tuple -from ruamel.yaml import YAML import ruamel.yaml.comments +from ruamel.yaml import YAML -from armi import runLog +from armi import context, runLog from armi.meta import __version__ as version -from armi import context from armi.settings.setting import Setting from armi.utils.customExceptions import ( InvalidSettingsFileError, diff --git a/armi/settings/tests/test_inspectors.py b/armi/settings/tests/test_inspectors.py index cb27b3e96..e3d81095d 100644 --- a/armi/settings/tests/test_inspectors.py +++ b/armi/settings/tests/test_inspectors.py @@ -16,9 +16,7 @@ import os import unittest -from armi import context -from armi import operators -from armi import settings +from armi import context, operators, settings from armi.settings import settingsValidation from armi.settings.settingsValidation import createQueryRevertBadPathToDefault from armi.utils import directoryChangers diff --git a/armi/settings/tests/test_settings.py b/armi/settings/tests/test_settings.py index 3cfae7386..1f363565b 100644 --- a/armi/settings/tests/test_settings.py +++ b/armi/settings/tests/test_settings.py @@ -18,23 +18,17 @@ import os import unittest -from ruamel.yaml import YAML import voluptuous as vol +from ruamel.yaml import YAML -from armi import configure -from armi import getApp -from armi import getPluginManagerOrFail -from armi import plugins -from armi import settings +from armi import configure, getApp, getPluginManagerOrFail, plugins, settings from armi.physics.fuelCycle import FuelHandlerPlugin -from armi.physics.fuelCycle.settings import CONF_CIRCULAR_RING_ORDER -from armi.physics.fuelCycle.settings import CONF_SHUFFLE_LOGIC +from armi.physics.fuelCycle.settings import CONF_CIRCULAR_RING_ORDER, CONF_SHUFFLE_LOGIC from armi.physics.neutronics.settings import CONF_NEUTRONICS_KERNEL from armi.reactor.flags import Flags -from armi.settings import caseSettings -from armi.settings import setting +from armi.settings import caseSettings, setting from armi.settings.settingsValidation import Inspector, validateVersion -from armi.tests import TEST_ROOT, ARMI_RUN_PATH +from armi.tests import ARMI_RUN_PATH, TEST_ROOT from armi.utils import directoryChangers from armi.utils.customExceptions import NonexistentSetting diff --git a/armi/settings/tests/test_settingsIO.py b/armi/settings/tests/test_settingsIO.py index 9b99f1b3c..b2f0e2552 100644 --- a/armi/settings/tests/test_settingsIO.py +++ b/armi/settings/tests/test_settingsIO.py @@ -17,11 +17,9 @@ import os import unittest -from armi import context -from armi import settings +from armi import context, settings from armi.cli import entryPoint -from armi.settings import setting -from armi.settings import settingsIO +from armi.settings import setting, settingsIO from armi.tests import TEST_ROOT from armi.utils import directoryChangers from armi.utils.customExceptions import ( diff --git a/armi/tests/__init__.py b/armi/tests/__init__.py index 6e5607a2a..be870e3ae 100644 --- a/armi/tests/__init__.py +++ b/armi/tests/__init__.py @@ -17,19 +17,16 @@ This package contains some input files that can be used across a wide variety of unit tests in other lower-level subpackages. """ -from typing import Optional import datetime import itertools import os import re import shutil import unittest +from typing import Optional -from armi import context -from armi import runLog -from armi.reactor import geometry -from armi.reactor import grids -from armi.reactor import reactors +from armi import context, runLog +from armi.reactor import geometry, grids, reactors TEST_ROOT = os.path.dirname(os.path.abspath(__file__)) ARMI_RUN_PATH = os.path.join(TEST_ROOT, "armiRun.yaml") diff --git a/armi/tests/anl-afci-177/anl-afci-177-fuelManagement.py b/armi/tests/anl-afci-177/anl-afci-177-fuelManagement.py index 62953ce44..cc608e6ef 100644 --- a/armi/tests/anl-afci-177/anl-afci-177-fuelManagement.py +++ b/armi/tests/anl-afci-177/anl-afci-177-fuelManagement.py @@ -12,9 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from armi.utils import units - from armi.physics.fuelCycle.fuelHandlers import FuelHandler +from armi.utils import units class SampleShuffler(FuelHandler): diff --git a/armi/tests/test_apps.py b/armi/tests/test_apps.py index c14ffe5a6..69a7478f2 100644 --- a/armi/tests/test_apps.py +++ b/armi/tests/test_apps.py @@ -16,15 +16,17 @@ import copy import unittest -from armi import configure -from armi import context -from armi import getApp -from armi import getDefaultPluginManager -from armi import isStableReleaseVersion -from armi import meta -from armi import plugins -from armi.reactor.flags import Flags +from armi import ( + configure, + context, + getApp, + getDefaultPluginManager, + isStableReleaseVersion, + meta, + plugins, +) from armi.__main__ import main +from armi.reactor.flags import Flags class TestPlugin1(plugins.ArmiPlugin): diff --git a/armi/tests/test_interfaces.py b/armi/tests/test_interfaces.py index 1f23afdd3..53bdbc07f 100644 --- a/armi/tests/test_interfaces.py +++ b/armi/tests/test_interfaces.py @@ -15,8 +15,7 @@ """Tests the Interface.""" import unittest -from armi import interfaces -from armi import settings +from armi import interfaces, settings class DummyInterface(interfaces.Interface): diff --git a/armi/tests/test_lwrInputs.py b/armi/tests/test_lwrInputs.py index 6cc37b81b..297a3ad3f 100644 --- a/armi/tests/test_lwrInputs.py +++ b/armi/tests/test_lwrInputs.py @@ -12,16 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. """Tests for C5G7 input files.""" -from logging import WARNING import os import unittest +from logging import WARNING from armi import runLog from armi.reactor.flags import Flags -from armi.tests import mockRunLogs -from armi.tests import TEST_ROOT -from armi.utils import directoryChangers from armi.reactor.tests import test_reactors +from armi.tests import TEST_ROOT, mockRunLogs +from armi.utils import directoryChangers TEST_INPUT_TITLE = "c5g7-settings.yaml" diff --git a/armi/tests/test_mpiActions.py b/armi/tests/test_mpiActions.py index 35bea5007..e89a3fc1b 100644 --- a/armi/tests/test_mpiActions.py +++ b/armi/tests/test_mpiActions.py @@ -14,16 +14,16 @@ """Tests for MPI actions.""" import unittest +from armi import context from armi.mpiActions import ( - _diagnosePickleError, DistributeStateAction, DistributionAction, MpiAction, - runActions, + _diagnosePickleError, _disableForExclusiveTasks, _makeQueue, + runActions, ) -from armi import context from armi.reactor.tests import test_reactors from armi.tests import mockRunLogs from armi.utils import iterables diff --git a/armi/tests/test_mpiFeatures.py b/armi/tests/test_mpiFeatures.py index 3682d5687..9194d5dab 100644 --- a/armi/tests/test_mpiFeatures.py +++ b/armi/tests/test_mpiFeatures.py @@ -24,24 +24,20 @@ or mpiexec.exe -n 2 python -m pytest armi/tests/test_mpiFeatures.py """ -from unittest.mock import patch import os import shutil import unittest +from unittest.mock import patch -from armi import context -from armi import mpiActions -from armi import settings +from armi import context, mpiActions, settings from armi.interfaces import Interface from armi.mpiActions import DistributeStateAction from armi.operators import OperatorMPI from armi.physics.neutronics.const import CONF_CROSS_SECTION -from armi.reactor import blueprints -from armi.reactor import reactors +from armi.reactor import blueprints, reactors from armi.reactor.parameters import parameterDefinitions from armi.reactor.tests import test_reactors -from armi.tests import ARMI_RUN_PATH, TEST_ROOT -from armi.tests import mockRunLogs +from armi.tests import ARMI_RUN_PATH, TEST_ROOT, mockRunLogs from armi.utils import pathTools from armi.utils.directoryChangers import TemporaryDirectoryChanger diff --git a/armi/tests/test_mpiParameters.py b/armi/tests/test_mpiParameters.py index 4754a7690..a0502ddf9 100644 --- a/armi/tests/test_mpiParameters.py +++ b/armi/tests/test_mpiParameters.py @@ -16,8 +16,7 @@ import unittest from armi import context -from armi.reactor import composites -from armi.reactor import parameters +from armi.reactor import composites, parameters # determine if this is a parallel run, and MPI is installed MPI_EXE = None diff --git a/armi/tests/test_plugins.py b/armi/tests/test_plugins.py index 6626d120d..7852ce653 100644 --- a/armi/tests/test_plugins.py +++ b/armi/tests/test_plugins.py @@ -19,13 +19,15 @@ import yamlize -from armi import context -from armi import getApp -from armi import getPluginManagerOrFail -from armi import interfaces -from armi import plugins -from armi import settings -from armi import utils +from armi import ( + context, + getApp, + getPluginManagerOrFail, + interfaces, + plugins, + settings, + utils, +) from armi.bookkeeping.db.passiveDBLoadPlugin import PassiveDBLoadPlugin from armi.physics.neutronics import NeutronicsPlugin from armi.reactor.blocks import Block diff --git a/armi/tests/test_user_plugins.py b/armi/tests/test_user_plugins.py index 0840afd58..55c6e1005 100644 --- a/armi/tests/test_user_plugins.py +++ b/armi/tests/test_user_plugins.py @@ -16,11 +16,7 @@ import os import unittest -from armi import context -from armi import getApp -from armi import interfaces -from armi import plugins -from armi import utils +from armi import context, getApp, interfaces, plugins, utils from armi.reactor.flags import Flags from armi.reactor.tests import test_reactors from armi.settings import caseSettings diff --git a/armi/utils/asciimaps.py b/armi/utils/asciimaps.py index 20cee223f..1a632db64 100644 --- a/armi/utils/asciimaps.py +++ b/armi/utils/asciimaps.py @@ -49,7 +49,6 @@ """ import re - from typing import Union from armi import runLog diff --git a/armi/utils/codeTiming.py b/armi/utils/codeTiming.py index c01b21435..12d22c2a8 100644 --- a/armi/utils/codeTiming.py +++ b/armi/utils/codeTiming.py @@ -14,9 +14,9 @@ """Utilities related to profiling code.""" import copy +import functools import os import time -import functools def timed(*args): diff --git a/armi/utils/customExceptions.py b/armi/utils/customExceptions.py index 229b31ffa..b3d62e380 100644 --- a/armi/utils/customExceptions.py +++ b/armi/utils/customExceptions.py @@ -16,8 +16,9 @@ Globally accessible exception definitions for better granularity on exception behavior and exception handling behavior. """ +from inspect import getframeinfo, stack + from armi import runLog -from inspect import stack, getframeinfo def info(func): diff --git a/armi/utils/densityTools.py b/armi/utils/densityTools.py index 94b46a82d..59d15438f 100644 --- a/armi/utils/densityTools.py +++ b/armi/utils/densityTools.py @@ -13,11 +13,11 @@ # limitations under the License. """Assorted utilities to help with basic density calculations.""" -from typing import Tuple, List, Dict +from typing import Dict, List, Tuple -from armi.nucDirectory import nucDir, nuclideBases, elements -from armi.utils import units from armi import runLog +from armi.nucDirectory import elements, nucDir, nuclideBases +from armi.utils import units def getNDensFromMasses(rho, massFracs, normalize=False): diff --git a/armi/utils/directoryChangers.py b/armi/utils/directoryChangers.py index 50a5c0cbd..4d8ea5146 100644 --- a/armi/utils/directoryChangers.py +++ b/armi/utils/directoryChangers.py @@ -19,10 +19,8 @@ import shutil import string -from armi import context -from armi import runLog -from armi.utils import pathTools -from armi.utils import safeCopy, safeMove +from armi import context, runLog +from armi.utils import pathTools, safeCopy, safeMove def _changeDirectory(destination): diff --git a/armi/utils/flags.py b/armi/utils/flags.py index f0b83c271..51fe1d726 100644 --- a/armi/utils/flags.py +++ b/armi/utils/flags.py @@ -25,8 +25,7 @@ provides most of the safety and functionality. """ import math - -from typing import Dict, Union, Sequence, List, Tuple +from typing import Dict, List, Sequence, Tuple, Union class auto: # noqa: N801 diff --git a/armi/utils/gridEditor.py b/armi/utils/gridEditor.py index 025afa386..9513b7699 100644 --- a/armi/utils/gridEditor.py +++ b/armi/utils/gridEditor.py @@ -63,21 +63,18 @@ import sys from typing import Dict, Optional, Sequence, Tuple, Union -import wx -import wx.adv import numpy as np import numpy.linalg +import wx +import wx.adv -from armi.utils import hexagon -from armi.utils import textProcessors -from armi.settings.caseSettings import Settings -from armi.reactor import geometry -from armi.reactor import grids -from armi.reactor.flags import Flags +from armi.reactor import geometry, grids from armi.reactor.blueprints import Blueprints, gridBlueprint, migrate -from armi.reactor.blueprints.gridBlueprint import GridBlueprint, saveToStream from armi.reactor.blueprints.assemblyBlueprint import AssemblyBlueprint - +from armi.reactor.blueprints.gridBlueprint import GridBlueprint, saveToStream +from armi.reactor.flags import Flags +from armi.settings.caseSettings import Settings +from armi.utils import hexagon, textProcessors UNIT_SIZE = 50 # pixels per assembly UNIT_MARGIN = 40 # offset applied to the draw area margins diff --git a/armi/utils/iterables.py b/armi/utils/iterables.py index 70fafc0a2..8169f81f9 100644 --- a/armi/utils/iterables.py +++ b/armi/utils/iterables.py @@ -13,8 +13,8 @@ # limitations under the License. """Module of utilities to help dealing with iterable objects in Python.""" -from itertools import chain, filterfalse, tee import struct +from itertools import chain, filterfalse, tee import numpy as np diff --git a/armi/utils/parsing.py b/armi/utils/parsing.py index 3bd379688..e8a716230 100644 --- a/armi/utils/parsing.py +++ b/armi/utils/parsing.py @@ -16,6 +16,7 @@ import ast import copy + from dateutil import parser diff --git a/armi/utils/plotting.py b/armi/utils/plotting.py index 5e99c48a4..5584bc489 100644 --- a/armi/utils/plotting.py +++ b/armi/utils/plotting.py @@ -29,26 +29,25 @@ import os import re -from matplotlib.collections import PatchCollection -from matplotlib.widgets import Slider -from mpl_toolkits import axes_grid1 -from ordered_set import OrderedSet import matplotlib.colors as mcolors import matplotlib.patches import matplotlib.pyplot as plt import matplotlib.text as mpl_text import numpy as np +from matplotlib.collections import PatchCollection +from matplotlib.widgets import Slider +from mpl_toolkits import axes_grid1 +from ordered_set import OrderedSet from armi import runLog from armi.bookkeeping import report from armi.materials import custom from armi.reactor import grids -from armi.reactor.components import Helix, Circle, DerivedShape +from armi.reactor.components import Circle, DerivedShape, Helix from armi.reactor.components.basicShapes import Hexagon, Rectangle, Square from armi.reactor.flags import Flags from armi.utils import hexagon - LUMINANCE_WEIGHTS = np.array([0.3, 0.59, 0.11, 0.0]) diff --git a/armi/utils/reportPlotting.py b/armi/utils/reportPlotting.py index 936bbec1d..c9e79a88f 100644 --- a/armi/utils/reportPlotting.py +++ b/armi/utils/reportPlotting.py @@ -28,16 +28,15 @@ import math import os -from matplotlib import colormaps -from matplotlib import colors as mpltcolors import matplotlib.path import matplotlib.projections.polar import matplotlib.pyplot as plt import matplotlib.spines import numpy as np +from matplotlib import colormaps +from matplotlib import colors as mpltcolors -from armi import runLog -from armi import settings +from armi import runLog, settings from armi.bookkeeping import report from armi.physics.neutronics import crossSectionGroupManager from armi.reactor.flags import Flags diff --git a/armi/utils/tabulate.py b/armi/utils/tabulate.py index 2f78c3ac8..2c0dee34d 100644 --- a/armi/utils/tabulate.py +++ b/armi/utils/tabulate.py @@ -210,14 +210,14 @@ Header column width can be specified in a similar way using `maxheadercolwidth`. """ +import dataclasses +import math +import re from collections import namedtuple from collections.abc import Iterable, Sized -from functools import reduce, partial +from functools import partial, reduce from itertools import chain, zip_longest from textwrap import TextWrapper -import dataclasses -import math -import re from armi import runLog diff --git a/armi/utils/tests/test_asciimaps.py b/armi/utils/tests/test_asciimaps.py index b154b1b50..48711ecf3 100644 --- a/armi/utils/tests/test_asciimaps.py +++ b/armi/utils/tests/test_asciimaps.py @@ -17,7 +17,6 @@ from armi.utils import asciimaps - CARTESIAN_MAP = """2 2 2 2 2 2 2 2 2 2 2 1 1 1 2 diff --git a/armi/utils/tests/test_custom_exceptions.py b/armi/utils/tests/test_custom_exceptions.py index 7060307a3..e8729dd4d 100644 --- a/armi/utils/tests/test_custom_exceptions.py +++ b/armi/utils/tests/test_custom_exceptions.py @@ -15,8 +15,7 @@ import unittest from armi.tests import mockRunLogs -from armi.utils.customExceptions import info, important -from armi.utils.customExceptions import warn, warn_when_root +from armi.utils.customExceptions import important, info, warn, warn_when_root class CustomExceptionTests(unittest.TestCase): diff --git a/armi/utils/tests/test_directoryChangers.py b/armi/utils/tests/test_directoryChangers.py index 30aec94fc..3b95b000e 100644 --- a/armi/utils/tests/test_directoryChangers.py +++ b/armi/utils/tests/test_directoryChangers.py @@ -13,13 +13,12 @@ # limitations under the License. """Module for testing directoryChangers.""" -from pathlib import Path import os import shutil import unittest +from pathlib import Path -from armi.utils import directoryChangers -from armi.utils import directoryChangersMpi +from armi.utils import directoryChangers, directoryChangersMpi class ExpectedException(Exception): diff --git a/armi/utils/tests/test_mathematics.py b/armi/utils/tests/test_mathematics.py index b7554b07a..2a38d4274 100644 --- a/armi/utils/tests/test_mathematics.py +++ b/armi/utils/tests/test_mathematics.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. """Testing mathematics utilities.""" -from math import sqrt import unittest +from math import sqrt import numpy as np diff --git a/armi/utils/tests/test_outputCache.py b/armi/utils/tests/test_outputCache.py index b8052ac58..fbc9a1545 100644 --- a/armi/utils/tests/test_outputCache.py +++ b/armi/utils/tests/test_outputCache.py @@ -16,8 +16,7 @@ import time import unittest -from armi.utils import directoryChangers -from armi.utils import outputCache +from armi.utils import directoryChangers, outputCache class TestOutputCache(unittest.TestCase): diff --git a/armi/utils/tests/test_plotting.py b/armi/utils/tests/test_plotting.py index bc28b5991..318e52447 100644 --- a/armi/utils/tests/test_plotting.py +++ b/armi/utils/tests/test_plotting.py @@ -20,8 +20,7 @@ from armi import settings from armi.nuclearDataIO.cccc import isotxs -from armi.reactor import blueprints -from armi.reactor import reactors +from armi.reactor import blueprints, reactors from armi.reactor.flags import Flags from armi.reactor.tests import test_reactors from armi.tests import ISOAA_PATH, TEST_ROOT diff --git a/armi/utils/tests/test_tabulate.py b/armi/utils/tests/test_tabulate.py index 1876cd250..06a27ec1b 100644 --- a/armi/utils/tests/test_tabulate.py +++ b/armi/utils/tests/test_tabulate.py @@ -19,32 +19,31 @@ https://github.com/astanin/python-tabulate """ -from collections import defaultdict -from collections import namedtuple -from collections import OrderedDict -from collections import UserDict +import unittest +from collections import OrderedDict, UserDict, defaultdict, namedtuple from dataclasses import dataclass from datetime import datetime -import unittest import numpy as np -from armi.utils.tabulate import _alignCellVeritically -from armi.utils.tabulate import _alignColumn -from armi.utils.tabulate import _bool -from armi.utils.tabulate import _buildLine -from armi.utils.tabulate import _buildRow -from armi.utils.tabulate import _format -from armi.utils.tabulate import _isMultiline -from armi.utils.tabulate import _multilineWidth -from armi.utils.tabulate import _normalizeTabularData -from armi.utils.tabulate import _tableFormats -from armi.utils.tabulate import _type -from armi.utils.tabulate import _visibleWidth -from armi.utils.tabulate import _wrapTextToColWidths -from armi.utils.tabulate import SEPARATING_LINE -from armi.utils.tabulate import tabulate -from armi.utils.tabulate import tabulateFormats +from armi.utils.tabulate import ( + SEPARATING_LINE, + _alignCellVeritically, + _alignColumn, + _bool, + _buildLine, + _buildRow, + _format, + _isMultiline, + _multilineWidth, + _normalizeTabularData, + _tableFormats, + _type, + _visibleWidth, + _wrapTextToColWidths, + tabulate, + tabulateFormats, +) class TestTabulateAPI(unittest.TestCase): @@ -543,9 +542,11 @@ def test_alignCellVeriticallyBottomMultiTextMultiplePad(self): def test_assortedRareEdgeCases(self): """Test some of the more rare edge cases in the purely internal functions.""" - from armi.utils.tabulate import _alignHeader - from armi.utils.tabulate import _prependRowIndex - from armi.utils.tabulate import _removeSeparatingLines + from armi.utils.tabulate import ( + _alignHeader, + _prependRowIndex, + _removeSeparatingLines, + ) self.assertEqual(_alignHeader("123", False, 3, 3, False, None), "123") diff --git a/armi/utils/tests/test_textProcessors.py b/armi/utils/tests/test_textProcessors.py index 1d15afcc6..141ebe58f 100644 --- a/armi/utils/tests/test_textProcessors.py +++ b/armi/utils/tests/test_textProcessors.py @@ -12,16 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. """Tests for functions in textProcessors.py.""" -from io import StringIO import logging import os import pathlib -import ruamel import unittest +from io import StringIO + +import ruamel from armi import runLog -from armi.tests import mockRunLogs -from armi.tests import TEST_ROOT +from armi.tests import TEST_ROOT, mockRunLogs from armi.utils import textProcessors from armi.utils.directoryChangers import TemporaryDirectoryChanger diff --git a/armi/utils/tests/test_triangle.py b/armi/utils/tests/test_triangle.py index 428f0eae2..cbf57bac1 100644 --- a/armi/utils/tests/test_triangle.py +++ b/armi/utils/tests/test_triangle.py @@ -13,6 +13,7 @@ # limitations under the License. """Test the basic triangle math.""" import unittest + from armi.utils import triangle diff --git a/armi/utils/tests/test_utils.py b/armi/utils/tests/test_utils.py index 1adc18ff3..b514b5692 100644 --- a/armi/utils/tests/test_utils.py +++ b/armi/utils/tests/test_utils.py @@ -13,9 +13,9 @@ # limitations under the License. """Testing some utility functions.""" -from collections import defaultdict import os import unittest +from collections import defaultdict import numpy as np diff --git a/armi/utils/textProcessors.py b/armi/utils/textProcessors.py index db9868316..e62bf411f 100644 --- a/armi/utils/textProcessors.py +++ b/armi/utils/textProcessors.py @@ -14,13 +14,12 @@ """Utility classes and functions for manipulating text files.""" import io import os -import re import pathlib -from typing import List, Tuple, Union, Optional, TextIO +import re +from typing import List, Optional, TextIO, Tuple, Union from armi import runLog - _INCLUDE_CTOR = False _INCLUDE_RE = re.compile(r"^([^#]*\s+)?!include\s+(.*)\n?$") _INDENT_RE = re.compile(r"^[\s\-\?:]*([^\s\-\?:].*)?$") diff --git a/armi/utils/units.py b/armi/utils/units.py index defa61110..a95061bd8 100644 --- a/armi/utils/units.py +++ b/armi/utils/units.py @@ -16,7 +16,6 @@ import scipy.constants - # Units (misc) DPA = "dpa" FIMA = "FIMA" diff --git a/doc/conf.py b/doc/conf.py index 1dc187fa4..987455cfd 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -35,10 +35,10 @@ import sys import warnings +import sphinx_rtd_theme from docutils import nodes, statemachine from docutils.parsers.rst import Directive, directives from sphinx.domains.python import PythonDomain -import sphinx_rtd_theme # handle python import locations for this execution PYTHONPATH = os.path.abspath("..") @@ -48,11 +48,8 @@ # Add dochelpers.py from doc/.static/ directory sys.path.insert(0, ".static") -from armi import apps +from armi import apps, context, disableFutureConfigures, meta from armi import configure as armi_configure -from armi import context -from armi import disableFutureConfigures -from armi import meta from armi.bookkeeping import tests as bookkeepingTests from armi.utils import safeCopy diff --git a/doc/gallery-src/framework/run_chartOfNuclides.py b/doc/gallery-src/framework/run_chartOfNuclides.py index 13fcfe3ad..f0818d7e4 100644 --- a/doc/gallery-src/framework/run_chartOfNuclides.py +++ b/doc/gallery-src/framework/run_chartOfNuclides.py @@ -25,8 +25,8 @@ """ import matplotlib.pyplot as plt -from armi.nucDirectory import nuclideBases from armi import configure +from armi.nucDirectory import nuclideBases configure(permissive=True) diff --git a/doc/gallery-src/framework/run_computeReactionRates.py b/doc/gallery-src/framework/run_computeReactionRates.py index 1c73f7e37..1a7c2d52b 100644 --- a/doc/gallery-src/framework/run_computeReactionRates.py +++ b/doc/gallery-src/framework/run_computeReactionRates.py @@ -26,19 +26,10 @@ import numpy as np from armi import configure, nuclideBases, settings -from armi.materials import ht9 -from armi.materials import sodium -from armi.materials import uZr +from armi.materials import ht9, sodium, uZr from armi.nuclearDataIO.cccc import isotxs -from armi.reactor import assemblies -from armi.reactor import blocks -from armi.reactor import blueprints -from armi.reactor import geometry -from armi.reactor import grids -from armi.reactor import reactors -from armi.reactor.components import Circle -from armi.reactor.components import DerivedShape -from armi.reactor.components import Hexagon +from armi.reactor import assemblies, blocks, blueprints, geometry, grids, reactors +from armi.reactor.components import Circle, DerivedShape, Hexagon from armi.reactor.flags import Flags from armi.tests import ISOAA_PATH diff --git a/doc/gallery-src/framework/run_fuelManagement.py b/doc/gallery-src/framework/run_fuelManagement.py index d355bbaf0..a55adcab2 100644 --- a/doc/gallery-src/framework/run_fuelManagement.py +++ b/doc/gallery-src/framework/run_fuelManagement.py @@ -30,7 +30,6 @@ # sphinx_gallery_thumbnail_number = 2 import math - from armi import configure from armi.physics.fuelCycle import fuelHandlers from armi.reactor.flags import Flags diff --git a/doc/gallery-src/framework/run_grids1_hex.py b/doc/gallery-src/framework/run_grids1_hex.py index 7d39ca1f0..c822a91a3 100644 --- a/doc/gallery-src/framework/run_grids1_hex.py +++ b/doc/gallery-src/framework/run_grids1_hex.py @@ -22,12 +22,12 @@ """ import math -import matplotlib.pyplot as plt import matplotlib.patches as mpatches +import matplotlib.pyplot as plt from matplotlib.collections import PatchCollection -from armi.reactor import grids from armi import configure +from armi.reactor import grids configure(permissive=True) diff --git a/doc/gallery-src/framework/run_isotxs.py b/doc/gallery-src/framework/run_isotxs.py index b0dbc50fa..095864039 100644 --- a/doc/gallery-src/framework/run_isotxs.py +++ b/doc/gallery-src/framework/run_isotxs.py @@ -20,10 +20,10 @@ """ import matplotlib.pyplot as plt +from armi import configure +from armi.nuclearDataIO.cccc import isotxs from armi.physics.neutronics import energyGroups from armi.tests import ISOAA_PATH -from armi.nuclearDataIO.cccc import isotxs -from armi import configure configure(permissive=True) diff --git a/doc/gallery-src/framework/run_materials.py b/doc/gallery-src/framework/run_materials.py index bb78d4e8d..ab469f1ae 100644 --- a/doc/gallery-src/framework/run_materials.py +++ b/doc/gallery-src/framework/run_materials.py @@ -22,8 +22,8 @@ More info about the materials here: :py:mod:`armi.materials`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np from armi import configure, materials from armi.nucDirectory import nuclideBases diff --git a/doc/gallery-src/framework/run_programmaticReactorDefinition.py b/doc/gallery-src/framework/run_programmaticReactorDefinition.py index e270afeb7..b9c2dce05 100644 --- a/doc/gallery-src/framework/run_programmaticReactorDefinition.py +++ b/doc/gallery-src/framework/run_programmaticReactorDefinition.py @@ -37,12 +37,14 @@ from armi import cases from armi.reactor import blueprints -from armi.reactor.blueprints import assemblyBlueprint -from armi.reactor.blueprints import blockBlueprint -from armi.reactor.blueprints import componentBlueprint -from armi.reactor.blueprints import gridBlueprint -from armi.reactor.blueprints import isotopicOptions -from armi.reactor.blueprints import reactorBlueprint +from armi.reactor.blueprints import ( + assemblyBlueprint, + blockBlueprint, + componentBlueprint, + gridBlueprint, + isotopicOptions, + reactorBlueprint, +) from armi.settings import caseSettings from armi.utils import plotting diff --git a/doc/gallery-src/framework/run_reactorFacemap.py b/doc/gallery-src/framework/run_reactorFacemap.py index 457aa3f5f..fd29de066 100644 --- a/doc/gallery-src/framework/run_reactorFacemap.py +++ b/doc/gallery-src/framework/run_reactorFacemap.py @@ -18,9 +18,9 @@ Load a test reactor from the test suite and plot a dummy power distribution from it. You can plot any block parameter. """ +from armi import configure from armi.reactor.tests import test_reactors from armi.utils import plotting -from armi import configure # configure ARMI configure(permissive=True) diff --git a/doc/gallery-src/framework/run_transmutationMatrix.py b/doc/gallery-src/framework/run_transmutationMatrix.py index 2546c65f1..82e5a2289 100644 --- a/doc/gallery-src/framework/run_transmutationMatrix.py +++ b/doc/gallery-src/framework/run_transmutationMatrix.py @@ -29,12 +29,12 @@ A Bateman equation/matrix exponential solver is required to actually *solve* transmutation and decay problems, which can be provided via a plugin. """ -import os import math +import os import matplotlib.patches as mpatch -from matplotlib.collections import PatchCollection import matplotlib.pyplot as plt +from matplotlib.collections import PatchCollection from armi.context import RES from armi.nucDirectory import nuclideBases diff --git a/pyproject.toml b/pyproject.toml index 330094aa1..affae444d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -167,11 +167,12 @@ exclude = [ [tool.ruff.lint] # Enable pycodestyle (E) and Pyflakes (F) codes by default. # D - NumPy docstring rules +# I - Sorting imports # N801 - Class name should use CapWords convention # SIM - code simplification rules # TID - tidy imports # TODO: We want to support PLW0603 - don't use the global keyword -select = ["E", "F", "D", "N801", "SIM", "TID"] +select = ["D", "E", "F", "I", "N801", "SIM", "TID"] # Ruff rules we ignore (for now) because they are not 100% automatable #