ReferenceTests for a Matrix

I’m struggling to figure out how to use @test_reference from ReferenceTests.jl for a Matrix{Float64} type. If I do

@test_reference "data.dat" data

then the data is stored as a string and compared as a string. This means I can’t use the by keyword to do a tolerance check. If I try to store as "data.csv" then I get an error Can't write this data to a CSV file.

If I want my data stored/loaded as a Matrix{Float64}, then which file format should I use? Or more generally, what is the recommended method to @test for matrix data? I like that @test_reference provides automatic file generation and loading, but is it better done another way?

I’ve also wanted this in the past and not found anything. It would be a great addition to ReferenceTests I think.

My work around is to broadcast isapprox with a reference matrix that I had saved in a .jl file.

M_ref = include("M_ref.jl")
@test all(isapprox.(M, M_ref))

Unfortunately it’s not very pretty and doesn’t have the automatic generation/updating of the file that ReferenceTests has.