You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, arbitrary parameters may be assigned to a property of UQTestFuns instances. If the underlying function supports it, then they will be consumed accordingly. The responsibility about how to consume the parameters is delegated to the actual implementation of the test function (i.e., inside the respective module). Users may change the value of the parameters directly on the instance.
However, the current implementation is not safe as there is no guarantee that user will supply the correct parameters, in particular, their types as a value of the parameter can be anything. Semantically, the parameters being arbitrary has no structure from one test function implementation to another.
Some refactoring is thus needed.
Refactoring idea
I would like for test function parameters to be encapsulated inside its own class, say, Parameters.
The class has the following main properties:
name or perhaps, id
_original_entries: the parameters created at the beginning
description
_dict: storing the simply the keywords and values of parameter entries. If the parameter value is modified on the fly (on the instance) then only the value here changes. An instance may be reset to the original value because we have to storages.
which is now more self-explanatory and much less cryptic.
The method as_dict() will return a dictionary whose values are each of the entries value; the key of this dictionary must match with the keyword arguments defined in the underlying function.
Furthermore, the number of entries in each Parameters must match with the declared keyword arguments, no more and no less.
That's why the keyword specified in the Parameters instance must be correct otherwise the function cannot find them.
The output of print() is as follows:
Name : Parameters-CircularPipeCrack-Verma2015
# of Parameters : 3
Description : Set of parameters for the circular pipe crack problem
used in Verma et al. (2015)
No. Symbol Keyword Value Type Description
----- ------ -------------- -------------- ------ --------------------------------
1 r pipe_radius 3.377e-1 float Radius of the pipe [m]
2 t pipe_thickness 3.377e-2 float Thickness of the pipe [m]
3 M bending_moment 3.0 float Applied bending moment [MNm]
The text was updated successfully, but these errors were encountered:
Introduce the FunParams class to handle UQ
test function parameters.
Updated class usage across the module
to ensure proper handling of parameters.
The test suite has been updated
to test latest changes.
This commit should resolve Issue #351.
Currently, arbitrary parameters may be assigned to a property of
UQTestFuns
instances. If the underlying function supports it, then they will be consumed accordingly. The responsibility about how to consume the parameters is delegated to the actual implementation of the test function (i.e., inside the respective module). Users may change the value of the parameters directly on the instance.However, the current implementation is not safe as there is no guarantee that user will supply the correct parameters, in particular, their types as a value of the parameter can be anything. Semantically, the parameters being arbitrary has no structure from one test function implementation to another.
Some refactoring is thus needed.
Refactoring idea
I would like for test function parameters to be encapsulated inside its own class, say,
Parameters
.The class has the following main properties:
name
or perhaps,id
_original_entries
: the parameters created at the beginningdescription
_dict
: storing the simply the keywords and values of parameter entries. If the parameter value is modified on the fly (on the instance) then only the value here changes. An instance may be reset to the original value because we have to storages.With the following methods:
add_parameter(keyword, symbol, valu, type, optional, description)
as_dict()
: returns the dictreset()
: return all values to the original entries.__getitem__()
__setitem__()
__contains__()
__str__()
__deepcopy__()
__copy__()
__len__()
Each parameter must have the following properties:
keyword
: keyword as appears in the test function implementation signaturevalue
: the value of the parametertype
: the type of the parameter value (for checking)optional
: whether this parameter is optionalsymbol
: the symbol as appear in the equationdescription
: the description the parameterSo the parameters for the circular pipe crack problem can be constructed as follows:
We can update the value as long as the assigned value is of consistent type. For instance:
The top-level signature of
eval_
method is now will be:instead of
This method is called by the
evaluate()
method:Note that parameters will be assigned in the call to the actual function as keyword arguments.
Now instead of:
we write the signature as:
which is now more self-explanatory and much less cryptic.
The method
as_dict()
will return a dictionary whose values are each of the entriesvalue
; the key of this dictionary must match with the keyword arguments defined in the underlying function.Furthermore, the number of entries in each
Parameters
must match with the declared keyword arguments, no more and no less.That's why the keyword specified in the
Parameters
instance must be correct otherwise the function cannot find them.The output of
print()
is as follows:The text was updated successfully, but these errors were encountered: