Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: Refactor np_can_hold_element to reduce cyclomatic complexity #60735

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

aksel2904
Copy link

Overview

This PR refactors the np_can_hold_element function to reduce its cyclomatic complexity and improve maintainability. The function was decomposed into smaller helper functions (_handle_integer_dtype, _handle_float_dtype, etc.), each handling a specific dtype logic. This improves readability and reduces the complexity of the main function.

Changes

  • Refactored np_can_hold_element into smaller helper functions:
    • _handle_integer_dtype
    • _handle_float_dtype
    • _handle_complex_dtype
    • _handle_boolean_dtype
    • _handle_string_dtype
  • Added docstrings to the helper functions for better documentation.
  • Ensured no changes to functionality or behavior during the refactor.
  • Ran flake8 and fixed style issues to comply with the project's code standards.

Testing

  • Verified that all existing tests in the Pandas test suite pass.
  • Confirmed no behavioral changes in np_can_hold_element.

Notes for Reviewers

  • The refactor was aimed at maintainability; the logic remains consistent with the original implementation.
  • Suggestions for additional tests or improvements are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant