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

Add another missing NamedTuple getindex method for StaticSymbol #123

Merged
merged 6 commits into from
Feb 9, 2024

Conversation

ianfiske
Copy link
Contributor

@ianfiske ianfiske commented Feb 6, 2024

Fixes #124 . This addresses the need to do

nt = (a=1, b=2, c=3)
nt[(static(:a), static(:b))]

This is a follow-up to #120 and #121.

As noted in #121, the Aqua tests currently fail, but the tests pass otherwise.

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (beb08ae) 0.00% compared to head (5219df6) 98.30%.
Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #123       +/-   ##
===========================================
+ Coverage    0.00%   98.30%   +98.30%     
===========================================
  Files           3        3               
  Lines         700      706        +6     
===========================================
+ Hits            0      694      +694     
+ Misses        700       12      -688     

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

@ChrisRackauckas
Copy link
Member

This test failure is real though. Fix the ambiguity? But I don't know if you can do that without piracy.

@ianfiske
Copy link
Contributor Author

ianfiske commented Feb 8, 2024

This test failure is real though. Fix the ambiguity? But I don't know if you can do that without piracy.

Yeah, the Aqua suggestion to implement

 getindex(::NamedTuple, ::Tuple{})

is clearly type piracy, so I'm thinking we should avoid it. But what is the fix? Should I submit at PR to julia base to implement getindex(::NamedTuple, ::Tuple{}) there? Not ideal due to the wait for it to be merged there and released, etc, but if you think this is the path forward, I'll submit a PR.

@Tokazama
Copy link
Collaborator

Tokazama commented Feb 8, 2024

Have you tried specifying at least one element for the tuple (Tuple{<:StaticSymbol, Vararg{<:StaticSymbol}})?

@ianfiske
Copy link
Contributor Author

ianfiske commented Feb 8, 2024

Tuple{<:StaticSymbol, Vararg{<:StaticSymbol}}

With

function Base.getindex(x::NamedTuple, symbols::Tuple{<:StaticSymbol, Vararg{<:StaticSymbol}})
    return x[map(known, symbols)]
end

I get

┌ Static
│  WARNING: Wrapping `Vararg` directly in UnionAll is deprecated (wrap the tuple instead).
│  You may need to write `f(x::Vararg{T})` rather than `f(x::Vararg{<:T})` or `f(x::Vararg{T}) where T` instead of `f(x::Vararg{T} where T)`.

But this warning goes away with

function Base.getindex(x::NamedTuple, symbols::Tuple{StaticSymbol, Vararg{StaticSymbol}})
    return x[map(known, symbols)]
end

@ChrisRackauckas
Copy link
Member

@ArnoStrouwen
Copy link
Member

My guess would be it fails because dev version of Static gets added to the SciMLBase project here:
https://github.com/SciML/Static.jl/actions/runs/7841889229/job/21399128321?pr=123#step:6:1049
However, Static is normally not a part of SciMLBase, hence Aqua complains it is a stale dep and has no compat entry.

@ChrisRackauckas
Copy link
Member

Is there a way to make this one bypass?

@ArnoStrouwen
Copy link
Member

I can't think of anything besides moving it out of the core group into its own group, which is then not ran here.

@ChrisRackauckas
Copy link
Member

Yeah let's just make a QA group.

@ChrisRackauckas ChrisRackauckas merged commit ca801c8 into SciML:master Feb 9, 2024
16 of 20 checks passed
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.

Another missing getindex method for NamedTuple and StaticSymbol
4 participants