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 setindex and improve merge for stacks #411

Merged
merged 1 commit into from
Oct 3, 2022
Merged

Conversation

rafaqz
Copy link
Owner

@rafaqz rafaqz commented Sep 26, 2022

@Lincoln-Hannah this is an example of incremental improvements to the syntax without changing any structure or adding macros.

This lets you merge AbstractDimStack and NamedTuple of AbstractDimArray and get a new AbstrackDimStack back.

# Merge a stack with new layers in another stack or NamedTuple
new_stack = merge(oldstack, (new1=dimarray, new2=dimarrary))
# Or use `NamedTuple` merge
new_stack = DimStack((; oldstack..., new1=dimarray, new2=dimarray))

And for your example in #410 :

Base.setindex(s, 4s[:one], :four)

They are still a bit clunky to use. But these are the kinds of simple Base methods I would hope to build a better syntax on top of. So Base julia NamedTuple methods do all the real work, we just wrap it.

@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2022

Codecov Report

Merging #411 (55c0331) into main (266d7e5) will decrease coverage by 4.12%.
The diff coverage is 41.17%.

❗ Current head 55c0331 differs from pull request most recent head 1f79d76. Consider uploading reports for the commit 1f79d76 to get more accurate results

@@            Coverage Diff             @@
##             main     #411      +/-   ##
==========================================
- Coverage   90.26%   86.14%   -4.13%     
==========================================
  Files          35       35              
  Lines        2363     2367       +4     
==========================================
- Hits         2133     2039      -94     
- Misses        230      328      +98     
Impacted Files Coverage Δ
src/plotrecipes.jl 0.00% <0.00%> (-81.00%) ⬇️
src/stack/stack.jl 93.93% <77.77%> (-2.68%) ⬇️
src/LookupArrays/lookup_arrays.jl 81.87% <0.00%> (-0.59%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@rafaqz rafaqz merged commit ab3dcce into main Oct 3, 2022
@rafaqz rafaqz deleted the better_merge_setindex branch October 3, 2022 03:24
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.

2 participants