Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
68 lines (62 loc) · 2.31 KB

File metadata and controls

68 lines (62 loc) · 2.31 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2019 Shapelets.io
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
using NUnit.Framework;
namespace Khiva.Tests
{
[TestFixture, Category("Regularization")]
public class RegularizationTests
{
[SetUp]
public void Init()
{
Library.CurrentBackend = Library.Backend.KhivaBackendCpu;
}
[Test]
public void TestGroupBySingleColumn()
{
int[,] tss = {{0, 1, 1, 2, 2, 3}, {0, 3, 3, 1, 1, 2}};
using (KhivaArray arr = KhivaArray.Create(tss), groupBy = Regularization.GroupBy(arr, 0))
{
int[] expected = {0, 3, 1, 2};
var result = groupBy.GetData1D<int>();
Assert.AreEqual(expected, result);
}
}
[Test]
public void TestGroupByDoubleKeyColumn()
{
float[,] tss = {{0, 1, 1, 2, 2, 3}, {1, 2, 2, 3, 3, 4}, {0, 3, 3, 1, 1, 2}};
using (KhivaArray arr = KhivaArray.Create(tss), groupBy = Regularization.GroupBy(arr, 0, 2))
{
float[] expected = {0, 3, 1, 2};
var result = groupBy.GetData1D<float>();
Assert.AreEqual(expected, result);
}
}
[Test]
public void TestGroupByDoubleKeyColumn2()
{
float[,] tss = {{0, 0, 1, 1, 1}, {0, 1, 0, 0, 1}, {1, 2, 3, 4, 5}};
using (KhivaArray arr = KhivaArray.Create(tss), groupBy = Regularization.GroupBy(arr, 0, 2))
{
float[] expected = {1, 2, 3.5F, 5};
var result = groupBy.GetData1D<float>();
Assert.AreEqual(expected, result);
}
}
[Test]
public void TestGroupByDoubleKeyDoubleValueColumn()
{
float[,] tss = {{0, 0, 0, 2, 2}, {2, 2, 2, 4, 4}, {0, 1, 2, 3, 4}, {1, 1, 1, 1, 1}};
using (KhivaArray arr = KhivaArray.Create(tss), groupBy = Regularization.GroupBy(arr, 0, 2, 2))
{
float[,] expected = {{1, 3.5F}, {1, 1}};
var result = groupBy.GetData2D<float>();
Assert.AreEqual(expected, result);
}
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.