geemap
geemap copied to clipboard
conversion.py: Draft basic cleanup - UNTESTED
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 + foo
→x += 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()']))
This conversion module has changed significantly in #1968. There are several merge conflicts now. Sorry.
No worries. This was meant more to document ideas than to be a PR that is merged.
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.