Beispiel #1
0
def test_dimensionality():
    feature_list = [
        (features.StrokeCount(), 1),
        (
            features.ConstantPointCoordinates(strokes=4,
                                              points_per_stroke=20,
                                              fill_empty_with=0),
            160,
        ),
        (
            features.ConstantPointCoordinates(strokes=0,
                                              points_per_stroke=20,
                                              fill_empty_with=0),
            60,
        ),
        (
            features.ConstantPointCoordinates(strokes=0,
                                              points_per_stroke=20,
                                              pen_down=False),
            40,
        ),
        (features.AspectRatio(), 1),
        (features.Width(), 1),
        (features.Height(), 1),
        (features.Time(), 1),
        (features.CenterOfMass(), 2),
    ]
    for feat, dimension in feature_list:
        assert feat.get_dimension() == dimension
Beispiel #2
0
def constant_point_coordinates_test():
    """Test features.ConstantPointCoordinates."""
    f = features.ConstantPointCoordinates(strokes=0,
                                          points_per_stroke=2,
                                          pen_down=False)
    g = features.ConstantPointCoordinates(strokes=0,
                                          points_per_stroke=200,
                                          pen_down=False)
    recording = testhelper.get_symbol_as_handwriting(292934)
    f._features_without_strokes(recording)
    g._features_without_strokes(recording)
    space_evenly = preprocessing.SpaceEvenly()
    space_evenly(recording)
    f._features_without_strokes(recording)
Beispiel #3
0
def dimension_test():
    l = [(features.ConstantPointCoordinates(), 160),
         (features.FirstNPoints(), 162),  # TODO: Check
         (features.StrokeCount(), 1),
         (features.Ink(), 1)
         ]
    for alg, dimension in l:
        nose.tools.assert_equal(alg.get_dimension(), dimension)
Beispiel #4
0
def repr_and_str_test():
    l = [features.ConstantPointCoordinates(),
         features.FirstNPoints(),
         features.StrokeCount(),
         features.Ink()
         ]
    for alg in l:
        str(alg)
        repr(alg)
Beispiel #5
0
def test_dimension():
    algorithms = [
        (features.ConstantPointCoordinates(), 160),
        (features.FirstNPoints(), 162),  # TODO: Check
        (features.StrokeCount(), 1),
        (features.Ink(), 1),
    ]
    for algorithm, dimension in algorithms:
        assert algorithm.get_dimension() == dimension
Beispiel #6
0
def simple_execution_test():
    algorithms = [
        features.ConstantPointCoordinates(),
        features.ConstantPointCoordinates(strokes=0),
        features.FirstNPoints(),
        # features.Bitmap(),
        features.Ink(),
        features.AspectRatio(),
        features.Width(),
        features.Time(),
        features.CenterOfMass(),
        features.StrokeCenter(),
        features.StrokeCenter(8),
        features.StrokeIntersections(),
        features.ReCurvature()
    ]
    for algorithm in algorithms:
        recording = testhelper.get_symbol_as_handwriting(292934)
        algorithm(recording)
Beispiel #7
0
def test_repr_and_str():
    algorithms = [
        features.ConstantPointCoordinates(),
        features.FirstNPoints(),
        features.StrokeCount(),
        features.Ink(),
    ]
    for algorithm in algorithms:
        str(algorithm)
        repr(algorithm)
Beispiel #8
0
def print_featurelist_test():
    """Test features.print_featurelist."""
    feature_list = [
        features.StrokeCount(),
        features.ConstantPointCoordinates(strokes=4,
                                          points_per_stroke=20,
                                          fill_empty_with=0),
        features.ConstantPointCoordinates(strokes=0,
                                          points_per_stroke=20,
                                          fill_empty_with=0),
        features.ConstantPointCoordinates(strokes=0,
                                          points_per_stroke=20,
                                          pen_down=False),
        features.AspectRatio(),
        features.Width(),
        features.Height(),
        features.Time(),
        features.CenterOfMass()
    ]
    features.print_featurelist(feature_list)
Beispiel #9
0
def feature_detection_test():
    l = [{'StrokeCount': None},
         {'ConstantPointCoordinates':
          [{'strokes': 4},
           {'points_per_stroke': 81},
           {'fill_empty_with': 0},
           {'pen_down': False}]
          }
         ]
    correct = [features.StrokeCount(),
               features.ConstantPointCoordinates(strokes=4,
                                                 points_per_stroke=81,
                                                 fill_empty_with=0,
                                                 pen_down=False)]
    feature_list = features.get_features(l)
    # TODO: Not only compare lengths of lists but actual contents.
    nose.tools.assert_equal(len(feature_list), len(correct))
Beispiel #10
0
def features_detection_test():
    feature_queue = [{
        'StrokeCount': None
    }, {
        'ConstantPointCoordinates': [{
            'strokes': 4,
            'points_per_stroke': 20,
            'fill_empty_with': 0
        }]
    }]
    correct = [
        features.StrokeCount(),
        features.ConstantPointCoordinates(strokes=4,
                                          points_per_stroke=20,
                                          fill_empty_with=0)
    ]
    feature_list = features.get_features(feature_queue)
    # TODO: Not only compare lengths of lists but actual contents.
    nose.tools.assert_equal(len(feature_list), len(correct))
Beispiel #11
0
def test_feature_detection():
    queue = [
        {"StrokeCount": None},
        {
            "ConstantPointCoordinates": [
                {"strokes": 4},
                {"points_per_stroke": 81},
                {"fill_empty_with": 0},
                {"pen_down": False},
            ]
        },
    ]
    correct = [
        features.StrokeCount(),
        features.ConstantPointCoordinates(
            strokes=4, points_per_stroke=81, fill_empty_with=0, pen_down=False
        ),
    ]
    feature_list = features.get_features(queue)
    # TODO: Not only compare lengths of lists but actual contents.
    assert len(feature_list) == len(correct)
Beispiel #12
0
def test_features_detection():
    feature_queue = [
        {
            "StrokeCount": None
        },
        {
            "ConstantPointCoordinates": [{
                "strokes": 4,
                "points_per_stroke": 20,
                "fill_empty_with": 0
            }]
        },
    ]
    correct = [
        features.StrokeCount(),
        features.ConstantPointCoordinates(strokes=4,
                                          points_per_stroke=20,
                                          fill_empty_with=0),
    ]
    feature_list = features.get_features(feature_queue)
    # TODO: Not only compare lengths of lists but actual contents.
    assert len(feature_list) == len(correct)