Skip to content

Refactor internal types#69

Merged
aefarrell merged 4 commits into
mainfrom
refactor-internal-types
Jul 5, 2025
Merged

Refactor internal types#69
aefarrell merged 4 commits into
mainfrom
refactor-internal-types

Conversation

@aefarrell
Copy link
Copy Markdown
Owner

GasDispersion historically has abused dispatch by ::Type{...}, which is discouraged in the julia style guide. This pull request changes the internal workings to use singletons.

This simplifies equationsets and adding new equation sets, and also opens up the possibility of more complicated correlations that are initialized with some parameters or something. Previous names for equationsets are preserved as constants, a short hand for the specific instance of BasicEquationSet to make lives easier, which also opens things up more cleanly for the user to make their own.

This also simplifies the atmospheric stability classes by adding to the type hierarchy, now classes are grouped into UnstableClass, NeutralClass, and StableClass, which makes dispatch simpler and eliminates a lot of type unions that were floating around.

Finally, methods were added to catch the old usage, throw a warning, but otherwise keep everything working. This should not be a breaking change for old code.

aefarrell added 4 commits July 3, 2025 20:50
GasDispersion.jl really abuses ::Type{...} and should, per the Julia style guide...not do that. Replaced dispatch by ::Type{} with dispatch by instance. Most correlations now dispatch based on singleton types, e.g. ClassA() is a singleton.

Added a type hierarchy for stability classes which should make code easier to read, e.g. ClassA <: UnstableClass <: StabilityClass, this allows for dispatch to be fine grained to the specific class or general to apply to all unstable or stable atmospheres without having to use so many type unions.

This is a breaking change.
Changed equation sets from distinct types to consts
Added interfaces for depreciated behaviour (dispatching on Type{...} instead of the singletons) as well as tests to show that the appropriate warnings are being passed.
Fixed doc tests and updated documentation.
@aefarrell aefarrell added this to the v0.4 milestone Jul 5, 2025
@aefarrell aefarrell self-assigned this Jul 5, 2025
@aefarrell aefarrell added the todo Things that need to be done label Jul 5, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 5, 2025

Codecov Report

Attention: Patch coverage is 99.66102% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.28%. Comparing base (cf87ba9) to head (2ec5c9d).

Files with missing lines Patch % Lines
src/models/simple_jet.jl 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #69      +/-   ##
==========================================
+ Coverage   96.03%   96.28%   +0.24%     
==========================================
  Files          46       46              
  Lines        2823     2905      +82     
==========================================
+ Hits         2711     2797      +86     
+ Misses        112      108       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aefarrell aefarrell merged commit a997019 into main Jul 5, 2025
94 checks passed
@aefarrell aefarrell deleted the refactor-internal-types branch July 5, 2025 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

todo Things that need to be done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant