-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
At the moment, the main methods of every ModelBlock that are called by the enclosing Model instance take no positional arguments and expect to receive data and config keyword arguments (preprocess, make_latent_rvs and make_observations). This makes documenting the potential key, value and defaults for the configuration dictionary cumbersome and difficult.
We could change the signature of the ModelBlock methods to take 1 positional argument (data) and then explicitly put all keys of the config as optional keyword arguments.
Example
The old signature:
class WithinBlockGP(ModelBlock):
...
make_latent_rvs(
self, *, data: Optional[DataFrame] = None, config: Optional[Dict[str, Any]] = None
) -> TensorVariable:
conf = self.read_config(config)
return self.make_within_block_component(data, **conf)
...Proposed new signature
class WithinBlockGP(ModelBlock):
...
make_latent_rvs(
self,
data: DataFrame,
*,
nested_hierarchies: Optional[Sequence[str]] = None,
name_prefix: str = "gp",
level_scale_kwargs: Optional[Dict[str, Any]] = None,
level_kernel_kwargs: Optional[Dict[int, Dict[str, Any]]] = None,
parametrization: ParametrizationType = None,
parametrized_by_level: bool = False,
coef_dims: Optional[Sequence[str]] = None,
time_column: Optional[str] = None,
model: Optional[Model] = None,
**kwargs,
) -> TensorVariable:
# Do whatever `make_within_block_component` used to do
...Comparison
Pros of the new signature:
- Clear potential configuration arguments
- Clear default values
- Easier to write docstrings for
Cons of the new signature:
- Different method signatures between parent and child classes
Modelneeds to unpack the configuration values and feed them to the correspondingModelBlock
In my opinion the pros greatly outweigh the cons.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request