Previously, the archives had a dtype property that held the dtype of the solution, objectives, and measures. However, these three may not always have the same dtype; furthermore, this excludes the threshold field and other additional fields provided by the user. Thus, this PR replaces dtype with dtypes, a dict that maps from field name to dtype of the associated field.
TODO
[x] Deprecate ArchiveBase.dtype -- now, calling archive.dtype will raise a RuntimeError with a deprecation notice
[x] Add ArchvieBase.dtypes
[x] Update calls to archive.dtype. In particular, we now use archive.dtypes["XXXX"], with XXXX being the field name that is appropriate to the use case, e.g., x0 in an emitter would be cast to archive.dtypes["solution"].
[x] Note that it was previously common to call archive.dtype(some_scalar_value). This is not very correct. To elaborate, archive.dtype was a numpy scalar type, e.g., np.float32 or np.float64, which is indeed callable. However, the actual dtype of an array, e.g., np.arange(5).dtype is an instance of numpy.dtype, which is not callable. Thus, a utility called np_scalar was introduced, which casts a provided value to a provided dtype, e.g., np_scalar(5.0, dtype=archive.dtypes["solution"])
Description
Previously, the archives had a
dtype
property that held the dtype of the solution, objectives, and measures. However, these three may not always have the same dtype; furthermore, this excludes the threshold field and other additional fields provided by the user. Thus, this PR replacesdtype
withdtypes
, a dict that maps from field name to dtype of the associated field.TODO
ArchiveBase.dtype
-- now, calling archive.dtype will raise a RuntimeError with a deprecation noticeArchvieBase.dtypes
archive.dtype
. In particular, we now usearchive.dtypes["XXXX"]
, with XXXX being the field name that is appropriate to the use case, e.g.,x0
in an emitter would be cast toarchive.dtypes["solution"]
.archive.dtype(some_scalar_value)
. This is not very correct. To elaborate,archive.dtype
was a numpy scalar type, e.g.,np.float32
ornp.float64
, which is indeed callable. However, the actual dtype of an array, e.g.,np.arange(5).dtype
is an instance ofnumpy.dtype
, which is not callable. Thus, a utility callednp_scalar
was introduced, which casts a provided value to a provided dtype, e.g.,np_scalar(5.0, dtype=archive.dtypes["solution"])
Status
yapf
pytest
pylint
HISTORY.md