Skip to content

Fix Covariate constructor and GLM intervalNr calculation#15

Open
alexeid wants to merge 2 commits intomasterfrom
fix-covariate-constructor
Open

Fix Covariate constructor and GLM intervalNr calculation#15
alexeid wants to merge 2 commits intomasterfrom
fix-covariate-constructor

Conversation

@alexeid
Copy link
Copy Markdown
Collaborator

@alexeid alexeid commented Feb 4, 2026

Summary

  • Fix Covariate(Double[], String) constructor to also populate valuesInput
  • Fix GLM intervalNr calculation for single-epoch models

Fix 1: Covariate constructor (fixes #14)

The constructor was setting the values field directly but not populating valuesInput. This caused:

  1. initAndValidate() to overwrite values with an empty array
  2. XML serialization to omit covariate values

Fix 2: GLM intervalNr calculation (fixes #16)

The hardcoded -2 in intervalNr calculation only worked when firstlargerzero=1 (i.e., when rateShifts starts with 0.0).

Changed to -firstlargerzero-1 which correctly computes the last valid interval index for any rateShifts configuration, including single-epoch models with rateShifts=[Infinity].

Fixes getCoalescentRate(), getNe(), and getMig() methods.

The Covariate(Double[], String) constructor was setting the values field
directly but not populating valuesInput. This caused two problems:

1. Calling initAndValidate() after the constructor would overwrite the
   values array with an empty array (since valuesInput was empty)
2. XML serialization would not include the covariate values

The fix ensures valuesInput is populated in the constructor, making the
object properly initialized and serializable.

Fixes #14
The hardcoded -2 in intervalNr calculation only worked when
firstlargerzero=1 (i.e., when rateShifts starts with 0.0).

Changed to -firstlargerzero-1 which correctly computes the last
valid interval index for any rateShifts configuration, including
single-epoch models with rateShifts=[Infinity].

Fixes getCoalescentRate(), getNe(), and getMig() methods.
@alexeid alexeid changed the title Fix Covariate constructor to populate valuesInput Fix Covariate constructor and GLM intervalNr calculation Feb 4, 2026
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.

GLM requires rateShifts even though marked as optional Covariate constructor values overwritten by initAndValidate()

1 participant