-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Added setindex with Integers for NamedTuple #43338
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
base: master
Are you sure you want to change the base?
Conversation
removed that one tab
@@ -368,7 +368,24 @@ julia> Base.setindex(nt, "a", :a) | |||
function setindex(nt::NamedTuple, v, idx::Symbol) | |||
merge(nt, (; idx => v)) | |||
end | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to add line breaks around the new definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth folding this docstring into the one for setindex(nt::NamedTuple, val, key::Symbol)
?
Thanks, great first PR! Please add some tests in test/namedtuple.jl. |
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Alright added some tests. |
Somehow a seemingly unrelated test is failing? |
As there was some recent activity in the ticket: can someone help me to figure out why these tests are failing? |
I rebased on current master and don't see any of the same failures. Tried pushing to the PR branch, but it's yours and doesn't allow pushing. I would suggest rebasing and force pushing here. |
Introduce another optional layer of indirection, doing lookup on first typename always, then leaftypes. This lets the intersection-iterators skip a lot of jl_isa queries later.
- remove `update_valid_age!(edge::InferenceState, sv::InferenceState)` and replace all the usages with `update_valid_age!(sv, edge.valid_worlds)`: this will simplify the incoming `AbsIntState` interface (see JuliaLang#48913) - remove `Effects(sv::InferenceState)` utility: replace all the usages with `sv.ipo_effects`, which is more explictly saying that we are looking at IPO-valid effects - normalize more `li::MethodInstance` to `mi::MethodInstance` - import `Core.MethodTable` - fix up `setindex!` return values
…aLang#48941) Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
…r` (JuliaLang#48225) This should allow constant propagation of `OptimizationParams`.
…uliaLang#48949) When linking directly to this section it is not obvious where the variables `greet` and `whom` are defined. This patch simply (re)defines these variables closer the their use.
…uliaLang#48932) We can ignore callee's `:noinbounds` effect when it is ensured to not taint `:consistent`-cy since a new method is also known to not taint it. Tests are added.
We currently very aggressively limit recursion if we came from a union split. The reason for this choice is to avoid accidental exponential inference times from excessive exploration of the call graph. Unfortunately, certain packages like Diffractor really like triggering the recursion heuristic at the moment, causing any unions to immediately cause imprecise inference. In the fullness of time, we should improve the recursion heuristic to do better in this case, but for the time being, add an inference option that simply lets it ignore the hardlimit recursion case and proceed anyway.
…iaLang#48931) * Install 7z, lld, dsymutil to private libexec/julia directory Installing files directly into /usr/libexec pollutes the install tree and can create conflicts if other apps do the same. Instead, install them to `private_libdir`, which defaults to `$(libexecdir)/julia`. This is similar to what we do with `private_libdir`.
) Avoid possible nested `Vararg`. Fix JuliaLang#48950
* adds fourthroot function
* add a Diagonal constructor and a conversion Co-authored-by: woclass <git@wo-class.cn>
In JuliaLang#48421 we removed all limits from apply_type, but that can lead to significant expression complexity which may be hard for subtyping to deal with. Try adding a heuristic size limiting constraint. Also do a bunch of code rearrangement and slight cleanup so that this change does not make the logic look complicated here. Solves JuliaLang#49127
* REPLCompletions: Add completions for var"" identifiers Fixes JuliaLang#49280. Mostly just moving code around, but there's one extra place where we're pattern matching var"". I do hope that after the future parser replacement, we can do these things on the in-progress AST rather than textually. * Apply suggestions from code review --------- Co-authored-by: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
Replace with SmallVector for better readability.
Type intersection assumed it was equal to Union{}, so this makes it unconstructable so that holds true. This is similar to what the NamedTuple constructor does. Secondarily, this fixes an inference bug where it would create Vararg{Union{}} and then incorrectly handle that fieldtype. - Fixes JuliaLang#32392 - Addresses part of the concerns discussed in JuliaLang#24614 (comment) - Addresses part of the issues presented in JuliaLang#26175 - May allow improving jl_type_equality_is_identity (https://github.com/JuliaLang/julia/pull/49017/files#diff-882927c6e612596e22406ae0d06adcee88a9ec05e8b61ad81b48942e2cb266e9R986) - May allow improving intersection (finish_unionall can be more aggressive at computing varval for any typevars that appears in covariant position and has lb=Union{} and ub=leaf type)
Makes a better error message too. Saves about 0.1% (0.15MB) on the standard system image.
This necessitated removing the unreachable DCE pass, since it would skip emitting SSA assignments, and then attempt to emit a label and then use the value, which was not legal. That necessitated making sure the IR was valid even when it was dead (a couple places tried to emit literal #f into the IR, instead of (null) or skipping it).
While these are free at runtime, they incur a small compile time cost to create an enumerate the backedge to `convert(::Type{T}, ::T) where T` which is shadowed by pretty much every `convert` method ever added later, requiring careful re-checking for invalidations. This drops the number of specializations of that method from over 1000 to under 100. With the other commits, seems to save over 1 MB (1%) from the standard system image.
Sometime `fieldtype` returns Union{Types}, which we can split during the if, to avoid union splitting on the convert call later when.
…aLang#47995) * Do not use widen for UInt128 --------- Co-authored-by: Oscar Smith <oscardssmith@gmail.com>
This release of libblastrampoline contains two new features: ILP64 Accelerate support, and LAPACK_jll support.
Need to convert the failure type from inference (Union{}) to the failure type for the new completions logic (nothing). Simultaneously update these tests to be more robust. There is no sort guaranteed order for `methods`, so the lookup needs to be the same as the completions is expected to do. Changed by 98988d8, which ended up conflicting with 35e4a1f.
…g#49312) In general, printing should take all reasonable steps to show even invalid data structures, since printing is used for debugging. In this case, the :invoke printing had some type asserts and minimum arg length constraints. Check those at the top and fall back to regular `Expr` printing if they are not met.
This changes the behavior of `select_platform()` to resolve ambiguities using a two-step process. Previously, we would simply sort the resultant triplets and return the last one (so as to provide asemi- arbitrary stability, and also to prefer higher version numbers over lower version numbers in tags). However, with the proliferation of tags (and especially the new `sanitize=memory` tags) we need a way to exclude these "extra" tags when our `HostPlatform()` does not have them. This new matching algorithm excludes candidates from matching with the platform if there are other candidates with fewer total tags. This results in a "simplest match first" behavior, which better represents the intent of tags in the first place.
…iaLang#49285) * when x is NaN in trig functions return x rather than NaN * prefer `isnan(x) | isnan(y)` --------- Co-authored-by: mikmoore <95002244+mikmoore@users.noreply.github.com>
* Working Native UTF-8 Validation --------- Co-authored-by: Oscar Smith <oscardssmith@gmail.com> Co-authored-by: Steven G. Johnson <stevenj@mit.edu>
Judging by the other `Matrix(Q)` tests, this should be an approximate equals. Testing with Apple Accelerate shows that all errors are on the order of `1e-16`.
The proper handling has not been implemented here, but it should not error at least.
…n run the event loop (JuliaLang#49094)
As discussed in #43155 this adds a method to use
Base.setindex
for NamedTuple with anInt
as index.