-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
TestExpansion.cs
42 lines (38 loc) · 1 KB
/
TestExpansion.cs
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
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VW;
using VW.Serializer.Attributes;
namespace cs_unittest
{
[TestClass]
public class TestExpansionClass
{
[TestMethod]
[TestCategory("Marshal")]
public void TestExpansion()
{
using (var vw = new VowpalWabbitExampleValidator<ExpansionContext>(string.Empty))
{
vw.Validate("| 3:.1 4:.2 5:.3", new ExpansionContext() { Features = new[] { .1f, .2f, .3f }, Offset = 3 });
}
}
}
public class ExpansionContext
{
public float[] Features { get; set; }
public int Offset { get; set; }
[Feature]
public IEnumerable<float> ExpandedFeatures
{
get
{
return Enumerable.Repeat(0f, this.Offset)
.Concat(Features);
}
}
}
}