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

Simplex tree ctors with data #1151

Merged

Conversation

VincentRouvreau
Copy link
Contributor

@VincentRouvreau VincentRouvreau commented Nov 7, 2024

rec_copy can copy or not simplex_data.
Some documentation and tests to explain when data are copied or not.
Fix #1127

Copy link
Collaborator

@hschreiber hschreiber left a comment

Choose a reason for hiding this comment

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

Is it wanted that the non assigned data seems to take a random value ? For unit test "simplex_data", the output is:

(2 1 0 ) filtration=0 - data='4'
(1 0 ) filtration=0 - data='5'
(2 0 ) filtration=0 - data='43808336'
(0 ) filtration=0 - data='2'
(2 1 ) filtration=0 - data='43808304'
(1 ) filtration=0 - data='43808304'
(2 ) filtration=0 - data='43808304'

Data is of type int and only 4 and 5 were assigned.

src/Simplex_tree/include/gudhi/Simplex_tree.h Outdated Show resolved Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree.h Outdated Show resolved Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree.h Outdated Show resolved Hide resolved
VincentRouvreau and others added 3 commits November 14, 2024 08:55
Co-authored-by: hschreiber <[email protected]>
Co-authored-by: hschreiber <[email protected]>
Co-authored-by: hschreiber <[email protected]>
@VincentRouvreau
Copy link
Contributor Author

Is it wanted that the non assigned data seems to take a random value ? For unit test "simplex_data", the output is:

(2 1 0 ) filtration=0 - data='4'
(1 0 ) filtration=0 - data='5'
(2 0 ) filtration=0 - data='43808336'
(0 ) filtration=0 - data='2'
(2 1 ) filtration=0 - data='43808304'
(1 ) filtration=0 - data='43808304'
(2 ) filtration=0 - data='43808304'

Data is of type int and only 4 and 5 were assigned.

It is the behaviour we want. We do not say it, but data are not initialized with a default value, that would take time. It is up to the user to deal with it.

@mglisse
Copy link
Member

mglisse commented Jan 19, 2025

We do not say it, but data are not initialized with a default value

If it was enough to disturb @hschreiber , maybe we should be explicit in the doc that this gets a default-initialization, and remind people that for scalars this may mean an indeterminate value.

Or we could change to value-initialize, I guess the main case where this could make a difference is if Simplex_data is a class that contains a large array of scalars, I don't know how likely that is.

(I haven't looked at the code)

@VincentRouvreau
Copy link
Contributor Author

If it was enough to disturb @hschreiber , maybe we should be explicit in the doc that this gets a default-initialization, and remind people that for scalars this may mean an indeterminate value.

I did so on 961919a

@@ -513,7 +524,21 @@ class Simplex_tree {
for (auto& map_el : root_.members()) {
map_el.second.assign_children(&root_);
}
rec_copy<Options::store_key>(
// Specific for optionnal data
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Specific for optionnal data
// Specific for optional data

(same elsewhere)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done on 72bbb88 for the 2 typos. Codespell pass on the rest of the code

@VincentRouvreau VincentRouvreau merged commit 86cb9b1 into GUDHI:master Feb 5, 2025
7 checks passed
@VincentRouvreau VincentRouvreau deleted the simplex_tree_ctors_with_data branch February 5, 2025 22:36
@VincentRouvreau VincentRouvreau added the 3.11.0 GUDHI version 3.11.0 label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11.0 GUDHI version 3.11.0 needed for 3.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Additionnal data in Simplex_tree are not copied
3 participants