|
22 | 22 | import numpy as np |
23 | 23 | import pandas as pd |
24 | 24 | import pyarrow as pa |
25 | | -from packaging import version |
26 | 25 |
|
27 | | -from .. import config |
28 | 26 | from ..features import Features |
29 | 27 | from ..features.features import _ArrayXDExtensionType, _is_zero_copy_only, decode_nested_example, pandas_types_mapper |
30 | 28 | from ..table import Table |
@@ -304,49 +302,46 @@ def __repr__(self): |
304 | 302 | self._format_all() |
305 | 303 | return repr(self.data) |
306 | 304 |
|
307 | | - if config.PY_VERSION >= version.parse("3.9"): |
308 | | - # merging with the union ("|") operator is supported in Python 3.9+ |
309 | | - |
310 | | - def __or__(self, other): |
311 | | - if isinstance(other, LazyDict): |
312 | | - inst = self.copy() |
313 | | - other = other.copy() |
314 | | - other._format_all() |
315 | | - inst.keys_to_format -= other.data.keys() |
316 | | - inst.data = inst.data | other.data |
317 | | - return inst |
318 | | - if isinstance(other, dict): |
319 | | - inst = self.copy() |
320 | | - inst.keys_to_format -= other.keys() |
321 | | - inst.data = inst.data | other |
322 | | - return inst |
323 | | - return NotImplemented |
324 | | - |
325 | | - def __ror__(self, other): |
326 | | - if isinstance(other, LazyDict): |
327 | | - inst = self.copy() |
328 | | - other = other.copy() |
329 | | - other._format_all() |
330 | | - inst.keys_to_format -= other.data.keys() |
331 | | - inst.data = other.data | inst.data |
332 | | - return inst |
333 | | - if isinstance(other, dict): |
334 | | - inst = self.copy() |
335 | | - inst.keys_to_format -= other.keys() |
336 | | - inst.data = other | inst.data |
337 | | - return inst |
338 | | - return NotImplemented |
339 | | - |
340 | | - def __ior__(self, other): |
341 | | - if isinstance(other, LazyDict): |
342 | | - other = other.copy() |
343 | | - other._format_all() |
344 | | - self.keys_to_format -= other.data.keys() |
345 | | - self.data |= other.data |
346 | | - else: |
347 | | - self.keys_to_format -= other.keys() |
348 | | - self.data |= other |
349 | | - return self |
| 305 | + def __or__(self, other): |
| 306 | + if isinstance(other, LazyDict): |
| 307 | + inst = self.copy() |
| 308 | + other = other.copy() |
| 309 | + other._format_all() |
| 310 | + inst.keys_to_format -= other.data.keys() |
| 311 | + inst.data = inst.data | other.data |
| 312 | + return inst |
| 313 | + if isinstance(other, dict): |
| 314 | + inst = self.copy() |
| 315 | + inst.keys_to_format -= other.keys() |
| 316 | + inst.data = inst.data | other |
| 317 | + return inst |
| 318 | + return NotImplemented |
| 319 | + |
| 320 | + def __ror__(self, other): |
| 321 | + if isinstance(other, LazyDict): |
| 322 | + inst = self.copy() |
| 323 | + other = other.copy() |
| 324 | + other._format_all() |
| 325 | + inst.keys_to_format -= other.data.keys() |
| 326 | + inst.data = other.data | inst.data |
| 327 | + return inst |
| 328 | + if isinstance(other, dict): |
| 329 | + inst = self.copy() |
| 330 | + inst.keys_to_format -= other.keys() |
| 331 | + inst.data = other | inst.data |
| 332 | + return inst |
| 333 | + return NotImplemented |
| 334 | + |
| 335 | + def __ior__(self, other): |
| 336 | + if isinstance(other, LazyDict): |
| 337 | + other = other.copy() |
| 338 | + other._format_all() |
| 339 | + self.keys_to_format -= other.data.keys() |
| 340 | + self.data |= other.data |
| 341 | + else: |
| 342 | + self.keys_to_format -= other.keys() |
| 343 | + self.data |= other |
| 344 | + return self |
350 | 345 |
|
351 | 346 | def __copy__(self): |
352 | 347 | # Identical to `UserDict.__copy__` |
|
0 commit comments