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
Style hashes incomplete, causing loss of styles. #46
Conversation
…f styles together in one workbook.
I don't think this actually fixes anything. Certain items were left out of the hash function by design as an optimization, as python's dict first checks Can you provide an example where style alignment fails? |
Looking through the code again, I see what you're saying. I think the definition of the What is the reason for having a different definition of Here is a short script that demonstrates the issue, and also shows some failing equality comparisons:
|
Your example doesn't check the hash code though, which is half the point. The YOLO switch is meant to reduce the number of comparisons required by offloading half the comparisons to the hash function and the other half to I did notice that |
I'm starting to appreciate the cleverness here, however my sample code above still produces a pretty significant bug. Given your explanation I can't quite figure why it's happening though. If you run the code sample above and then open Do you have any ideas how this could be happening? |
After some debugging I figured out why this is occurring, it's due to the hash function in Style only checking the hash for Font and Fill, so the equality constraints are never checked since Style is a parent class for these. That is, Font and other type classes needs to be checked for hash and equality, but the primitive properties can still satisfy the half hash half equality behavior. I think a reasonable fix is to hash all the non-primitive children in Style and all other parent-containing classes as this retains the performance benefit. I'll get a fix for this in a bit, thanks for finding it, this is quite an obscure bug. :) |
Pushed the fix to dev, I tested your code and it now works. I believe I covered all the cases where this could occur, but feel free to file another issue if you find a case that I missed. |
Style hashes are incomplete, not accounting for quite a few style attributes. This prevents usage of many style cominations as they are thrown out during style alignment.