Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Renaming Database3 to Database, but preserving the API #1961

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions armi/bookkeeping/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@
from armi import runLog

# 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",
"DatabaseInterface",
"compareDatabases",
Expand Down Expand Up @@ -98,7 +100,7 @@ def loadOperator(
The time node to load the reactor from.
statePointName: str
State point name at the end, E.G. `EOC` or `EOL`.
Full name would be C0N2EOC, see database3.getH5GroupName
Full name would be C0N2EOC, see database.getH5GroupName
allowMissing : bool
Whether to emit a warning, rather than crash if reading a database
with undefined parameters. Default False.
Expand Down Expand Up @@ -138,7 +140,7 @@ def loadOperator(
"of the database."
)

db = Database3(pathToDb, "r")
db = Database(pathToDb, "r")
with db:
# init Case here as it keeps track of execution time and assigns a reactor
# attribute. This attribute includes the time it takes to initialize the reactor
Expand Down Expand Up @@ -181,7 +183,7 @@ def _getH5File(db):
All this being said, we are probably violating this already with genAuxiliaryData,
but we have to start somewhere.
"""
if isinstance(db, Database3):
if isinstance(db, Database):
return db.h5db
else:
raise TypeError("Unsupported Database type ({})!".format(type(db)))
15 changes: 7 additions & 8 deletions armi/bookkeeping/db/compareDB3.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
import numpy as np

from armi import runLog
from armi.bookkeeping.db import database3
from armi.bookkeeping.db.database3 import Database3
from armi.bookkeeping.db import database
from armi.bookkeeping.db.database import Database
from armi.bookkeeping.db.factory import databaseFactory
from armi.bookkeeping.db.permissions import Permissions
from armi.reactor.composites import ArmiObject
Expand Down Expand Up @@ -179,7 +179,7 @@ def compareDatabases(
with OutputWriter(outputName) as out:
ref = databaseFactory(refFileName, Permissions.READ_ONLY_FME)
src = databaseFactory(srcFileName, Permissions.READ_ONLY_FME)
if not isinstance(ref, Database3) or not isinstance(src, Database3):
if not isinstance(ref, Database) or not isinstance(src, Database):
raise TypeError(
"This database comparer only knows how to deal with database version "
"3; received {} and {}".format(type(ref), type(src))
Expand Down Expand Up @@ -363,8 +363,8 @@ def _diffSpecialData(
return

try:
src = database3.unpackSpecialData(srcData[()], srcData.attrs, paramName)
ref = database3.unpackSpecialData(refData[()], refData.attrs, paramName)
src = database.unpackSpecialData(srcData[()], srcData.attrs, paramName)
ref = database.unpackSpecialData(refData[()], refData.attrs, paramName)
except Exception:
runLog.error(
f"Unable to unpack special data for paramName {paramName}. "
Expand All @@ -380,9 +380,8 @@ def _diffSpecialData(
diffResults.addDiff(compName, paramName, np.inf, np.inf, np.inf)
return

# make sure not to try to compare empty arrays. Numpy is mediocre at
# these; they are super degenerate and cannot participate in concatenation.
# Why?
# Make sure not to try to compare empty arrays. Numpy is mediocre at these;
# they are super degenerate and cannot participate in concatenation.
if 0 not in dSrc.shape:
# Use the mean of the two to calc relative error. This is more robust to
# changes that cause one of the values to be zero, while the other is
Expand Down
Loading
Loading