JDFTx Inputs - boundary value checking #4410
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Major changes:
-- Added a
validate_value_bounds
method toAbstractTag
, that by default always returnsTrue, ""
-- Added an alternate
AbstractNumericTag
that inheritsAbstractTag
to implementvalidate_value_bounds
properly--- Changed boundary storing to the following fields
----
ub
andlb
----- Can either be
None
, or some value to indicate an upper or lower bound----
ub_incl
andlb_incl
----- If True, applies
>=
instead of>
in comparative checks on upper and lower bounds-- Switched inheritance of
FloatTag
andIntTag
fromAbstractTag
toAbstractNumericTag
-- Implemented
validate_value_bounds
forTagContainer
to dispatch checking for contained subtags-- Added a method
validate_boundaries
toJDFTXInfile
to runvalidate_value_bounds
on all contained tags and values-- Added
validate_value_boundaries
argument for initialization methods ofJDFTXInfile
, which will runvalidate_boundaries
after initializingJDFTXInfile
but before returning when True--- Note that this is explicitly disabled when initializing a
JDFTXInfile
from the input summary in aJDFTXOutfileSlice
- boundary values may exist internally in JDFTx for non-inclusive bounded tags as the default values, but cannot be passed in the input file. For this reason, errors on boundary checking must be an easily disabled feature for the construction and manipulation of aJDFTXInfile
, but out-of-bounds values must never be written when writing a file for passing to JDFTx.Todos
-- Implement some way boundary checking can run when adding tags to a pre-existing
JDFTXInfile
object--- boundary checking is currently only run when initializing from a pre-existing collection of input tags
--- writing this into
JDFTXInfile.__setitem__
is too extreme as it would require adding an attribute toJDFTXInfile
to allow disabling the check--- the better solution would be to implement a more obvious user-friendly method for reading in additional inputs so that the user doesn't need to learn how to properly write out the dictionary representation of complicated tag containers.
-- Fill out reference tags for other unimplemented boundaries