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

conversion.py: Draft basic cleanup - UNTESTED #1897

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

schwehr
Copy link
Collaborator

@schwehr schwehr commented Feb 2, 2024

I haven't tested these changes. Without unit tests, I would not trust these changes.

The goal was to capture some initial cleanups that can be done on this file.

Changes:

  • Remove commented out code
  • Simplify use_math()
  • Remove unnecessary variables if just returning a value
  • Move code out of with open() scopes
  • x = x + foox += foo
  • No need to test a list to make sure it's not None if files is not None:
  • Comprehensions can be done right on results of a glob

There is a lot more than can be done (like making most of this code totally isolated from Jupyter), but this is a start.

An easy starter unit test:

class ConversionTest(unittest.TestCase):

  def test_use_math(self):
    self.assertFalse(conversion.use_math(['math', 'mATH']))
    self.assertTrue(conversion.use_math(['a', 'Math.pow()']))

@schwehr schwehr marked this pull request as draft February 2, 2024 23:11
@giswqs
Copy link
Member

giswqs commented Apr 16, 2024

This conversion module has changed significantly in #1968. There are several merge conflicts now. Sorry.

@schwehr
Copy link
Collaborator Author

schwehr commented Apr 16, 2024

No worries. This was meant more to document ideas than to be a PR that is merged.

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.

None yet

2 participants