public void CompareDentriteList() { Cell c1 = new Cell(1, 1, 10, 1, NeoCortexEntities.NeuroVisualizer.CellActivity.ActiveCell); Cell c2 = new Cell(1, 1, 10, 1, NeoCortexEntities.NeuroVisualizer.CellActivity.ActiveCell); Cell c3 = new Cell(2, 1, 10, 1, NeoCortexEntities.NeuroVisualizer.CellActivity.ActiveCell); DistalDendrite d1 = new DistalDendrite(c1, 1, 1, 1, 0.5, 10); DistalDendrite d2 = new DistalDendrite(c1, 1, 1, 1, 0.5, 10); DistalDendrite d3 = new DistalDendrite(c1, 2, 1, 1, 0.5, 10); DistalDendrite d4 = new DistalDendrite(c2, 2, 2, 1, 0.5, 10); List <DistalDendrite> list1 = new List <DistalDendrite>() { d1, d2, d2 }; List <DistalDendrite> list2 = new List <DistalDendrite>() { d1, d2, d3 }; // Not same by reference Assert.IsFalse(d1 == d2); // d1 and d2 are same by value. Assert.IsTrue(d1.Equals(d2)); // d1 and d3 are NOT same by value. Assert.IsFalse(d1.Equals(d3)); // d3 and d4 are NOT same by value. Assert.IsFalse(d3.Equals(d4)); // Lists are same by value. list1.SequenceEqual(list2); // All same by references. list2 = new List <DistalDendrite>() { d1, d1, d1 }; // Lists are strill same by value. list1.SequenceEqual(list2); list2 = new List <DistalDendrite>() { d1, d2, d3 }; Assert.IsTrue(d1.Equals(d2)); Assert.IsFalse(d1.Equals(d3)); }
public void CompareDentrites() { Cell c1 = new Cell(1, 1, 10, 1, NeoCortexEntities.NeuroVisualizer.CellActivity.ActiveCell); Cell c2 = new Cell(1, 1, 10, 1, NeoCortexEntities.NeuroVisualizer.CellActivity.ActiveCell); Cell c3 = new Cell(2, 1, 10, 1, NeoCortexEntities.NeuroVisualizer.CellActivity.ActiveCell); DistalDendrite d1 = new DistalDendrite(c1, 1, 1, 1, 0.5, 10); DistalDendrite d2 = new DistalDendrite(c1, 1, 1, 1, 0.5, 10); DistalDendrite d3 = new DistalDendrite(c1, 2, 1, 1, 0.5, 10); Assert.IsTrue(d1.Equals(d2)); Assert.IsFalse(d1.Equals(d3)); }
public void TestModelClasses() { //Test Segment equality Column column1 = new Column(2, 0); Cell cell1 = new Cell(column1, 0); Segment s1 = new DistalDendrite(cell1, 0, 1, 0); Assert.IsTrue(s1.Equals(s1)); // test == Assert.IsFalse(s1.Equals(null)); Segment s2 = new DistalDendrite(cell1, 0, 1, 0); Assert.IsTrue(s1.Equals(s2)); Cell cell2 = new Cell(column1, 0); Segment s3 = new DistalDendrite(cell2, 0, 1, 0); Assert.IsTrue(s1.Equals(s3)); //Segment's Cell has different index Cell cell3 = new Cell(column1, 1); Segment s4 = new DistalDendrite(cell3, 0, 1, 0); Assert.IsFalse(s1.Equals(s4)); //Segment has different index Segment s5 = new DistalDendrite(cell3, 1, 1, 0); Assert.IsFalse(s4.Equals(s5)); Assert.IsTrue(s5.ToString().Equals("1")); Assert.AreEqual(-1, s4.CompareTo(s5)); Assert.AreEqual(1, s5.CompareTo(s4)); //Different type of segment Segment s6 = new ProximalDendrite(0); Assert.IsFalse(s5.Equals(s6)); Console.WriteLine(s4.CompareTo(s5)); }
public void SerializeDistalDendrite() { Cell cell = new Cell(1, 1, 1, 1, new CellActivity()); DistalDendrite distal = new DistalDendrite(cell, 1, 2, 2, 1.0, 100); //distal.Synapses.Add(new Synapse(cell, 1, 23, 1.0)); //distal.Synapses.Add(new Synapse(cell, 3, 27, 1.0)); using (StreamWriter sw = new StreamWriter($"ser_{nameof(SerializeDistalDendrite)}.txt")) { distal.Serialize(sw); } using (StreamReader sr = new StreamReader($"ser_{nameof(SerializeDistalDendrite)}.txt")) { DistalDendrite distal1 = DistalDendrite.Deserialize(sr); Assert.IsTrue(distal1.Equals(distal)); } }
public void SerializeDistalDendrite(int flatIdx, long lastUsedIteration, int ordinal, double synapsePermConnected, int numInputs) { Cell cell = new Cell(12, 14, 16, 18, new CellActivity()); var distSeg1 = new DistalDendrite(cell, 1, 2, 2, 1.0, 100); cell.DistalDendrites.Add(distSeg1); var distSeg2 = new DistalDendrite(cell, 44, 24, 34, 1.0, 100); cell.DistalDendrites.Add(distSeg2); Cell preSynapticcell = new Cell(11, 14, 16, 18, new CellActivity()); var synapse1 = new Synapse(cell, distSeg1.SegmentIndex, 23, 1.0); preSynapticcell.ReceptorSynapses.Add(synapse1); var synapse2 = new Synapse(cell, distSeg2.SegmentIndex, 27, 1.0); preSynapticcell.ReceptorSynapses.Add(synapse2); // Serializes the segment to file. using (StreamWriter sw = new StreamWriter($"ser_{nameof(SerializeDistalDendrite)}.txt")) { distSeg1.Serialize(sw); } using (StreamReader sr = new StreamReader($"ser_{nameof(SerializeDistalDendrite)}.txt")) { HtmSerializer2 ser = new HtmSerializer2(); DistalDendrite distSegment1 = ser.DeserializeDistalDendrite(sr); Assert.IsTrue(distSegment1.Equals(distSeg1)); } }