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

Fix brackets display #112

Merged

Conversation

jianan1104
Copy link
Contributor

Overview

Fix brackets display, replace \left( to \mathopen{}\left( and \right) to \mathclose{}\right)

Details

Modify function def _wrap_operand in the src/latexify/function_codegen.py line by 422, Change the original brackets string to fix the display.

  • before
    image

  • after
    截圖 2022-11-16 上午1 21 26

References

#90

…ght) to \mathclose{}\right)

Fix brackets display
@jianan1104 jianan1104 requested a review from odashi as a code owner November 15, 2022 17:43
@odashi
Copy link
Collaborator

odashi commented Nov 15, 2022

@jianan1104 Thanks! You also need to fix all tests that are related to this change. Running ./checks.sh could check if the test passes or not.

Copy link
Collaborator

@odashi odashi left a comment

Choose a reason for hiding this comment

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

I think there are other brackets in function_codegen.py, and it would be great if we fixed all of them.

@odashi odashi added this to the v0.3 milestone Nov 15, 2022
@jianan1104
Copy link
Contributor Author

@jianan1104 Thanks! You also need to fix all tests that are related to this change. Running ./checks.sh could check if the test passes or not.

Thank you for reviewing. No problem. I'll fix it asap.

@jianan1104 jianan1104 requested a review from odashi November 16, 2022 03:56
@jianan1104
Copy link
Contributor Author

@odashi Hi, odashi. just fix and test the code, please check it.

Copy link
Collaborator

@odashi odashi left a comment

Choose a reason for hiding this comment

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

The logic looks fine, thanks!

It looks some lines exceed the length limit (88 characters) though I didn't realize why Black didn't warn about them. Could you fix them as well?

checks.sh Outdated
@@ -3,4 +3,4 @@ set -eoux pipefail

python -m pytest src -vv
python -m black --check src
python -m pflake8 src
python -m flake8 src
Copy link
Collaborator

Choose a reason for hiding this comment

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

Revert this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. sorry for this change. I have no experience with pflake8(flake8 for pyproject), so I just edit it by intuition.

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

import math
from collections.abc import Callable
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are some changes about only the import order, which are not related to the essential point of this pull request. Could you revert these changes to prevent breaking the blame history?

