Skip to content

Commit

Permalink
Merge pull request #919 from aeturrell/pydoclint
Browse files Browse the repository at this point in the history
Introducing pydoclint to the repo
  • Loading branch information
aeturrell authored Jan 13, 2025
2 parents 4b208c9 + 1b8360e commit d34e565
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ repos:
entry: nbstripout
language: python
types: [jupyter]
- repo: https://github.com/jsh9/pydoclint
rev: 0.6.0
hooks:
- id: pydoclint
args: [--style=google, --config=pyproject.toml, src/]
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies = [
"rich>=13.9.4",
"typeguard>=4.4.1",
"pyarrow>=17.0.0",
"pydoclint>=0.6.0",
]

[dependency-groups]
Expand Down Expand Up @@ -55,3 +56,7 @@ show_error_codes = true
show_error_context = true
ignore_missing_imports = true
disallow_untyped_calls = false

[tool.pydoclint]
style = 'google'
exclude = ["noxfile.py", "tests/", "docs/"]
25 changes: 18 additions & 7 deletions src/skimpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ def _infer_datatypes(df: pd.DataFrame) -> pd.DataFrame:


@typechecked
def _round_series(s: pd.Series, places=2) -> pd.Series:
def _round_series(s: pd.Series, places: int = 2) -> pd.Series:
"""Rounds numerical series to places number of significant figures
Args:
s (pd.Series): Input series
places (int, optional): Number of significant figures to round to. Defaults to 2.
Returns:
pd.Series: Series with numbers rounded to places s.f.
Expand Down Expand Up @@ -289,15 +290,15 @@ def _dataframe_to_rich_table(
return table


def _find_nearest(array, value):
def _find_nearest(array: np.ndarray, value: float) -> float:
"""Find the nearest numerical match to value in an array.
Args:
array (np.ndarray): An array of numbers to match with.
value (float): Single value to find an entry in array that is close.
Returns:
np.array: The entry in array that is closest to value.
float: The entry in array that is closest to value.
"""
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
Expand Down Expand Up @@ -612,10 +613,13 @@ def _delete_unsupported_columns(df: pd.DataFrame) -> pd.DataFrame:
supported.
Args:
df (pd.DataFrame): _description_
df (pd.DataFrame): Input dataframe.
Returns:
pd.DataFrame: _description_
pd.DataFrame: Dataframe with unsupported columns removed.
Raises:
ValueError: If the input dataframe only has unsupported column types.
"""
df_types = (
pd.DataFrame(df.apply(pd.api.types.infer_dtype, axis=0))
Expand Down Expand Up @@ -643,7 +647,7 @@ def _skim_computation(
df_in (pd.DataFrame): Input pandas dataframe to create a summary of.
Returns:
[rich.table.Table, JSON]: Rich table grid to print to console, JSON of summary stats.
Tuple[rich.table.Table, JSON]: Rich table grid to print to console, JSON of summary stats.
"""
if hasattr(df_in, "name") and "name" not in df_in.columns:
name = str(df_in.name)
Expand Down Expand Up @@ -767,6 +771,9 @@ def skim(
Args:
df_in (Union[pd.DataFrame, pl.DataFrame]): Dataframe to skim.
Raises:
NotImplementedError: If the dataframe has a MultiIndex column structure.
Examples
--------
Skim a dataframe
Expand Down Expand Up @@ -846,6 +853,10 @@ def skim_get_figure(
df_in (Union[pd.DataFrame, pl.DataFrame]): Dataframe to skim.
save_path (Union[os.PathLike, str]): Path to save figure to (include extension).
format (str, optional): svg, html, or text. Defaults to "svg".
Raises:
ValueError: If the format is not one of svg, html, or text.
"""
df_out = _convert_to_pandas(df_in)
grid, _ = _skim_computation(df_out)
Expand Down Expand Up @@ -908,7 +919,7 @@ def clean_columns(
ValueError: If case is not valid.
Returns:
(Union[pd.DataFrame, pl.DataFrame]): Dataframe with cleaned column names.
Union[pd.DataFrame, pl.DataFrame]: Dataframe with cleaned column names.
Examples
--------
Expand Down
4 changes: 2 additions & 2 deletions src/skimpy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
@click.command()
@click.version_option()
@click.argument("input")
def main(input) -> None:
def main(input: str) -> None:
"""The skimpy command line interface. Usage refers only to command line.
Args:
input ([csv]): A csv file to produce summary statistics on
input (str): String of path of csv file to produce summary statistics on
"""
df = pd.read_csv(input, parse_dates=True)
df = df.infer_objects()
Expand Down
27 changes: 26 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d34e565

Please sign in to comment.