Tell us what’s happening:
I finished my code.
but I get this error on a test when I run the code.
======================================================================
FAIL: test_plot_lines (test_module.LinePlotTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/boilerplate-sea-level-predictor/test_module.py", line 35, in test_plot_lines
np.testing.assert_almost_equal(actual, expected, 7, "Expected different line for first line of best fit.")
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/home/runner/boilerplate-sea-level-predictor/venv/lib/python3.10/site-packages/numpy/testing/_private/utils.py", line 588, in assert_almost_equal
return assert_array_almost_equal(actual, desired, decimal, err_msg)
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/home/runner/boilerplate-sea-level-predictor/venv/lib/python3.10/site-packages/numpy/testing/_private/utils.py", line 1099, in assert_array_almost_equal
assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/home/runner/boilerplate-sea-level-predictor/venv/lib/python3.10/site-packages/numpy/testing/_private/utils.py", line 778, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not almost equal to 7 decimals
Expected different line for first line of best fit.
(shapes (134,), (171,) mismatch)
x: array([-0.542124 , -0.4790794, -0.4160349, -0.3529903, -0.2899457,
-0.2269011, -0.1638565, -0.1008119, -0.0377674, 0.0252772,
0.0883218, 0.1513664, 0.214411 , 0.2774556, 0.3405002,...
y: array([-0.542124 , -0.4790794, -0.4160349, -0.3529903, -0.2899457,
-0.2269011, -0.1638565, -0.1008119, -0.0377674, 0.0252772,
0.0883218, 0.1513664, 0.214411 , 0.2774556, 0.3405002,...
----------------------------------------------------------------------
Ran 4 tests in 2.917s
FAILED (failures=1)
I can’t understand why my code failed this test and how to fix it. Can anybody help me, I would be grateful.
Challenge: Data Analysis with Python Projects - Sea Level Predictor
Link to the challenge: