source: branches/MetisMQI/src/test/java/weka/filters/unsupervised/attribute/NumericToNominalTest.java

Last change on this file was 29, checked in by gnappo, 15 years ago

Taggata versione per la demo e aggiunto branch.

File size: 2.2 KB
Line 
1/*
2 *    This program is free software; you can redistribute it and/or modify
3 *    it under the terms of the GNU General Public License as published by
4 *    the Free Software Foundation; either version 2 of the License, or
5 *    (at your option) any later version.
6 *
7 *    This program is distributed in the hope that it will be useful,
8 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *    GNU General Public License for more details.
11 *
12 *    You should have received a copy of the GNU General Public License
13 *    along with this program; if not, write to the Free Software
14 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17/*
18 * Copyright (C) 2006 University of Waikato, Hamilton, New Zealand
19 */
20
21package weka.filters.unsupervised.attribute;
22
23import weka.core.Attribute;
24import weka.core.Instances;
25import weka.filters.AbstractFilterTest;
26import weka.filters.Filter;
27
28import junit.framework.Test;
29import junit.framework.TestSuite;
30
31/**
32 * Tests NumericToNominal. Run from the command line with:<p>
33 * java weka.filters.unsupervised.attribute.NumericToNominalTest
34 *
35 * @author FracPete (fracpete at waikato dot ac dot nz)
36 * @version $Revision: 1.2 $
37 */
38public class NumericToNominalTest extends AbstractFilterTest {
39 
40  public NumericToNominalTest(String name) { 
41    super(name);
42  }
43
44  /** Creates a default NumericToNominal */
45  public Filter getFilter() {
46    return new NumericToNominal();
47  }
48
49  public void testTypical() {
50    Instances result = useFilter();
51    // Number of attributes and instances shouldn't change
52    assertEquals(m_Instances.numAttributes(), result.numAttributes());
53    assertEquals(m_Instances.numInstances(), result.numInstances());
54    // no date and numeric attributes should remain
55    if (result.checkForAttributeType(Attribute.DATE))
56      fail("Date attribute(s) left over!");
57    if (result.checkForAttributeType(Attribute.NUMERIC))
58      fail("Numeric attribute(s) left over!");
59  }
60
61  public static Test suite() {
62    return new TestSuite(NumericToNominalTest.class);
63  }
64
65  public static void main(String[] args){
66    junit.textui.TestRunner.run(suite());
67  }
68}
Note: See TracBrowser for help on using the repository browser.