code: def test_errors(data):
      """Tests errors."""
      # y is not a column vector.
      with LogCapture(LOGGER_NAME) as log_capture:
          qr = QuantileRegression()
          qr.fit(data["x"], data["y"].reshape(-1, 1))
          log_capture.check_present(
              (
                  LOGGER_NAME,
                  "WARNING",
                  "A column-vector y was passed when a 1d array was expected. "
                  "Please change the shape of y to (n_samples,), "
                  "for example using ravel().",
              )
          )
      # Shapes of x and y do not match.
      with pytest.raises(
          ValueError, match="The shapes of x and y do not match. "
      ):
          qr = QuantileRegression()
          qr.fit(data["x"], data["y"][:5])
      # Quantile not in range.
      with pytest.raises(
          ValueError, match="Quantile q must be between 0.0 and 1.0,"
      ):
          qr = QuantileRegression(quantile=-0.1)
          qr.fit(data["x"], data["y"])
      # Sample weight length wrong.
      with pytest.raises(
          ValueError,
          match="The length of sample weight must match the number of observations",
      ):
          qr = QuantileRegression(sample_weight=[1, 2])
          qr.fit(data["x"], data["y"])
      # Feature weight length wrong.
      with pytest.raises(
          ValueError,
          match="The length of feature weight must match the number of features",
      ):
          qr = QuantileRegression(feature_weight=[1, 2])
          qr.fit(data["x"], data["y"])
      # Max iterations not in range.
      with pytest.raises(
          ValueError, match="max_iter must be a positive integer,"
      ):
          qr = QuantileRegression(max_iter=0)
          qr.fit(data["x"], data["y"])
      # Tolerance not in range.
      with pytest.raises(
          ValueError, match="tol must be a positive number, found"
      ):
          qr = QuantileRegression(tol=-1)
          qr.fit(data["x"], data["y"])
  
file_path: greykite/greykite/tests/algo/common/test_l1_quantile_regression.py
imports: import numpy
  import pytest
  from testfixtures import LogCapture
  from greykite.algo.common.l1_quantile_regression import QuantileRegression
  from greykite.algo.common.l1_quantile_regression import l1_quantile_regression
  from greykite.algo.common.l1_quantile_regression import ordinary_quantile_regression
  from greykite.common.logging import LOGGER_NAME
label_desc: Use image node_id 8 for calling a global function with example usage: test_errors(data) without return types