Skip to content

Conversation

@eroell
Copy link
Collaborator

@eroell eroell commented Nov 7, 2025

PR Checklist

  • This comment contains a description of changes (with reason)
  • Referenced issue is linked
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

Description of changes

Fixes #945, see there for a checklist

ehrapy.pp.simple_impute for timeseries.

Technical details

Additional context

@github-actions github-actions bot added the enhancement New feature or request label Nov 7, 2025
@eroell eroell requested review from agerardy and sueoglu November 7, 2025 16:36
Copy link
Member

@Zethson Zethson left a comment

Choose a reason for hiding this comment

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

Thank you! A bit pedantic but this is supposed to be a role model

Copy link
Collaborator

@agerardy agerardy left a comment

Choose a reason for hiding this comment

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

I think I understood it :)

def test_simple_impute_basic(impute_num_edata, strategy):
edata_imputed = simple_impute(impute_num_edata, strategy=strategy, copy=True)
_base_check_imputation(impute_num_edata, edata_imputed)
def test_simple_impute_basic(impute_num_edata, array_type, strategy):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Explanation: This test and the following one are specific for the function, which is about imputation here


@pytest.mark.parametrize("array_type", ARRAY_TYPES_NUMERIC_3D_ABLE)
@pytest.mark.parametrize("strategy", ["mean", "median", "most_frequent"])
def test_simple_impute_3D_edata(mcar_edata, array_type, strategy):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Explanation: this test checks that for numeric data, the method can handle 3D data.

There might be combinations of arguments that are not supported, which should be mentioned in the documentation if not obvious.


@pytest.mark.parametrize("array_type", ARRAY_TYPES_NONNUMERIC)
@pytest.mark.parametrize("strategy", ["mean", "median", "most_frequent"])
def test_simple_impute_3D_edata_nonnumeric(edata_mini_3D_missing_values, array_type, strategy):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Explanation: this checks whether the function can also handle non-numeric 3D data.

There might be combinations of arguments that are not supported, which should be mentioned in the documentation if not obvious.



ARRAY_TYPES = (asarray, as_dense_dask_array)
ARRAY_TYPES_NUMERIC = (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I suggest these collections of array types for testing, which I hope reduces some repetitiveness

Copy link
Member

Choose a reason for hiding this comment

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

I wonder whether we should have this here or even in our compat code because we might also use this for the implementations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree actually, didn't occur to me before. -> asked @sueoglu to move in #967

@eroell eroell merged commit 77812e5 into main Nov 21, 2025
14 checks passed
@eroell eroell deleted the feature/simple-impute-timeseries branch November 21, 2025 20:51
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.

Longitudinal simple_impute

5 participants