Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/datautils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,29 @@ function _svector2array(c_vec::Vector{SVector{N_rep, T}}) where {N_rep,T<:Number
return c_matrix
end

"""
save_h5fdata(rdata, filename )

Saves a friction tensor dataset with the HDF5 file structure expected by `load_h5fdata`, for use in training scripts.

# Arguments

## `rdata`:
A `Vector{NamedTuple}` containing the training data in the following format.

```
(
at = ::JuLIP.Atoms,
friction_tensor = sparse(::Matrix),
friction_indices = ::Vector{Int}
)
```

## `filename`

Name of the file to save to (including h5 extension).

"""
function save_h5fdata(rdata, filename )
fid = h5open(filename, "w")
try
Expand Down Expand Up @@ -102,7 +125,7 @@ end

function BlockDenseArray(full_tensor::Matrix; indices=1:size(full_tensor,1))
@assert size(full_tensor,1) == size(full_tensor,2)
return BlockDenseMatrix(full_tensor[indice,indices], indices)
return BlockDenseMatrix(full_tensor[indices,indices], indices)
end

struct FrictionData{A}
Expand All @@ -124,4 +147,4 @@ end
# end


end
end
Loading