Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertClose ¶
AssertClose fails t for every element of got outside tol of want
Types ¶
type Comparison ¶
type Comparison struct {
// Worst is the largest |got-want| relative to the comparison's scale:
// the measured error that tolerances are set from
Worst float64
Mismatches []Mismatch
}
Comparison is the outcome of comparing got against want
func Compare ¶
func Compare[T Number](got, want []T, tol Tolerance) (c Comparison, err error)
Compare measures got against want element by element, with errors relative to max|want| (see Tolerance) NaN in the same position of both counts as a match, as in numpy.allclose(equal_nan=True) NaN in only one is always a mismatch
func CompareScaled ¶
func CompareScaled[T Number](got, want []T, tol Tolerance, floor float64) (c Comparison, err error)
CompareScaled is Compare with errors measured relative to max(max|want|, floor) use it when want can legitimately be ~0 while the computation that produced it handled much larger values, such as a filter rejecting its input: rounding error then scales with those values, and relative to ~0 alone it would look enormous
type Complex ¶ added in v0.2.0
Complex is a vector of complex values as stored in reference vector JSON {"re":[...], "im":[...]}
func (Complex) Values ¶ added in v0.2.0
func (c Complex) Values() (values []complex128, err error)
Values combines Re and Im into complex values
type Floats ¶ added in v0.5.0
type Floats []float64
Floats is a vector of floats as stored in reference vector JSON, where NaN, which JSON can't represent, is null
func (*Floats) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON decodes a JSON array of numbers and nulls, nulls as NaN
type Meta ¶
type Meta struct {
Description string `json:"description"`
Versions map[string]string `json:"versions"` // e.g. {"scipy": "1.18.1", "numpy": "2.5.3"}
}
Meta is the header every reference vector file carries: embed it in each vector type
type Number ¶
type Number interface {
float64 | complex128
}
Number is the element types Compare can handle
type Source ¶ added in v0.4.0
type Source string
Source is the tool a set of reference vectors come from and the testdata/ directory they are in
type Tolerance ¶
type Tolerance struct {
Rel float64 // relative to each expected value
Scaled float64 // relative to the comparison's scale, so small but valid slices are still checked
}
Tolerance says how close got must be to want for a slice comparison a value passes if |got-want| <= Scaled*scale + Rel*|want|, where scale is max|want|, or the floor given to CompareScaled if that's larger