Closed JonasIsensee closed 5 years ago
Tests pass, the fails are on nightly only.
@MikeInnes can you please have a look and merge if possible? It would make our scientific work much, much easier.
Seems reasonable to me. Can I suggest using Dict
-style syntax for the keyword arguments? e.g. FileIO.save("test.bson", :r=>r, :str=>tr, :num=>num)
Good idea. I added the syntax you suggested. There is however one odd quirk:
julia> save("test.bson", :a => "test1", :b => 2, :c => rand(5))
julia> load("test.bson")
Dict{Symbol,Any} with 3 entries:
:a => "test1"
:b => 2
:c => [0.420764, 0.00832725, 0.478815, 0.875597, 0.170539]
julia> save("test.bson", :a => "test1", :b => 2, :c, rand(5))
julia> load("test.bson")
Dict{Any,Any} with 2 entries:
:c => [0.259777, 0.31934, 0.468751, 0.62964, 0.213068]
:a=>"test1" => :b=>2
In the second case, the first pair is used as key for the second pair, because the third set was not given as a pair.
Best to just remove the conflicting syntax there and only allow pairs.
I'm not a big fan of it either.
I added it in the first place, as this is the syntax supported by both JLD
and JLD2
.
If all support the same IO syntax, one just needs to exchange the file-type suffix to switch between
data formats.
It's up to you
Maybe the JLD syntax predates pairs? It seems like an odd choice otherwise. Maybe the newer-style syntax can be added there (you can do it from your own code at worst).
@MikeInnes since this is merged can you please tag a new release as well? it is necessary for working with FileIO.
Hi, I implemented the relevant functions for
BSON
to work withFileIO
.The syntax
bson("test.bson", a=1, b=2)
sadly cannot be ported as this syntax is already used for working with|>
. Instead I implemented it to look likeFileIO.save("test.bson", :a, 1, :b, 2)
.To add tests for this relatively simple functionality I would need to make
FileIO
a dependency so I haven't done this so far.The relevant PR to add the format to FileIO as well is here: https://github.com/JuliaIO/FileIO.jl/pull/224
closes #24