Skip to content

Allow arbitrary storage for ContrastsMatrix and other contrasts breakage - #273

Merged
kleinschmidt merged 18 commits into
masterfrom
dfk/break-contrasts
Mar 13, 2023
Merged

kleinschmidt merged 18 commits into
masterfrom
dfk/break-contrasts

Conversation

@kleinschmidt

Copy link
Copy Markdown
Member

This makes a few breaking changes that we've planned for a while (fixes #175):

  • adds an additional type parameter M<:AbstractMatrix to ContrastsMatrix which can now use any AbstractMatrix to represent the contrasts (with tests for SparseMatrixCSC storage)
  • makes teh labels= and levels= kwargs for HypothesisCoding mandatory
  • un-exports ContrastsCoding and removes the corresponding deprecation warning.
  • removes the deprecated (and previously ignored) base= kwarg for SeqDiffCoding

I did not implement "more specific termnames" because I anticipate that being an enormous bikeshed 😂

@kleinschmidt kleinschmidt mentioned this pull request Jan 25, 2023
3 of 5 tasks
Comment thread src/contrasts.jl
Comment on lines +104 to +105
struct ContrastsMatrix{C <: AbstractContrasts, M <: AbstractMatrix, T, U}
matrix::M

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any particular reason to put M in second position? Putting it at the end would avoid breakage.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

my thinking here (near as I can reconstruct it at this point) was that we're already doing a breaking release, and this position puts it in a place where you can specify it without needing to specify the other parameters.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK so you suppose it will be more common to specify M than T or U?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah definitely. those are only there to make the contrast lookup type stable/inferrable

Comment thread src/contrasts.jl Outdated
Comment on lines +544 to +547
levels === nothing &&
throw(ArgumentError("kwarg `levels` must be specified for HypothesisCoding"))
labels === nothing &&
throw(ArgumentError("kwarg `labels` must be specified for HypothesisCoding"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe just dropping the default value nothing would be enough, as the error message is quite explicit?

Comment thread test/contrasts.jl Resolved
Comment thread src/contrasts.jl
Comment on lines +104 to +105
struct ContrastsMatrix{C <: AbstractContrasts, M <: AbstractMatrix, T, U}
matrix::M

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK so you suppose it will be more common to specify M than T or U?

Comment thread test/contrasts.jl Outdated
Comment on lines +377 to +378
mat = StatsModels.contrasts_matrix(contrasts, 1, 4)
spmat = sparse(mat)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unused?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

unused

@kleinschmidt
kleinschmidt merged commit 623906f into master Mar 13, 2023
@kleinschmidt
kleinschmidt deleted the dfk/break-contrasts branch March 13, 2023 16:57
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.

breaking changes to contrasts

2 participants