Closed sunxd3 closed 7 months ago
Attention: Patch coverage is 80.76923%
with 20 lines
in your changes are missing coverage. Please review.
Project coverage is 82.72%. Comparing base (
b342b3d
) to head (22ad3fa
). Report is 6 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
src/varname.jl | 80.76% | 20 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Before, Setfield
has ==
defined for IndexLens
(https://github.com/jw3126/Setfield.jl/blob/e31e1e361bd6a251124aa578122e6198b81197b5/src/lens.jl#L196), and we have AbstractPPL.ConcretizedSlice{Int, Base.OneTo{Int}}(Base.OneTo(100)) == UnitRange(1, 100)
, so the two VarName
is equivalent. By saying "they are functor", I am just making a guess why Accessors
doesn't have this ==
defined as Setfield
does: it might be related to the semantic meaning of functions equivalence.
@torfjelde another look?
Just made some adjustment, Setfield
is removed from the deps.
The interpolation is weaker compared to before. It is mainly attributed to Accessors.parse_obj_optic
. Now more than one interpolated symbol (e.g. @varname($n1[$n2+1])
), and interpolation of the LHS of a .
expr (e.g. $name.a[1]
) are disallowed.
By saying "they are functor", I am just making a guess why Accessors doesn't have this == defined as Setfield does: it might be related to the semantic meaning of functions equivalence.
Might be worth raising an issue and asking about this, as IIUC it should be okay to define ==
for some of the optics, e.g the getindex one.
The interpolation ability was added by @phipsgabler at https://github.com/jw3126/Setfield.jl/pull/168, but this never got ported to Accessors.
I do think the interpolation can be quite handy, but that means we need to keep Setfield around for a while.
Is there a reason why we can't just copy-paste the macro? :shrug:
Is there a reason why we can't just copy-paste the macro? 🤷
That should work since it is only a small utility function.
@torfjelde @yebai function copied, not sure if it's small, but it should maintain the interpolation ability.
Changes from
Setfield
toAccessors
Accessors
is based onComposeFunction
, which means all theoptic
s are either function or functor. Also, noget(obj, optic)
interface, butoptic(obj)
.Lens
abstract type doesn't exist inAccessors
,IdentityLens
is justidentity
,ComposedLens
is nowComposedOptic
(alias forComposedFunction
)Inner
andOuter
are interchanged,l1 ∘ l2
inSetfield
isl2 ∘ l1
inAccessors
.Accessors
adopted⨟
(\bbsemi
"opposite compose") fromCompositionBase
:l1 ∘ l2
inSetfield
isl1 ⨟ l2
inAccessors
.Unsure
VarNames
are changed, before@varname(y[:], true)
and@varname(y[1:100]
(wherey = zeros(10,10)
) are considered to be==
. But withAccesssors
, twoIndexLens
are generally not equivalent even when they have the same field because they are also functors.Accessor.parse_obj_optic
andSetfield.parse_obj_lens
behave differently when deal with interpolation. I have tried and failed to maintain the current interface withAccessor.parse_obj_optic
, so I am keepingSetfield.parse_obj_lens
(andSetfield
as a dependency), while replace theLens
with optic in the result ofSetfield.parse_obj_lens
.