Comments (6)
Just found this:
JuliaLang/julia#37517
If I'm reading this right, it seems that in 1.6 ∘
will return a ComposedFunction
instead of an anonymous one. So at that point all of this will work. But I'm on 1.5, which is why I'm seeing strange results. Does that sound right?
from accessors.jl.
hi, I'm starting to think Accessors can be a big role in Soss, not just as a library, but also in the generated code I use for sampling. The idea would be to have a collection of optics for each model, and compose these to descend into submodels.
Sounds really exciting I need to check this out.
If I'm reading this right, it seems that in 1.6 ∘ will return a ComposedFunction instead of an anonymous one. So at that point all of this will work. But I'm on 1.5, which is why I'm seeing strange results. Does that sound right?
I think you can just dispatch on Accessors.ComposedOptic. Accessors.jl does this also internally. On 1.5 it is an alias for the scary looking var"..."
. On 1.6 it is an alias for Base.ComposedFunction
.
Other than the bad printing, I did not encounter any problems on 1.5.
from accessors.jl.
I need to check this out
It's mostly here, specifically in
function sourceSample()
function(m::Model)
_m = canonical(m)
proc(_m, st::Assign) = :($(st.x) = $(st.rhs))
proc(_m, st::Sample) = :($(st.x) = value(sample(_rng, $(st.rhs))))
proc(_m, st::Return) = :(_value = $(st.rhs))
proc(_m, st::LineNumber) = nothing
vals = map(x -> Expr(:(=), x,x),parameters(_m))
wrap(kernel) = @q begin
_rng -> begin
_value = nothing
$kernel
_trace = $(Expr(:tuple, vals...))
return (value = _value, trace = _trace)
end
end
buildSource(_m, proc, wrap) |> flatten
end
end
The trace
property will contain values for latent variables. But one of those might itself be the output of a model, in which case we need to keep track of its latent variables as well. So I'm thinking I can pass an optic to represent the current scope.
I think you can just dispatch on Accessors.ComposedOptic. Accessors.jl does this also internally. On 1.5 it is an alias for the scary looking
var"..."
. On 1.6 it is an alias forBase.ComposedFunction
.
Other than the bad printing, I did not encounter any problems on 1.5.
Great! I'll try this, thanks :)
from accessors.jl.
Confirmed!!
julia> using Accessors
julia> outeroptic(::Accessors.ComposedOptic{A,B}) where {A,B} = A
outeroptic (generic function with 1 method)
julia> o = @optic _.a.b
(@optic _.b) ∘ (@optic _.a)
julia> outeroptic(o)
Accessors.PropertyLens{:b}
from accessors.jl.
Just opened cscherrer/Soss.jl#227
I think this is resolved on the Accessors side, thanks @jw3126
from accessors.jl.
Oh, last post here wasn't clear. I mean I'll close the issue, since it's currently more an issue on the Soss side. @jw3126 if you're interested I'd welcome any feedback there :)
from accessors.jl.
Related Issues (20)
- "Concat lens": combine multiple lenses side by side HOT 7
- Assemble an object from optics HOT 7
- `hasproperty()` analogue for optics HOT 3
- IndexLens and changing the container size HOT 3
- `Base.show` ambiguity
- @reset naming convention HOT 4
- fate of insert and delete after these functions get into Base
- How to @reset when the field is known only by its equivalent symbol. HOT 2
- Only a single function argument can be the optic target HOT 3
- [Feature request] Set multiple fields at once HOT 6
- Errors in extensions during precompilation HOT 5
- multi-argument modify HOT 4
- `set` for `StructArray`
- Bad idea, would avoid using this pkg HOT 14
- To be or not to be HOT 3
- Traversal order of `Recursive` HOT 11
- `==` not defined for `IndexLens` HOT 4
- String properties not supported HOT 3
- Tests fail on 1.11 HOT 2
- `@(re)set` very slow when a parametric inner constructor is defined? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from accessors.jl.