| 114 | ], |
| 115 | ) |
| 116 | def test_trendline_nan_values(backend, mode, options): |
| 117 | start_date = 1970 |
| 118 | df = ( |
| 119 | nw.from_native(px.data.gapminder(return_type=backend)) |
| 120 | .filter(nw.col("continent") == "Oceania") |
| 121 | .with_columns( |
| 122 | pop=nw.when(nw.col("year") >= start_date) |
| 123 | .then(nw.col("pop")) |
| 124 | .otherwise(None) |
| 125 | ) |
| 126 | ) |
| 127 | |
| 128 | fig = px.scatter( |
| 129 | df.to_native(), |
| 130 | x="year", |
| 131 | y="pop", |
| 132 | color="country", |
| 133 | trendline=mode, |
| 134 | trendline_options=options, |
| 135 | ) |
| 136 | for trendline in fig["data"][1::2]: |
| 137 | assert trendline.x[0] >= start_date |
| 138 | assert len(trendline.x) == len(trendline.y) |
| 139 | |
| 140 | |
| 141 | def test_ols_trendline_slopes(): |