Пример #1
0
def test_calculate_bin_centers_raises_not_1d():
    """
    Test we get a ValueError with a non-1D array.

    """
    a = np.arange(20).reshape((4, 5))
    binning.calculate_bin_centers(a)
Пример #2
0
def test_calculate_bin_centers_raises_1_val():
    """
    Test we get a ValueError with a single value array.

    """
    a = np.array([5])
    binning.calculate_bin_centers(a)
Пример #3
0
def test_calculate_bin_centers_raises_1_val():
    """
    Test we get a ValueError with a single value array.

    """
    a = np.array([5])
    binning.calculate_bin_centers(a)
Пример #4
0
def test_calculate_bin_centers_raises_not_1d():
    """
    Test we get a ValueError with a non-1D array.

    """
    a = np.arange(20).reshape((4, 5))
    binning.calculate_bin_centers(a)
Пример #5
0
def test_calculate_bin_centers_two_val():
    """
    Test the edge case where there is only one bin.

    """
    edges = [1, 2]
    centers = [1.5]

    np.testing.assert_array_equal(binning.calculate_bin_centers(edges),
                                  centers)
Пример #6
0
def test_center_edge_center_roundtrip():
    """
    Test that we can start with centers and roundtrip to the same centers.

    """
    centers = [1, 2, 4, 10, 20]
    calc_edges = binning.calculate_bin_edges(centers)
    calc_centers = binning.calculate_bin_centers(calc_edges)

    np.testing.assert_array_equal(calc_centers, centers)
Пример #7
0
def test_calculate_bin_centers_two_val():
    """
    Test the edge case where there is only one bin.

    """
    edges = [1, 2]
    centers = [1.5]

    np.testing.assert_array_equal(binning.calculate_bin_centers(edges),
                                  centers)
Пример #8
0
def test_center_edge_center_roundtrip():
    """
    Test that we can start with centers and roundtrip to the same centers.

    """
    centers = [1, 2, 4, 10, 20]
    calc_edges = binning.calculate_bin_edges(centers)
    calc_centers = binning.calculate_bin_centers(calc_edges)

    np.testing.assert_array_equal(calc_centers, centers)
Пример #9
0
def test_calculate_bin_centers():
    edges = [1, 2, 4, 10, 20]
    centers = [1.5, 2.5, 5.5, 14.5]

    np.testing.assert_array_equal(binning.calculate_bin_centers(edges),
                                  centers)
Пример #10
0
def test_calculate_bin_centers():
    edges = [1, 2, 4, 10, 20]
    centers = [1.5, 2.5, 5.5, 14.5]

    np.testing.assert_array_equal(binning.calculate_bin_centers(edges),
                                  centers)