Wraps of Narwhals generate_temporary_column_name to generate a token which is guaranteed to not be in columns, nor in [col + token for col in columns]
(n_bytes, columns)
| 187 | |
| 188 | |
| 189 | def _generate_temporary_column_name(n_bytes, columns) -> str: |
| 190 | """Wraps of Narwhals generate_temporary_column_name to generate a token |
| 191 | which is guaranteed to not be in columns, nor in [col + token for col in columns] |
| 192 | """ |
| 193 | counter = 0 |
| 194 | while True: |
| 195 | # This is guaranteed to not be in columns by Narwhals |
| 196 | token = nw.generate_temporary_column_name(n_bytes, columns=columns) |
| 197 | |
| 198 | # Now check that it is not in the [col + token for col in columns] list |
| 199 | if token not in {f"{c}{token}" for c in columns}: |
| 200 | return token |
| 201 | |
| 202 | counter += 1 |
| 203 | if counter > 100: |
| 204 | msg = ( |
| 205 | "Internal Error: Plotly was not able to generate a column name with " |
| 206 | f"{n_bytes=} and not in {columns}.\n" |
| 207 | "Please report this to " |
| 208 | "https://github.com/plotly/plotly.py/issues/new and we will try to " |
| 209 | "replicate and fix it." |
| 210 | ) |
| 211 | raise AssertionError(msg) |
| 212 | |
| 213 | |
| 214 | def get_decorated_label(args, column, role): |
no outgoing calls
no test coverage detected