Skip to content

Features: TakeProperties #400

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 227 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
227 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
f726960
Merge branch 'gv/final/features' into JH/functions/feature_TakeProper…
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
fff6885
Merge branch 'gv/final/features' into JH/functions/feature_TakeProper…
Jul 11, 2025
22452fe
Merge branch 'develop' into JH/functions/feature_TakeProperties
Jul 14, 2025
9ec752b
Merge branch 'develop' into JH/functions/feature_TakeProperties
Jul 28, 2025
20ed6d3
Update /features/TakeProperties
Jul 28, 2025
b137273
U
Jul 28, 2025
9f97899
Revert "U"
Jul 28, 2025
bd93967
UU
Jul 28, 2025
080043e
uuu
Jul 28, 2025
9476cb6
uu
Jul 29, 2025
a3e961b
small changes
mirjagranfors Jul 30, 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
38 changes: 19 additions & 19 deletions deeptrack/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def propagate_data_to_dependencies(
"Transpose",
"Permute",
"OneHot",
"TakeProperties", #TODO ***JH***
"TakeProperties",
]


Expand Down Expand Up @@ -9440,11 +9440,11 @@ def get(
class TakeProperties(Feature):
"""Extract all instances of a set of properties from a pipeline.

Only extracts the properties if the feature contains all given
property-names. The order of the properties is not guaranteed to be the
Only extracts the properties if the feature contains all given
property-names. The order of the properties is not guaranteed to be the
same as the evaluation order.

If there is only a single property name, this will return a list of the
If there is only a single property name, this will return a list of the
property values.

Parameters
Expand All @@ -9453,7 +9453,7 @@ class TakeProperties(Feature):
The feature from which to extract properties.
names: list[str]
The names of the properties to extract
**kwargs:: dict of str to Any
**kwargs: dict of str to Any
Additional keyword arguments passed to the parent `Feature` class.

Attributes
Expand All @@ -9462,18 +9462,18 @@ class TakeProperties(Feature):
Indicates whether this feature distributes computation across inputs.
Always `False` for `TakeProperties`, as it processes sequentially.
__list_merge_strategy__: int
Specifies how lists of properties are merged. Set to
Specifies how lists of properties are merged. Set to
`MERGE_STRATEGY_APPEND` to append values to the result list.

Methods
-------
`get(image: Any, names: tuple[str, ...], **kwargs: dict[str, Any]) -> np.ndarray | tuple[np.ndarray, ...]`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is too long

Extract the specified properties from the feature pipeline.

Examples
--------
>>> import deeptrack as dt

>>> class ExampleFeature(Feature):
... def __init__(self, my_property, **kwargs):
... super().__init__(my_property=my_property, **kwargs)
Expand All @@ -9489,7 +9489,7 @@ class TakeProperties(Feature):

Create a `Gaussian` feature:
>>> noise_feature = dt.Gaussian(mu=7, sigma=12)

Use `TakeProperties` to extract the property:
>>> take_properties = dt.TakeProperties(noise_feature)
>>> output = take_properties.get(image=None, names=["mu"])
Expand All @@ -9502,9 +9502,9 @@ class TakeProperties(Feature):
__list_merge_strategy__: int = MERGE_STRATEGY_APPEND

def __init__(
self: TakeProperties,
self: Feature,
feature: Feature,
*names: str,
*names: PropertyLike[str],
**kwargs: Any,
):
"""Initialize the TakeProperties feature.
Expand All @@ -9513,23 +9513,23 @@ def __init__(
----------
feature: Feature
The feature from which to extract properties.
*names: str
*names: PropertyLike[str]
One or more names of the properties to extract.
= **kwargs: Any, optional
**kwargs: Any, optional
Additional keyword arguments passed to the parent `Feature` class.

"""

super().__init__(names=names, **kwargs)
self.feature = self.add_feature(feature)

def get(
self: TakeProperties,
self: Feature,
image: Any,
names: tuple[str, ...],
_ID: tuple[int, ...] = (),
**kwargs: Any,
) -> np.ndarray | tuple[np.ndarray, ...]:
) -> NDArray | tuple[NDArray, torch.Tensor, ...]:
"""Extract the specified properties from the feature pipeline.

This method retrieves the values of the specified properties from the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one extra blank space at the end of the line

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also the case for line 9545

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And some more lines. So please double check this :)

Expand All @@ -9549,7 +9549,7 @@ def get(

Returns
-------
np.ndarray or tuple[np.ndarray, ...]
NDArray or tuple[NDArray, torch.Tensor, ...]
If a single property name is provided, a NumPy array containing the
property values is returned. If multiple property names are
provided, a tuple of NumPy arrays is returned, where each array
Expand Down Expand Up @@ -9578,8 +9578,8 @@ def get(
if key[:len(_ID)] == _ID:
res[name].append(value.current_value())

# Convert the results to NumPy arrays.
res = tuple([np.array(res[name]) for name in names])
# Convert the results to tuple.
res = tuple([res[name] for name in names])

# Return a single array if only one property name is specified.
if len(res) == 1:
Expand Down
54 changes: 45 additions & 9 deletions deeptrack/tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -2678,23 +2678,59 @@ def __init__(self, my_property, **kwargs):
output = take_properties.get(image=None, names=["my_property"])
self.assertEqual(output, [42])

# with `Gaussian` feature
# with `Gaussian` feature
noise_feature = Gaussian(mu=7, sigma=12)

take_properties = features.TakeProperties(noise_feature)
output = take_properties.get(image=None, names=["mu"])
self.assertEqual(output, [7])
output = take_properties.get(image=None, names=["sigma"])
self.assertEqual(output, [12])

# with `Gaussian` feature
noise_feature = Gaussian(mu=7, sigma=12)
# with `Gaussian` feature with float properties
noise_feature = Gaussian(mu=7.123, sigma=12.123)

take_properties = features.TakeProperties(noise_feature)
output = take_properties.get(image=None, names=["mu"])
self.assertEqual(output, [7])
output = take_properties.get(image=None, names=["sigma"])
self.assertEqual(output, [12])
output = take_properties.get(image=None, names=["mu", "sigma"])
self.assertEqual(output, ([7.123], [12.123]))
self.assertEqual(output[0][0], 7.123)
self.assertEqual(output[1][0], 12.123)

### Test with PyTorch tensor (if available)
if TORCH_AVAILABLE:
class ExampleFeature(features.Feature):
def __init__(self, my_property, **kwargs):
super().__init__(my_property=my_property, **kwargs)

feature = ExampleFeature(my_property=
properties.Property(torch.tensor(42.123)))

take_properties = features.TakeProperties(feature)
take_properties = features.TakeProperties(feature)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for writing this twice after each other? It is the same for the numpy test

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is something historic, I just copied and pasted from the previous numpy test. I will check and clean them,

output = take_properties.get(image=None, names=["my_property"])
torch.testing.assert_close(output[0], torch.tensor(42.123))

# with `Gaussian` feature
noise_feature = Gaussian(
mu=torch.tensor(7), sigma=torch.tensor(12)
)

take_properties = features.TakeProperties(noise_feature)
output = take_properties.get(image=None, names=["mu"])
torch.testing.assert_close(output[0], torch.tensor(7))
output = take_properties.get(image=None, names=["sigma"])
torch.testing.assert_close(output[0], torch.tensor(12))

# with `Gaussian` feature with float properties
random_mu = torch.rand(1)
random_sigma = torch.rand(1)
noise_feature = Gaussian(mu=random_mu, sigma=random_sigma)

take_properties = features.TakeProperties(noise_feature)
output = take_properties.get(image=None, names=["mu", "sigma"])
torch.testing.assert_close(output, ([random_mu], [random_sigma]))
torch.testing.assert_close(output[0][0], random_mu)
torch.testing.assert_close(output[1][0], random_sigma)


if __name__ == "__main__":
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