Parameter Models
This module provides parameter models for configuring various plotting functions in Soundscapy. These models help ensure type safety and provide a consistent interface for configuring plots.
CLASS | DESCRIPTION |
---|---|
DensityParams |
Parameters for density plot functions. |
JointPlotParams |
Parameters for joint plot functions. |
ParamModel |
Base model for parameter validation using dataclasses. |
SPISeabornParams |
Base parameters for SPI seaborn plotting functions. |
SPISimpleDensityParams |
Parameters for SPI simple density plot functions. |
ScatterParams |
Parameters for scatter plot functions. |
SeabornParams |
Base parameters for seaborn plotting functions. |
SimpleDensityParams |
Parameters for simple density plot functions. |
StyleParams |
Parameters for plot styling. |
SubplotsParams |
Parameters for subplots. |
DensityParams
Bases: SeabornParams
Parameters for density plot functions.
METHOD | DESCRIPTION |
---|---|
as_seaborn_kwargs |
Convert parameters to kwargs compatible with seaborn functions. |
to_outline |
Convert to outline parameters. |
as_seaborn_kwargs
as_seaborn_kwargs(drop=None)
Convert parameters to kwargs compatible with seaborn functions.
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
Dictionary of parameter values suitable for seaborn plotting functions. |
Source code in soundscapy/plotting/param_models.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
|
to_outline
to_outline(*, alpha=1, fill=False)
Convert to outline parameters.
PARAMETER | DESCRIPTION |
---|---|
alpha
|
Alpha value for the outline.
TYPE:
|
fill
|
Whether to fill the outline.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DensityParams
|
New instance with outline parameters. |
Source code in soundscapy/plotting/param_models.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
|
JointPlotParams
ParamModel
Base model for parameter validation using dataclasses.
This class provides the foundation for all parameter models with common configuration settings and utility methods.
METHOD | DESCRIPTION |
---|---|
__getitem__ |
Get a parameter value using dictionary-style access. |
__post_init__ |
Process extra fields after initialization. |
as_dict |
Get all parameters as a dictionary. |
drop |
Remove a parameter without returning its value. |
get |
Get a parameter value with a default fallback. |
get_changed_params |
Get parameters that have been changed from their defaults. |
get_multiple |
Get multiple parameters as a dictionary. |
pop |
Remove a parameter and return its value. |
update |
Update the attributes of the instance based on the provided parameters. |
ATTRIBUTE | DESCRIPTION |
---|---|
current_field_names |
Get the names of all current fields. |
defined_field_names |
Get the names of all fields defined for the model. |
current_field_names
property
current_field_names
Get the names of all current fields.
RETURNS | DESCRIPTION |
---|---|
List[str]
|
List of field names |
defined_field_names
property
defined_field_names
Get the names of all fields defined for the model.
RETURNS | DESCRIPTION |
---|---|
List[str]
|
List of field names |
__getitem__
__getitem__(key)
Get a parameter value using dictionary-style access.
PARAMETER | DESCRIPTION |
---|---|
key
|
Name of the parameter
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
Parameter value |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If the parameter doesn't exist |
Source code in soundscapy/plotting/param_models.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
__post_init__
__post_init__()
Process extra fields after initialization.
Source code in soundscapy/plotting/param_models.py
57 58 59 60 61 62 |
|
as_dict
as_dict(drop=None)
Get all parameters as a dictionary.
RETURNS | DESCRIPTION |
---|---|
Dict[str, Any]
|
Dictionary of parameter values |
Source code in soundscapy/plotting/param_models.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
drop
drop(keys, *, ignore_missing=True)
Remove a parameter without returning its value.
PARAMETER | DESCRIPTION |
---|---|
keys
|
Name of the parameter or list of parameters |
ignore_missing
|
If True, ignore missing keys. If False, raise KeyError for missing keys.
TYPE:
|
Source code in soundscapy/plotting/param_models.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
get
get(key, default=None)
Get a parameter value with a default fallback.
PARAMETER | DESCRIPTION |
---|---|
key
|
Name of the parameter
TYPE:
|
default
|
Default value if parameter doesn't exist
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
Parameter value or default |
Source code in soundscapy/plotting/param_models.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
get_changed_params
get_changed_params()
Get parameters that have been changed from their defaults.
This method compares the current parameter values against the default values and returns a dictionary containing only the parameters that differ from their defaults.
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
Dictionary of parameters that differ from defaults, with keys as parameter names and values as their current values (not default values). |
Source code in soundscapy/plotting/param_models.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
get_multiple
get_multiple(keys)
Get multiple parameters as a dictionary.
PARAMETER | DESCRIPTION |
---|---|
keys
|
List of parameter names |
RETURNS | DESCRIPTION |
---|---|
Dict[str, Any]
|
Dictionary of parameter values |
Source code in soundscapy/plotting/param_models.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
pop
pop(key)
Remove a parameter and return its value.
For fields defined in the model, the value is reset to its default.
PARAMETER | DESCRIPTION |
---|---|
key
|
Name of the parameter
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
Value of the removed parameter |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If the parameter doesn't exist |
Source code in soundscapy/plotting/param_models.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
update
update(*, extra='allow', ignore_null=True, **kwargs)
Update the attributes of the instance based on the provided parameters.
PARAMETER | DESCRIPTION |
---|---|
extra
|
Determines how to handle extra fields in
TYPE:
|
ignore_null
|
If True, removes
TYPE:
|
**kwargs
|
Field names and values to be updated.
TYPE:
|
Source code in soundscapy/plotting/param_models.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
SPISeabornParams
Bases: SeabornParams
Base parameters for SPI seaborn plotting functions.
METHOD | DESCRIPTION |
---|---|
as_seaborn_kwargs |
Convert parameters to kwargs compatible with seaborn functions. |
as_seaborn_kwargs
as_seaborn_kwargs(drop=None)
Convert parameters to kwargs compatible with seaborn functions.
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
Dictionary of parameter values suitable for seaborn plotting functions. |
Source code in soundscapy/plotting/param_models.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
|
SPISimpleDensityParams
ScatterParams
SeabornParams
Bases: ParamModel
Base parameters for seaborn plotting functions.
METHOD | DESCRIPTION |
---|---|
as_seaborn_kwargs |
Convert parameters to kwargs compatible with seaborn functions. |
crosscheck_palette_hue |
Check if the palette is valid for the given hue. |
as_seaborn_kwargs
as_seaborn_kwargs(drop=None)
Convert parameters to kwargs compatible with seaborn functions.
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
Dictionary of parameter values suitable for seaborn plotting functions. |
Source code in soundscapy/plotting/param_models.py
345 346 347 348 349 350 351 352 353 354 355 |
|
crosscheck_palette_hue
crosscheck_palette_hue()
Check if the palette is valid for the given hue.
This method ensures that palette is only used when hue is provided.
Source code in soundscapy/plotting/param_models.py
337 338 339 340 341 342 343 |
|
SimpleDensityParams
StyleParams
SubplotsParams
Bases: ParamModel
Parameters for subplots.
METHOD | DESCRIPTION |
---|---|
as_plt_subplots_args |
Pass matplotlib subplot arguments to a plt.subplots call. |
ATTRIBUTE | DESCRIPTION |
---|---|
n_subplots |
Get the number of subplots.
TYPE:
|
n_subplots_by |
"The number of subplots allocated for each subplot_by category.
TYPE:
|
n_subplots
property
n_subplots
Get the number of subplots.
RETURNS | DESCRIPTION |
---|---|
int
|
Number of subplots |
n_subplots_by
class-attribute
instance-attribute
n_subplots_by = -1
"The number of subplots allocated for each subplot_by category.
as_plt_subplots_args
as_plt_subplots_args()
Pass matplotlib subplot arguments to a plt.subplots call.
PARAMETER | DESCRIPTION |
---|---|
ax
|
Matplotlib Axes object.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
Dictionary of subplot parameters. |
Source code in soundscapy/plotting/param_models.py
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
|
show_submodules: true