code: def test_ols_trendline_slopes():
      fig = px.scatter(x=[0, 1], y=[0, 1], trendline="ols")
      # should be "y = 1 * x + 0" but sometimes is some tiny number instead
      assert "y = 1 * x + " in fig.data[1].hovertemplate
      results = px.get_trendline_results(fig)
      params = results["px_fit_results"].iloc[0].params
      assert np.all(np.isclose(params, [0, 1]))
  
      fig = px.scatter(x=[0, 1], y=[1, 2], trendline="ols")
      assert "y = 1 * x + 1<br>" in fig.data[1].hovertemplate
      results = px.get_trendline_results(fig)
      params = results["px_fit_results"].iloc[0].params
      assert np.all(np.isclose(params, [1, 1]))
  
      fig = px.scatter(
          x=[0, 1],
          y=[1, 2],
          trendline="ols",
          trendline_options=dict(add_constant=False),
      )
      assert "y = 2 * x<br>" in fig.data[1].hovertemplate
      results = px.get_trendline_results(fig)
      params = results["px_fit_results"].iloc[0].params
      assert np.all(np.isclose(params, [2]))
  
      fig = px.scatter(
          x=[1, 1],
          y=[0, 0],
          trendline="ols",
          trendline_options=dict(add_constant=False),
      )
      assert "y = 0 * x<br>" in fig.data[1].hovertemplate
      results = px.get_trendline_results(fig)
      params = results["px_fit_results"].iloc[0].params
      assert np.all(np.isclose(params, [0]))
  
      fig = px.scatter(x=[1, 1], y=[0, 0], trendline="ols")
      assert "y = 0<br>" in fig.data[1].hovertemplate
      results = px.get_trendline_results(fig)
      params = results["px_fit_results"].iloc[0].params
      assert np.all(np.isclose(params, [0]))
  
      fig = px.scatter(x=[1, 2], y=[0, 0], trendline="ols")
      assert "y = 0 * x + 0<br>" in fig.data[1].hovertemplate
      fig = px.scatter(x=[0, 0], y=[1, 1], trendline="ols")
      assert "y = 0 * x + 1<br>" in fig.data[1].hovertemplate
      fig = px.scatter(x=[0, 0], y=[1, 2], trendline="ols")
      assert "y = 0 * x + 1.5<br>" in fig.data[1].hovertemplate
  
file_path: plotly.py/packages/python/plotly/plotly/tests/test_optional/test_px/test_trendline.py
imports: import plotly.express
  import numpy
  import pandas
  import pytest
  from datetime import datetime
label_desc: Use image node_id 4 for calling a global function with example usage: test_ols_trendline_slopes() without return types