Пример #1
0
 def _():
     assert bf.frequency([1, 1.0, '1', '1.0'], cast=False) == {
         1: 1,
         1.0: 1,
         '1': 1,
         '1.0': 1
     }
Пример #2
0
def graph_frequency_histogram(arr,
                              bar_color='green',
                              title='Graph of Frequencies'):
    """
    This function generates a graph of the frequencies of the elements in the input array, arr
    This function utilizes matplotlib and will produce errors if the package is not installed
    To install matplotlib, use 'pip install matplotlib'
    """
    plt.style.use('ggplot')

    dictionary = bf.frequency(arr)
    keys = dictionary.keys()
    values = [dictionary[i] for i in keys]
    x_pos = [i for i in range(len(keys))]

    plt.bar(x_pos, values, color=bar_color)
    plt.title(title)
    plt.xticks(x_pos, keys)
    plt.show()
Пример #3
0
 def _():
     assert bf.frequency([1, 1.0, '1', '1.0'], cast=True) == {1.0: 4}
Пример #4
0
 def _():
     assert bf.frequency([1, 2]) == {1: 1, 2: 1}
Пример #5
0
 def _():
     assert bf.frequency([1, 1]) == {1: 2}
Пример #6
0
 def _():
     assert bf.frequency([]) == {}