def test_mean_attack_per_type():
    """
    Tests the output of both versions of mean_attack_per_type() function.
    """
    answer_1 = {'water': 140.5, 'fire': 47.5}
    answer_2 = ({
        'normal': 108.0,
        'fire': 99.4,
        'water': 99.75,
        'fighting': 99.66666666666667,
        'grass': 105.3529411764706,
        'poison': 121.75,
        'bug': 25.0,
        'fairy': 76.33333333333333,
        'psychic': 114.83333333333333,
        'rock': 84.85714285714286,
        'flying': 110.83333333333333,
        'ghost': 88.0,
        'ground': 116.6,
        'electric': 64.0
    })

    # Test Part 0 - Manual
    print('Test mean_attack_per_type from Part 0 - Manual')

    assert_equals(answer_1, hw2_manual.mean_attack_per_type(data_m1))
    assert_equals(answer_2, hw2_manual.mean_attack_per_type(data_m2))

    # Test Part 1 - Pandas
    print('Test mean_attack_per_type from Part 1 - Pandas')

    assert_equals(answer_1, hw2_pandas.mean_attack_per_type(data_p1))
    assert_equals(answer_2, hw2_pandas.mean_attack_per_type(data_p2))
示例#2
0
def test_mean_attack_per_type():
    """
    Tests the function: mean_attack_per_type
    """
    print('Testing mean_attack_per_type')

    # Cases from the made up "spec" for this problem
    assert_equals({
        'water': 140.5,
        'fire': 47.5
    }, hw2_manual.mean_attack_per_type(data1))
    assert_equals({
        'water': 140.5,
        'fire': 47.5
    }, hw2_pandas.mean_attack_per_type(data2))
    # Additional two cases
    assert_equals(
        {
            'fighting': 20.0,
            'fire': 63.666666666666664,
            'normal': 104.0,
            'water': 130.33333333333334
        }, hw2_manual.mean_attack_per_type(data3))
    assert_equals(
        {
            'fighting': 20.0,
            'fire': 63.666666666666664,
            'normal': 104.0,
            'water': 130.33333333333334
        }, hw2_pandas.mean_attack_per_type(data4))
示例#3
0
def test_mean_attack_per_type():
    # manual
    assert_equals({
        'fire': 47.5,
        'water': 140.5
    }, hw2_manual.mean_attack_per_type(_pokemon_test))
    assert_equals({'normal': 104}, hw2_manual.mean_attack_per_type(_single))
    # pandas
    assert_equals({
        'fire': 47.5,
        'water': 140.5
    }, hw2_pandas.mean_attack_per_type(_pokemon_test_df))
    assert_equals({'normal': 104}, hw2_pandas.mean_attack_per_type(_single_df))
示例#4
0
def test_mean_attack_per_type():
    """
    Test the function mean_attack_per_type
    """
    print('Testing mean_attack_per_type')

    assert_equals({'water': 140.5, 'fire': 47.5},
                  hw2_manual.mean_attack_per_type(data1))
    assert_equals({'water': 140.5, 'fire': 47.5},
                  hw2_pandas.mean_attack_per_type(data2))
    assert_equals({'fighting': 20, 'fire': 79, 'grass': 105, 'normal': 68,
                   'poison': 30, 'water': 110},
                  hw2_manual.mean_attack_per_type(data5))
    assert_equals({'fighting': 20, 'fire': 79, 'grass': 105, 'normal': 68,
                   'poison': 30, 'water': 110},
                  hw2_pandas.mean_attack_per_type(data6))
示例#5
0
def test_manual_mean_attack_per_type():
    '''
    Tests the manual mean_attack_per_type function
    '''

    test_data = parse(POKEMON_TEST_FILE)
    my_data = parse(MY_POKEMON_FILE)
    print('Testing mean_attack_per_type')

    # Spec test
    expected = {'water': 140.5, 'fire': 47.5}
    received = hw2_manual.mean_attack_per_type(test_data)

    assert_equals(expected, received)

    # My test
    expected = {'water': 140.5, 'fire': 47.5, 'pyschic': 40, 'normal': 0}
    received = hw2_manual.mean_attack_per_type(my_data)

    assert_equals(expected, received)
示例#6
0
def test_mean_attack_per_type():
    '''
    Test mean_attack_per_type funciton.
    '''
    print("test_mean_attack_per_type")
    print('Part0')
    assert_equals({'water': 140.5, 'fire': 47.5},
                  hw2_manual.mean_attack_per_type(parsed_data))
    assert_equals({'bug': 25.0, 'electric': 64.0, 'fairy': 76.33,
                   'fighting': 99.67, 'fire': 99.31, 'flying': 110.83,
                   'ghost': 88.0, 'grass': 97.0, 'ground': 110.25,
                   'normal': 119.88, 'poison': 123.7, 'psychic': 127.75,
                   'rock': 88.17, 'water': 101.8},
                  hw2_manual.mean_attack_per_type(parsed_data2))
    print('Part1')
    assert_equals({'water': 140.5, 'fire': 47.5},
                  hw2_pandas.mean_attack_per_type(DATA))
    assert_equals({'bug': 25.0, 'electric': 64.0, 'fairy': 76.33,
                   'fighting': 99.67, 'fire': 99.31, 'flying': 110.83,
                   'ghost': 88.0, 'grass': 97.0, 'ground': 110.25,
                   'normal': 119.88, 'poison': 123.7, 'psychic': 127.75,
                   'rock': 88.17, 'water': 101.8},
                  hw2_pandas.mean_attack_per_type(DATA2))
示例#7
0
def part0():
    """
    Calculates various statistics about the Pokemon dataset using
    the implementation in Part 0.
    """
    print('=== Starting Part 0 ===')
    data = cse163_utils.parse(DATA)

    print('Number of species:', hw2_manual.species_count(data))
    print('Highest level pokemon:', hw2_manual.max_level(data))
    print('Low-level Pokemon', hw2_manual.filter_range(data, 1, 9))
    print('Average attack for fire types',
          hw2_manual.mean_attack_for_type(data, 'fire'))
    print('Count of each Pokemon type:')
    print(hw2_manual.count_types(data))
    print('Highest stage for each Pokemon type')
    print(hw2_manual.highest_stage_per_type(data))
    print('Average attack for each Pokemon type')
    print(hw2_manual.mean_attack_per_type(data))