Skip to content

Features: Store #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 226 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
226 commits
Select commit Hold shift + click to select a range
381630d
Update features.py
giovannivolpe Jun 18, 2025
c6132f4
Update features.py
giovannivolpe Jun 18, 2025
4b68ce1
Update features.py
giovannivolpe Jun 18, 2025
21044e8
Update features.py
giovannivolpe Jun 22, 2025
0f55b17
Update test_features.py
giovannivolpe Jun 22, 2025
017f21e
Update features.py
giovannivolpe Jun 22, 2025
3e4a546
Value
giovannivolpe Jun 23, 2025
83bb491
Update test_features.py
giovannivolpe Jun 23, 2025
8851004
remove __gpu_compatible__
giovannivolpe Jun 23, 2025
c806cfd
Update features.py
giovannivolpe Jun 23, 2025
a1f71d7
Update test_features.py
giovannivolpe Jun 23, 2025
b1ca6ca
Update features.py
giovannivolpe Jun 23, 2025
0a78b0f
Update test_features.py
giovannivolpe Jun 23, 2025
2ea065b
Update aberrations.py
giovannivolpe Jun 23, 2025
d1b8d34
Update optics.py
giovannivolpe Jun 23, 2025
84fecbd
Update image.py
giovannivolpe Jun 23, 2025
6eafa18
Update holography.py
giovannivolpe Jun 23, 2025
addebc9
Update features.py
giovannivolpe Jun 23, 2025
15cdd3c
Update features.py
giovannivolpe Jun 23, 2025
ef06761
Update test_features.py
giovannivolpe Jun 24, 2025
c8b3df6
Update features.py
giovannivolpe Jun 24, 2025
17e3921
Update test_features.py
giovannivolpe Jun 24, 2025
83a3566
Update features.py
giovannivolpe Jun 24, 2025
158f247
Update test_features.py
giovannivolpe Jun 24, 2025
00533aa
Update features.py
giovannivolpe Jun 24, 2025
910dae0
Update test_features.py
giovannivolpe Jun 24, 2025
755e09b
Update features.py
giovannivolpe Jun 24, 2025
046b6e2
Update features.py
giovannivolpe Jun 24, 2025
0c83f7c
Update features.py
giovannivolpe Jun 24, 2025
b2da196
Update features.py
giovannivolpe Jun 24, 2025
5730015
Update test_features.py
giovannivolpe Jun 24, 2025
0c16b48
Update features.py
giovannivolpe Jun 24, 2025
c8319d3
Update features.py
giovannivolpe Jun 24, 2025
01fe26d
Update test_features.py
giovannivolpe Jun 24, 2025
c9c418a
Update test_features.py
giovannivolpe Jun 24, 2025
d414d40
Update features.py
giovannivolpe Jun 24, 2025
5179396
Update features.py
giovannivolpe Jun 24, 2025
62a4507
Update test_features.py
giovannivolpe Jun 24, 2025
1b8a24c
Update features.py
giovannivolpe Jun 25, 2025
66108d8
Update test_features.py
giovannivolpe Jun 25, 2025
5fbb7cd
Update test_features.py
giovannivolpe Jun 25, 2025
6c744fb
Update features.py
giovannivolpe Jun 25, 2025
5224632
Update test_features.py
giovannivolpe Jun 25, 2025
4b127ef
Update features.py
giovannivolpe Jun 25, 2025
0edf8fd
Update test_features.py
giovannivolpe Jun 25, 2025
c827935
Update features.py
giovannivolpe Jun 25, 2025
6f65d74
Update features.py
giovannivolpe Jun 25, 2025
63093f9
Update test_features.py
giovannivolpe Jun 25, 2025
3f8a9cf
Update features.py
giovannivolpe Jun 25, 2025
3af492b
Update features.py
giovannivolpe Jun 25, 2025
ae805ee
Update test_features.py
giovannivolpe Jun 25, 2025
7a5b83f
Update features.py
giovannivolpe Jun 27, 2025
1cf1973
Update test_features.py
giovannivolpe Jun 27, 2025
27a76b1
Update features.py
giovannivolpe Jun 27, 2025
927f6ab
Update features.py
giovannivolpe Jun 27, 2025
7040b1c
Update test_features.py
giovannivolpe Jun 27, 2025
bfd6852
Update features.py
giovannivolpe Jun 27, 2025
f90f2c1
Update features.py
giovannivolpe Jun 27, 2025
f25fc1c
Update test_features.py
giovannivolpe Jun 27, 2025
65773d0
Update features.py
giovannivolpe Jun 27, 2025
155dcf3
Update features.py
giovannivolpe Jun 27, 2025
12a88e1
Update features.py
giovannivolpe Jun 27, 2025
4eb169c
Update test_features.py
giovannivolpe Jun 27, 2025
e6734f0
Update features.py
giovannivolpe Jun 27, 2025
3dee646
Update test_features.py
giovannivolpe Jun 27, 2025
a5a9736
Update test_features.py
giovannivolpe Jun 27, 2025
dcae336
Update features.py
giovannivolpe Jun 27, 2025
c7985bf
Update test_features.py
giovannivolpe Jun 27, 2025
0128f22
Update features.py
giovannivolpe Jun 27, 2025
2234f8d
Update test_features.py
giovannivolpe Jun 27, 2025
a23fa7c
Update features.py
giovannivolpe Jun 30, 2025
5c67108
Update test_features.py
giovannivolpe Jun 30, 2025
fd5fc9f
Update test_features.py
giovannivolpe Jun 30, 2025
1714d5c
Update features.py
giovannivolpe Jun 30, 2025
3ef47fd
Update test_features.py
giovannivolpe Jun 30, 2025
9f1f019
Update features.py
giovannivolpe Jun 30, 2025
ca3e443
Update test_features.py
giovannivolpe Jun 30, 2025
b5ea873
Update features.py
giovannivolpe Jun 30, 2025
9c7bb29
Update test_features.py
giovannivolpe Jun 30, 2025
ee903ab
Update features.py
giovannivolpe Jun 30, 2025
4d94ed0
Update test_features.py
giovannivolpe Jun 30, 2025
a58bdc8
Update features.py
giovannivolpe Jun 30, 2025
485fd1d
Update test_features.py
giovannivolpe Jun 30, 2025
ad358a3
Update test_features.py
giovannivolpe Jun 30, 2025
5610d40
Update features.py
giovannivolpe Jun 30, 2025
eb17bab
Update features.py
giovannivolpe Jun 30, 2025
6ccdfac
Update test_features.py
giovannivolpe Jul 1, 2025
4b4d547
Update features.py
giovannivolpe Jul 1, 2025
0cc0132
Update features.py
giovannivolpe Jul 1, 2025
362ad85
Update features.py
giovannivolpe Jul 1, 2025
07383ce
Update features.py
giovannivolpe Jul 1, 2025
0be5371
Update _config.py
giovannivolpe Jul 1, 2025
fffdf6d
Update features.py
giovannivolpe Jul 1, 2025
df8330f
Update features.py
giovannivolpe Jul 1, 2025
57e42ec
Update features.py
giovannivolpe Jul 1, 2025
e4e9750
Update features.py
giovannivolpe Jul 1, 2025
4355a71
Update features.py
giovannivolpe Jul 2, 2025
55d6788
Update features.py
giovannivolpe Jul 2, 2025
a55e95f
Update features.py
giovannivolpe Jul 2, 2025
b247a65
Update features.py
giovannivolpe Jul 2, 2025
2c61e9f
Update features.py
giovannivolpe Jul 2, 2025
434d661
Update features.py
giovannivolpe Jul 2, 2025
c356091
Update features.py
giovannivolpe Jul 2, 2025
f790513
Update features.py
giovannivolpe Jul 2, 2025
c05ca7a
Update features.py
giovannivolpe Jul 2, 2025
9b42746
Update features.py
giovannivolpe Jul 2, 2025
bb709db
Update features.py
giovannivolpe Jul 2, 2025
d5920c8
Update features.py
giovannivolpe Jul 2, 2025
d28a829
Update features.py
giovannivolpe Jul 2, 2025
50491da
Update features.py
giovannivolpe Jul 2, 2025
a969692
Update features.py
giovannivolpe Jul 2, 2025
1320523
Update features.py
giovannivolpe Jul 2, 2025
adaa426
Update features.py
giovannivolpe Jul 3, 2025
7d2379f
Update _config.py
giovannivolpe Jul 3, 2025
2c0edc6
Update features.py
giovannivolpe Jul 3, 2025
38319bf
Update features.py
giovannivolpe Jul 3, 2025
edb5c5b
Update features.py
giovannivolpe Jul 4, 2025
91633c6
Updated the documentation of features/__sub__ (#356)
mirjagranfors Jul 4, 2025
9c7e4c4
Update documentation of features/__pow__ (#359)
JChonpca Jul 4, 2025
c6934da
Update features.py
giovannivolpe Jul 4, 2025
673b98c
Update features.py
giovannivolpe Jul 4, 2025
263bd57
Update features.py
giovannivolpe Jul 4, 2025
dac7c79
Update features.py
giovannivolpe Jul 4, 2025
fb865d5
added get_backend() as a feature method + unittesting to switch and g…
mirjagranfors Jul 5, 2025
e6dc8b8
Update features.py
giovannivolpe Jul 5, 2025
26ea2b2
Update test_features.py
giovannivolpe Jul 5, 2025
cf2fce7
Sequences restructuring (#345)
Pwhsky Jul 5, 2025
3572764
Update features.py
giovannivolpe Jul 5, 2025
cafb1e0
Update features.py
giovannivolpe Jul 5, 2025
1cf97ff
Update features.py
giovannivolpe Jul 5, 2025
6d67783
Update features.py
giovannivolpe Jul 5, 2025
5cf559b
Update features.py
giovannivolpe Jul 5, 2025
7945439
Update features.py
giovannivolpe Jul 5, 2025
1ba87cd
Update augmentations.py
giovannivolpe Jul 5, 2025
4d51258
Update types.py
giovannivolpe Jul 5, 2025
352bcb2
Update utils.py
giovannivolpe Jul 5, 2025
396b954
Update types.py
giovannivolpe Jul 5, 2025
6ce4109
Update test_features.py
giovannivolpe Jul 5, 2025
43b7f37
Update test_utils.py
giovannivolpe Jul 5, 2025
f6383ff
Update DTAT387_types.ipynb
giovannivolpe Jul 5, 2025
582d60e
u
giovannivolpe Jul 5, 2025
3c848b5
Update types.py
giovannivolpe Jul 6, 2025
2434e7e
Update DTAT301_features.ipynb
giovannivolpe Jul 6, 2025
cdafe07
Update DTAT387_types.ipynb
giovannivolpe Jul 6, 2025
e8d797f
Update DTAT306_properties.ipynb
giovannivolpe Jul 6, 2025
9067d2d
Update DTAT301_features.ipynb
giovannivolpe Jul 6, 2025
19cb53e
Update DTAT306_properties.ipynb
giovannivolpe Jul 6, 2025
1cfa3ae
Update DTAT341_sequences.ipynb
giovannivolpe Jul 6, 2025
3bda822
Update features.py
giovannivolpe Jul 6, 2025
445abd8
Added more documentation for features/__rsub__ (#363)
mirjagranfors Jul 8, 2025
df7fb81
Added more documentation for features/__mul__ (#364)
mirjagranfors Jul 8, 2025
69ae21a
Added more documentation to features/__rmul__ (#365)
mirjagranfors Jul 8, 2025
c35e5be
Update features.py
giovannivolpe Jul 8, 2025
1bb3541
Polish documentationof feature/__pow__ (#366)
JChonpca Jul 8, 2025
d9d93ea
Add documentation of features/__rpow__ (#367)
JChonpca Jul 8, 2025
f54dd7b
polishing of sources
giovannivolpe Jul 8, 2025
3dcfbee
Update base.py
giovannivolpe Jul 8, 2025
08c3cb9
Update base.py
giovannivolpe Jul 8, 2025
3c5a439
Update base.py
giovannivolpe Jul 8, 2025
c34f3da
Update base.py
giovannivolpe Jul 8, 2025
a0c1692
Update base.py
giovannivolpe Jul 8, 2025
b715bda
Update base.py
giovannivolpe Jul 8, 2025
2b36344
Update base.py
giovannivolpe Jul 8, 2025
ab42235
Update base.py
giovannivolpe Jul 8, 2025
88c4458
features: __truediv__ (#362)
Pwhsky Jul 9, 2025
dcd3314
Update base.py
giovannivolpe Jul 9, 2025
ca587ea
al/features/__rtruediv__ polishing (#369)
Pwhsky Jul 9, 2025
0f7ab6b
Update features.py
giovannivolpe Jul 9, 2025
5b8db3e
features: __floordiv__ (#368)
Pwhsky Jul 9, 2025
e36d948
Update features.py
giovannivolpe Jul 9, 2025
1ddce89
Update base.py
giovannivolpe Jul 9, 2025
6057d6e
Update base.py
giovannivolpe Jul 9, 2025
3638042
Update base.py
giovannivolpe Jul 9, 2025
7a757e7
Update base.py
giovannivolpe Jul 9, 2025
fcc3802
Update base.py
giovannivolpe Jul 9, 2025
bc6a9ca
Update base.py
giovannivolpe Jul 9, 2025
cbaa5fc
Update base.py
giovannivolpe Jul 9, 2025
2afc37d
Update base.py
giovannivolpe Jul 9, 2025
cb892da
Update base.py
giovannivolpe Jul 9, 2025
28488f6
Update base.py
giovannivolpe Jul 9, 2025
6c9dccc
Features: ChannelFirst2d (#361)
Pwhsky Jul 10, 2025
1c60d4e
Update features.py
giovannivolpe Jul 10, 2025
612e125
Create __init__.py
giovannivolpe Jul 10, 2025
0e37b0f
Create test_base.py
giovannivolpe Jul 10, 2025
e935305
Update test_base.py
giovannivolpe Jul 10, 2025
472d769
Update DTAT391A_sources.base.ipynb
giovannivolpe Jul 10, 2025
ea8be6b
Delete interface_v2.mp4
giovannivolpe Jul 10, 2025
7d8529d
Update DTAT391B_sources.folder.ipynb
giovannivolpe Jul 10, 2025
a73a799
Update folder.py
giovannivolpe Jul 10, 2025
9b5bc20
Update test_features.py
giovannivolpe Jul 10, 2025
8013e17
Update folder.py
giovannivolpe Jul 10, 2025
033d3a0
Update folder.py
giovannivolpe Jul 10, 2025
a9c8f5d
Update folder.py
giovannivolpe Jul 10, 2025
39ee320
Merge branch 'gv/final/features' into JH/functions/feature_Store
Jul 10, 2025
6db8a93
Update folder.py
giovannivolpe Jul 10, 2025
4527ff2
Create test_folder.py
giovannivolpe Jul 10, 2025
6412727
Update test_folder.py
giovannivolpe Jul 10, 2025
f6de929
Update folder.py
giovannivolpe Jul 10, 2025
75bf02d
Update folder.py
giovannivolpe Jul 10, 2025
d02d6ab
Update test_folder.py
giovannivolpe Jul 10, 2025
5cbefb9
Add docs of /features/__gt__ (#372)
JChonpca Jul 11, 2025
e8d781c
Add docs of /features/__rgt__ (#373)
JChonpca Jul 11, 2025
3e614c0
Add docs of /features/__lt__ (#374)
JChonpca Jul 11, 2025
a208162
Add docs of /features/__rlt__ (#375)
JChonpca Jul 11, 2025
fb34c58
Update features.py
giovannivolpe Jul 11, 2025
cf185f1
Add docs of /features/__le__ (#376)
JChonpca Jul 11, 2025
467ea52
Update features.py
giovannivolpe Jul 11, 2025
19b0e9c
Add docs of /features/__rle__ (#377)
JChonpca Jul 11, 2025
1281142
Update features.py
giovannivolpe Jul 11, 2025
21033f6
Update features.py
giovannivolpe Jul 11, 2025
5418ed5
add docs of /features/__ge__ (#378)
JChonpca Jul 11, 2025
bd596df
Update features.py
giovannivolpe Jul 11, 2025
0a61658
Add docs of /features/__rge__ (#379)
JChonpca Jul 11, 2025
838f766
Add docs of /features/__xor__ (#382)
JChonpca Jul 11, 2025
7f643b7
Add docs of /features/__rand__ (#381)
JChonpca Jul 11, 2025
32e4e90
add docs of /features/__and__ (#380)
JChonpca Jul 11, 2025
d97196c
Update features.py
giovannivolpe Jul 11, 2025
d00871f
Merge branch 'gv/final/features' into JH/functions/feature_Store
Jul 11, 2025
d0bfac9
Merge branch 'develop' into JH/functions/feature_Store
Jul 14, 2025
240700e
Merge branch 'develop' into JH/functions/feature_Store
Jul 27, 2025
1503c4b
Update /features/Store
Jul 28, 2025
a6edfdc
u
Jul 28, 2025
caa3268
uu
Jul 28, 2025
f127868
minor typos
mirjagranfors Jul 29, 2025
272f22a
formatting
mirjagranfors Jul 29, 2025
ca4ec8b
uuuu
Jul 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions deeptrack/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def propagate_data_to_dependencies(
"ChannelFirst2d",
"Upscale", # TODO ***AL***
"NonOverlapping", # TODO ***AL***
"Store", # TODO ***JH***
"Store",
"Squeeze",
"Unsqueeze",
"ExpandDims",
Expand Down Expand Up @@ -8804,9 +8804,9 @@ def _resample_volume_position(
class Store(Feature):
"""Store the output of a feature for reuse.

The `Store` feature evaluates a given feature and stores its output in an
internal dictionary. Subsequent calls with the same key will return the
stored value unless the `replace` parameter is set to `True`. This enables
The `Store` feature evaluates a given feature and stores its output in an
internal dictionary. Subsequent calls with the same key will return the
stored value unless the `replace` parameter is set to `True`. This enables
caching and reuse of computed feature outputs.

Parameters
Expand All @@ -8815,10 +8815,10 @@ class Store(Feature):
The feature to evaluate and store.
key: Any
The key used to identify the stored output.
replace: bool, optional
If `True`, replaces the stored value with a new computation. It defaults
to `False`.
**kwargs:: dict of str to Any
replace: PropertyLike[bool], optional
If `True`, replaces the stored value with the current computation. It
defaults to `False`.
**kwargs: dict of str to Any
Additional keyword arguments passed to the parent `Feature` class.

Attributes
Expand Down Expand Up @@ -8852,22 +8852,26 @@ class Store(Feature):
>>> cached_output = store_feature(None, key="example", replace=False)
>>> print(cached_output == output)
True
>>> print(cached_output == value_feature())
False

Retrieve the stored value recomputing:
>>> value_feature.update()
>>> cached_output = store_feature(None, key="example", replace=True)
>>> print(cached_output == output)
False
>>> print(cached_output == value_feature())
True

"""

__distributed__: bool = False

def __init__(
self: Store,
self: Feature,
feature: Feature,
key: Any,
replace: bool = False,
replace: PropertyLike[bool] = False,
**kwargs: Any,
):
"""Initialize the Store feature.
Expand All @@ -8878,8 +8882,8 @@ def __init__(
The feature to evaluate and store.
key: Any
The key used to identify the stored output.
replace: bool, optional
If `True`, replaces the stored value with a new computation.
replace: PropertyLike[bool], optional
If `True`, replaces the stored value with a new computation.
It defaults to `False`.
**kwargs:: dict of str to Any
Additional keyword arguments passed to the parent `Feature` class.
Expand All @@ -8891,7 +8895,7 @@ def __init__(
self._store: dict[Any, Image] = {}

def get(
self: Store,
self: Feature,
_: Any,
key: Any,
replace: bool,
Expand Down
25 changes: 25 additions & 0 deletions deeptrack/tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -2408,10 +2408,35 @@ def test_Store(self):
value_feature.update()
cached_output = store_feature(None, key="example", replace=False)
self.assertEqual(cached_output, output)
self.assertNotEqual(cached_output, value_feature())

value_feature.update()
cached_output = store_feature(None, key="example", replace=True)
self.assertNotEqual(cached_output, output)
self.assertEqual(cached_output, value_feature())

if TORCH_AVAILABLE:

value_feature = features.Value(lambda: torch.rand(1))

store_feature = features.Store(
feature=value_feature, key="example"
)

output = store_feature(None, key="example", replace=False)

value_feature.update()
cached_output = store_feature(None, key="example", replace=False)
torch.testing.assert_close(cached_output, output)
with self.assertRaises(AssertionError):
torch.testing.assert_close(cached_output, value_feature())

value_feature.update()
cached_output = store_feature(None, key="example", replace=True)
with self.assertRaises(AssertionError):
torch.testing.assert_close(cached_output, output)
torch.testing.assert_close(cached_output, value_feature())



def test_Squeeze(self):
Expand Down
13 changes: 10 additions & 3 deletions tutorials/3-advanced-topics/DTAT391B_sources.folder.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -111,7 +111,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -174,7 +174,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -430,6 +430,13 @@
"List all image paths in train:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Prepare an example path to one of the files:"
]
},
{
"cell_type": "code",
"execution_count": 15,
Expand Down
Loading