8586878889909192939495
odorComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JComboBox source = (JComboBox)arg0.getSource(); Odor odr = (Odor)source.getSelectedItem(); if (getJNetwork() != null) { getJNetwork().setOdor(odr); getJNetwork().repaint();
131415161718192021222324
public class OdorTest { @Test public void testOdor() { Odor o = new Odor(); assert( o.getInputs() == null && o.getMean() == Double.NaN && o.getStandardDeviation() == Double.NaN && o.equals(new Odor())); }
272829303132333435
public void testGetMean() { double[] zscores = {0.1, 1.0, 1.5, 2.0, 2.5, 3.0}; SummedGaussian g = new SummedGaussian(zscores, Util.arraySum(zscores)); Odor o = new Odor(zscores.length, g); assert(o.getMean() == g.getMean() && o.getMean() == Util.arrayMean(zscores)); }
39404142434445464748
{ double[] zscores = {0.1, 1.0, 1.5, 2.0, 2.5, 3.0}; SummedGaussian g = new SummedGaussian(zscores, Util.arraySum(zscores)); Odor o = new Odor(zscores.length, g); assert(o.getStandardDeviation() == g.getStandardDeviation() && o.getStandardDeviation() == Util.standardDeviation(zscores)); }
104105106107108109110111112
public void testGetInputs() { double[] zscores = {0.1, 1.0, 1.5, 2.0, 2.5, 3.0}; SummedGaussian g = new SummedGaussian(zscores, Util.arraySum(zscores)); Odor o1 = new Odor(zscores.length, g); assert( Util.arrayContains(zscores,o1.getInputs())); }
112113114115116117118119120121122123124125126127128129
} @Test public void testEqualsObject() { Odor o1 = new Odor(); Odor o2 = new Odor(); assert( o1.equals(o2)); double[] zscores = {0.1, 1.0, 1.5, 2.0, 2.5, 3.0}; SummedGaussian g = new SummedGaussian(zscores, Util.arraySum(zscores)); o1 = new Odor(3, g); o2 = new Odor(3, g); assert (o1.equals(o2)); }
129130131132133134135136137138139140141142143144145146
} @Test public void testCompareTo() { Odor o1 = new Odor(); Odor o2 = new Odor(); assert( o1.compareTo(o2) == Integer.MIN_VALUE); double[] zscores = {0.1, 1.0, 1.5, 2.0, 2.5, 3.0}; SummedGaussian g = new SummedGaussian(zscores, Util.arraySum(zscores)); o1 = new Odor(3, g); o2 = new Odor(3, g); assert ( o1.compareTo(o2) != 0 ); }