Skip to content

Commit

Permalink
Remove typing module (#27)
Browse files Browse the repository at this point in the history
* remove typing module.

* Remove unused import.

* Update audpsychometric/core/datasets/__init__.py

Co-authored-by: Hagen Wierstorf <[email protected]>

---------

Co-authored-by: Hagen Wierstorf <[email protected]>
  • Loading branch information
ChristianGeng and hagenw authored Oct 23, 2024
1 parent a74031c commit c136845
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 deletions audpsychometric/core/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def read_dataset(data_set_name: str) -> pd.DataFrame:
return df


def list_datasets():
r"""List tests datasets available in package.
def list_datasets() -> pd.DataFrame:
"""List datasets available in package.
Returns:
dataframe listing available datasets
Expand Down
26 changes: 14 additions & 12 deletions audpsychometric/core/gold_standard.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import typing
from __future__ import annotations

from collections.abc import Sequence

import numpy as np
import pandas as pd
Expand All @@ -7,10 +9,10 @@


def agreement_categorical(
ratings: typing.Sequence,
ratings: Sequence,
*,
axis: int = 1,
) -> typing.Union[float, np.ndarray]:
) -> float | np.ndarray:
r"""Confidence score for categorical ratings.
The agreement for categorical data
Expand Down Expand Up @@ -50,12 +52,12 @@ def _agreement(x):


def agreement_numerical(
ratings: typing.Sequence,
ratings: Sequence,
minimum: float,
maximum: float,
*,
axis: int = 1,
) -> typing.Union[float, np.ndarray]:
) -> float | np.ndarray:
r"""Confidence score for numerical ratings.
.. math::
Expand Down Expand Up @@ -103,10 +105,10 @@ def _agreement(row):


def evaluator_weighted_estimator(
ratings: typing.Sequence,
ratings: Sequence,
*,
axis: int = 1,
) -> typing.Union[float, np.ndarray]:
) -> float | np.ndarray:
r"""Evaluator weighted estimator (EWE) of raters' votes.
The EWE is described in
Expand Down Expand Up @@ -150,10 +152,10 @@ def evaluator_weighted_estimator(


def mode(
ratings: typing.Sequence,
ratings: Sequence,
*,
axis: int = 1,
) -> typing.Any:
) -> object:
r"""Mode of categorical ratings.
``None`` and ``nan`` values are ignored per item.
Expand Down Expand Up @@ -200,7 +202,7 @@ def mode(


def rater_agreement(
ratings: typing.Sequence,
ratings: Sequence,
*,
axis: int = 1,
) -> np.ndarray:
Expand Down Expand Up @@ -256,7 +258,7 @@ def rater_agreement(
return np.array(agreements)


def _value_or_array(values: np.ndarray) -> typing.Union[float, np.ndarray]:
def _value_or_array(values: np.ndarray) -> float | np.ndarray:
r"""Convert single valued arrays to value.
Squeeze array,
Expand All @@ -276,7 +278,7 @@ def _value_or_array(values: np.ndarray) -> typing.Union[float, np.ndarray]:
return values


def _mode(ratings: np.ndarray, *, remove_nan=False) -> typing.Any:
def _mode(ratings: np.ndarray, *, remove_nan=False) -> object:
"""Mode of categorical values.
Args:
Expand Down
16 changes: 9 additions & 7 deletions audpsychometric/core/reliability.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import typing
from __future__ import annotations

from collections.abc import Sequence

import numpy as np
import pandas as pd
Expand All @@ -9,10 +11,10 @@


def cronbachs_alpha(
ratings: typing.Sequence,
ratings: Sequence,
*,
axis: int = 1,
) -> typing.Tuple[float, typing.Dict]:
) -> tuple[float, dict]:
r"""Calculate Cronbach's alpha.
The Cronbach coefficient quantifying interrater agreement.
Expand Down Expand Up @@ -67,10 +69,10 @@ def cronbachs_alpha(


def congeneric_reliability(
ratings: typing.Sequence,
ratings: Sequence,
*,
axis: int = 1,
) -> typing.Tuple[float, typing.Dict]:
) -> tuple[float, dict]:
r"""Congeneric reliability coefficient.
Extracts the first Principal Component as a measurement model
Expand Down Expand Up @@ -111,12 +113,12 @@ def congeneric_reliability(


def intra_class_correlation(
ratings: typing.Sequence,
ratings: Sequence,
*,
axis: int = 1,
icc_type: str = "ICC_1_1",
anova_method: str = "pingouin",
) -> typing.Tuple[float, typing.Dict]:
) -> tuple[float, dict]:
r"""Intraclass Correlation.
Intraclass correlation calculates rating reliability by relating
Expand Down

0 comments on commit c136845

Please sign in to comment.