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

Task: Add # may vary tag to random output, and automate line length issues #96

Open
2 tasks
bmwoodruff opened this issue Jun 19, 2024 · 1 comment
Open
2 tasks
Assignees
Labels

Comments

@bmwoodruff
Copy link
Collaborator

Description:

The current reviewtools.py file process_text_block does not check for

  • lines longer than 79
  • random output

This causes two problems:

  1. When running spin lint, the generated examples will fail if longer than 79 characters (thanks @jud-sdev for help in Review: AI Gen Examples for ma.dot, ma.cumsum and ma.prod #87).
  2. When running python tools/refguide_check --doctests, random output will fail (thanks @ogidig5 for help in Review: AI Gen Examples for numpy.linalg.svdvals function #86).

I'd like to automate much of this.

  • I have to find a good way to reformat python code (I'm sure there is a package out there that will reformat code to stay within a specified length. I already know how to use a textwrapping function in the commit_message_creator function, which will handle regular text just fine. The issue will be formatting python code (and I'm sure it's been done).
  • I'll play with a few options for detecting random (search for rand, then expand it to np.rand or other things till it captures exactly what's needed.)
  • Update reviewtools.py with two new functions to do this.

Acceptance Criteria:

  • Random output is appropriately tagged in reviewtools.py
  • Lines longer than 79 characters are appropriately split into shorter lines, resulting in still valid python code.
@bmwoodruff bmwoodruff self-assigned this Jun 19, 2024
@bmwoodruff
Copy link
Collaborator Author

Looks like black is designed to format long code, so that may work. I'll have to substract the indent (and may be the >>>) from the length, but I think this will work for getting input code lengths shrunk to under 79 characters. I know they're planning to increase the limit to 88 soon. If they get that done before we're done, then we swap a number.

The package textwrap will format long strings. This works for the headers between code blocks. If they are multiline, then combine them into a string before wrapping them and then writing them.

I'm not yet sure about formatting the output cells to be 79 or less.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant