From a4f1c0aa0f6afe606a2bad1046534bb2ebdd96d1 Mon Sep 17 00:00:00 2001 From: Eric Ma Date: Sat, 14 Oct 2023 08:01:44 -0400 Subject: [PATCH] [INF] Infra upgrades (#1294) * chore: update pre-commit hooks - Removed unused hooks: isort, flake8 - Added new hook: ruff - Updated black and interrogate hooks configuration - Commented out darglint due to timeout issues on pre-commit CI This update aims to improve code quality checks and ensure consistency across the codebase. * feat: Add ruff tool configuration to pyproject.toml This commit introduces a new feature to the codebase by adding the configuration for the ruff tool in the pyproject.toml file. The configuration includes enabling pycodestyle and Pyflakes codes, allowing fixes for all enabled rules, excluding commonly ignored directories, setting the line length to 88, allowing unused variables when underscore-prefixed, and assuming Python 3.8. It also sets the default complexity level to 10 for the mccabe tool under ruff. * chore(pyproject.toml): Update target Python version to 3.10 This commit updates the target Python version in the pyproject.toml file from 3.8 to 3.10. * chore(environment-dev): update Python and rdkit versions - Python version updated from 3.9 to 3.10 - rdkit version constraint removed * chore: Comment out darglint and add --fix arg to ruff In this commit, the darglint pre-commit hook has been commented out. Additionally, the --fix argument has been added to the ruff pre-commit hook. * infra: satisfy the shiny new ruff linter * chore: disable darglint in pre-commit config Due to performance issues, darglint has been commented out in the pre-commit configuration. It may be replaced by ruff in the future. See https://github.com/astral-sh/ruff/issues/458 for more details. * feat: update pre-commit hooks and add pydoclint - Updated the version of pre-commit-hooks from v4.4.0 to v4.5.0. - Added pydoclint as an interim replacement for darglint with configuration in pyproject.toml. * refactor(janitor/utils): use isinstance for type checking Changed the type checking in the skipna function from using type() to isinstance() for better Pythonic practice. * refactor: update docstrings and remove redundant comments In this commit, we have updated the docstring for the `_get_data_df` method in the `DataDescription` class to provide more detailed information about its functionality. We have also removed the redundant comments from the `__init__` method of the `col` class in `utils.py` as they were not providing any additional value. * chore: remove darglint checks workflow This commit removes the darglint checks workflow from the GitHub actions. The workflow was initially added to run darglint checks manually due to the pre-commit CI timing out. Now that the issue has been resolved, the workflow is no longer needed. * feat(janitor): add 'col' utility to functions This commit introduces the 'col' utility from the utils module into the janitor package. This utility can now be accessed directly from the janitor package. * refactor(janitor): update import statements and function usage - Updated import statement in __init__.py to include DropLabel from functions.utils - Modified usage of expand_grid function in expand_grid.py to be directly called instead of through the janitor module * test: remove redundant dataframe method registration tests This commit removes the test_df_registration.py file, which contained redundant tests for dataframe method registration. These tests were not necessary as the registration of these methods is guaranteed by the pandas-flavor library. * feat(utils): add dynamic_import function and import janitor.chemistry in test - Added a new function `dynamic_import` in `janitor/utils.py` that allows for dynamic importing of all modules in a directory. - Imported `janitor.chemistry` in `tests/chemistry/test_maccs_keys_fingerprint.py` to ensure it's available during testing. - Also added `importlib` and `pathlib.Path` to `janitor/utils.py` to support the new function. * feat(janitor/functions): add dynamic import functionality - Imported dynamic_import from janitor.utils - Called dynamic_import function with __name__ as argument * refactor: update dynamic_import argument and limit test examples - In `janitor/functions/__init__.py`, the argument passed to `dynamic_import` has been updated from `__name__` to `Path(__name__)` to leverage the pathlib library for more robust path handling. - In `tests/functions/test_conditional_join.py`, the number of examples for several tests has been limited to improve test performance and reduce runtime. * refactor(janitor/functions): remove unused imports and dynamic import function This commit removes the unused imports 'Path' from 'pathlib' and 'dynamic_import' from 'janitor.utils'. It also removes the call to 'dynamic_import' function which is no longer needed. * refactor(tests): import janitor module in test files - Modified the import statements in test_expand_grid.py and test_factorize_columns.py to include the janitor module. - This change ensures that the janitor module is explicitly imported in the test files. * test: import janitor in test_fill_direction.py This commit adds an import statement for the janitor module in the test_fill_direction.py file. This is necessary for the proper functioning of the tests in this file. * refactor(janitor): reorganize function imports and remove unused imports This commit reorganizes the function imports in the janitor package to improve code readability and maintainability. It also removes an unused import from the main __init__.py file. * test: limit max examples in pytest settings to 10 This commit reduces the maximum number of examples generated by pytest for each test case from unlimited to 10. This change is intended to speed up test execution time without significantly reducing test coverage. * test: limit max examples in pytest settings to 10 In an effort to optimize testing time, the maximum number of examples for each test in the pytest settings has been reduced to 10. This change affects multiple test functions in the 'test_conditional_join.py' file. * test: limit max examples in pytest settings to 10 for multiple test functions * test: limit max examples in pytest to improve test performance * feat(devguide): expand section on writing code This commit expands the "Write the Code" section in the developer guide. It provides more detailed instructions on best practices for writing code, including committing early and often, staying updated with the dev branch, and writing tests. It also updates the "Check your code" section to include information about pre-commit hooks. * chore(github-actions): update checkout action and remove test matrix This commit updates the version of the checkout action used in the GitHub Actions workflow from v3 to v4. It also removes the matrix strategy for running tests, which previously included "turtle" and "not turtle" subsets. Now, all tests will be run without any subset specification. * test: Add execution test for conditional_join function This commit introduces a new test for the conditional_join function in the test_conditional_join.py file. The test uses an example directly from the conditional_join docstring to verify the function's correct operation. --- .github/workflows/darglint-checks.yml | 42 ---- .github/workflows/tests.yml | 6 +- .pre-commit-config.yaml | 40 ++-- environment-dev.yml | 4 +- janitor/accessors/data_description.py | 5 +- janitor/engineering.py | 1 - janitor/finance.py | 2 +- janitor/functions/__init__.py | 85 ++++++- janitor/functions/_numba.py | 7 +- janitor/functions/add_columns.py | 7 +- janitor/functions/also.py | 3 +- janitor/functions/bin_numeric.py | 6 +- janitor/functions/case_when.py | 8 +- janitor/functions/clean_names.py | 9 +- janitor/functions/coalesce.py | 3 +- janitor/functions/collapse_levels.py | 2 +- janitor/functions/complete.py | 12 +- janitor/functions/concatenate_columns.py | 5 +- janitor/functions/conditional_join.py | 15 +- janitor/functions/convert_date.py | 5 +- janitor/functions/count_cumulative_unique.py | 2 +- .../functions/currency_column_to_numeric.py | 3 +- janitor/functions/deconcatenate_column.py | 5 +- janitor/functions/drop_constant_columns.py | 2 +- janitor/functions/drop_duplicate_columns.py | 3 +- janitor/functions/dropnotnull.py | 3 +- janitor/functions/encode_categorical.py | 2 +- janitor/functions/expand_grid.py | 10 +- janitor/functions/factorize_columns.py | 3 +- janitor/functions/fill.py | 3 +- janitor/functions/filter.py | 3 +- janitor/functions/find_replace.py | 5 +- janitor/functions/flag_nulls.py | 5 +- janitor/functions/get_dupes.py | 3 +- janitor/functions/groupby_agg.py | 3 +- janitor/functions/groupby_topk.py | 6 +- janitor/functions/impute.py | 7 +- janitor/functions/jitter.py | 3 +- janitor/functions/join_apply.py | 4 +- janitor/functions/label_encode.py | 7 +- janitor/functions/limit_column_characters.py | 2 +- janitor/functions/min_max_scale.py | 5 +- janitor/functions/move.py | 9 +- janitor/functions/pivot.py | 10 +- janitor/functions/process_text.py | 3 +- janitor/functions/remove_columns.py | 3 +- janitor/functions/remove_empty.py | 2 +- janitor/functions/rename_columns.py | 3 +- janitor/functions/reorder_columns.py | 3 +- janitor/functions/round_to_fraction.py | 1 + janitor/functions/row_to_names.py | 3 +- janitor/functions/select.py | 9 +- janitor/functions/shuffle.py | 3 +- janitor/functions/sort_column_value_order.py | 4 +- janitor/functions/sort_naturally.py | 3 +- janitor/functions/take_first.py | 3 +- janitor/functions/then.py | 4 +- janitor/functions/to_datetime.py | 3 +- janitor/functions/toset.py | 4 +- janitor/functions/transform_columns.py | 3 +- janitor/functions/truncate_datetime.py | 2 +- janitor/functions/update_where.py | 6 +- janitor/functions/utils.py | 44 ++-- janitor/io.py | 14 +- janitor/spark/backend.py | 1 - janitor/spark/functions.py | 3 +- janitor/timeseries.py | 2 +- janitor/utils.py | 27 ++- mkdocs/devguide.md | 45 ++-- pyproject.toml | 49 ++++ .../chemistry/test_maccs_keys_fingerprint.py | 2 +- tests/chemistry/test_molecular_descriptors.py | 2 - tests/chemistry/test_morgan_fingerprint.py | 3 - tests/functions/test_add_column.py | 13 +- tests/functions/test_add_columns.py | 5 +- tests/functions/test_bin_numeric.py | 7 +- tests/functions/test_case_when.py | 17 +- tests/functions/test_complete.py | 13 +- tests/functions/test_conditional_join.py | 225 ++++++++++-------- tests/functions/test_encode_categorical.py | 26 +- tests/functions/test_expand_grid.py | 48 ++-- tests/functions/test_factorize_columns.py | 2 + tests/functions/test_fill_direction.py | 2 + tests/functions/test_fill_empty.py | 2 +- tests/functions/test_filter_column_isin.py | 12 +- tests/functions/test_flag_nulls.py | 2 +- tests/functions/test_move.py | 10 +- tests/functions/test_pivot_longer.py | 4 +- tests/functions/test_remove_empty.py | 5 +- tests/functions/test_reorder_columns.py | 5 +- tests/functions/test_select.py | 2 +- tests/functions/test_select_columns.py | 11 +- tests/functions/test_select_rows.py | 1 - tests/io/test_read_commandline.py | 3 +- tests/io/test_tidyxl.py | 6 +- tests/io/test_xlsx_table.py | 8 +- tests/math/test_ecdf.py | 3 +- tests/ml/test_get_features_targets.py | 9 +- .../spark/functions/test_clean_names_spark.py | 2 +- tests/test_df_registration.py | 161 ------------- tests/test_documentation_build.py | 1 - 101 files changed, 615 insertions(+), 619 deletions(-) delete mode 100644 .github/workflows/darglint-checks.yml delete mode 100644 tests/test_df_registration.py diff --git a/.github/workflows/darglint-checks.yml b/.github/workflows/darglint-checks.yml deleted file mode 100644 index f30734de9..000000000 --- a/.github/workflows/darglint-checks.yml +++ /dev/null @@ -1,42 +0,0 @@ -# Temporarily run darglint using github actions rather than pre-commit CI because it is consistently -# more than 5min to run and timing out. To be removed once ruff supports darglint rules. -name: darglint checks - -on: - # only run darglint checks when src-code changes - push: - branches: - - dev - paths: - - "janitor/**" - - ".github/workflows/darglint-checks.yml" - pull_request: - branches: - - dev - paths: - - "janitor/**" - - ".github/workflows/darglint-checks.yml" - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - run-darglint: - name: Run darglint checks manually - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: "3.11" - check-latest: false - - - name: Run darglint only with pre-commit - uses: pre-commit/action@v3.0.0 - with: - extra_args: darglint --all-files diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f27b47ef5..13eb5647b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,8 +27,6 @@ jobs: run-tests: strategy: fail-fast: false - matrix: - test-subset: ["turtle", "not turtle"] runs-on: ubuntu-latest name: Run pyjanitor test suite @@ -39,7 +37,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # See: https://github.com/marketplace/actions/setup-miniconda - name: Setup miniconda @@ -58,7 +56,7 @@ jobs: run: pytest -v -r a -n auto --color=yes --durations=0 --cov=janitor --cov-append --cov-report term-missing --cov-report xml --doctest-only janitor - name: Run unit tests - run: pytest -v -r a -n auto --color=yes --durations=0 --cov=janitor --cov-append --cov-report term-missing --cov-report xml tests -m "${{ matrix.test-subset }}" + run: pytest -v -r a -n auto --color=yes --durations=0 --cov=janitor --cov-append --cov-report term-missing --cov-report xml tests # https://github.com/codecov/codecov-action - name: Upload code coverage diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5eccdc949..0508c2912 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,38 +8,34 @@ repos: - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - - repo: https://github.com/psf/black rev: 23.9.1 hooks: - id: black args: [--config, pyproject.toml] - - # - repo: https://github.com/pycqa/isort - # rev: 5.11.2 - # hooks: - # - id: isort - # name: isort (python) - - repo: https://github.com/econchick/interrogate rev: 1.5.0 hooks: - id: interrogate args: [-c, pyproject.toml] + # Taking out darglint because it takes too long to run. + # It may be superseded by ruff: https://github.com/astral-sh/ruff/issues/458 + # - repo: https://github.com/terrencepreilly/darglint + # rev: v1.8.1 + # hooks: + # - id: darglint + # args: [-v 2] # this config makes the error messages a bit less cryptic. - - repo: https://github.com/terrencepreilly/darglint - rev: v1.8.1 + # The interim replacement for darglint is pydoclint. + - repo: https://github.com/jsh9/pydoclint + rev: 0.3.3 hooks: - - id: darglint - args: [-v 2] # this config makes the error messages a bit less cryptic. - - - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + - id: pydoclint + args: + - "--config=pyproject.toml" + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.0.292 hooks: - - id: flake8 - args: [--exclude, nbconvert_config.py] - -ci: - skip: - # FIXME: darglint is timing out on pre-commit CI (cf. #1236, #1246) - - darglint + - id: ruff + args: [--fix] diff --git a/environment-dev.yml b/environment-dev.yml index 77f5dd775..3c59895d8 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -2,7 +2,7 @@ name: pyjanitor-dev channels: - conda-forge dependencies: - - python=3.9 + - python=3.10 - biopython - black=22.12.0 # keep this in sync with `.pre-commit-config.yaml` - bump2version=1.0.1 @@ -40,7 +40,7 @@ dependencies: - pytest-xdist - pytest-doctestplus - python-language-server - - rdkit=2021.09.3 + - rdkit - recommonmark - seaborn - twine diff --git a/janitor/accessors/data_description.py b/janitor/accessors/data_description.py index 1b254e459..4025b1da6 100644 --- a/janitor/accessors/data_description.py +++ b/janitor/accessors/data_description.py @@ -13,11 +13,14 @@ class DataDescription: """ def __init__(self, data): - """Initialize DataDescription class.""" self._data = data self._desc = {} def _get_data_df(self) -> pd.DataFrame: + """Get a table of descriptive information in a DataFrame format. + + :returns: A DataFrame containing the descriptive information. + """ df = self._data data_dict = {} diff --git a/janitor/engineering.py b/janitor/engineering.py index bb1b99b3e..00f9e4946 100644 --- a/janitor/engineering.py +++ b/janitor/engineering.py @@ -7,7 +7,6 @@ from .utils import check, import_message - try: import unyt except ImportError: diff --git a/janitor/finance.py b/janitor/finance.py index b33814516..72984473a 100644 --- a/janitor/finance.py +++ b/janitor/finance.py @@ -9,8 +9,8 @@ import requests from janitor.errors import JanitorError -from .utils import check, deprecated_alias, is_connected +from .utils import check, deprecated_alias, is_connected currency_set = { "AUD", diff --git a/janitor/functions/__init__.py b/janitor/functions/__init__.py index c4e8cd049..b2dbe5d26 100644 --- a/janitor/functions/__init__.py +++ b/janitor/functions/__init__.py @@ -43,7 +43,7 @@ from .expand_grid import expand_grid from .factorize_columns import factorize_columns from .fill import fill_direction, fill_empty -from .filter import filter_date, filter_column_isin, filter_on, filter_string +from .filter import filter_column_isin, filter_date, filter_on, filter_string from .find_replace import find_replace from .flag_nulls import flag_nulls from .get_dupes import get_dupes @@ -64,7 +64,7 @@ from .reorder_columns import reorder_columns from .round_to_fraction import round_to_fraction from .row_to_names import row_to_names -from .select import select_columns, select_rows, select +from .select import select, select_columns, select_rows from .shuffle import shuffle from .sort_column_value_order import sort_column_value_order from .sort_naturally import sort_naturally @@ -76,10 +76,85 @@ from .truncate_datetime import truncate_datetime_dataframe from .update_where import update_where from .utils import ( - patterns, - unionize_dataframe_categories, DropLabel, - get_index_labels, col, get_columns, + get_index_labels, + patterns, + unionize_dataframe_categories, ) + +__all__ = [ + "add_columns", + "also", + "bin_numeric", + "case_when", + "change_type", + "clean_names", + "coalesce", + "collapse_levels", + "complete", + "concatenate_columns", + "conditional_join", + "convert_excel_date", + "convert_matlab_date", + "convert_unix_date", + "count_cumulative_unique", + "currency_column_to_numeric", + "deconcatenate_column", + "drop_constant_columns", + "drop_duplicate_columns", + "dropnotnull", + "encode_categorical", + "expand_column", + "expand_grid", + "factorize_columns", + "fill_direction", + "fill_empty", + "filter_date", + "filter_column_isin", + "filter_on", + "filter_string", + "find_replace", + "flag_nulls", + "get_dupes", + "groupby_agg", + "groupby_topk", + "impute", + "jitter", + "join_apply", + "label_encode", + "limit_column_characters", + "min_max_scale", + "move", + "pivot_longer", + "pivot_wider", + "process_text", + "remove_columns", + "remove_empty", + "rename_column", + "rename_columns", + "reorder_columns", + "round_to_fraction", + "row_to_names", + "select_columns", + "select_rows", + "select", + "shuffle", + "sort_column_value_order", + "sort_naturally", + "take_first", + "then", + "to_datetime", + "toset", + "transform_column", + "transform_columns", + "truncate_datetime_dataframe", + "update_where", + "patterns", + "unionize_dataframe_categories", + "DropLabel", + "get_index_labels", + "col", + "get_columns", +] diff --git a/janitor/functions/_numba.py b/janitor/functions/_numba.py index 10a429a03..235996ca2 100644 --- a/janitor/functions/_numba.py +++ b/janitor/functions/_numba.py @@ -2,14 +2,15 @@ import numpy as np import pandas as pd +from numba import njit, prange +from pandas.api.types import is_datetime64_dtype, is_extension_array_dtype + from janitor.functions.utils import ( _generic_func_cond_join, _JoinOperator, - less_than_join_types, greater_than_join_types, + less_than_join_types, ) -from numba import njit, prange -from pandas.api.types import is_extension_array_dtype, is_datetime64_dtype def _numba_equi_join(df, right, eqs, ge_gt, le_lt): diff --git a/janitor/functions/add_columns.py b/janitor/functions/add_columns.py index 7c61ca775..b2a506a68 100644 --- a/janitor/functions/add_columns.py +++ b/janitor/functions/add_columns.py @@ -1,9 +1,10 @@ +from typing import Any, List, Tuple, Union + +import numpy as np +import pandas as pd import pandas_flavor as pf from janitor.utils import check, deprecated_alias, refactored_function -import pandas as pd -from typing import Union, List, Any, Tuple -import numpy as np @pf.register_dataframe_method diff --git a/janitor/functions/also.py b/janitor/functions/also.py index 5ba9d4747..486892eb4 100644 --- a/janitor/functions/also.py +++ b/janitor/functions/also.py @@ -1,7 +1,8 @@ """Implementation source for chainable function `also`.""" from typing import Any, Callable -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf @pf.register_dataframe_method diff --git a/janitor/functions/bin_numeric.py b/janitor/functions/bin_numeric.py index 32c6c56bf..0929b6e2f 100644 --- a/janitor/functions/bin_numeric.py +++ b/janitor/functions/bin_numeric.py @@ -1,11 +1,11 @@ """Implementation source for `bin_numeric`.""" -from typing import Any, Optional, Union, Sequence -import pandas_flavor as pf +from typing import Any, Optional, Sequence, Union + import pandas as pd +import pandas_flavor as pf from janitor.utils import check, check_column, deprecated_alias - ScalarSequence = Sequence[float] diff --git a/janitor/functions/case_when.py b/janitor/functions/case_when.py index 1563ee54e..0aacd4a5e 100644 --- a/janitor/functions/case_when.py +++ b/janitor/functions/case_when.py @@ -1,10 +1,12 @@ """Implementation source for `case_when`.""" -from pandas.core.common import apply_if_callable +import warnings from typing import Any -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from pandas.api.types import is_scalar -import warnings +from pandas.core.common import apply_if_callable + from janitor.utils import check, find_stack_level warnings.simplefilter("always", DeprecationWarning) diff --git a/janitor/functions/clean_names.py b/janitor/functions/clean_names.py index a27d99a39..e0e6b0014 100644 --- a/janitor/functions/clean_names.py +++ b/janitor/functions/clean_names.py @@ -1,13 +1,14 @@ """Functions for cleaning columns names.""" -from janitor.utils import deprecated_alias -from janitor.functions.utils import get_index_labels, _is_str_or_cat -from pandas.api.types import is_scalar +import unicodedata from typing import Hashable, Optional, Union + import pandas as pd import pandas_flavor as pf +from pandas.api.types import is_scalar from janitor.errors import JanitorError -import unicodedata +from janitor.functions.utils import _is_str_or_cat, get_index_labels +from janitor.utils import deprecated_alias @pf.register_dataframe_method diff --git a/janitor/functions/coalesce.py b/janitor/functions/coalesce.py index 2206ca214..9178eccb7 100644 --- a/janitor/functions/coalesce.py +++ b/janitor/functions/coalesce.py @@ -1,10 +1,11 @@ """Function for performing coalesce.""" from typing import Any, Optional, Union + import pandas as pd import pandas_flavor as pf -from janitor.utils import check, deprecated_alias from janitor.functions.utils import get_index_labels +from janitor.utils import check, deprecated_alias @pf.register_dataframe_method diff --git a/janitor/functions/collapse_levels.py b/janitor/functions/collapse_levels.py index 8781a4302..aae722fdb 100644 --- a/janitor/functions/collapse_levels.py +++ b/janitor/functions/collapse_levels.py @@ -1,9 +1,9 @@ """Implementation of the `collapse_levels` function.""" import pandas as pd import pandas_flavor as pf +from pandas.api.types import is_string_dtype from janitor.utils import check -from pandas.api.types import is_string_dtype @pf.register_dataframe_method diff --git a/janitor/functions/complete.py b/janitor/functions/complete.py index 05adfd49f..5171cccf6 100644 --- a/janitor/functions/complete.py +++ b/janitor/functions/complete.py @@ -1,13 +1,13 @@ -from typing import Optional, Union, List, Tuple, Dict, Any -from pandas.core.common import apply_if_callable -import pandas_flavor as pf -import pandas as pd import functools -from pandas.api.types import is_list_like, is_scalar +from typing import Any, Dict, List, Optional, Tuple, Union -from janitor.utils import check, check_column +import pandas as pd +import pandas_flavor as pf +from pandas.api.types import is_list_like, is_scalar +from pandas.core.common import apply_if_callable from janitor.functions.utils import _computations_expand_grid +from janitor.utils import check, check_column @pf.register_dataframe_method diff --git a/janitor/functions/concatenate_columns.py b/janitor/functions/concatenate_columns.py index bb199564f..f738ba49c 100644 --- a/janitor/functions/concatenate_columns.py +++ b/janitor/functions/concatenate_columns.py @@ -1,8 +1,9 @@ from typing import Hashable, List -import pandas_flavor as pf + import pandas as pd -from janitor.errors import JanitorError +import pandas_flavor as pf +from janitor.errors import JanitorError from janitor.utils import deprecated_alias diff --git a/janitor/functions/conditional_join.py b/janitor/functions/conditional_join.py index a0261c507..ab20f1fd3 100644 --- a/janitor/functions/conditional_join.py +++ b/janitor/functions/conditional_join.py @@ -1,10 +1,12 @@ from __future__ import annotations + import operator -from typing import Union, Any, Optional, Hashable, Literal +import warnings +from typing import Any, Hashable, Literal, Optional, Union + import numpy as np import pandas as pd import pandas_flavor as pf -import warnings from pandas.core.dtypes.common import ( is_datetime64_dtype, is_dtype_equal, @@ -12,18 +14,17 @@ is_numeric_dtype, is_string_dtype, ) - from pandas.core.reshape.merge import _MergeOperation -from janitor.utils import check, check_column, find_stack_level from janitor.functions.utils import ( - _JoinOperator, _generic_func_cond_join, + _JoinOperator, _keep_output, - less_than_join_types, - greater_than_join_types, col, + greater_than_join_types, + less_than_join_types, ) +from janitor.utils import check, check_column, find_stack_level warnings.simplefilter("always", DeprecationWarning) diff --git a/janitor/functions/convert_date.py b/janitor/functions/convert_date.py index fd0e039d0..471bc8ebf 100644 --- a/janitor/functions/convert_date.py +++ b/janitor/functions/convert_date.py @@ -1,9 +1,10 @@ -from pandas.errors import OutOfBoundsDatetime import datetime as dt from typing import Hashable -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from pandas.api.types import is_numeric_dtype +from pandas.errors import OutOfBoundsDatetime from janitor.utils import deprecated_alias diff --git a/janitor/functions/count_cumulative_unique.py b/janitor/functions/count_cumulative_unique.py index f5dec4729..435c20be2 100644 --- a/janitor/functions/count_cumulative_unique.py +++ b/janitor/functions/count_cumulative_unique.py @@ -2,8 +2,8 @@ from typing import Hashable import numpy as np -import pandas_flavor as pf import pandas as pd +import pandas_flavor as pf from janitor.utils import check_column diff --git a/janitor/functions/currency_column_to_numeric.py b/janitor/functions/currency_column_to_numeric.py index 1194caa06..db75243c7 100644 --- a/janitor/functions/currency_column_to_numeric.py +++ b/janitor/functions/currency_column_to_numeric.py @@ -1,7 +1,8 @@ from functools import partial from typing import Optional, Union -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.utils import check, check_column, deprecated_alias diff --git a/janitor/functions/deconcatenate_column.py b/janitor/functions/deconcatenate_column.py index 1baeb00c4..0ef16b11d 100644 --- a/janitor/functions/deconcatenate_column.py +++ b/janitor/functions/deconcatenate_column.py @@ -1,9 +1,10 @@ """Implementation of deconcatenating columns.""" from typing import Hashable, List, Optional, Tuple, Union -import pandas_flavor as pf + import pandas as pd -from janitor.errors import JanitorError +import pandas_flavor as pf +from janitor.errors import JanitorError from janitor.utils import deprecated_alias diff --git a/janitor/functions/drop_constant_columns.py b/janitor/functions/drop_constant_columns.py index dac16dddc..a87caa0f9 100644 --- a/janitor/functions/drop_constant_columns.py +++ b/janitor/functions/drop_constant_columns.py @@ -1,6 +1,6 @@ """Implementation of drop_constant_columns.""" -import pandas_flavor as pf import pandas as pd +import pandas_flavor as pf @pf.register_dataframe_method diff --git a/janitor/functions/drop_duplicate_columns.py b/janitor/functions/drop_duplicate_columns.py index 45e0e0b5d..00bec253f 100644 --- a/janitor/functions/drop_duplicate_columns.py +++ b/janitor/functions/drop_duplicate_columns.py @@ -1,7 +1,8 @@ """Implementation for `drop_duplicate_columns`.""" from typing import Hashable -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf @pf.register_dataframe_method diff --git a/janitor/functions/dropnotnull.py b/janitor/functions/dropnotnull.py index 37af5df24..ac9190e59 100644 --- a/janitor/functions/dropnotnull.py +++ b/janitor/functions/dropnotnull.py @@ -1,7 +1,8 @@ """Implementation source for `dropnotnull`.""" from typing import Hashable -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.utils import deprecated_alias diff --git a/janitor/functions/encode_categorical.py b/janitor/functions/encode_categorical.py index 3c46bd200..b99296be1 100644 --- a/janitor/functions/encode_categorical.py +++ b/janitor/functions/encode_categorical.py @@ -7,8 +7,8 @@ import pandas_flavor as pf from pandas.api.types import is_list_like -from janitor.utils import check_column, deprecated_alias, find_stack_level from janitor.functions.utils import get_index_labels +from janitor.utils import check_column, deprecated_alias, find_stack_level @pf.register_dataframe_method diff --git a/janitor/functions/expand_grid.py b/janitor/functions/expand_grid.py index cb9ce1f87..14735ac37 100644 --- a/janitor/functions/expand_grid.py +++ b/janitor/functions/expand_grid.py @@ -1,11 +1,11 @@ """Implementation source for `expand_grid`.""" from typing import Dict, Optional, Union -import pandas_flavor as pf -import pandas as pd -from janitor.utils import check +import pandas as pd +import pandas_flavor as pf from janitor.functions.utils import _computations_expand_grid +from janitor.utils import check @pf.register_dataframe_method @@ -42,7 +42,7 @@ def expand_grid( Examples: >>> import pandas as pd - >>> import janitor as jn + >>> from janitor.functions.expand_grid import expand_grid >>> df = pd.DataFrame({"x": [1, 2], "y": [2, 1]}) >>> data = {"z": [1, 2, 3]} >>> df.expand_grid(df_key="df", others=data) @@ -58,7 +58,7 @@ def expand_grid( `expand_grid` works with non-pandas objects: >>> data = {"x": [1, 2, 3], "y": [1, 2]} - >>> jn.expand_grid(others=data) + >>> expand_grid(others=data) x y 0 0 0 1 1 diff --git a/janitor/functions/factorize_columns.py b/janitor/functions/factorize_columns.py index 5f5a78dec..772edd1ee 100644 --- a/janitor/functions/factorize_columns.py +++ b/janitor/functions/factorize_columns.py @@ -1,7 +1,8 @@ """Implementation of the `factorize_columns` function""" from typing import Any, Hashable, Iterable, Union -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.functions.utils import _factorize diff --git a/janitor/functions/fill.py b/janitor/functions/fill.py index ca6d8da58..565f08aae 100644 --- a/janitor/functions/fill.py +++ b/janitor/functions/fill.py @@ -5,13 +5,14 @@ import pandas as pd import pandas_flavor as pf +from multipledispatch import dispatch + from janitor.utils import ( check, check_column, deprecated_alias, refactored_function, ) -from multipledispatch import dispatch @pf.register_dataframe_method diff --git a/janitor/functions/filter.py b/janitor/functions/filter.py index 9a87e257b..e3c007216 100644 --- a/janitor/functions/filter.py +++ b/janitor/functions/filter.py @@ -6,10 +6,11 @@ import numpy as np import pandas as pd import pandas_flavor as pf + from janitor.utils import ( deprecated_alias, - refactored_function, find_stack_level, + refactored_function, ) warnings.simplefilter("always", DeprecationWarning) diff --git a/janitor/functions/find_replace.py b/janitor/functions/find_replace.py index c3a9e67de..3c0764e60 100644 --- a/janitor/functions/find_replace.py +++ b/janitor/functions/find_replace.py @@ -1,10 +1,11 @@ """Implementation for find_replace.""" -from typing import Dict, Any -from janitor.utils import refactored_function +from typing import Any, Dict import pandas as pd import pandas_flavor as pf +from janitor.utils import refactored_function + @pf.register_dataframe_method @refactored_function( diff --git a/janitor/functions/flag_nulls.py b/janitor/functions/flag_nulls.py index 8ab124deb..91e885213 100644 --- a/janitor/functions/flag_nulls.py +++ b/janitor/functions/flag_nulls.py @@ -1,8 +1,9 @@ """Implementation source for `flag_nulls`.""" from typing import Hashable, Iterable, Optional, Union -import pandas_flavor as pf -import pandas as pd + import numpy as np +import pandas as pd +import pandas_flavor as pf from janitor.utils import check_column diff --git a/janitor/functions/get_dupes.py b/janitor/functions/get_dupes.py index 3473e20e1..1bf1797c7 100644 --- a/janitor/functions/get_dupes.py +++ b/janitor/functions/get_dupes.py @@ -1,7 +1,8 @@ """Implementation of the `get_dupes` function""" from typing import Hashable, Iterable, Optional, Union -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.utils import deprecated_alias diff --git a/janitor/functions/groupby_agg.py b/janitor/functions/groupby_agg.py index 4173ecba9..c926b060a 100644 --- a/janitor/functions/groupby_agg.py +++ b/janitor/functions/groupby_agg.py @@ -1,7 +1,8 @@ """Implementation source for `groupby_agg`.""" from typing import Callable, List, Union -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.utils import deprecated_alias, refactored_function diff --git a/janitor/functions/groupby_topk.py b/janitor/functions/groupby_topk.py index 80a0c1e9d..15399dd62 100644 --- a/janitor/functions/groupby_topk.py +++ b/janitor/functions/groupby_topk.py @@ -1,10 +1,10 @@ """Implementation of the `groupby_topk` function""" from typing import Hashable, Union -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf -from janitor.utils import check_column -from janitor.utils import check, deprecated_alias +from janitor.utils import check, check_column, deprecated_alias @pf.register_dataframe_method diff --git a/janitor/functions/impute.py b/janitor/functions/impute.py index db6f7d16b..6f681de87 100644 --- a/janitor/functions/impute.py +++ b/janitor/functions/impute.py @@ -1,13 +1,12 @@ """Implementation of `impute` function""" +from itertools import product from typing import Any, Optional - -import pandas_flavor as pf import pandas as pd +import pandas_flavor as pf -from janitor.utils import deprecated_alias from janitor.functions.utils import get_index_labels -from itertools import product +from janitor.utils import deprecated_alias @pf.register_dataframe_method diff --git a/janitor/functions/jitter.py b/janitor/functions/jitter.py index 46f2635a3..686794058 100644 --- a/janitor/functions/jitter.py +++ b/janitor/functions/jitter.py @@ -1,8 +1,9 @@ """Implementation of the `jitter` function.""" from typing import Hashable, Iterable, Optional + import numpy as np -import pandas_flavor as pf import pandas as pd +import pandas_flavor as pf from janitor.utils import check diff --git a/janitor/functions/join_apply.py b/janitor/functions/join_apply.py index d608fd10a..57a2261e1 100644 --- a/janitor/functions/join_apply.py +++ b/janitor/functions/join_apply.py @@ -1,7 +1,9 @@ """Implementation of the `join_apply` function""" from typing import Callable -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf + from janitor.utils import refactored_function diff --git a/janitor/functions/label_encode.py b/janitor/functions/label_encode.py index 4294f2859..0f2ecdc40 100644 --- a/janitor/functions/label_encode.py +++ b/janitor/functions/label_encode.py @@ -1,11 +1,12 @@ """Implementation of `label_encode` function""" -from typing import Hashable, Iterable, Union import warnings -import pandas_flavor as pf +from typing import Hashable, Iterable, Union + import pandas as pd +import pandas_flavor as pf -from janitor.utils import deprecated_alias from janitor.functions.utils import _factorize +from janitor.utils import deprecated_alias @pf.register_dataframe_method diff --git a/janitor/functions/limit_column_characters.py b/janitor/functions/limit_column_characters.py index 2ba450bea..d3475be87 100644 --- a/janitor/functions/limit_column_characters.py +++ b/janitor/functions/limit_column_characters.py @@ -1,6 +1,6 @@ """Implementation of limit_column_characters.""" -import pandas_flavor as pf import pandas as pd +import pandas_flavor as pf from janitor.utils import check diff --git a/janitor/functions/min_max_scale.py b/janitor/functions/min_max_scale.py index f8c4fe8b1..4d7ef878c 100644 --- a/janitor/functions/min_max_scale.py +++ b/janitor/functions/min_max_scale.py @@ -1,10 +1,9 @@ from __future__ import annotations -import pandas_flavor as pf import pandas as pd +import pandas_flavor as pf -from janitor.utils import deprecated_alias -from janitor.utils import deprecated_kwargs +from janitor.utils import deprecated_alias, deprecated_kwargs @pf.register_dataframe_method diff --git a/janitor/functions/move.py b/janitor/functions/move.py index 21877c3df..13423ef43 100644 --- a/janitor/functions/move.py +++ b/janitor/functions/move.py @@ -1,10 +1,11 @@ """Implementation of move.""" -import pandas_flavor as pf -import pandas as pd +from typing import Any + import numpy as np +import pandas as pd +import pandas_flavor as pf -from typing import Any -from janitor.functions.utils import _select_index, _index_converter +from janitor.functions.utils import _index_converter, _select_index @pf.register_dataframe_method diff --git a/janitor/functions/pivot.py b/janitor/functions/pivot.py index 5c2d8d165..3e6dbc640 100644 --- a/janitor/functions/pivot.py +++ b/janitor/functions/pivot.py @@ -1,22 +1,22 @@ -from collections import defaultdict -from itertools import zip_longest, chain import re import warnings -from typing import Optional, Pattern, Union, Callable +from collections import defaultdict +from itertools import chain, zip_longest +from typing import Callable, Optional, Pattern, Union import numpy as np import pandas as pd import pandas_flavor as pf from pandas.api.types import ( - is_list_like, is_categorical_dtype, is_extension_array_dtype, + is_list_like, ) from pandas.core.dtypes.concat import concat_compat from janitor.functions.utils import ( - get_index_labels, _computations_expand_grid, + get_index_labels, ) from janitor.utils import check, refactored_function diff --git a/janitor/functions/process_text.py b/janitor/functions/process_text.py index 191e53526..54bc4a98c 100644 --- a/janitor/functions/process_text.py +++ b/janitor/functions/process_text.py @@ -1,8 +1,9 @@ """Implementation source for `process_text`.""" import inspect from typing import Any -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.utils import ( check, diff --git a/janitor/functions/remove_columns.py b/janitor/functions/remove_columns.py index 547fc4736..4f9e41f4f 100644 --- a/janitor/functions/remove_columns.py +++ b/janitor/functions/remove_columns.py @@ -1,7 +1,8 @@ """Implementation of remove_columns.""" from typing import Hashable, Iterable, Union -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.utils import deprecated_alias, refactored_function diff --git a/janitor/functions/remove_empty.py b/janitor/functions/remove_empty.py index 5c18e2b04..7375e5efe 100644 --- a/janitor/functions/remove_empty.py +++ b/janitor/functions/remove_empty.py @@ -1,6 +1,6 @@ """Implementation of remove_empty.""" -import pandas_flavor as pf import pandas as pd +import pandas_flavor as pf @pf.register_dataframe_method diff --git a/janitor/functions/rename_columns.py b/janitor/functions/rename_columns.py index d3d5fc970..f5b0af3d7 100644 --- a/janitor/functions/rename_columns.py +++ b/janitor/functions/rename_columns.py @@ -1,6 +1,7 @@ from typing import Callable, Dict, Union -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.utils import check_column, deprecated_alias, refactored_function diff --git a/janitor/functions/reorder_columns.py b/janitor/functions/reorder_columns.py index 9e7bcf222..abf16d8b1 100644 --- a/janitor/functions/reorder_columns.py +++ b/janitor/functions/reorder_columns.py @@ -1,7 +1,8 @@ """Implementation source for `reorder_columns`.""" from typing import Hashable, Iterable, Union -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.utils import check diff --git a/janitor/functions/round_to_fraction.py b/janitor/functions/round_to_fraction.py index 04e3ebcfa..84de5c343 100644 --- a/janitor/functions/round_to_fraction.py +++ b/janitor/functions/round_to_fraction.py @@ -4,6 +4,7 @@ import numpy as np import pandas as pd import pandas_flavor as pf + from janitor.utils import check, check_column, deprecated_alias diff --git a/janitor/functions/row_to_names.py b/janitor/functions/row_to_names.py index 979e591f3..ce4a5792f 100644 --- a/janitor/functions/row_to_names.py +++ b/janitor/functions/row_to_names.py @@ -1,7 +1,8 @@ """Implementation of the `row_to_names` function.""" import warnings -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.utils import check diff --git a/janitor/functions/select.py b/janitor/functions/select.py index 2865d0d6a..80c536b78 100644 --- a/janitor/functions/select.py +++ b/janitor/functions/select.py @@ -1,9 +1,10 @@ from typing import Any -import pandas_flavor as pf + import pandas as pd -from janitor.utils import refactored_function -from janitor.utils import check, deprecated_alias -from janitor.functions.utils import _select, DropLabel # noqa: F401 +import pandas_flavor as pf + +from janitor.functions.utils import DropLabel, _select # noqa: F401 +from janitor.utils import check, deprecated_alias, refactored_function @pf.register_dataframe_method diff --git a/janitor/functions/shuffle.py b/janitor/functions/shuffle.py index 308ef010a..20435f3da 100644 --- a/janitor/functions/shuffle.py +++ b/janitor/functions/shuffle.py @@ -1,7 +1,8 @@ """Implementation of `shuffle` functions.""" from typing import Any -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf @pf.register_dataframe_method diff --git a/janitor/functions/sort_column_value_order.py b/janitor/functions/sort_column_value_order.py index 6e4f162e5..ee9ce2903 100644 --- a/janitor/functions/sort_column_value_order.py +++ b/janitor/functions/sort_column_value_order.py @@ -1,7 +1,9 @@ """Implementation of the `sort_column_value_order` function.""" -import pandas_flavor as pf import pandas as pd +import pandas_flavor as pf + from janitor.utils import check, check_column + from .remove_columns import remove_columns # noqa: F401 diff --git a/janitor/functions/sort_naturally.py b/janitor/functions/sort_naturally.py index 1b4679f84..a7950ba2b 100644 --- a/janitor/functions/sort_naturally.py +++ b/janitor/functions/sort_naturally.py @@ -1,7 +1,8 @@ """Implementation of the `sort_naturally` function.""" from typing import Any -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from natsort import index_natsorted diff --git a/janitor/functions/take_first.py b/janitor/functions/take_first.py index 5c555142e..0fc52e474 100644 --- a/janitor/functions/take_first.py +++ b/janitor/functions/take_first.py @@ -1,7 +1,8 @@ """Implementation of take_first function.""" from typing import Hashable, Iterable, Union -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf @pf.register_dataframe_method diff --git a/janitor/functions/then.py b/janitor/functions/then.py index 3b4467fd0..4ea4e1a6e 100644 --- a/janitor/functions/then.py +++ b/janitor/functions/then.py @@ -1,7 +1,9 @@ """Implementation source for `then`.""" from typing import Callable -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf + from janitor.utils import refactored_function diff --git a/janitor/functions/to_datetime.py b/janitor/functions/to_datetime.py index ca33cbc8f..10d09d000 100644 --- a/janitor/functions/to_datetime.py +++ b/janitor/functions/to_datetime.py @@ -1,7 +1,8 @@ """Implementation source for `to_datetime`.""" from typing import Any, Hashable -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.utils import deprecated_alias, refactored_function diff --git a/janitor/functions/toset.py b/janitor/functions/toset.py index ab2357937..9cb0c50f7 100644 --- a/janitor/functions/toset.py +++ b/janitor/functions/toset.py @@ -1,7 +1,9 @@ """Implementation of the `toset` function.""" from typing import Set -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf + from janitor.utils import refactored_function diff --git a/janitor/functions/transform_columns.py b/janitor/functions/transform_columns.py index 66874497d..ea0539f72 100644 --- a/janitor/functions/transform_columns.py +++ b/janitor/functions/transform_columns.py @@ -1,6 +1,7 @@ from typing import Callable, Dict, Hashable, List, Optional, Tuple, Union -import pandas_flavor as pf + import pandas as pd +import pandas_flavor as pf from janitor.utils import check, check_column, deprecated_alias diff --git a/janitor/functions/truncate_datetime.py b/janitor/functions/truncate_datetime.py index 7643c1bf9..6bec8ea8a 100644 --- a/janitor/functions/truncate_datetime.py +++ b/janitor/functions/truncate_datetime.py @@ -1,8 +1,8 @@ """Implementation of the `truncate_datetime` family of functions.""" import datetime as dt -import pandas_flavor as pf import pandas as pd +import pandas_flavor as pf from pandas.api.types import is_datetime64_any_dtype diff --git a/janitor/functions/update_where.py b/janitor/functions/update_where.py index 0209dd9a9..205817187 100644 --- a/janitor/functions/update_where.py +++ b/janitor/functions/update_where.py @@ -1,11 +1,13 @@ """Function for updating values based on other column values.""" from typing import Any, Hashable -import pandas_flavor as pf + import pandas as pd -from janitor.utils import deprecated_alias +import pandas_flavor as pf from pandas.api.types import is_bool_dtype +from janitor.utils import deprecated_alias + @pf.register_dataframe_method @deprecated_alias(target_col="target_column_name") diff --git a/janitor/functions/utils.py b/janitor/functions/utils.py index aa936a30c..07e6d4ae8 100644 --- a/janitor/functions/utils.py +++ b/janitor/functions/utils.py @@ -1,11 +1,18 @@ """Utility functions for all of the functions submodule.""" from __future__ import annotations + import fnmatch +import inspect +import re import warnings from collections.abc import Callable as dispatch_callable -import re +from dataclasses import dataclass +from enum import Enum +from functools import singledispatch from typing import ( + Any, + Callable, Hashable, Iterable, List, @@ -13,28 +20,23 @@ Optional, Pattern, Union, - Callable, - Any, ) -from pandas.core.groupby.generic import DataFrameGroupBy, SeriesGroupBy -from pandas.core.common import is_bool_indexer -from dataclasses import dataclass -from enum import Enum + +import numpy as np import pandas as pd -from janitor.utils import check, _expand_grid, find_stack_level +from multipledispatch import dispatch from pandas.api.types import ( - union_categoricals, - is_scalar, - is_list_like, + is_bool_dtype, is_datetime64_dtype, + is_list_like, + is_scalar, is_string_dtype, - is_bool_dtype, + union_categoricals, ) -import numpy as np -import inspect -from multipledispatch import dispatch -from janitor.utils import check_column -from functools import singledispatch +from pandas.core.common import is_bool_indexer +from pandas.core.groupby.generic import DataFrameGroupBy, SeriesGroupBy + +from janitor.utils import _expand_grid, check, check_column, find_stack_level warnings.simplefilter("always", DeprecationWarning) @@ -1055,14 +1057,6 @@ class col: """ def __init__(self, column: Hashable): - """Initialize a new instance of the `col` class. - - Args: - column (Hashable): The name of the column to be selected. - - Raises: - TypeError: If the `column` parameter is not hashable. - """ self.cols = column check("column", self.cols, [Hashable]) self.join_args = None diff --git a/janitor/io.py b/janitor/io.py index 9ca8bb63e..e61e2797c 100644 --- a/janitor/io.py +++ b/janitor/io.py @@ -1,18 +1,18 @@ from __future__ import annotations + +import inspect import os import subprocess +from collections import defaultdict from glob import glob from io import StringIO -from typing import Any, Iterable, Union, TYPE_CHECKING, NamedTuple - +from itertools import chain +from typing import TYPE_CHECKING, Any, Iterable, NamedTuple, Union import pandas as pd -import inspect from .errors import JanitorError -from .utils import deprecated_alias, check, import_message -from collections import defaultdict -from itertools import chain +from .utils import check, deprecated_alias, import_message @deprecated_alias(seperate_df="separate_df", filespath="files_path") @@ -385,8 +385,8 @@ def xlsx_cells( try: from openpyxl import load_workbook - from openpyxl.cell.read_only import ReadOnlyCell from openpyxl.cell.cell import Cell + from openpyxl.cell.read_only import ReadOnlyCell from openpyxl.workbook.workbook import Workbook except ImportError: import_message( diff --git a/janitor/spark/backend.py b/janitor/spark/backend.py index 5bc460fdc..46c5ee0ee 100644 --- a/janitor/spark/backend.py +++ b/janitor/spark/backend.py @@ -2,7 +2,6 @@ from functools import wraps - try: from pyspark.pandas.extensions import register_dataframe_accessor diff --git a/janitor/spark/functions.py b/janitor/spark/functions.py index 9ae42d0e4..a43f7338d 100644 --- a/janitor/spark/functions.py +++ b/janitor/spark/functions.py @@ -4,7 +4,6 @@ from typing import Union from janitor import utils as janitor_utils -from . import backend from janitor.functions.clean_names import ( _change_case, _normalize_1, @@ -12,6 +11,8 @@ _strip_underscores_func, ) +from . import backend + try: from pyspark.sql import DataFrame except ImportError: diff --git a/janitor/timeseries.py b/janitor/timeseries.py index 965058544..35a0e05d3 100644 --- a/janitor/timeseries.py +++ b/janitor/timeseries.py @@ -6,8 +6,8 @@ import pandas as pd import pandas_flavor as pf -from .utils import check from .errors import JanitorError +from .utils import check @pf.register_dataframe_method diff --git a/janitor/utils.py b/janitor/utils.py index 3bc30b212..1c275fb0a 100644 --- a/janitor/utils.py +++ b/janitor/utils.py @@ -1,11 +1,12 @@ """Miscellaneous utility functions.""" - from __future__ import annotations +import importlib import os import socket import sys from functools import singledispatch, wraps +from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Union from warnings import warn @@ -435,7 +436,7 @@ def transform(x): """ def _wrapped(x, *args, **kwargs): - if (type(x) is float and np.isnan(x)) or x is None: + if (isinstance(x, float) and np.isnan(x)) or x is None: return np.nan return f(x, *args, **kwargs) @@ -544,3 +545,25 @@ def find_stack_level() -> int: else: break return n + + +def dynamic_import(file_path: Path): + """Dynamically import all modules in a directory. + + :param file_path: The path to the file + containing the modules to import. + """ + # Iterate through all files in the current directory + for filename in file_path.glob("*.py"): + # Check if the file is a Python file and it's not the current __init__.py + if filename != "__init__.py": + # Get the module name (without the .py extension) + module_name = filename.name + # Dynamically import the module + module = importlib.import_module( + f".{module_name}", package=__name__ + ) + # Import all symbols from the module into the current namespace + for name in dir(module): + if not name.startswith("_"): # avoid importing private symbols + globals()[name] = getattr(module, name) diff --git a/mkdocs/devguide.md b/mkdocs/devguide.md index 3470b6f25..920b25e7d 100644 --- a/mkdocs/devguide.md +++ b/mkdocs/devguide.md @@ -121,6 +121,7 @@ source activate pyjanitor-dev || conda activate pyjanitor-dev ### Plan out the change you'd like to contribute The old adage rings true: + > failing to plan means planning to fail. We'd encourage you to flesh out the idea you'd like to contribute @@ -149,7 +150,24 @@ To create a new branch: git checkout -b dev ``` -Now you can make your changes locally. +### Write the Code + +As you work, remember to adhere to the coding standards and practices that pyjanitor follows. If in doubt, refer to existing code or bring up your questions in the GitHub issue you created. Some tips for writing code: + +**Commit Early, Commit Often:** Make frequent, smaller commits. This helps to track progress and makes it easier for maintainers to follow your work. Include useful commit messages that describe the changes you're making: + +**Stay Updated with dev branch:** Regularly pull the latest changes from the dev branch to ensure your feature branch is up-to-date, reducing the likelihood of merge conflicts: + +```bash +git fetch origin dev +git rebase origin/dev +``` + +**Write Tests:** For every feature or bugfix, accompanying tests are essential. +They ensure the feature works as expected or the bug is truly fixed. +Tests should ideally run in less than 2 seconds. +If using Hypothesis for testing, +apply the `@settings(max_examples=10, timeout=None)` decorator. ### Check your environment @@ -164,19 +182,18 @@ development and you are ready to contribute 🥳. ### Check your code -When you're done making changes, commit your staged files with a meaningful message. -While we have automated checks that run before code is committed via pre-commit and GitHub Actions -to run tests before code can be merged, -you can still manually run the following commands to check that your changes are properly -formatted and that all tests still pass. - -To do so: - -* Run `make lint` to check code styling problems. -* Run `make format` to format your code. -* Run `python -m interrogate -c pyproject.toml` to check your code for missing docstring. -* Run `darglint -v 2` to check quality of your docstrings. -* Run `python -m pytest` to run all unit tests. +When you're done making changes, +commit your staged files with a meaningful message. +If installed correctly, you will automatically run pre-commit hooks +that check code for code style adherence. +These same checks will be run on GitHub Actions, +so no worries if you don't have the running locally. +If the pre-commit hooks fail, +be sure to fix the issues (as raised by them) before committing. +If you feel lost on how to fix the code, +please feel free to ping the maintainers on GitHub - +we can take things slowly to get it right, +and make this an educational opportunity for all who come by! !!! tip You can run `python -m pytest -m "not turtle"` to run the fast tests. diff --git a/pyproject.toml b/pyproject.toml index c2efd0b94..b1ab80bfa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,3 +45,52 @@ markers = [ "documentation: tests for documentation", "turtle: tests that take more than 5 seconds to execute", ] + + +[tool.ruff] +# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default. +select = ["E", "F", "I"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"] +unfixable = [] + +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", + "nbconvert_config.py", +] + +# Same as Black. +line-length = 88 + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +# Assume Python 3.10 +target-version = "py310" + +[tool.ruff.mccabe] +# Unlike Flake8, default to a complexity level of 10. +max-complexity = 10 diff --git a/tests/chemistry/test_maccs_keys_fingerprint.py b/tests/chemistry/test_maccs_keys_fingerprint.py index c42e7de9d..34562921a 100644 --- a/tests/chemistry/test_maccs_keys_fingerprint.py +++ b/tests/chemistry/test_maccs_keys_fingerprint.py @@ -3,7 +3,7 @@ import pytest from helpers import running_on_ci -import janitor.chemistry # noqa: disable=unused-import +import janitor.chemistry # noqa: F401 # Skip all tests if rdkit not installed pytestmark = pytest.mark.skipif( diff --git a/tests/chemistry/test_molecular_descriptors.py b/tests/chemistry/test_molecular_descriptors.py index ae660f7d5..0575c0ad9 100644 --- a/tests/chemistry/test_molecular_descriptors.py +++ b/tests/chemistry/test_molecular_descriptors.py @@ -3,8 +3,6 @@ import pytest from helpers import running_on_ci -import janitor.chemistry # noqa: disable=unused-import - # Skip all tests if rdkit not installed pytestmark = pytest.mark.skipif( (importlib.util.find_spec("rdkit") is None) & ~running_on_ci(), diff --git a/tests/chemistry/test_morgan_fingerprint.py b/tests/chemistry/test_morgan_fingerprint.py index f76070a8b..036de3f82 100644 --- a/tests/chemistry/test_morgan_fingerprint.py +++ b/tests/chemistry/test_morgan_fingerprint.py @@ -3,9 +3,6 @@ import pytest from helpers import running_on_ci -import janitor.chemistry # noqa: disable=unused-import - -# Skip all tests if rdkit not installed pytestmark = pytest.mark.skipif( (importlib.util.find_spec("rdkit") is None) & ~running_on_ci(), reason="rdkit tests only required for CI", diff --git a/tests/functions/test_add_column.py b/tests/functions/test_add_column.py index f15858655..c8be59e87 100644 --- a/tests/functions/test_add_column.py +++ b/tests/functions/test_add_column.py @@ -1,8 +1,7 @@ import numpy as np import pandas as pd import pytest -from hypothesis import given -from hypothesis import settings +from hypothesis import given, settings from hypothesis import strategies as st from pandas.testing import assert_series_equal @@ -11,7 +10,7 @@ @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_add_column_add_integer(df): """col_name wasn't a string""" with pytest.raises(TypeError): @@ -50,7 +49,7 @@ def test_add_column_too_few_but_no_fill_remaining(dataframe): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_add_column_scalar(df): """Checks `add_column` works as expected when adding a numeric scalar to the column""" @@ -66,7 +65,7 @@ def test_add_column_scalar(df): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_add_column_string(df): """Checks `add_column` works as expected when adding a string scalar to the column. @@ -98,7 +97,7 @@ def test_add_column_iterator_repeat_subtraction(dataframe): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_add_column_fill_scalar(df): """Checks the `fill_remaining` parameter works as expected when value is a scalar.""" @@ -110,7 +109,7 @@ def test_add_column_fill_scalar(df): @pytest.mark.functions @given(df=df_strategy(), vals=st.lists(elements=st.integers())) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_add_column_fill_remaining_iterable(df, vals: list): """Checks the `fill_remaining` parameter works as expected.""" if len(vals) > len(df) or not vals: diff --git a/tests/functions/test_add_columns.py b/tests/functions/test_add_columns.py index c3c0582fd..0cbc7cee6 100644 --- a/tests/functions/test_add_columns.py +++ b/tests/functions/test_add_columns.py @@ -1,8 +1,7 @@ import numpy as np import pandas as pd import pytest -from hypothesis import given -from hypothesis import settings +from hypothesis import given, settings from hypothesis import strategies as st from pandas.testing import assert_series_equal @@ -15,7 +14,7 @@ x_vals=st.floats(), n_yvals=st.integers(min_value=0, max_value=100), ) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_add_columns(df, x_vals, n_yvals): """ Test for adding multiple columns at the same time. diff --git a/tests/functions/test_bin_numeric.py b/tests/functions/test_bin_numeric.py index 9e00bfaec..8ea9af287 100644 --- a/tests/functions/test_bin_numeric.py +++ b/tests/functions/test_bin_numeric.py @@ -1,13 +1,12 @@ import pytest -from hypothesis import given -from hypothesis import settings +from hypothesis import given, settings from janitor.testing_utils.strategies import df_strategy @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_bin_numeric_expected_columns(df): df = df.bin_numeric(from_column_name="a", to_column_name="a_bin") expected_columns = [ @@ -24,7 +23,7 @@ def test_bin_numeric_expected_columns(df): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_bin_numeric_kwargs_has_no_retbins(df): with pytest.raises(ValueError): labels = ["a", "b", "c", "d", "e"] diff --git a/tests/functions/test_case_when.py b/tests/functions/test_case_when.py index aa7b2e516..b9b369b2f 100644 --- a/tests/functions/test_case_when.py +++ b/tests/functions/test_case_when.py @@ -1,8 +1,7 @@ import numpy as np import pandas as pd import pytest -from hypothesis import settings -from hypothesis import given +from hypothesis import given, settings from pandas.testing import assert_frame_equal from janitor.testing_utils.strategies import ( @@ -129,7 +128,7 @@ def test_error_multiple_conditions(): @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_case_when_condition_callable(df): """Test case_when for callable.""" result = df.case_when( @@ -141,7 +140,7 @@ def test_case_when_condition_callable(df): @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_case_when_condition_eval(df): """Test case_when for callable.""" result = df.case_when("a < 10", "baby", default="bleh", column_name="bleh") @@ -151,7 +150,7 @@ def test_case_when_condition_eval(df): @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_case_when_replacement_callable(df): """Test case_when for callable.""" result = df.case_when( @@ -166,7 +165,7 @@ def test_case_when_replacement_callable(df): @given(df=categoricaldf_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_case_when_default_array(df): """ Test case_when for scenarios where `default` is array-like @@ -184,7 +183,7 @@ def test_case_when_default_array(df): @given(df=categoricaldf_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_case_when_default_list_like(df): """ Test case_when for scenarios where `default` is list-like, @@ -203,7 +202,7 @@ def test_case_when_default_list_like(df): @given(df=categoricaldf_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_case_when_default_index(df): """ Test case_when for scenarios where `default` is an index. @@ -221,7 +220,7 @@ def test_case_when_default_index(df): @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_case_when_multiple_args(df): """Test case_when for multiple arguments.""" result = df.case_when( diff --git a/tests/functions/test_complete.py b/tests/functions/test_complete.py index 717308b23..dd7bad560 100644 --- a/tests/functions/test_complete.py +++ b/tests/functions/test_complete.py @@ -3,8 +3,7 @@ import numpy as np import pandas as pd import pytest -from hypothesis import given -from hypothesis import settings +from hypothesis import given, settings from pandas.testing import assert_frame_equal from janitor.testing_utils.strategies import categoricaldf_strategy @@ -208,7 +207,7 @@ def test_type_explicit(fill_df): @given(df=categoricaldf_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_all_strings_no_nulls(df): """ Test `complete` output when *columns @@ -230,7 +229,7 @@ def test_all_strings_no_nulls(df): @given(df=categoricaldf_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_dict_callable(df): """ Test `complete` output when *columns @@ -284,7 +283,7 @@ def test_dict_extension_array(df): @given(df=categoricaldf_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_dict_numpy(df): """ Test `complete` output when *columns @@ -311,7 +310,7 @@ def test_dict_numpy(df): @given(df=categoricaldf_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_dict_Index(df): """ Test `complete` output when *columns @@ -340,7 +339,7 @@ def test_dict_Index(df): @given(df=categoricaldf_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_dict_duplicated(df): """ Test `complete` output when *columns diff --git a/tests/functions/test_conditional_join.py b/tests/functions/test_conditional_join.py index 2b15fa857..2de138dbe 100644 --- a/tests/functions/test_conditional_join.py +++ b/tests/functions/test_conditional_join.py @@ -1,17 +1,15 @@ import numpy as np import pandas as pd import pytest - - from hypothesis import given, settings from pandas.testing import assert_frame_equal + +from janitor import col from janitor.testing_utils.strategies import ( conditional_df, conditional_right, ) -from janitor import col - @pytest.fixture def dummy(): @@ -31,6 +29,23 @@ def series(): return pd.Series([2, 3, 4], name="B") +def test_conditional_join(): + """Execution test for conditional_join. + + This example is lifted directly from the conditional_join docstring. + """ + df1 = pd.DataFrame({"value_1": [2, 5, 7, 1, 3, 4]}) + df2 = pd.DataFrame( + { + "value_2A": [0, 3, 7, 12, 0, 2, 3, 1], + "value_2B": [1, 5, 9, 15, 1, 4, 6, 3], + } + ) + df1.conditional_join( + df2, col("value_1") > col("value_2A"), col("value_1") < col("value_2B") + ) + + def test_df_columns_right_columns_both_None(dummy, series): """Raise if both df_columns and right_columns is None""" with pytest.raises( @@ -253,7 +268,7 @@ def test_check_use_numba_equi_join(dummy): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_check_use_numba_equi_join_no_le_or_ge(df, right): """ @@ -361,7 +376,7 @@ def test_dtype_category_non_equi(): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_floats_keep_first(df, right): """Test output for a single condition. "<".""" @@ -392,7 +407,7 @@ def test_single_condition_less_than_floats_keep_first(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_floats_keep_last(df, right): """Test output for a single condition. "<".""" @@ -424,7 +439,7 @@ def test_single_condition_less_than_floats_keep_last(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_floats(df, right): """Test output for a single condition. "<".""" @@ -449,8 +464,8 @@ def test_single_condition_less_than_floats(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) @pytest.mark.turtle +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_floats_keep_first_numba(df, right): """Test output for a single condition. "<".""" @@ -482,7 +497,7 @@ def test_single_condition_less_than_floats_keep_first_numba(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @pytest.mark.turtle @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_floats_keep_last_numba(df, right): @@ -517,7 +532,7 @@ def test_single_condition_less_than_floats_keep_last_numba(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @pytest.mark.turtle @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_ints_extension_array_numba_first_match( @@ -556,7 +571,7 @@ def test_single_condition_less_than_ints_extension_array_numba_first_match( assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @pytest.mark.turtle @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_ints_extension_array_numba_last_match( @@ -596,7 +611,7 @@ def test_single_condition_less_than_ints_extension_array_numba_last_match( @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_ints(df, right): """Test output for a single condition. "<".""" @@ -623,7 +638,7 @@ def test_single_condition_less_than_ints(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_ints_numba(df, right): """Test output for a single condition. "<".""" @@ -651,7 +666,7 @@ def test_single_condition_less_than_ints_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_ints_extension_array(df, right): """Test output for a single condition. "<".""" @@ -682,7 +697,7 @@ def test_single_condition_less_than_ints_extension_array(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_ints_extension_array_numba(df, right): """Test output for a single condition. "<".""" @@ -719,7 +734,7 @@ def test_single_condition_less_than_ints_extension_array_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_equal(df, right): """Test output for a single condition. "<=". DateTimes""" @@ -747,7 +762,7 @@ def test_single_condition_less_than_equal(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_equal_numba(df, right): """Test output for a single condition. "<=". DateTimes""" @@ -781,7 +796,7 @@ def test_single_condition_less_than_equal_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_date(df, right): """Test output for a single condition. "<". Dates""" @@ -807,7 +822,7 @@ def test_single_condition_less_than_date(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_less_than_date_numba(df, right): """Test output for a single condition. "<". Dates""" @@ -834,7 +849,7 @@ def test_single_condition_less_than_date_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_greater_than_datetime(df, right): """Test output for a single condition. ">". Datetimes""" @@ -860,7 +875,7 @@ def test_single_condition_greater_than_datetime(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_greater_than_datetime_numba(df, right): """Test output for a single condition. ">". Datetimes""" @@ -887,7 +902,7 @@ def test_single_condition_greater_than_datetime_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_greater_than_ints(df, right): """Test output for a single condition. ">=".""" @@ -915,7 +930,7 @@ def test_single_condition_greater_than_ints(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_greater_than_ints_numba(df, right): """Test output for a single condition. ">=".""" @@ -949,7 +964,7 @@ def test_single_condition_greater_than_ints_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_greater_than_floats_floats(df, right): """Test output for a single condition. ">".""" @@ -981,7 +996,7 @@ def test_single_condition_greater_than_floats_floats(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_greater_than_floats_floats_numba(df, right): """Test output for a single condition. ">".""" @@ -1014,7 +1029,7 @@ def test_single_condition_greater_than_floats_floats_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_greater_than_ints_extension_array(df, right): """Test output for a single condition. ">".""" @@ -1043,7 +1058,7 @@ def test_single_condition_greater_than_ints_extension_array(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_greater_than_ints_extension_array_numba(df, right): """Test output for a single condition. ">".""" @@ -1073,7 +1088,7 @@ def test_single_condition_greater_than_ints_extension_array_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_not_equal_ints(df, right): """Test output for a single condition. "!=".""" @@ -1100,7 +1115,7 @@ def test_single_condition_not_equal_ints(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_not_equal_ints_numba(df, right): """Test output for a single condition. "!=".""" @@ -1128,7 +1143,7 @@ def test_single_condition_not_equal_ints_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_not_equal_floats_only(df, right): """Test output for a single condition. "!=".""" @@ -1156,7 +1171,7 @@ def test_single_condition_not_equal_floats_only(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_not_equal_floats_only_numba(df, right): """Test output for a single condition. "!=".""" @@ -1190,7 +1205,7 @@ def test_single_condition_not_equal_floats_only_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_not_equal_datetime(df, right): """Test output for a single condition. "!=".""" @@ -1218,7 +1233,7 @@ def test_single_condition_not_equal_datetime(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_single_condition_not_equal_datetime_numba(df, right): """Test output for a single condition. "!=".""" @@ -1252,7 +1267,7 @@ def test_single_condition_not_equal_datetime_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_how_left(df, right): """Test output when `how==left`. "<=".""" @@ -1293,7 +1308,7 @@ def test_how_left(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_how_left_multiindex(df, right): """Test output when `how==left`. "<=".""" @@ -1337,7 +1352,7 @@ def test_how_left_multiindex(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_how_left_sort(df, right): """Test output when `how==left`. "<=".""" @@ -1378,7 +1393,7 @@ def test_how_left_sort(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_how_right(df, right): @@ -1413,7 +1428,7 @@ def test_how_right(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_how_right_sort(df, right): @@ -1453,7 +1468,7 @@ def test_how_right_sort(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_conditions_gt_and_lt_dates(df, right): """Test output for interval conditions.""" @@ -1485,7 +1500,7 @@ def test_dual_conditions_gt_and_lt_dates(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_dual_conditions_ge_and_le_dates(df, right): @@ -1515,7 +1530,7 @@ def test_dual_conditions_ge_and_le_dates(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_dual_conditions_le_and_ge_dates(df, right): @@ -1545,7 +1560,7 @@ def test_dual_conditions_le_and_ge_dates(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_conditions_ge_and_le_dates_right_open(df, right): """Test output for interval conditions.""" @@ -1577,7 +1592,7 @@ def test_dual_conditions_ge_and_le_dates_right_open(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_conditions_ge_and_le_numbers(df, right): """Test output for interval conditions, for numeric dtypes.""" @@ -1604,7 +1619,7 @@ def test_dual_conditions_ge_and_le_numbers(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_dual_conditions_le_and_ge_numbers(df, right): @@ -1637,7 +1652,7 @@ def test_dual_conditions_le_and_ge_numbers(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_conditions_gt_and_lt_numbers(df, right): """Test output for interval conditions.""" @@ -1666,7 +1681,7 @@ def test_dual_conditions_gt_and_lt_numbers(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_dual_conditions_gt_and_lt_numbers_left_open(df, right): @@ -1695,7 +1710,7 @@ def test_dual_conditions_gt_and_lt_numbers_left_open(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_conditions_gt_and_lt_numbers_(df, right): """ @@ -1726,7 +1741,7 @@ def test_dual_conditions_gt_and_lt_numbers_(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_dual_conditions_gt_and_lt_numbers_left_join(df, right): @@ -1773,7 +1788,7 @@ def test_dual_conditions_gt_and_lt_numbers_left_join(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_conditions_gt_and_lt_numbers_right_join(df, right): """ @@ -1821,7 +1836,7 @@ def test_dual_conditions_gt_and_lt_numbers_right_join(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=2) @given(df=conditional_df(), right=conditional_right()) def test_dual_ne_extension(df, right): """ @@ -1856,7 +1871,7 @@ def test_dual_ne_extension(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_ne(df, right): """ @@ -1888,7 +1903,7 @@ def test_dual_ne(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_ne_numba_extension(df, right): """ @@ -1925,7 +1940,7 @@ def test_dual_ne_numba_extension(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_ne_dates(df, right): """ @@ -1957,7 +1972,7 @@ def test_dual_ne_dates(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_ne_numba_dates(df, right): """ @@ -1988,7 +2003,7 @@ def test_dual_ne_numba_dates(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_multiple_ne_dates(df, right): @@ -2025,7 +2040,7 @@ def test_multiple_ne_dates(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_conditions_eq_and_ne(df, right): """Test output for equal and not equal conditions.""" @@ -2057,7 +2072,7 @@ def test_dual_conditions_eq_and_ne(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_conditions_ne_and_eq(df, right): """Test output for equal and not equal conditions.""" @@ -2085,7 +2100,7 @@ def test_dual_conditions_ne_and_eq(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_gt_lt_ne_conditions(df, right): @@ -2121,7 +2136,7 @@ def test_gt_lt_ne_conditions(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_gt_lt_ne_numba_conditions(df, right): @@ -2159,7 +2174,7 @@ def test_gt_lt_ne_numba_conditions(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_gt_ne_conditions(df, right): """ @@ -2190,7 +2205,7 @@ def test_gt_ne_conditions(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_gt_ne_numba_conditions(df, right): """ @@ -2222,7 +2237,7 @@ def test_gt_ne_numba_conditions(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_le_ne_conditions(df, right): """ @@ -2253,7 +2268,7 @@ def test_le_ne_conditions(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_le_ne_numba_conditions(df, right): """ @@ -2284,7 +2299,7 @@ def test_le_ne_numba_conditions(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_gt_lt_ne_start(df, right): @@ -2320,7 +2335,7 @@ def test_gt_lt_ne_start(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_ge_le_ne_extension_array(df, right): @@ -2357,7 +2372,7 @@ def test_ge_le_ne_extension_array(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_ge_le_ne_extension_array_numba(df, right): @@ -2396,7 +2411,7 @@ def test_ge_le_ne_extension_array_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_ge_lt_ne_extension(df, right): """ @@ -2435,7 +2450,7 @@ def test_ge_lt_ne_extension(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_ge_lt_ne_numba_extension(df, right): """ @@ -2475,7 +2490,7 @@ def test_ge_lt_ne_numba_extension(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_eq_ge_and_le_numbers(df, right): """Test output for multiple conditions.""" @@ -2506,7 +2521,7 @@ def test_eq_ge_and_le_numbers(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_ge_and_le_diff_numbers_numba(df, right): """Test output for multiple conditions.""" @@ -2538,7 +2553,7 @@ def test_dual_ge_and_le_diff_numbers_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_ge_and_le_diff_numbers(df, right): """Test output for multiple conditions.""" @@ -2569,7 +2584,7 @@ def test_dual_ge_and_le_diff_numbers(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_ge_lt_ne_extension_variant(df, right): """ @@ -2606,7 +2621,7 @@ def test_ge_lt_ne_extension_variant(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_ge_lt_ne_extension_variant_numba(df, right): """ @@ -2644,7 +2659,7 @@ def test_ge_lt_ne_extension_variant_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_ge_eq_and_le_numbers_variant(df, right): """Test output for multiple conditions.""" @@ -2675,7 +2690,7 @@ def test_ge_eq_and_le_numbers_variant(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_multiple_ge_eq_and_le_numbers(df, right): """Test output for multiple conditions.""" @@ -2712,7 +2727,7 @@ def test_multiple_ge_eq_and_le_numbers(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_ge_eq_and_multiple_le_numbers(df, right): """Test output for multiple conditions.""" @@ -2748,7 +2763,7 @@ def test_ge_eq_and_multiple_le_numbers(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_multiple_eqs_variant(df, right): @@ -2784,7 +2799,7 @@ def test_multiple_eqs_variant(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_ge_and_le_range_numbers(df, right): """Test output for multiple conditions.""" @@ -2815,7 +2830,7 @@ def test_dual_ge_and_le_range_numbers(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_ge_and_le_range_numbers_numba(df, right): """Test output for multiple conditions.""" @@ -2847,7 +2862,7 @@ def test_dual_ge_and_le_range_numbers_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_ge_and_le_range_numbers_df_columns_only(df, right): """Test output for multiple conditions and select df only.""" @@ -2880,7 +2895,7 @@ def test_dual_ge_and_le_range_numbers_df_columns_only(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_dual_ge_and_le_range_numbers_right_only(df, right): """Test output for multiple conditions and select right only.""" @@ -2911,7 +2926,7 @@ def test_dual_ge_and_le_range_numbers_right_only(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_ge_eq_and_le_numbers(df, right): @@ -2942,7 +2957,7 @@ def test_ge_eq_and_le_numbers(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_ge_eq_and_le_numbers_force(df, right): @@ -2974,7 +2989,7 @@ def test_ge_eq_and_le_numbers_force(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_ge_eq_and_le_numbers_variant_numba(df, right): @@ -3005,7 +3020,7 @@ def test_ge_eq_and_le_numbers_variant_numba(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_ge_eq_and_le_numbers_numba(df, right): @@ -3037,7 +3052,7 @@ def test_ge_eq_and_le_numbers_numba(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_ge_eq_and_le_integers_numba(df, right): @@ -3069,7 +3084,7 @@ def test_ge_eq_and_le_integers_numba(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_ge_eq_and_lt_integers_numba(df, right): @@ -3101,7 +3116,7 @@ def test_ge_eq_and_lt_integers_numba(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_gt_eq_integers_numba(df, right): @@ -3132,7 +3147,7 @@ def test_gt_eq_integers_numba(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_gt_eq_dates_numba(df, right): @@ -3168,7 +3183,7 @@ def test_gt_eq_dates_numba(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_lt_eq_integers_numba(df, right): @@ -3199,7 +3214,7 @@ def test_lt_eq_integers_numba(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_lt_eq_dates_numba(df, right): @@ -3235,7 +3250,7 @@ def test_lt_eq_dates_numba(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_ge_eq_and_le_dates_numba(df, right): @@ -3272,7 +3287,7 @@ def test_ge_eq_and_le_dates_numba(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_ge_eq_and_le_datess_numba(df, right): @@ -3316,7 +3331,7 @@ def test_ge_eq_and_le_datess_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_multiple_non_equi(df, right): """Test output for multiple conditions.""" @@ -3352,7 +3367,7 @@ def test_multiple_non_equi(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_multiple_non_equii(df, right): @@ -3392,7 +3407,7 @@ def test_multiple_non_equii(df, right): assert_frame_equal(expected, actual) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) @pytest.mark.turtle def test_multiple_non_equii_col_syntax(df, right): @@ -3433,7 +3448,7 @@ def test_multiple_non_equii_col_syntax(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_multiple_non_eqi(df, right): """Test output for multiple conditions.""" @@ -3480,7 +3495,7 @@ def test_multiple_non_eqi(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_multiple_non_eqi_numba(df, right): """Test output for multiple conditions.""" @@ -3528,7 +3543,7 @@ def test_multiple_non_eqi_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_multiple_non_eq(df, right): """Test output for multiple conditions.""" @@ -3565,7 +3580,7 @@ def test_multiple_non_eq(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_multiple_non_eq_numba(df, right): """Test output for multiple conditions.""" @@ -3612,7 +3627,7 @@ def test_multiple_non_eq_numba(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_multiple_eqs(df, right): """Test output for multiple conditions.""" @@ -3647,7 +3662,7 @@ def test_multiple_eqs(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_multiple_eqs_outer(df, right): """Test output for multiple conditions.""" @@ -3702,7 +3717,7 @@ def test_multiple_eqs_outer(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_multiple_eqs_col_syntax(df, right): """Test output for multiple conditions.""" @@ -3737,7 +3752,7 @@ def test_multiple_eqs_col_syntax(df, right): @pytest.mark.turtle -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=conditional_df(), right=conditional_right()) def test_eq_strings(df, right): """Test output for joins on strings.""" diff --git a/tests/functions/test_encode_categorical.py b/tests/functions/test_encode_categorical.py index cb637eb23..2340edae5 100644 --- a/tests/functions/test_encode_categorical.py +++ b/tests/functions/test_encode_categorical.py @@ -1,9 +1,9 @@ +import datetime + import numpy as np import pandas as pd -import datetime import pytest -from hypothesis import given -from hypothesis import settings +from hypothesis import given, settings from pandas.testing import assert_frame_equal from janitor.testing_utils.strategies import ( @@ -33,7 +33,7 @@ def test_encode_categorical(df): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_encode_categorical_missing_column(df): """ Raise KeyError for missing columns @@ -46,7 +46,7 @@ def test_encode_categorical_missing_column(df): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_encode_categorical_missing_columns(df): """ Raise KeyError for missing columns @@ -59,7 +59,7 @@ def test_encode_categorical_missing_columns(df): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_encode_categorical_multiple_column_names(df): """ Test output when more than one column is provided @@ -129,7 +129,7 @@ def test_categories_ndim_DataFrame_gt_1_in_kwargs(df_checks): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_categories_null_in_categories(df): """ Raise ValueError if categories is provided, but has nulls. @@ -140,7 +140,7 @@ def test_categories_null_in_categories(df): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_non_unique_cat(df): """Raise ValueError if categories is provided, but is not unique.""" with pytest.raises(ValueError): @@ -149,7 +149,7 @@ def test_non_unique_cat(df): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_empty_cat(df): """Raise ValueError if empty categories is provided.""" with pytest.raises(ValueError): @@ -158,7 +158,7 @@ def test_empty_cat(df): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_empty_col(df): """ Raise ValueError if categories is provided, @@ -185,7 +185,7 @@ def test_warnings(df): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_order_wrong_option_in_kwargs(df): """ Raise ValueError if a string is provided, but is not @@ -197,7 +197,7 @@ def test_order_wrong_option_in_kwargs(df): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_empty_col_sort(df): """ Raise ValueError if a string is provided, @@ -210,7 +210,7 @@ def test_empty_col_sort(df): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_empty_col_appearance(df): """ Raise ValueError if a string is provided, diff --git a/tests/functions/test_expand_grid.py b/tests/functions/test_expand_grid.py index 9f2033549..3b37f886f 100644 --- a/tests/functions/test_expand_grid.py +++ b/tests/functions/test_expand_grid.py @@ -3,17 +3,19 @@ import numpy as np import pandas as pd import pytest -from hypothesis import given -from hypothesis import settings +from hypothesis import given, settings from pandas.testing import assert_frame_equal -from janitor.functions import expand_grid -from janitor.testing_utils.strategies import df_strategy -from janitor.testing_utils.strategies import categoricaldf_strategy +import janitor # noqa: F401 +from janitor.functions.expand_grid import expand_grid +from janitor.testing_utils.strategies import ( + categoricaldf_strategy, + df_strategy, +) @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_others_not_dict(df): """Raise Error if `others` is not a dictionary.""" with pytest.raises(TypeError): @@ -21,7 +23,7 @@ def test_others_not_dict(df): @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_others_none(df): """Return DataFrame if no `others`, and df exists.""" assert_frame_equal(df.expand_grid("df"), df) @@ -33,7 +35,7 @@ def test_others_empty(): @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_df_key(df): """Raise error if df exists and df_key is not supplied.""" with pytest.raises(KeyError): @@ -41,7 +43,7 @@ def test_df_key(df): @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_df_key_hashable(df): """Raise error if df exists and df_key is not Hashable.""" with pytest.raises(TypeError): @@ -78,7 +80,7 @@ def test_index_empty(): expand_grid(others={"x": pd.Index([], dtype=int)}) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=df_strategy()) def test_series(df): """Test expand_grid output for Series input.""" @@ -96,7 +98,7 @@ def test_series(df): assert_frame_equal(result, expected) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=df_strategy()) def test_series_dataframe(df): """Test expand_grid output for Series and DataFrame inputs.""" @@ -113,7 +115,7 @@ def test_series_dataframe(df): assert_frame_equal(result, expected) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=df_strategy()) def test_series_multiindex_dataframe(df): """ @@ -138,7 +140,7 @@ def test_series_multiindex_dataframe(df): assert_frame_equal(result, expected) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=df_strategy()) def test_numpy_1d(df): """Test expand_grid output for a 1D numpy array.""" @@ -155,7 +157,7 @@ def test_numpy_1d(df): assert_frame_equal(result, expected) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=categoricaldf_strategy()) def test_numpy_2d(df): """Test expand_grid output for a 2D numpy array""" @@ -173,7 +175,7 @@ def test_numpy_2d(df): assert_frame_equal(result, expected, check_dtype=False) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=df_strategy()) def test_index(df): """Test expand_grid output for a pandas Index that has a name.""" @@ -190,7 +192,7 @@ def test_index(df): assert_frame_equal(result, expected) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=df_strategy()) def test_index_name_none(df): """Test expand_grid output for a pandas Index without a name.""" @@ -205,7 +207,7 @@ def test_index_name_none(df): assert_frame_equal(result, expected) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=categoricaldf_strategy()) def test_multiindex(df): """Test expand_grid output for a pandas MultiIndex with a name.""" @@ -223,7 +225,7 @@ def test_multiindex(df): assert_frame_equal(result, expected) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=categoricaldf_strategy()) def test_multiindex_names_none(df): """Test expand_grid output for a pandas MultiIndex without a name.""" @@ -241,7 +243,7 @@ def test_multiindex_names_none(df): assert_frame_equal(result, expected) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=df_strategy()) def test_pandas_extension_array(df): """Test expand_grid output for a pandas array.""" @@ -258,7 +260,7 @@ def test_pandas_extension_array(df): assert_frame_equal(result, expected) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=df_strategy()) def test_sequence(df): """Test expand_grid output for list.""" @@ -275,7 +277,7 @@ def test_sequence(df): assert_frame_equal(result, expected, check_dtype=False) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=df_strategy()) def test_scalar(df): """Test expand_grid output for a scalar value.""" @@ -293,7 +295,7 @@ def test_scalar(df): assert_frame_equal(result, expected, check_dtype=False) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=df_strategy()) def test_chain_df(df): """Test expand_grid in a method-chain operation.""" @@ -310,7 +312,7 @@ def test_chain_df(df): assert_frame_equal(result, expected) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) @given(df=df_strategy()) def test_series_name(df): """Test expand_grid where the Series has no name.""" diff --git a/tests/functions/test_factorize_columns.py b/tests/functions/test_factorize_columns.py index 1fdc0e525..453c12604 100644 --- a/tests/functions/test_factorize_columns.py +++ b/tests/functions/test_factorize_columns.py @@ -10,6 +10,8 @@ import pandas as pd import pytest +import janitor # noqa: F401 + @pytest.mark.functions def test_single_column_factorize_columns(): diff --git a/tests/functions/test_fill_direction.py b/tests/functions/test_fill_direction.py index 83a856912..e5d53e856 100644 --- a/tests/functions/test_fill_direction.py +++ b/tests/functions/test_fill_direction.py @@ -3,6 +3,8 @@ import pytest from pandas.testing import assert_frame_equal +import janitor # noqa: F401 + @pytest.fixture def df(): diff --git a/tests/functions/test_fill_empty.py b/tests/functions/test_fill_empty.py index ed8a46384..660966cfe 100644 --- a/tests/functions/test_fill_empty.py +++ b/tests/functions/test_fill_empty.py @@ -1,5 +1,5 @@ -import pytest import pandas as pd +import pytest @pytest.mark.functions diff --git a/tests/functions/test_filter_column_isin.py b/tests/functions/test_filter_column_isin.py index e63334ff6..b15210136 100644 --- a/tests/functions/test_filter_column_isin.py +++ b/tests/functions/test_filter_column_isin.py @@ -1,15 +1,15 @@ import pytest -from hypothesis import assume -from hypothesis import given -from hypothesis import settings +from hypothesis import assume, given, settings -from janitor.testing_utils.strategies import categoricaldf_strategy -from janitor.testing_utils.strategies import names_strategy +from janitor.testing_utils.strategies import ( + categoricaldf_strategy, + names_strategy, +) @pytest.mark.functions @given(df=categoricaldf_strategy(), iterable=names_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_filter_column_isin(df, iterable): """ `filter_column_isin` should return the property that the column of diff --git a/tests/functions/test_flag_nulls.py b/tests/functions/test_flag_nulls.py index e46713eea..ab80e80ef 100644 --- a/tests/functions/test_flag_nulls.py +++ b/tests/functions/test_flag_nulls.py @@ -1,6 +1,6 @@ """Tests for `flag_nulls` function.""" -import pytest import pandas as pd +import pytest from pandas.testing import assert_frame_equal from janitor.functions import flag_nulls diff --git a/tests/functions/test_move.py b/tests/functions/test_move.py index 50cb630c5..e0a559919 100644 --- a/tests/functions/test_move.py +++ b/tests/functions/test_move.py @@ -1,10 +1,8 @@ -import pytest import numpy as np import pandas as pd - -from pandas.testing import assert_series_equal, assert_index_equal -from hypothesis import given -from hypothesis import settings +import pytest +from hypothesis import given, settings +from pandas.testing import assert_index_equal, assert_series_equal from janitor.testing_utils.strategies import df_strategy @@ -160,7 +158,7 @@ def test_move_invalid_args(dataframe): @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_move_reorder_columns(df): """Replicate reorder_columns""" assert all( diff --git a/tests/functions/test_pivot_longer.py b/tests/functions/test_pivot_longer.py index 0945925bd..a607dc379 100644 --- a/tests/functions/test_pivot_longer.py +++ b/tests/functions/test_pivot_longer.py @@ -1,10 +1,8 @@ import numpy as np import pandas as pd import pytest - -from pandas.testing import assert_frame_equal from pandas import NA - +from pandas.testing import assert_frame_equal df = [1, 2, 3] diff --git a/tests/functions/test_remove_empty.py b/tests/functions/test_remove_empty.py index 8d77af997..dca8ea95a 100644 --- a/tests/functions/test_remove_empty.py +++ b/tests/functions/test_remove_empty.py @@ -1,15 +1,14 @@ import numpy as np import pandas as pd import pytest -from hypothesis import given -from hypothesis import settings +from hypothesis import given, settings from janitor.testing_utils.strategies import df_strategy @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_remove_empty(df): """This test ensures that there are no columns that are completely null""" df = df.remove_empty() diff --git a/tests/functions/test_reorder_columns.py b/tests/functions/test_reorder_columns.py index c3d947ccb..b1f673518 100644 --- a/tests/functions/test_reorder_columns.py +++ b/tests/functions/test_reorder_columns.py @@ -1,13 +1,12 @@ import pytest -from hypothesis import given -from hypothesis import settings +from hypothesis import given, settings from janitor.testing_utils.strategies import df_strategy @pytest.mark.functions @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_reorder_columns(df): # NOTE: This test essentially has four different tests underneath it. # WE should be able to refactor this using pytest.mark.parametrize. diff --git a/tests/functions/test_select.py b/tests/functions/test_select.py index 0245b91ac..aefec35d5 100644 --- a/tests/functions/test_select.py +++ b/tests/functions/test_select.py @@ -1,5 +1,5 @@ -import pandas as pd import numpy as np +import pandas as pd import pytest from pandas.testing import assert_frame_equal diff --git a/tests/functions/test_select_columns.py b/tests/functions/test_select_columns.py index 301303996..ae5932a76 100644 --- a/tests/functions/test_select_columns.py +++ b/tests/functions/test_select_columns.py @@ -1,13 +1,14 @@ -import pandas as pd import datetime -import numpy as np import re -import pytest -from pandas.testing import assert_frame_equal from itertools import product -from janitor.functions.utils import patterns, DropLabel, get_columns +import numpy as np +import pandas as pd +import pytest from pandas.api.types import is_numeric_dtype +from pandas.testing import assert_frame_equal + +from janitor.functions.utils import DropLabel, get_columns, patterns @pytest.mark.functions diff --git a/tests/functions/test_select_rows.py b/tests/functions/test_select_rows.py index fa0e27fd8..e7919f2f5 100644 --- a/tests/functions/test_select_rows.py +++ b/tests/functions/test_select_rows.py @@ -4,7 +4,6 @@ import numpy as np import pandas as pd import pytest - from pandas.testing import assert_frame_equal diff --git a/tests/io/test_read_commandline.py b/tests/io/test_read_commandline.py index 9885ac08e..24ae5f14d 100644 --- a/tests/io/test_read_commandline.py +++ b/tests/io/test_read_commandline.py @@ -1,13 +1,12 @@ import os import sys +import tempfile from subprocess import CalledProcessError - import pandas as pd import pytest import janitor.io -import tempfile def test_read_commandline(dataframe): diff --git a/tests/io/test_tidyxl.py b/tests/io/test_tidyxl.py index 54cca0888..b4f677be9 100644 --- a/tests/io/test_tidyxl.py +++ b/tests/io/test_tidyxl.py @@ -1,10 +1,10 @@ -import pytest - -from janitor import io from pathlib import Path + +import pytest from openpyxl import load_workbook from pandas.testing import assert_series_equal +from janitor import io TEST_DATA_DIR = "tests/test_data" filename = Path(TEST_DATA_DIR).joinpath("worked-examples.xlsx").resolve() diff --git a/tests/io/test_xlsx_table.py b/tests/io/test_xlsx_table.py index e0ff8a146..d0c2061fc 100644 --- a/tests/io/test_xlsx_table.py +++ b/tests/io/test_xlsx_table.py @@ -1,11 +1,11 @@ +from pathlib import Path + import pandas as pd import pytest - -from janitor import io -from pandas.testing import assert_frame_equal -from pathlib import Path from openpyxl import load_workbook +from pandas.testing import assert_frame_equal +from janitor import io TEST_DATA_DIR = "tests/test_data" filename = Path(TEST_DATA_DIR).joinpath("016-MSPTDA-Excel.xlsx").resolve() diff --git a/tests/math/test_ecdf.py b/tests/math/test_ecdf.py index 58d3b3ea5..2b5361728 100644 --- a/tests/math/test_ecdf.py +++ b/tests/math/test_ecdf.py @@ -1,7 +1,6 @@ import numpy as np import pytest -from hypothesis import given -from hypothesis import settings +from hypothesis import given, settings from hypothesis.extra.pandas import series diff --git a/tests/ml/test_get_features_targets.py b/tests/ml/test_get_features_targets.py index 129114641..754595c52 100644 --- a/tests/ml/test_get_features_targets.py +++ b/tests/ml/test_get_features_targets.py @@ -1,6 +1,5 @@ import pytest -from hypothesis import given -from hypothesis import settings +from hypothesis import given, settings import janitor.ml # noqa: F401 from janitor.testing_utils.strategies import df_strategy @@ -8,7 +7,7 @@ @pytest.mark.ml @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_get_features_targets(df): """Test one column returned as target and rest as features.""" X, y = df.clean_names().get_features_targets( @@ -20,7 +19,7 @@ def test_get_features_targets(df): @pytest.mark.ml @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_get_features_targets_multi_features(df): """Test one column returned as target and two as features.""" X, y = df.clean_names().get_features_targets( @@ -33,7 +32,7 @@ def test_get_features_targets_multi_features(df): @pytest.mark.ml @given(df=df_strategy()) -@settings(deadline=None) +@settings(deadline=None, max_examples=10) def test_get_features_target_multi_columns(df): """Test two columns returned as target and rest as features.""" X, y = df.clean_names().get_features_targets( diff --git a/tests/spark/functions/test_clean_names_spark.py b/tests/spark/functions/test_clean_names_spark.py index 135dc5b46..a4ef0d177 100644 --- a/tests/spark/functions/test_clean_names_spark.py +++ b/tests/spark/functions/test_clean_names_spark.py @@ -42,7 +42,7 @@ def test_clean_names_special_characters(spark_df): assert set(spark_df.columns) == set(expected_columns) -@pytest.mark.xfail(reason="causing issues in CI, to be fixed later") +@pytest.mark.skip(reason="causing issues in CI, to be fixed later") @pytest.mark.spark_functions def test_clean_names_case_type_uppercase(spark_df): """Tests case_type parameter 'upper' takes effect.""" diff --git a/tests/test_df_registration.py b/tests/test_df_registration.py deleted file mode 100644 index 37c22c114..000000000 --- a/tests/test_df_registration.py +++ /dev/null @@ -1,161 +0,0 @@ -""" -Author: Eric J. Ma -Date: 18 July 2018 - -The intent of these tests is to test that dataframe method registration works. -""" -import pandas as pd -import pytest - -import janitor # noqa: F401 - - -@pytest.fixture -def dataframe(): - data = { - "a": [1, 2, 3], - "Bell__Chart": [1, 2, 3], - "decorated-elephant": [1, 2, 3], - } - df = pd.DataFrame(data) - return df - - -def test_clean_names_registration(dataframe): - """Test if DataFrame has clean_method method""" - assert dataframe.__getattr__("clean_names") - - -def test_remove_empty_registration(dataframe): - """Test if DataFrame has remove_empty method""" - assert dataframe.__getattr__("remove_empty") - - -def test_get_dupes_registration(dataframe): - """Test if DataFrame has get_dupes method""" - assert dataframe.__getattr__("get_dupes") - - -def test_encode_categorical_registration(dataframe): - """Test if DataFrame has encode_categorical method""" - assert dataframe.__getattr__("encode_categorical") - - -def test_label_encode_registration(dataframe): - """Test if DataFrame has label_encode method""" - assert dataframe.__getattr__("label_encode") - - -def test_factorize_columns_registration(dataframe): - """Test if DataFrame has factorize_columns method""" - assert dataframe.__getattr__("factorize_columns") - - -def test_get_features_targets_registration(dataframe): - """Test if DataFrame has get_features_targets method""" - assert dataframe.__getattr__("get_features_targets") - - -def test_rename_column_registration(dataframe): - """Test if DataFrame has rename_column method""" - assert dataframe.__getattr__("rename_column") - - -def test_coalesce_registration(dataframe): - """Test if DataFrame has coalesce method""" - assert dataframe.__getattr__("coalesce") - - -def test_convert_excel_date_registration(dataframe): - """Test if DataFrame has convert_excel_date method""" - assert dataframe.__getattr__("convert_excel_date") - - -def test_convert_matlab_date_registration(dataframe): - """Test if DataFrame has convert_matlab_date method""" - assert dataframe.__getattr__("convert_matlab_date") - - -def test_convert_unix_date_registration(dataframe): - """Test if DataFrame has convert_unix_date method""" - assert dataframe.__getattr__("convert_unix_date") - - -def test_fill_empty_registration(dataframe): - """Test if DataFrame has fill_empty method""" - assert dataframe.__getattr__("fill_empty") - - -def test_expand_column_registration(dataframe): - """Test if DataFrame has expand_column method""" - assert dataframe.__getattr__("expand_column") - - -def test_concatenate_columns_registration(dataframe): - """Test if DataFrame has concatenate_columns method""" - assert dataframe.__getattr__("concatenate_columns") - - -def test_deconcatenate_column_registration(dataframe): - """Test if DataFrame has deconcatenate_column method""" - assert dataframe.__getattr__("deconcatenate_column") - - -def test_filter_string_registration(dataframe): - """Test if DataFrame has filter_string method""" - assert dataframe.__getattr__("filter_string") - - -def test_filter_on_registration(dataframe): - """Test if DataFrame has filter_on method""" - assert dataframe.__getattr__("filter_on") - - -def test_remove_columns_registration(dataframe): - """Test if DataFrame has remove_columns method""" - assert dataframe.__getattr__("remove_columns") - - -def test_change_type_registration(dataframe): - """Test if DataFrame has change_type method""" - assert dataframe.__getattr__("change_type") - - -def test_filter_date_registration(dataframe): - """Test if DataFrame has filter_date method""" - assert dataframe.__getattr__("filter_date") - - -def test_conditional_join_registration(dataframe): - """Test if DataFrame has conditional_join method""" - assert dataframe.__getattr__("conditional_join") - - -def test_pivot_longer_registration(dataframe): - """Test if DataFrame has pivot_longer method""" - assert dataframe.__getattr__("pivot_longer") - - -def test_pivot_wider_registration(dataframe): - """Test if DataFrame has pivot_wider method""" - assert dataframe.__getattr__("pivot_wider") - - -def test_expand_grid_registration(dataframe): - """Test if DataFrame has expand_grid method""" - assert dataframe.__getattr__("expand_grid") - - -def test_process_text_registration(dataframe): - """Test if DataFrame has process_text method""" - assert dataframe.__getattr__("process_text") - - -def test_fill_direction_registration(dataframe): - """Test if DataFrame has fill_direction method""" - assert dataframe.__getattr__("fill_direction") - - -def test_drop_constant_columns_registration(dataframe): - """Test if DataFrame has drop_constant_columns method""" - assert dataframe.__getattr__("drop_constant_columns") diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index 353ad6b5d..51022abce 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -4,7 +4,6 @@ import pytest - # If `mkdocs` wasn't installed in environment, just skip. # Can't use `pytest.importorskip("mkdocs")`, 'mkdocs' is also # a folder name to pyjanitor project.