Skip to content

Commit

Permalink
As/expand dims types (#3941)
Browse files Browse the repository at this point in the history
* Force Observable{Any} in `apply_expand_dimensions`

* Add a test

---------

Co-authored-by: Anshul Singhvi <anshulsinghvi@gmail.com>
  • Loading branch information
SimonDanisch and asinghvi17 authored Jun 6, 2024
1 parent 5c30eb1 commit b4a9242
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/interfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function apply_expand_dimensions(trait, args, args_obs, deregister)
if isnothing(expanded)
return args_obs
else
new_obs = map(Observable, expanded)
new_obs = map(Observable{Any}, expanded)
fs = onany(args_obs...) do args...
expanded = expand_dimensions(trait, args...)
for (obs, arg) in zip(new_obs, expanded)
Expand Down
11 changes: 11 additions & 0 deletions test/dim-converts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,14 @@ end
test_cleanup(dates)
end
end

@testset "Type constraints (#3938)" begin
# Integers cannot be converted to Irrationals,
# so if the type of the observable is tightened
# somewhere within the pipeline, there should be a
# conversion error!
obs = Observable{Vector}([π, π])
f, a, p = plot(obs)
obs.val = [1, 1] # Integers are not convertible to Irrational, so if the type was "solidified" here, there should be a conversion error
@test_nowarn notify(obs)
end

0 comments on commit b4a9242

Please sign in to comment.