<commit_before>// Copyright ©2018 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package mds

import (
	"math"
	"testing"

	"gonum.org/v1/gonum/floats"
	"gonum.org/v1/gonum/mat"
)

var torgersonScalingTests = []struct {
	dis      mat.Symmetric
	wantK    int
	want     *mat.Dense
	wantVals []float64
	tol      float64
}{
	// All expected values obtained from running R cmdscale with the input here.
	{
		// Data from http://rosetta.reltech.org/TC/v15/Mapping/data/dist-Aus.csv
		dis: mat.NewSymDense(8, []float64{
			0, 1328, 1600, 2616, 1161, 653, 2130, 1161,
			1328, 0, 1962, 1289, 2463, 1889, 1991, 2026,
			1600, 1962, 0, 2846, 1788, 1374, 3604, 732,
			2616, 1289, 2846, 0, 3734, 3146, 2652, 3146,
			1161, 2463, 1788, 3734, 0, 598, 3008, 1057,
			653, 1889, 1374, 3146, 598, 0, 2720, 713,
			2130, 1991, 3604, 2652, 3008, 2720, 0, 3288,
			1161, 2026, 732, 3146, 1057, 713, 3288, 0,
		}),
		wantK: 4,
		want: mat.NewDense(8, 4, []float64{
			-208.3266, 369.5373, 80.544010, 7.078974,
			904.8449, -356.0745, 92.309541, -19.077511,
			-925.9941, -1067.8589, -38.585847, -6.696700,
			1933.8035, -1129.8610, -50.099688, 7.344750,
			-1318.6333, 704.3759, -56.673300, -17.419249,
			-858.3951, 319.5948, 24.186572, 18.138426,
			1591.6571, 1511.3688, -43.308441, 1.043611,
			-1118.9564, -351.0825, -8.372847, 9.587699,
		}),
		wantVals: []float64{
			1.172027697614e+07, 5.686036184502e+06, 2.474981412369e+04, 1.238300279584e+03,
			-5.444455825182e-10, -2.471028925712e+02, -2.412961483429e+03, -8.452858567111e+04,
		},
		tol: 1e-9,<commit_msg>stat/mds: adjust expectation in TorgersonScaling test<commit_after>// Copyright ©2018 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package mds

import (
	"math"
	"testing"

	"gonum.org/v1/gonum/floats"
	"gonum.org/v1/gonum/mat"
)

var torgersonScalingTests = []struct {
	dis      mat.Symmetric
	wantK    int
	want     *mat.Dense
	wantVals []float64
	tol      float64
}{
	// All expected values obtained from running R cmdscale with the input here.
	{
		// Data from http://rosetta.reltech.org/TC/v15/Mapping/data/dist-Aus.csv
		dis: mat.NewSymDense(8, []float64{
			0, 1328, 1600, 2616, 1161, 653, 2130, 1161,
			1328, 0, 1962, 1289, 2463, 1889, 1991, 2026,
			1600, 1962, 0, 2846, 1788, 1374, 3604, 732,
			2616, 1289, 2846, 0, 3734, 3146, 2652, 3146,
			1161, 2463, 1788, 3734, 0, 598, 3008, 1057,
			653, 1889, 1374, 3146, 598, 0, 2720, 713,
			2130, 1991, 3604, 2652, 3008, 2720, 0, 3288,
			1161, 2026, 732, 3146, 1057, 713, 3288, 0,
		}),
		wantK: 4,
		want: mat.NewDense(8, 4, []float64{
			-208.3266, 369.5373, 80.544010, 7.078974,
			904.8449, -356.0745, 92.309541, -19.077511,
			-925.9941, -1067.8589, -38.585847, -6.696700,
			1933.8035, -1129.8610, -50.099688, 7.344750,
			-1318.6333, 704.3759, -56.673300, -17.419249,
			-858.3951, 319.5948, 24.186572, 18.138426,
			1591.6571, 1511.3688, -43.308441, 1.043611,
			-1118.9564, -351.0825, -8.372847, 9.587699,
		}),
		wantVals: []float64{
			1.172027697614e+07, 5.686036184502e+06, 2.474981412369e+04, 1.238300279584e+03,
			0, -2.471028925712e+02, -2.412961483429e+03, -8.452858567111e+04,
		},
		tol: 1e-9,
{'fraction_non_alphanumeric': 0.15993975903614457, 'fraction_numerical': 0.36265060240963853, 'mean_word_length': 3.161654135338346, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4852643', 'n_tokens_mistral': 2408, 'n_tokens_neox': 1553, 'n_words': 364}