Skip to content

GDR-3366: replace hardcoded Duration values with NA_real_#119

Merged
bczech merged 3 commits into
mainfrom
GDR-3366
May 5, 2026
Merged

GDR-3366: replace hardcoded Duration values with NA_real_#119
bczech merged 3 commits into
mainfrom
GDR-3366

Conversation

@bczech
Copy link
Copy Markdown
Contributor

@bczech bczech commented Apr 28, 2026

Description

What changed?

Related JIRA issue: GDR-3366

Replaced hardcoded Duration values with NA_real_ in PRISM and PSet importers:

  • prism_to_gdrDF.R: removed hardcoded 120 for control and treatment data in convert_LEVEL6_prism_to_gDR_input()
  • pset_to_gdrDF.R: removed hardcoded 72 fallback when Duration is missing from PSet data

Why was it changed?

The hardcoded values (120 for PRISM level6, 72 for PSets) were arbitrary and factually incorrect — they do not reflect the actual treatment duration from the source data. Using NA_real_ is semantically honest: the duration is unknown and should not be fabricated.

Checklist for sustainable code base

  • I added tests for any code changed/added
  • I added documentation for any code changed/added
  • I made sure naming of any new functions is self-explanatory and consistent

Logistic checklist

  • Package version bumped
  • Changelog updated

Screenshots (optional)

@bczech bczech requested a review from a team as a code owner April 28, 2026 12:18
@bczech bczech requested review from darsoo and gladkia and removed request for a team April 28, 2026 12:18
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the package version to 1.9.12 and replaces hardcoded 'Duration' values with 'NA_real_' in the PRISM and PSet importers. While unit tests were added for the PRISM importer, feedback suggests adding similar tests for the PSet importer to ensure consistency. Additionally, it is recommended to retain or update the documentation comments in the PSet importer to explain the initialization of the 'Duration' field.

Comment thread R/pset_to_gdrDF.R
Comment on lines 205 to 207
if (!duration %in% names(dt)) {
dt[, (duration) := 72]
dt[, (duration) := NA_real_]
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While replacing the hardcoded value with NA_real_ is correct, removing the comment entirely makes the code less self-documenting. It would be beneficial to keep a comment explaining that Duration is a required field in the gDR pipeline and is being initialized with NA_real_ when missing from the source data to maintain semantic honesty.

Comment on lines +64 to +65
expect_true(all(is.na(df_prism$result$Duration)))
expect_type(df_prism$result$Duration, "double")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The added tests correctly verify that Duration is NA and of type double for Level 6 PRISM data. However, similar assertions are missing for the PSet importer tests in tests/testthat/test-pset_to_gdrDF.R. To ensure consistency and prevent regressions, consider adding equivalent checks to the PSet unit tests where the default NA_real_ assignment is expected to occur.

@bczech bczech merged commit 93e5909 into main May 5, 2026
3 of 4 checks passed
@bczech bczech deleted the GDR-3366 branch May 5, 2026 07:42
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.

3 participants