-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Failing to Format with an Ignored Matrix Matrix #1562
Comments
This seems to happen any time I have a matrix like this that I want ignored for formatting, I also have one like this:
that causes that file to fail, however that file is much longer so I only posted the shorter one. Interestingly, I have several matrices that are defined outside of any function and those seem to work fine. |
The bug where Black misbehaves when a # fmt: off
zigzag_indices = Tensor([
0, 1, 5, 6, 14, 15, 27, 28,
2, 4, 7, 13, 16, 26, 29, 42,
3, 8, 12, 17, 25, 30, 41, 43,
9, 11, 18, 24, 31, 40, 44, 53,
10, 19, 23, 32, 38, 45, 52, 54,
20, 22, 33, 38, 46, 51, 55, 60,
21, 34, 36, 47, 50, 56, 59, 61,
35, 36, 48, 49, 57, 58, 62, 63
]).long()
+ # fmt: on And if I do this to the matrices in your file, Black doesn't error out anymore: (black) richard-26@ubuntu-laptop:~/programming/black$ diff -u --color original.py test.py
--- original.py 2020-07-26 17:13:45.733409772 -0400
+++ test.py 2020-07-26 17:14:23.469736395 -0400
@@ -34,6 +34,7 @@
-0.168735892, -0.331264108, 0.50000,
0.50000, -0.418687589, -0.081312411
]).view(3, 3).transpose(0, 1)
+ # fmt: on
b = torch.Tensor([0, 128, 128]).view(1, 3, 1, 1)
@@ -81,6 +82,7 @@
1, -0.344136286, -0.714136286,
1, 1.77200, 0
]).view(3, 3).transpose(0, 1)
+ # fmt: on
b = torch.Tensor([0, 128, 128]).view(1, 3, 1, 1)
(black) richard-26@ubuntu-laptop:~/programming/black$ black test.py
reformatted test.py
All done! ✨ 🍰 ✨
1 file reformatted. Hopefully that helps! Thanks for the bug report. Environment:
|
That did fix it, for some reason I thought I already tried that thanks |
Describe the bug
I get
INTERNAL ERROR: Black produced code that is not equivalent to the source
when I try to format my code which contains a matrix that I have manually formatted and told black to ignore using# fmt: off
, the full source code is:The two matrices
ycbcr_from_rgb
andrgb_from_ycbcr
seem to be causing the problem, if I remove# fmt: off
then it runs to completion but of course destroys the formatting on the matrices.When I do this on the black playground, which seems to still have an issue but without a visible error message (e.g. it just gives back incorrect code) I get a weird extra indentation on the second function, almost like black is interpreting it to be part of the first function. I think this can link may work.
To Reproduce Steps to reproduce the behavior:
Expected behavior Formats my code correctly
Environment (please complete the following information):
Does this bug also happen on master?
Yes, verified on the playground and on my local machine.
The text was updated successfully, but these errors were encountered: