Skip to content
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

Fix add existing tree to annotation #1201

Merged
merged 19 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions webknossos/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
- Refactored the PimsTiffReader to read the data directly from the tiff file without creating a memmap-able copy first. This greatly reduces the time and storage requirements for converting large tiff files. [#1212](https://github.com/scalableminds/webknossos-libs/pull/1212)

### Fixed
- Fixed an issue where adding existing trees to an annotation fails. [#1201](https://github.com/scalableminds/webknossos-libs/pull/1201)
- Fixed unpickling of the SSL_Context to allow for a second or third pickling. [#1223](https://github.com/scalableminds/webknossos-libs/pull/1223)
- Fixed offset error in upsample_cube job [#1209](https://github.com/scalableminds/webknossos-libs/pull/1209)

Expand All @@ -50,15 +51,13 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
- Fixed pickling issue that has been introduced in 0.15.9. [#1218](https://github.com/scalableminds/webknossos-libs/pull/1218)



## [0.15.10](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.15.10) - 2024-11-25
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.15.9...v0.15.10)

### Fixed
- Fixed pickling issue that has been introduced in 0.15.9. [#1218](https://github.com/scalableminds/webknossos-libs/pull/1218)



## [0.15.9](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.15.9) - 2024-11-25
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.15.8...v0.15.9)

Expand Down
12 changes: 12 additions & 0 deletions webknossos/tests/test_skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,15 @@ def test_add_tree_with_obj_and_properties(tmp_path: Path) -> None:
assert new_tree.color == (1, 2, 3, 1)

skeleton_b.save(output_path)


def test_add_tree_with_group() -> None:
annotation = wk.Annotation(
name="my_annotation", dataset_name="my_dataset", voxel_size=(11, 11, 24)
)
group = annotation.skeleton.add_group("a group")
tree = group.add_tree("a tree")

skeleton_a = create_dummy_skeleton()

skeleton_a.add_tree(tree)
9 changes: 6 additions & 3 deletions webknossos/webknossos/skeleton/group.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import copy
from typing import TYPE_CHECKING, Iterator, Optional, Set, Tuple, Union, cast
from typing import TYPE_CHECKING, Any, Iterator, Optional, Set, Tuple, Union, cast

import attr
from boltons.strutils import unit_len
Expand Down Expand Up @@ -220,7 +220,7 @@ def children(self) -> Iterator[GroupOrTree]:
@property
def trees(self) -> Iterator[Tree]:
"""Returns all (immediate) tree children as an iterator.
Use flattened_trees if you need also need trees within subgroups."""
Use flattened_trees if you also need trees within subgroups."""
return (child for child in self._child_trees)

@property
Expand Down Expand Up @@ -430,5 +430,8 @@ def as_nml_group(self) -> wknml.Group:
children=[g.as_nml_group() for g in self._child_groups],
)

def __eq__(self, other: Any) -> bool:
return type(other) is type(self) and self._id == other._id

def __hash__(self) -> int:
return self._id
return id(self)
5 changes: 1 addition & 4 deletions webknossos/webknossos/skeleton/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Vector3 = Tuple[float, float, float]


@attr.define
@attr.define(eq=False)
class Skeleton(Group):
"""A hierarchical representation of skeleton annotations in WEBKNOSSOS.

Expand Down Expand Up @@ -281,6 +281,3 @@ def write(self, out_path: PathLike) -> None:
"""Deprecated. Use Skeleton.save instead."""
warn_deprecated("Skeleton.write", "skeleton.save")
self.save(out_path)

def __hash__(self) -> int:
return id(self)
Loading