# ReferenceTests for a Matrix

**URL:** https://discourse.julialang.org/t/referencetests-for-a-matrix/67431
**Category:** General Usage
**Created:** [August 31, 2021, 3:03pm UTC](https://discourse.julialang.org/t/referencetests-for-a-matrix/67431 "2021-08-31T15:03:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Brad\_Carman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brad_carman/32/17631_2.png) [@Brad\_Carman](https://discourse.julialang.org/u/Brad_Carman)
#### Post date: [August 31, 2021, 3:03pm UTC](https://discourse.julialang.org/t/referencetests-for-a-matrix/67431/1 "2021-08-31T15:03:04Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![mmiller](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mmiller/32/20805_2.png) [@mmiller](https://discourse.julialang.org/u/mmiller)
#### Post date: [August 31, 2021, 5:23pm UTC](https://discourse.julialang.org/t/referencetests-for-a-matrix/67431/2 "2021-08-31T17:23:17Z")

</div>

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.

```nohighlight
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.