(Btw, I think I need to introduce some static checker (e.g., isort) to constrain the style around imports.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem.

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

@odashi
Copy link
Collaborator

odashi commented Nov 16, 2022

It looks the CI accidentally passes though it detected some errors:

Run python -m pflake8 src
src/integration_tests/regression_test.py:91:89: E501 line too long ([11](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:12)4 > 88 characters)
src/integration_tests/regression_test.py:99:89: E501 line too long (115 > 88 characters)
src/integration_tests/regression_test.py:227:89: E501 line too long (132 > 88 characters)
src/latexify/__init__.py:7:1: E722 do not use bare 'except'
src/latexify/codegen/function_codegen_test.py:59:89: E501 line too long (107 > 88 characters)
src/latexify/codegen/function_codegen_test.py:75:89: E501 line too long (108 > 88 characters)
src/latexify/codegen/function_codegen_test.py:104:89: E501 line too long (107 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[12](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:13)0:89: E501 line too long (108 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[14](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:15)5:89: E501 line too long (103 > 88 characters)
src/latexify/codegen/function_codegen_test.py:149:89: E501 line too long (105 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[15](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:16)3:89: E501 line too long (115 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[17](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:18)7:89: E501 line too long (125 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[19](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:20)4:89: E501 line too long (91 > 88 characters)
src/latexify/codegen/function_codegen_test.py:198:89: E501 line too long (109 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[20](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:21)3:89: E501 line too long (93 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[22](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:23)3:89: E501 line too long (119 > 88 characters)
src/latexify/codegen/function_codegen_test.py:2[28](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:29):89: E501 line too long (114 > 88 characters)
src/latexify/codegen/function_codegen_test.py:229:89: E501 line too long (111 > 88 characters)

@jianan1104
Copy link
Contributor Author

It looks the CI accidentally passes though it detected some errors:

Run python -m pflake8 src
src/integration_tests/regression_test.py:91:89: E501 line too long ([11](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:12)4 > 88 characters)
src/integration_tests/regression_test.py:99:89: E501 line too long (115 > 88 characters)
src/integration_tests/regression_test.py:227:89: E501 line too long (132 > 88 characters)
src/latexify/__init__.py:7:1: E722 do not use bare 'except'
src/latexify/codegen/function_codegen_test.py:59:89: E501 line too long (107 > 88 characters)
src/latexify/codegen/function_codegen_test.py:75:89: E501 line too long (108 > 88 characters)
src/latexify/codegen/function_codegen_test.py:104:89: E501 line too long (107 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[12](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:13)0:89: E501 line too long (108 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[14](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:15)5:89: E501 line too long (103 > 88 characters)
src/latexify/codegen/function_codegen_test.py:149:89: E501 line too long (105 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[15](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:16)3:89: E501 line too long (115 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[17](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:18)7:89: E501 line too long (125 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[19](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:20)4:89: E501 line too long (91 > 88 characters)
src/latexify/codegen/function_codegen_test.py:198:89: E501 line too long (109 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[20](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:21)3:89: E501 line too long (93 > 88 characters)
src/latexify/codegen/function_codegen_test.py:[22](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:23)3:89: E501 line too long (119 > 88 characters)
src/latexify/codegen/function_codegen_test.py:2[28](https://github.com/google/latexify_py/actions/runs/3476330689/jobs/5811657602#step:5:29):89: E501 line too long (114 > 88 characters)
src/latexify/codegen/function_codegen_test.py:229:89: E501 line too long (111 > 88 characters)

I do not know if any lint tool can fix automatically? or just edit line by line?

@odashi
Copy link
Collaborator

odashi commented Nov 16, 2022

I do not know if any lint tool can fix automatically? or just edit line by line?

Length limit error is usually resolved by running Black, but I guess long string literals couldn't be handled correctly. So (unfortunately) some errors need to be fixed manually.

Btw, I also noticed that the list above contains some existing errors in main. I will fix it first ASAP.

It looks the accident around flake8 was reported recently:
csachs/pyproject-flake8#19

@odashi
Copy link
Collaborator

odashi commented Nov 16, 2022

@jianan1104 I fixed CIs. Could you merge the main into this pull request so that the flake8 errors kill the CI appropriately?

@jianan1104
Copy link
Contributor Author

jianan1104 commented Nov 16, 2022

@jianan1104 I fixed CIs. Could you merge the main into this pull request so that the flake8 errors kill the CI appropriately?

Sure. merged. wait for ci result...

@jianan1104
Copy link
Contributor Author

jianan1104 commented Nov 16, 2022

I do not know if any lint tool can fix automatically? or just edit line by line?

Length limit error is usually resolved by running Black, but I guess long string literals couldn't be handled correctly. So (unfortunately) some errors need to be fixed manually.

Btw, I also noticed that the list above contains some existing errors in main. I will fix it first ASAP.

It looks the accident around flake8 was reported recently: csachs/pyproject-flake8#19

@odashi Done

@jianan1104 jianan1104 requested a review from odashi November 16, 2022 14:16
Copy link
Collaborator

@odashi odashi left a comment

Choose a reason for hiding this comment

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

Really great work, thanks!

@odashi odashi added the feature label Nov 16, 2022
@odashi
Copy link
Collaborator

odashi commented Nov 16, 2022

Fixes #90

@odashi odashi merged commit 0a7eafa into google:main Nov 16, 2022
@jianan1104
Copy link
Contributor Author

Really great work, thanks!

Glad to be a contributor.

@jianan1104 jianan1104 deleted the add-mathopen-and-mathclose-to-parentheses branch November 21, 2022 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants