geemap icon indicating copy to clipboard operation
geemap copied to clipboard

conversion.py: Draft basic cleanup - UNTESTED

Open schwehr opened this issue 1 year ago • 2 comments

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 avatar Feb 02 '24 23:02 schwehr

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

giswqs avatar Apr 16 '24 17:04 giswqs

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

schwehr avatar Apr 16 '24 21:04 schwehr

The conversion module has changed significantly. There are a lot of conflicts that need to be resoloved. I am going to close this one for now and open a new one.

giswqs avatar Jun 15 '24 00:06 giswqs