Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update entropy types #1915

Merged
merged 13 commits into from
Jan 16, 2025
Merged

Update entropy types #1915

merged 13 commits into from
Jan 16, 2025

Conversation

victorlin
Copy link
Member

@victorlin victorlin commented Nov 21, 2024

Description of proposed changes

Updates TypeScript usage to be consistent with #1864, etc.

I thought of these changes after adding 6215591.

Discussions

Checklist

@victorlin victorlin self-assigned this Nov 21, 2024
@nextstrain-bot nextstrain-bot temporarily deployed to auspice-victorlin-updat-jrdeox November 21, 2024 01:36 Inactive
src/util/entropyCreateStateFromJsons.ts Outdated Show resolved Hide resolved
@victorlin victorlin temporarily deployed to auspice-victorlin-updat-jrdeox November 21, 2024 19:39 Inactive
@victorlin victorlin temporarily deployed to auspice-victorlin-updat-ih84hn December 6, 2024 17:48 Inactive
src/util/entropyCreateStateFromJsons.ts Outdated Show resolved Hide resolved
src/util/entropyCreateStateFromJsons.ts Outdated Show resolved Hide resolved
src/util/entropyCreateStateFromJsons.ts Outdated Show resolved Hide resolved
src/util/entropyCreateStateFromJsons.ts Outdated Show resolved Hide resolved
@victorlin victorlin force-pushed the victorlin/update-entropy-types branch from ce1f446 to cad5eb6 Compare January 6, 2025 23:32
src/util/entropyCreateStateFromJsons.ts Show resolved Hide resolved
src/util/entropyCreateStateFromJsons.ts Outdated Show resolved Hide resolved
src/util/entropyCreateStateFromJsons.ts Show resolved Hide resolved
src/util/entropyCreateStateFromJsons.ts Outdated Show resolved Hide resolved
This allows for more specific type narrowing.
Improves readability.
This allows some code editors to show the comment on hover.

I also added two new types (Phase, Frame) to replace some comments.

Notably, a type assertion in _frame is a necessary part of this
translation. I considered extracting the modulus operation into a
separate _mod3 function to reduce clutter in the _frame function,
however that seemed to be an unnecessary complication.
These were not consistent in the same file. I've also opted to not use
them in the tree component types.
The previous error message code indicated the possibility that this
property is unset. Express that directly in the type annotation and
simplify the error message code.
Checking against undefined is more direct.
The function is only used in two places, both of which specify a valid
strand value.
This is only used in one place, so use it directly.
Setting the nested dictionary value directly is more readable.
These types had ignored the reality that the JSON input can be anything.
The removal better aligns with the validation that is already present in
the functions. More validation has been added to accommodate for newly
exposed type errors.
@victorlin victorlin force-pushed the victorlin/update-entropy-types branch from 0d9600b to d3e89c0 Compare January 10, 2025 07:09
Copy link
Member

@jameshadfield jameshadfield left a comment

Choose a reason for hiding this comment

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

I ended up reading through the code changes all together as there was a fair bit of layering - it all looks good from what I can tell. If there's anything particular to look at please let me know & I can re-check.

"Note that -ve strand RNA viruses are typically annotated as 5' → 3'.");

if (!nucAnnotation) {
throw new Error("Genome annotation missing 'nuc' definition");
Copy link
Member

Choose a reason for hiding this comment

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

[comment, no changes please] This made me think of how nice it'd be to have #1813

@victorlin
Copy link
Member Author

Thanks for the reviews @genehack and @jameshadfield! Merging this now.

@victorlin victorlin merged commit 5270cf1 into master Jan 16, 2025
18 checks passed
@victorlin victorlin deleted the victorlin/update-entropy-types branch January 16, 2025 00:13
@victorlin victorlin mentioned this pull request Jan 16, 2025
3 tasks
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.

4 participants