-
Notifications
You must be signed in to change notification settings - Fork 6
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
allow more Param types #39
base: master
Are you sure you want to change the base?
Conversation
5ee3cc9
to
285168e
Compare
Codecov Report
@@ Coverage Diff @@
## master #39 +/- ##
==========================================
+ Coverage 79.88% 81.00% +1.12%
==========================================
Files 4 4
Lines 174 179 +5
==========================================
+ Hits 139 145 +6
+ Misses 35 34 -1
Continue to review full report at Codecov.
|
Could I get some context on this? Why is this necessary? It seems to me that filtering is already possible by table operations on |
The original design always had But I get your point, there are 2 ways of achieving this - table/vector manipulation outside of the object, or modification of the param type. This way is going to be better for type stability where that's required, and is pretty easy to specify by the user. But its also less flexible. |
I know the original design had I'm not sure this is better for type stability. The main type stability issue in using So, for example, if one works only with In other words, I don't think this is the main problem hindering type stability... or am I missing something? |
end | ||
setparent!(m, newparent) | ||
end | ||
end | ||
# TODO do this with lenses | ||
@inline function _setindex(obj, xs::Tuple, nm::Symbol) | ||
@inline function _setindex(obj, xs::Tuple, nm::Symbol; select=SELECT, ignore=IGNORE) |
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.
Should select
and ignore
maybe have type bounds, Type{T} where {T<:AbstractParam}
?
@@ -246,3 +246,28 @@ end | |||
@test isa(tuplegroups.A.i, Tuple) | |||
@test isa(tuplegroups.B.j, Tuple) | |||
end | |||
|
|||
struct FreeParam{T,P<:NamedTuple} <: AbstractParam{T} |
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.
If we're going to do this, then the macro to abstract away this boilerplate (and reduce chance of user error) should be included in this PR, I think.
FreeParam(val; kwargs...) = FreeParam((; val=val, kwargs...)) | ||
FreeParam(; kwargs...) = FreeParam((; kwargs...)) | ||
|
||
@testset "spefify param type" begin |
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.
Since you seem to agree that the FreeParam
/FixedParam
is not a good use-case for this feature, I would like to see an example use-case where this feature actually is actually necessary in contrast to using table manipulations, i.e. something where simply adding an extra field to Param
wouldn't cut it or would be prohibitively difficult. I can't really think of one off the top of my head, but maybe you can.
I have changed my mind about this, but I think the changes here will conflict a lot with #44, so it might be better for me to simply copy these changes into that PR by hand rather than try to resolve the merge conflicts. |
Nice to see you finally came around ;) Probably making a separate PR afterwards is better, or do you need this for your PR? |
We can do it in another PR. |
@briochemc this PR addes
select
keywords everywhere so that we can filter by other wrapper types - e.g.AbstractParam
. (andignore
for the case there are types in your object that don't reconstruct, but that's a minor detail)@bgroenks96 you might want to have a look at this and give some feedback. We will need to changing the grouping as well to not always use
Param
.But, from the new tests, this is the kind of this it adds with
select
:Probably we want a
@param MyParam
macro to define all those constructors automatically