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

Tensors with proto-indices supported for hashing in a leaf node. #227

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

bimalgaudel
Copy link
Member

No description provided.

Nullptr-like expr returns empty string on deparse.
@@ -97,6 +97,7 @@ std::wstring deparse_scalar(const Constant::scalar_type& scalar) {

std::wstring deparse(const ExprPtr& expr, bool annot_sym) {
using namespace details;
if (!expr) return {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would argue that passing a nullptr into this function is an error

Copy link
Member Author

Choose a reason for hiding this comment

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

Creating nullptr-like ExprPtr is very easy as of now (e.g. by default construction). I believe it is convenient to return an empty string for such expressions. I am using this feature to read/write equations to a file for debugging purposes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Exactly because it is easy, I think the program should error as soon as possible in order to indicate the part of the code in which you are using a nullptr.

I mean, I'm not against this change - it's just that in my view hiding the use of a nullptr in your code may be a bad idea as it will likely not do what you want it to anyway i.e. will likely cause trouble down the line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Empty string -> Nullptr.
Nullptr -> Empty string.

It's a one-to-one mapping. We don't buy much by throwing on empty string parse or nullptr deparse, especially because these functions are convenient functions -- not the core SeQuant features.

Copy link
Member Author

Choose a reason for hiding this comment

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

Btw, I called it a bug fix because, previously, the master supported this feature. See here.

@evaleev evaleev merged commit d6bd8e7 into master Jul 30, 2024
10 checks passed
@evaleev evaleev deleted the gaudel/fix/tot_leaf_hash branch July 30, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants