Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #105 +/- ##
==========================================
+ Coverage 93.63% 94.51% +0.87%
==========================================
Files 8 8
Lines 220 237 +17
==========================================
+ Hits 206 224 +18
+ Misses 14 13 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Jul 17, 2026
cgarling
reviewed
Jul 17, 2026
cgarling
left a comment
Member
There was a problem hiding this comment.
Separating the frame type from the numeric type makes sense to me
LGTM
Co-authored-by: Chris Garling <chris.t.garling@gmail.com>
Member
Author
This was referenced Jul 17, 2026
Member
Author
|
Hi all, just checking back in about this. Happy to just get things moving on my end if that's preferred. Can also just check back in the next week or so if that works better for folks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR aims to simplify the various
convert/constructor methods in this package by redesigning them around two rules:1. Specified type parameters are honored exactly, unspecified ones are inferred from the input.
convert(CartesianCoords, c)keeps the input's frame and element typeconvert(CartesianCoords{GalCoords}, c)rotates and infers the element typeconvert(CartesianCoords{GalCoords, Float32}, c)returns exactly that type (as theconvertcontract requires)2. Everything reduces to two orthogonal primitives.
cartesian/spherical) and frame rotation (rotmat)convertconvertcomposes the primitivesBelow is a summary of what this redesign buys us.
TCis now a frame tagThe
TCparameter ofCartesianCoords{TC, TF}is only ever used to pick a rotation matrix and to rebuild a spherical coordinate. Both need the frame identity (including static parameters like the FK5 equinox), not the element type of the angles that produced the vector. Storing a fully parameterized type there duplicated the element type and even allowed contradictory states likeCartesianCoords{ICRSCoords{Float64}, Float32}.TCis now canonically the element-type-free constructor (ICRSCoords,FK5Coords{2000}, etc.), with the element type carried byTFalone:This also matches how the rest of the package already treated
TC(rotmatsignatures, the NearestNeighbors.jl extension, the test suite). Dispatch gets simpler too:f(c::CartesianCoords{ICRSCoords})now matches directly, no{<:ICRSCoords}needed.Parameterized tags remain valid: the tag's element type then determines the data's element type (e.g.,
CartesianCoords{ICRSCoords{Float16}}(c)holdsFloat16data), and a conflicting explicitTFthrows anArgumentError, so the tag and the stored vector can never disagree.Fixes
All of these were broken before (
MethodError, ambiguity, or wrong result):The last one was a latent bug:
convertreturning a type other than the one requested breaks arraysetindex!, struct field assignment, and inference.Equality and hashing
==now compares the frame tag (viaConstructionBase.constructorof) plus the values, so element types no longer need to match. For example,ICRSCoords(1.0, 2.0) == ICRSCoords{Float32}(1.0, 2.0), in the same way1.0 == 1.0f0. Different frames (including different equinoxes) still compare unequal.A matching
Base.hashis added so value-equal coordinates of different element types collide inDict/Set, as thehashcontract requires. This turns a long-standing@test_brokeninto a passing test.Breaking changes
cartesian(c)and inferred conversions now produce the frame-tag form (CartesianCoords{ICRSCoords, Float64}instead ofCartesianCoords{ICRSCoords{Float64}, Float64}). Dispatch written asCartesianCoords{<:ICRSCoords}keeps working. Only exact-parameter type checks are affected.==across element types of the same frame is now value-based (was alwaysfalse).CartesianCoords{ICRSCoords{Float16}, Float32}) now throw instead of silently constructing a contradictory type.CartesianCoords{TC}(vec::AbstractVector{<:Integer})now floats the element type, consistent with the spherical constructors.Follow-up
With every conversion reduced to
rotmat+ representation change, frames whose transform is not a rotation (e.g., FK4's E-terms in #101) can be supported by promoting the frame-change primitive to a function (frame_transform(to, from, v), defaulting torotmat(to, from) * v). This avoids needing to define customconvertmethods.