Exemplo n.º 1
0
def mock_data_plot():
    """
    Do a plot of the mock data supplied in the question
    """
    my_data = md.data()
    data_array = md.split_data(my_data)
    # print(data_array)
    m, b = linear_fit(data_array)
    plot_fit(data_array, m, b)
Exemplo n.º 2
0
    def calc_calibrations(self, sensor_data):
        self.log("calculating sensor calibrations")
        self.log(sensor_data)
        calibrations = []
        for sensor_id, readings in sensor_data:
            m, b = linear_fit(readings)
            calibrations.append(Calibration(sensor_id, 1, readings, m, b))

        self.log(calibrations)
                    
        return calibrations
Exemplo n.º 3
0
def test_unit_line():
    points = [
        (1, 1),
        (2, 2),
        (3, 3),
        (4, 4),
    ]

    m, b = linear_fit(points)

    assert np.isclose(m, 1)
    assert np.isclose(b, 0)
Exemplo n.º 4
0
def test_flat_line():
    points = [
        (1, 2),
        (2, 1),
        (3, 2),
        (4, 1),
        (5, 2),
    ]

    m, b = linear_fit(points)

    assert np.isclose(m, 0)
    assert np.isclose(b, 1.6)
Exemplo n.º 5
0
def simple_plot():
    """
    Do a plot of the simple point cloud
    """
    points = [
        (1, 2),
        (2, 1),
        (3, 2),
        (4, 1),
        (5, 2),
    ]

    m, b = linear_fit(points)

    print(m)
    print(b)

    plot_fit(points, m, b)