Skip to content

Commit 046e0bf

Browse files
bump version
1 parent 86b387a commit 046e0bf

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ReactiveDynamics"
22
uuid = "c7456e7d-545a-4b79-91ea-6e93d96dd4d4"
3-
version = "0.2.4"
3+
version = "0.2.5"
44

55
[deps]
66
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"

src/loadsave.jl

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const RN_attrs = string.(propertynames(ReactionNetwork().subparts))
1414

1515
function get_attrs(object)
1616
object = object isa Symbol ? objects_aliases[object] : object
17-
17+
1818
filter(x -> occursin(object, x), RN_attrs)
1919
end
2020

@@ -67,12 +67,15 @@ function load_network(dict::Dict)
6767
end
6868

6969
function import_network_csv(pathmap)
70-
dict = Dict(); for (key, paths) in pathmap
70+
dict = Dict()
71+
for (key, paths) in pathmap
7172
push!(dict, key => [])
7273
for path in paths
73-
data = DataFrame(CSV.File(path; delim=";;", types=String, stripwhitespace=true, comment="#"))
74+
data = DataFrame(CSV.File(path; delim = ";;", types = String,
75+
stripwhitespace = true, comment = "#"))
7476
for row in eachrow(data)
75-
object = Dict(); for (attr, val) in Iterators.zip(keys(row), values(row))
77+
object = Dict()
78+
for (attr, val) in Iterators.zip(keys(row), values(row))
7679
!ismissing(val) && push!(object, string(attr) => val)
7780
end
7881
push!(dict[key], object)
@@ -85,8 +88,9 @@ end
8588

8689
function import_network(path::AbstractString)
8790
if splitext(path)[2] == ".csv"
88-
pathmap = Dict(val => [] for val in [collect(values(objects_aliases)); "registered"])
89-
for row in CSV.File(path; delim=";;", stripwhitespace=true, comment="#")
91+
pathmap = Dict(val => []
92+
for val in [collect(values(objects_aliases)); "registered"])
93+
for row in CSV.File(path; delim = ";;", stripwhitespace = true, comment = "#")
9094
push!(pathmap[row.type], joinpath(dirname(path), row.path))
9195
end
9296

@@ -96,7 +100,6 @@ function import_network(path::AbstractString)
96100
end
97101
end
98102

99-
100103
function export_network(acs::ReactionNetwork, path::AbstractString)
101104
if splitext(path)[2] == ".csv"
102105
exported_network = export_network(acs)
@@ -105,18 +108,19 @@ function export_network(acs::ReactionNetwork, path::AbstractString)
105108
push!(paths, (key, "export-$key.csv"))
106109
objs_exported = DataFrame(Dict(attr => [] for attr in get_attrs(key)))
107110
for obj in objs
108-
push!(objs_exported, [get(obj, key, missing) for key in names(objs_exported)])
111+
push!(objs_exported,
112+
[get(obj, key, missing) for key in names(objs_exported)])
109113
end
110114

111-
CSV.write(joinpath(dirname(path), "export-$key.csv"), objs_exported, delim=";;")
115+
CSV.write(joinpath(dirname(path), "export-$key.csv"), objs_exported,
116+
delim = ";;")
112117
end
113-
CSV.write(path, paths, delim=";;")
118+
CSV.write(path, paths, delim = ";;")
114119
else
115120
open(io -> TOML.print(io, export_network(acs)), path, "w+")
116121
end
117122
end
118123

119-
120124
"""
121125
Export model to a file: this can be either a single TOML file encoding the entire model,
122126
or a batch of CSV files (a root file and a number of files, each per a class of objects).

tutorial/loadsave/loadsave.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ sol_ = @solve prob_ trajectories=20
2121

2222
# export the same model (w/o registered functions)
2323
@export_network sir_acs modell.toml
24-
mkpath("csv_"); @export_network sir_acs "csv_/model.csv"
24+
mkpath("csv_");
25+
@export_network sir_acs "csv_/model.csv";
2526

2627
# load multiple models
2728
@load_models models.txt
@@ -31,4 +32,4 @@ mkpath("csv_"); @export_network sir_acs "csv_/model.csv"
3132
@export_solution_as_csv sol sol.csv
3233

3334
# another test
34-
@import_network model2.toml sir_acs_2
35+
@import_network model2.toml sir_acs_2

0 commit comments

Comments
 (0)