public void CopyMapToFrame(INetworkAdjList network, IEdgeBoolMap map, IFrame frame) { bool[] vals = new bool[network.EdgeCount]; int ctr = 0; foreach (IEdge edge in network.EdgeEnumerator) { vals[ctr++] = map[edge]; } SimpleFrame sFrame = frame as SimpleFrame; using (SimpleFrameTool tool = new SimpleFrameTool()) { tool.AddColumn<bool>(sFrame, map.Name, vals); } }
public void AddColumnOfBools_IsNotAddedIfArrayLengthMisMatch(int testId, int rowCount, int expectedIndex, Type[] colTypes) { SimpleFrame frame0 = SimpleFrameGenerator.CreateTable(rowCount, colTypes) as SimpleFrame; SimpleFrameTool tool = new SimpleFrameTool(); Random rand = new Random(); bool[] data = new bool[rowCount + 1]; int index = tool.AddColumn(frame0, "col X", data); Assert.AreEqual(expectedIndex, index, "RowCount should match expected"); Assert.AreEqual(colTypes.Length, frame0.ColumnCount, "ColumnCount should match expected."); tool.Dispose(); }
public void CopyMapToFrame(INetworkAdjList network, INodeDoubleMap map, IFrame frame) { double[] vals = new double[network.NodeCount]; int ctr = 0; foreach (INode node in network.NodeEnumerator) { vals[ctr++] = map[node]; } SimpleFrame sFrame = frame as SimpleFrame; using (SimpleFrameTool tool = new SimpleFrameTool()) { tool.AddColumn<double>(sFrame, map.Name, vals); } }
public void AddColumnOfBools(int testId, int rowCount, int expectedIndex, Type[] colTypes) { SimpleFrame frame0 = SimpleFrameGenerator.CreateTable(rowCount, colTypes) as SimpleFrame; SimpleFrameTool tool = new SimpleFrameTool(); Random rand = new Random(); bool[] data = new bool[rowCount]; for (int i = 0; i < rowCount; i++) { data[i] = Convert.ToBoolean(rand.Next(2)); } int index = tool.AddColumn(frame0, "col X", data); Assert.AreEqual(expectedIndex, index, "RowCount should match expected"); Assert.AreEqual(colTypes.Length + 1, frame0.ColumnCount, "ColumnCount should match expected."); for (int i = 0; i < frame0.Rows.Count; i++) { Assert.AreEqual<bool>(data[i], (bool)frame0.Rows[i][index], "Item should match expected"); } tool.Dispose(); }
public void PadRows_VerifyPaddingIsTrueCopies(int initRowCount, int newRowCount, int expectedRowCount, Type[] colTypes) { IFrame frame0 = SimpleFrameGenerator.CreateTable(initRowCount, colTypes); SimpleFrameTool tool = new SimpleFrameTool(); tool.PadRows(frame0, newRowCount); Assert.AreEqual(expectedRowCount, frame0.RowCount, "RowCount should match expected"); tool.Dispose(); // verify the new padding are inidividual copies SimpleFrame xF = frame0 as SimpleFrame; xF.Rows[1][0] = 33; xF.Rows[1][1] = "####"; Assert.AreNotEqual(xF.Rows[1][0], xF.Rows[2][0]); Assert.AreNotEqual(xF.Rows[1][1], xF.Rows[2][1]); }
public void PadRows(int initRowCount, int newRowCount, int expectedRowCount, Type[] colTypes) { IFrame frame0 = SimpleFrameGenerator.CreateTable(initRowCount, colTypes); SimpleFrameTool tool = new SimpleFrameTool(); tool.PadRows(frame0, newRowCount); Assert.AreEqual(expectedRowCount, frame0.RowCount, "RowCount should match expected"); tool.Dispose(); }
public void AddInitialColumnOfStrings(int rowCount) { SimpleFrame frame0 = new SimpleFrame(); SimpleFrameTool tool = new SimpleFrameTool(); Random rand = new Random(); string[] data = new string[rowCount]; for (int i = 0; i < rowCount; i++) { data[i] = string.Format("val-{0}", i); } int index = tool.AddInitialColumn<string>(frame0, "col X", data); Assert.AreEqual(0, index, "index should match expected"); Assert.AreEqual(1, frame0.ColumnCount, "ColumnCount should match expected."); for (int i = 0; i < frame0.Rows.Count; i++) { Assert.AreEqual<string>(data[i], (string)frame0.Rows[i][index], "Item should match expected"); } tool.Dispose(); }
public void AddInitialColumnOfInts(int rowCount) { SimpleFrame frame0 = new SimpleFrame(); SimpleFrameTool tool = new SimpleFrameTool(); Random rand = new Random(); int[] data = new int[rowCount]; for (int i = 0; i < rowCount; i++) { data[i] = rand.Next(); } int index = tool.AddInitialColumn<int>(frame0, "col X", data); Assert.AreEqual(0, index, "index should match expected"); Assert.AreEqual(1, frame0.ColumnCount, "ColumnCount should match expected."); for (int i = 0; i < frame0.Rows.Count; i++) { Assert.AreEqual<int>(data[i], (int)frame0.Rows[i][index], "Item should match expected"); } tool.Dispose(); }