Refact individual parameters
What does the code in the MR do ?
This MR implements a bunch of quality of life changes for IndividualParameters
: implements some refactoring, enables ID-based membership tests, updates the documentation and type hints, and improves tests and coverage. It also implements a new custom exception, LeaspyKeyError
.
New features
- ID-based membership test for
IndividualParameters
objects, i.e. correct implementation of'SUB-ID-12' in ip
using__contains__
, as illustrated (for IndividualParameters) in #42. - New custom exception
LeaspyKeyError
, deriving from KeyError, for better handling of "mapping key not found" situations
Refactoring
IndividualParameters
- Replace
.subset()
by.__getitem__()
for consistency withData
- Make
._indices
and.parameters_shape
properties instead of independently computed attributes, to ensure consistency - Rewrite
.add_individual_parameters()
for clarity only (no structural or functional changes) - Refact pandas I/O to leverage
from_dict
andto_dict
pandas methods, and enable deeper-nested list parameters (although currently only scalars and 1D lists are supported by other methods)
Documentation
Updated documentation of some IndividualParameters
methods, including more accurate type hinting and appropriate Leaspy exceptions. Updated IndividualParameters
docstring.
Where should the reviewer start ?
I would suggest reviewing listed changes in the same order as above.
How can the code be tested ?
New tests have been implemented for the added / refactored features. All tests succeed.
When is the MR due for? (review deadline)
Those are mostly quality of life / nice to have changes, so no priority.
What issues are linked to the MR ?
This addresses half of #42 (the other half being addressed in !80 (merged) )