Skip to content

Conversation

@SvenKlaassen
Copy link
Member

@SvenKlaassen SvenKlaassen commented Nov 24, 2025

Refactor DoubleMLFramework

This pull request refactors the creation and usage of the DoubleMLFramework class to require a DoubleMLCore object as an argument, rather than a dictionary of arrays. It also introduces a new test suite for validating DoubleMLCore's input checks, and updates all relevant tests and code to use the new pattern. Additionally, some unused dictionary keys are removed from test utilities and framework construction.

Core API Refactor:

  • The DoubleMLFramework class is now instantiated with a DoubleMLCore object (using the dml_core argument) instead of a dictionary. All code and tests that previously passed a dictionary are updated to first create a DoubleMLCore instance and pass it to DoubleMLFramework.

  • The DoubleMLCore class is now imported and included in the public API.

Test and Utility Updates:

  • All test fixtures and helper functions that previously constructed DoubleMLFramework from a dictionary are updated to use DoubleMLCore instead.

  • The test utility function generate_dml_dict and framework construction in DoubleML remove unused keys (thetas, ses, treatment_names) to match the new interface.
    Validation Improvements:

  • A new test suite test_core_exceptions.py is added to comprehensively check input validation and error handling in DoubleMLCore, including array shapes, types, and required dictionary keys. (doubleml/tests/test_core_exceptions.py)

Framework Construction and Sensitivity:

  • When constructing frameworks for causal contrast, the code now explicitly creates a new DoubleMLCore with updated sensitivity elements instead of mutating the existing framework.

PR Checklist

Please fill out this PR checklist (see our contributing guidelines for details).

  • The title of the pull request summarizes the changes made.
  • The PR contains a detailed description of all changes and additions.
  • References to related issues or PRs are added.
  • The code passes all (unit) tests.
  • Enhancements or new feature are equipped with unit tests.
  • The changes adhere to the PEP8 standards.

Copy link
Member

@JanTeichertKluge JanTeichertKluge left a comment

Choose a reason for hiding this comment

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

Thanks for the refactoring, i really like the new DoubleMLCore object, i think it helps a lot for clarity and maintainability.

@SvenKlaassen SvenKlaassen marked this pull request as ready for review November 24, 2025 15:13
@SvenKlaassen SvenKlaassen linked an issue Nov 25, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor DoubleMLFramework

3 participants