atdata 0.1.1a3__tar.gz → 0.1.2a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {atdata-0.1.1a3 → atdata-0.1.2a1}/PKG-INFO +1 -1
- {atdata-0.1.1a3 → atdata-0.1.2a1}/pyproject.toml +1 -1
- {atdata-0.1.1a3 → atdata-0.1.2a1}/src/atdata/__init__.py +1 -0
- {atdata-0.1.1a3 → atdata-0.1.2a1}/src/atdata/dataset.py +38 -1
- {atdata-0.1.1a3 → atdata-0.1.2a1}/tests/test_dataset.py +30 -1
- {atdata-0.1.1a3 → atdata-0.1.2a1}/.github/workflows/uv-publish-pypi.yml +0 -0
- {atdata-0.1.1a3 → atdata-0.1.2a1}/.github/workflows/uv-test.yml +0 -0
- {atdata-0.1.1a3 → atdata-0.1.2a1}/.gitignore +0 -0
- {atdata-0.1.1a3 → atdata-0.1.2a1}/.python-version +0 -0
- {atdata-0.1.1a3 → atdata-0.1.2a1}/LICENSE +0 -0
- {atdata-0.1.1a3 → atdata-0.1.2a1}/README.md +0 -0
- {atdata-0.1.1a3 → atdata-0.1.2a1}/src/atdata/_helpers.py +0 -0
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import webdataset as wds
|
|
7
7
|
|
|
8
|
+
import functools
|
|
8
9
|
from dataclasses import dataclass
|
|
9
10
|
import uuid
|
|
10
11
|
|
|
@@ -415,4 +416,40 @@ class Dataset( Generic[ST] ):
|
|
|
415
416
|
# This default implementation simply creates a list one sample at a time
|
|
416
417
|
# """
|
|
417
418
|
# assert cls.batch_class is not None, 'No batch class specified'
|
|
418
|
-
# return cls.batch_class( **batch )
|
|
419
|
+
# return cls.batch_class( **batch )
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
##
|
|
423
|
+
# Shortcut decorators
|
|
424
|
+
|
|
425
|
+
# def packable( cls ):
|
|
426
|
+
# """TODO"""
|
|
427
|
+
|
|
428
|
+
# def decorator( cls ):
|
|
429
|
+
# # Create a new class dynamically
|
|
430
|
+
# # The new class inherits from the new_parent_class first, then the original cls
|
|
431
|
+
# new_bases = (PackableSample,) + cls.__bases__
|
|
432
|
+
# new_cls = type(cls.__name__, new_bases, dict(cls.__dict__))
|
|
433
|
+
|
|
434
|
+
# # Optionally, update __module__ and __qualname__ for better introspection
|
|
435
|
+
# new_cls.__module__ = cls.__module__
|
|
436
|
+
# new_cls.__qualname__ = cls.__qualname__
|
|
437
|
+
|
|
438
|
+
# return new_cls
|
|
439
|
+
# return decorator
|
|
440
|
+
|
|
441
|
+
def packable( cls ):
|
|
442
|
+
"""TODO"""
|
|
443
|
+
|
|
444
|
+
##
|
|
445
|
+
|
|
446
|
+
as_dataclass = dataclass( cls )
|
|
447
|
+
|
|
448
|
+
class as_packable( as_dataclass, PackableSample ):
|
|
449
|
+
pass
|
|
450
|
+
|
|
451
|
+
as_packable.__name__ = cls.__name__
|
|
452
|
+
|
|
453
|
+
##
|
|
454
|
+
|
|
455
|
+
return as_packable
|
|
@@ -51,7 +51,7 @@ test_cases = [
|
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
'SampleType': NumpyTestSample,
|
|
54
|
-
'sample_data':
|
|
54
|
+
'sample_data':
|
|
55
55
|
{
|
|
56
56
|
'label': 9_001,
|
|
57
57
|
'image': np.random.randn( 1024, 1024 ),
|
|
@@ -89,6 +89,35 @@ def test_create_sample(
|
|
|
89
89
|
|
|
90
90
|
#
|
|
91
91
|
|
|
92
|
+
def test_decorator_syntax():
|
|
93
|
+
"""Test use of decorator syntax for sample types"""
|
|
94
|
+
|
|
95
|
+
@atdata.packable
|
|
96
|
+
class BasicTestSampleDecorated:
|
|
97
|
+
name: str
|
|
98
|
+
position: int
|
|
99
|
+
value: float
|
|
100
|
+
|
|
101
|
+
@atdata.packable
|
|
102
|
+
class NumpyTestSampleDecorated:
|
|
103
|
+
label: int
|
|
104
|
+
image: NDArray
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
|
|
108
|
+
test_create_sample( BasicTestSampleDecorated, {
|
|
109
|
+
'name': 'Hello, world!',
|
|
110
|
+
'position': 42,
|
|
111
|
+
'value': 1024.768,
|
|
112
|
+
} )
|
|
113
|
+
|
|
114
|
+
test_create_sample( NumpyTestSampleDecorated, {
|
|
115
|
+
'label': 9_001,
|
|
116
|
+
'image': np.random.randn( 1024, 1024 ),
|
|
117
|
+
} )
|
|
118
|
+
|
|
119
|
+
#
|
|
120
|
+
|
|
92
121
|
@pytest.mark.parametrize(
|
|
93
122
|
('SampleType', 'sample_data', 'sample_wds_stem'),
|
|
94
123
|
[ (case['SampleType'], case['sample_data'], case['sample_wds_stem'])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|