Instrument Models¶
circumplex.instruments.models
¶
Instrument data models.
| CLASS | DESCRIPTION |
|---|---|
InstrumentScale |
Single scale within an instrument. |
ResponseAnchor |
Response option for an instrument. |
ResponseItem |
Single item within an instrument. |
NormativeSample |
Normative sample metadata and statistics. |
Instrument |
Circumplex instrument definition. |
| FUNCTION | DESCRIPTION |
|---|---|
register_instrument |
Register an instrument in the global registry. |
get_instrument |
Retrieve an instrument by its abbreviation. |
show_instruments |
List all registered instrument abbreviations. |
InstrumentScale
dataclass
¶
Single scale within an instrument.
ResponseAnchor
dataclass
¶
Response option for an instrument.
NormativeSample
dataclass
¶
NormativeSample(sample_id: int, size: int, population: str, reference: str, url: str, statistics: DataFrame)
Normative sample metadata and statistics.
Instrument
dataclass
¶
Instrument(name: str, abbrev: str, construct: str, reference: str, url: str, status: str, scales: tuple[InstrumentScale, ...], anchors: tuple[ResponseAnchor, ...], items: tuple[ResponseItem, ...] | None = None, norms: tuple[NormativeSample, ...] = (), prefix: str = '', suffix: str = '')
Circumplex instrument definition.
| METHOD | DESCRIPTION |
|---|---|
get_angles |
Get angular positions for all scales. |
get_scale |
Get scale by abbreviation. |
get_item |
Get item by item ID. |
__repr__ |
Return a human-readable multi-line summary of the instrument. |
__rich_repr__ |
Yield lines for rich-rendered representation. |
info |
Print instrument information. |
info_scales |
Return information about instrument scales, optionally with items. |
info_anchors |
Return the response anchors for the instrument. |
info_norms |
Return information about available normative samples. |
score |
Compute mean scale scores for the instrument. |
norm_standardize |
Standardize scale-level data using a normative sample. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
n_scales |
Number of scales in the instrument.
TYPE:
|
n_items |
Number of items in the instrument.
TYPE:
|
scale_labels |
Get names of all scales. |
scale_abbrevs |
Get abbreviations of all scales. |
get_angles
¶
get_scale
¶
Get scale by abbreviation.
Source code in src/circumplex/instruments/models.py
get_item
¶
Get item by item ID.
Source code in src/circumplex/instruments/models.py
__repr__
¶
Return a human-readable multi-line summary of the instrument.
Source code in src/circumplex/instruments/models.py
__rich_repr__
¶
Yield lines for rich-rendered representation.
Source code in src/circumplex/instruments/models.py
info
¶
info(*, scales: bool = True, anchors: bool = True, items: bool = False, norms: bool = True, rich_print: bool = True) -> None
Print instrument information.
Source code in src/circumplex/instruments/models.py
info_scales
¶
Return information about instrument scales, optionally with items.
Source code in src/circumplex/instruments/models.py
info_anchors
¶
Return the response anchors for the instrument.
Source code in src/circumplex/instruments/models.py
info_norms
¶
Return information about available normative samples.
Source code in src/circumplex/instruments/models.py
score
¶
score(data: DataFrame, items: Iterable[str | int], prefix: str = '', suffix: str = '', *, na_rm: bool = True, append: bool = True) -> pd.DataFrame
Compute mean scale scores for the instrument.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
DataFrame containing item-level data.
TYPE:
|
items
|
Iterable of item names or integer indices in |
prefix
|
String affixes to add to resulting scale column names.
TYPE:
|
suffix
|
String affixes to add to resulting scale column names.
TYPE:
|
na_rm
|
If True, ignore missing values when computing means.
TYPE:
|
append
|
If True, append scores to
TYPE:
|
Source code in src/circumplex/instruments/models.py
norm_standardize
¶
norm_standardize(data: DataFrame, sample_id: int, scales: Iterable[str | int] | None = None, prefix: str = '', suffix: str = '_z', *, append: bool = True) -> pd.DataFrame
Standardize scale-level data using a normative sample.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
DataFrame containing at least circumplex scales.
TYPE:
|
sample_id
|
The ID of the normative sample to use for standardization.
TYPE:
|
scales
|
The variable names or column numbers for the scales in |
prefix
|
Prefix to add to standardized scale names.
TYPE:
|
suffix
|
Suffix to add to standardized scale names.
TYPE:
|
append
|
If True, append standardized scales to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with standardized scale-level data. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/circumplex/instruments/models.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |
register_instrument
¶
get_instrument
¶
Retrieve an instrument by its abbreviation.
Source code in src/circumplex/instruments/models.py
show_instruments
¶
List all registered instrument abbreviations.