Skip to content

Commit ee51a52

Browse files
committed
Remove code for Python < 3.9
1 parent a256b85 commit ee51a52

File tree

3 files changed

+46
-50
lines changed

3 files changed

+46
-50
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
AUDIO_REQUIRE = [
142142
"soundfile>=0.12.1",
143143
"librosa",
144-
"soxr>=0.4.0; python_version>='3.9'", # Supports numpy-2
144+
"soxr>=0.4.0", # Supports numpy-2
145145
]
146146

147147
VISION_REQUIRE = [

src/datasets/formatting/formatting.py

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -304,49 +304,46 @@ def __repr__(self):
304304
self._format_all()
305305
return repr(self.data)
306306

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
307+
def __or__(self, other):
308+
if isinstance(other, LazyDict):
309+
inst = self.copy()
310+
other = other.copy()
311+
other._format_all()
312+
inst.keys_to_format -= other.data.keys()
313+
inst.data = inst.data | other.data
314+
return inst
315+
if isinstance(other, dict):
316+
inst = self.copy()
317+
inst.keys_to_format -= other.keys()
318+
inst.data = inst.data | other
319+
return inst
320+
return NotImplemented
321+
322+
def __ror__(self, other):
323+
if isinstance(other, LazyDict):
324+
inst = self.copy()
325+
other = other.copy()
326+
other._format_all()
327+
inst.keys_to_format -= other.data.keys()
328+
inst.data = other.data | inst.data
329+
return inst
330+
if isinstance(other, dict):
331+
inst = self.copy()
332+
inst.keys_to_format -= other.keys()
333+
inst.data = other | inst.data
334+
return inst
335+
return NotImplemented
336+
337+
def __ior__(self, other):
338+
if isinstance(other, LazyDict):
339+
other = other.copy()
340+
other._format_all()
341+
self.keys_to_format -= other.data.keys()
342+
self.data |= other.data
343+
else:
344+
self.keys_to_format -= other.keys()
345+
self.data |= other
346+
return self
350347

351348
def __copy__(self):
352349
# Identical to `UserDict.__copy__`

tests/test_arrow_dataset.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3142,12 +3142,11 @@ def test_tf_dataset_options(self, in_memory):
31423142
self.assertEqual(len(tf_dataset), 2) # One batch of 3 and one batch of 1
31433143
self.assertEqual(len(tf_dataset_with_drop), 1) # Incomplete batch of 1 is dropped
31443144
# Test that `NotImplementedError` is raised `batch_size` is None and `num_workers` is > 0
3145-
if sys.version_info >= (3, 8):
3146-
with self._create_dummy_dataset(in_memory, tmp_dir.name, multiple_columns=True) as dset:
3147-
with self.assertRaisesRegex(
3148-
NotImplementedError, "`batch_size` must be specified when using multiple workers"
3149-
):
3150-
dset.to_tf_dataset(columns="col_1", batch_size=None, num_workers=2)
3145+
with self._create_dummy_dataset(in_memory, tmp_dir.name, multiple_columns=True) as dset:
3146+
with self.assertRaisesRegex(
3147+
NotImplementedError, "`batch_size` must be specified when using multiple workers"
3148+
):
3149+
dset.to_tf_dataset(columns="col_1", batch_size=None, num_workers=2)
31513150
del tf_dataset # For correct cleanup
31523151
del tf_dataset_with_drop
31533152

0 commit comments

Comments
 (0)