Skip to content

Commit dadc0ce

Browse files
Merge pull request #3 from maurergroup/data-save
Fix typo and add docstring for data saving function
2 parents 96ba9d1 + bd1d735 commit dadc0ce

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/datautils.jl

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ function _svector2array(c_vec::Vector{SVector{N_rep, T}}) where {N_rep,T<:Number
2626
return c_matrix
2727
end
2828

29+
"""
30+
save_h5fdata(rdata, filename )
31+
32+
Saves a friction tensor dataset with the HDF5 file structure expected by `load_h5fdata`, for use in training scripts.
33+
34+
# Arguments
35+
36+
## `rdata`:
37+
A `Vector{NamedTuple}` containing the training data in the following format.
38+
39+
```
40+
(
41+
at = ::JuLIP.Atoms,
42+
friction_tensor = sparse(::Matrix),
43+
friction_indices = ::Vector{Int}
44+
)
45+
```
46+
47+
## `filename`
48+
49+
Name of the file to save to (including h5 extension).
50+
51+
"""
2952
function save_h5fdata(rdata, filename )
3053
fid = h5open(filename, "w")
3154
try
@@ -102,7 +125,7 @@ end
102125

103126
function BlockDenseArray(full_tensor::Matrix; indices=1:size(full_tensor,1))
104127
@assert size(full_tensor,1) == size(full_tensor,2)
105-
return BlockDenseMatrix(full_tensor[indice,indices], indices)
128+
return BlockDenseMatrix(full_tensor[indices,indices], indices)
106129
end
107130

108131
struct FrictionData{A}
@@ -124,4 +147,4 @@ end
124147
# end
125148

126149

127-
end
150+
end

0 commit comments

Comments
 (0)