-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add some methods to make JLSOFile more Dict-like #108
Conversation
- Before: gave an error - Now: returns a `JLSOFile` with no objects
return JLSOFile( | ||
Dict(kwargs); | ||
data; |
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.
i don't love this magic keyword constructor, which has some "special" keywords (version
, julia
, ...) and then eats all the others as key/value pairs to be serialised... especially as we have a :key => value
pair constructor already: JLSOFile(data::Pair{Symbol}...; kwargs...) = JLSOFile(Dict(data); kwargs...)
But I think removing this is another issue (and breaking). Maybe we should open an issue about that.
But whether we have magic-keywords or not, i think this is now the correct behjaviour for JLSOFile()
(before it was a cryptic error)
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.
Yeah, :+1 for just using pairs for data objects. I think this was proposed cause some folks like creating dataframes with the keyword constructor and we often don't change the special keywords. Please open an issue to delete this method as it should be easy enough to deprecate.
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.
Codecov Report
@@ Coverage Diff @@
## master #108 +/- ##
==========================================
+ Coverage 97.56% 97.67% +0.11%
==========================================
Files 6 6
Lines 205 215 +10
==========================================
+ Hits 200 210 +10
Misses 5 5
Continue to review full report at Codecov.
|
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.
LGTM, would you mind bumping the minor release?
return JLSOFile( | ||
Dict(kwargs); | ||
data; |
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.
Yeah, :+1 for just using pairs for data objects. I think this was proposed cause some folks like creating dataframes with the keyword constructor and we often don't change the special keywords. Please open an issue to delete this method as it should be easy enough to deprecate.
keys
,haskey
,get
andget!
forJLSOFile
(but notiterate
as i didn't have a use-cae for it); closes ShouldJLSOFile
haveget
,get!
,keys
andhaskey
methods #107JLSOFile()
to return aJLSOFile
, whereas onmaster
it errrors:save(io, ::JLSOFile)
methodTogether, this allows users to write code like
or
The main advantage is this allows working with a
JLSOFile
similar to working with the Dict that would be returned byJLSO.load(filename)
, but withJLSOFile
lazily deserialising (unlikeload
)