Skip to content

[ENH] clean-up refactor of TimeSeriesDataSet #1746

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

Merged
merged 34 commits into from
Jan 10, 2025
Merged

Conversation

fkiraly
Copy link
Collaborator

@fkiraly fkiraly commented Jan 3, 2025

This PR carries out a clean-up refactor of TimeSeriesDataSet. No changes are made to the logic.

This is in preparation for major work items impacting the logic, e.g., removal of the pandas coupling (see #1685), or a 2.0 rework (see #1736).
In general, a clean state would make these easier.

Work carried out:

  • clear, and complete docstrings, in numpydoc format
  • separating logic, e.g., for parameter checking, data formatting, default handling
  • reducing cognitive complexity and max indentations, addressing "code smells"
  • linting

@fkiraly fkiraly added the enhancement New feature or request label Jan 3, 2025
Copy link
Member

@fnhirwa fnhirwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this clean-up looks good to me 😊

A one point that we should consider:

  • I think we can start handling exceptions using if conditions instead of assert as if is optimized for runtime, and for some cases for example if a user is running a python program using optimizer flags(python -O or python -OO) the assert conditions are skipped.
def divide(a, b):
    if b == 0:
        raise ValueError("Denominator cannot be zero.")
    return a / b
print(divide(1, 0) # ValueError: Cannot divide by zero when we do python -O script.py

When we use assert

def divide(a, b):
    assert b != 0, "Denominator cannot be zero."
    return a / b
print(divide(2/0)) # ZeroDivisionError: division by zero with python -O

For the second case, the exception we wanted to handle was skipped and we got an unexpected exception which can affect the exceptions handling in general for the case of our codebase.

@fkiraly
Copy link
Collaborator Author

fkiraly commented Jan 10, 2025

thanks for review, @fnhirwa - merging so we avoid issues with the linting PR, I will address the assert/raise issue later.

@fkiraly fkiraly merged commit 0bf7a19 into main Jan 10, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants