Log dimensions.
[lightning.git] / exportnumpy_test.go
index 91921a8502bd4c6fb16ed395749b8e6733d3cb1b..96e04cc014a00e15181f4f7c92076b329a9d1f27 100644 (file)
@@ -17,7 +17,7 @@ func (s *exportSuite) TestFastaToNumpy(c *check.C) {
        exited := (&importer{}).RunCommand("import", []string{"-local=true", "-tag-library", "testdata/tags", "-ref", "testdata/ref", "testdata/a.1.fasta"}, &bytes.Buffer{}, &buffer, os.Stderr)
        c.Assert(exited, check.Equals, 0)
        var output bytes.Buffer
-       exited = (&exportNumpy{}).RunCommand("export-numpy", nil, &buffer, &output, os.Stderr)
+       exited = (&exportNumpy{}).RunCommand("export-numpy", []string{"-local=true"}, &buffer, &output, os.Stderr)
        c.Check(exited, check.Equals, 0)
        npy, err := gonpy.NewReader(&output)
        c.Assert(err, check.IsNil)
@@ -45,3 +45,32 @@ func sortUints(variants []uint16) {
                }
        }
 }
+
+func (s *exportSuite) TestOnehot(c *check.C) {
+       for _, trial := range []struct {
+               incols  int
+               in      []uint16
+               outcols int
+               out     []uint16
+       }{
+               {2, []uint16{1, 1, 1, 1}, 2, []uint16{1, 1, 1, 1}},
+               {2, []uint16{1, 1, 1, 2}, 3, []uint16{1, 1, 0, 1, 0, 1}},
+               {
+                       // 2nd column => 3 one-hot columns
+                       // 4th column => 0 one-hot columns
+                       4, []uint16{
+                               1, 1, 0, 0,
+                               1, 2, 1, 0,
+                               1, 3, 0, 0,
+                       }, 5, []uint16{
+                               1, 1, 0, 0, 0,
+                               1, 0, 1, 0, 1,
+                               1, 0, 0, 1, 0,
+                       },
+               },
+       } {
+               out, outcols := recodeOnehot(trial.in, trial.incols)
+               c.Check(out, check.DeepEquals, trial.out)
+               c.Check(outcols, check.Equals, trial.outcols)
+       }
+}