-
Notifications
You must be signed in to change notification settings - Fork 67
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
output squared filtration values true/false mechanism for Delaunay complexes #1172
output squared filtration values true/false mechanism for Delaunay complexes #1172
Conversation
Test 3.13 with numpy 1.26.0
* \note Weighted Alpha complex can have negative filtration values. If `output_squared_values` is set to `false`, | ||
* filtration values will be `NaN` in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understood correctly, contrary to the regular Alpha filtration, the filtration values in a weighted Alpha filtration are not distances and the option of having output_squared_values
. If the user did not want the filtration values (what the NaN represent, I guess?), he would just use a simplex tree with store_filtration
at false
, no?
Or are the NaN needed for some cases? Or did I simply misunderstood something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the weighted case, filtration values are the power distance of the smallest power sphere, and it can be a negative value. If it is asked to square root the filtration values, these will be NaN. I am ok with the idea to deactivate the square root mechanism in the weighted case. I will print a user warning in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The power distance is not euclidean, from which the "square trick" is coming from. The option of squared or not squared feels off topic in this context. So, I would be more in the favor that we ignore this argument in the case of weighted alpha complexes (i.e., we do the same thing whatever its value). We could just state it like that in the documentation of the method, I am not sure a warning is needed then.
Except is there is some technical detail for which the NaN are helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did so on 44a6747, but I had to print a warning to the user in case he sets weights but don't want square filtration values.
// For users to be able to define their own sqrt function on their desired Filtration_value type | ||
using std::sqrt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could perhaps add in the concept of SimplicialComplexForAlpha
that for "custom" filtration value types, having its own sqrt
is possible and if not existing std::sqrt
is used instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I specified it on 021561a
@@ -29,8 +30,9 @@ using Simplex_tree = Gudhi::Simplex_tree<>; | |||
using Filtration_value = Simplex_tree::Filtration_value; | |||
|
|||
void program_options(int argc, char *argv[], std::string &off_file_points, bool &exact, bool &fast, | |||
std::string &weight_file, std::string &output_file_diag, Filtration_value &alpha_square_max_value, | |||
int &coeff_field_characteristic, Filtration_value &min_persistence); | |||
bool& output_squared_root_values, std::string &weight_file, std::string &output_file_diag, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be output_squared_values
instead of output_squared_root_values
? To be more consistent with the create_complex
interface.
And is the correct term not square_root
(without de d
)? Or is it used as some sort of verb?
Edit: it seems that for the utilities in general (also for cech etc.), the option is inverted to the notion for the option. Was there a particular reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for the utilities the option is inverted because I wanted to keep backward compatibility.
Before this feature, it was returning squared values, so I wanted the utils to keep the behaviour.
And then the user can ask for square root filtration values with -s
.
Does it seem ok for you ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I just realized that this code will only be used precompiled with command lines, it is not a method to include. The only way to keep the old behaviour without inverting the argument would be to use -squared-filtrations=ON
by default and explicity put -squared-filtrations=OFF
instead of --square-root-filtrations
in the command line arguments.
If this is too annoying to do, just keep it like that then. But I would still correct output_squared_root_values
to output_square_root_values
. Or be more explicit about the meaning of the option with do_not_square_filtration_values
.
On this note, we could also change output_squared_values
to use_squared_filtration_values
/ output_squared_filtration_values
. As just value
sounds a bit vague. But that is perhaps a bit subjective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
} | ||
std::clog << "Weighted alpha complex with output_squared_values\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it the other way around? "without output_squared_values", as create_complex<false>
is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the log on a8d8634
…y but to fit output_squared_filtration feature
…atibility but to fit output_squared_filtration feature
@mglisse In the Weighted case, do you think we should always set |
…root_filtrations_assert_weighted
…ted case + some tests
@hschreiber I took your proposal on 4ee4878 to always set |
* \exception std::invalid_argument In case of a Weighted Alpha complex with `Output_squared_values` set to `false`, | ||
* as Weighted Alpha complex can have negative filtration values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Radical, but I am fine with the new proposition (even though, the value should be the other way around, as the filtration value is not squared (couldn't be negative otherwise), but technically it would not fit with the default value of the non weighted case). But here I would write "..., as the filtration values of a Weighted Alpha complex results from a power product and not from an euclidean distance. Therefore this template argument should be kept to the default value." instead of "..., as Weighted Alpha complex can have negative filtration values."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with your proposal. On bc7fbb6
If a user knows they always have positive weights and wants the square root, it seems a bit disappointing to say NO when it would actually work just fine. |
filtration: Set this value to `None` (default value) if filtration values are not needed to be computed | ||
(will be set to `NaN`). Set it to `alpha` to compute the filtration values with the Alpha complex, or | ||
to `cech` to compute the Delaunay Cech complex. | ||
output_squared_values: Square filtration values when `True`. Default is `True`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the Python doc mention somewhere that passing False
can be dangerous with negative weights?
But what is the meaning of a "square rooted filtration value" of a weighted alpha complex? Would we return something like |
Replace #1138 (remove function instead of classes)
While keeping backward compatibilities of former Delaunay complexes (cpp, utils and python)
Fix #80 and #771