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

MHS/DAS 1480/fixes regression test and debugging instructions #14

Merged

Conversation

flamingbear
Copy link
Member

Description

Fixes regression tests for AVNIR related to previous release.

Jira Issue ID

DAS-1480

Local Test Steps

No logical tests unless you want to see if you can get the debugging running on your machine.

PR Acceptance Checklist

  • [ N/A ] Jira ticket acceptance criteria met.
    (this is a cleanup PR)
  • [ X ] version.txt and CHANGE.md updated if any service code is changed.
  • [ N/A ] Tests added/updated and passing.
  • [ X ] Documentation updated (if needed).

@flamingbear flamingbear force-pushed the mhs/DAS-1480/regression-test-and-debugging-instructions branch from 137bdb4 to 9396904 Compare June 13, 2022 22:45
Copy link
Member

@owenlittlejohns owenlittlejohns left a comment

Choose a reason for hiding this comment

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

The debugging instructions are incredibly useful and should give other developers a really useful tool during development. Thanks for adding them.

I mostly only had nitpicks, but before hitting approve, would be interested to know what you think about the any condition. It might just be that I've misunderstood what it's trying to do.

README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
@@ -696,7 +696,8 @@ def recolor(self, layerid, srcfile, dstdir):
if relatedUrl.type == 'Color Map':
colormap = '/vsicurl/' + relatedUrl.url
discrete = True
if colormap is None and ('png' in fmt.mime or 'jpeg' in fmt.mime):
image_types = ['png', 'jpeg', 'tiff']
if colormap is None and any(i_type for i_type in image_types if i_type in fmt.mime):
Copy link
Member

Choose a reason for hiding this comment

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

Could this any statement be simplified to:

if colormap is None and any(i_type in fmt.mime for i_type in image_types):
    ...

Although this condition feels like it was originally a little off. I think what's trying to be checked here is whether the MIME type is a PNG, JPEG or (now) a TIFF. In which case, it might be better to have:

if colormap is None and fmt.mime in ['image/png', 'image/jpeg', 'image/tiff', 'image/tif']:
    ...

Note that image/tiff and image/tif are both valid MIME types for a TIFF, so that should be included in whatever ends up happening. (I wonder also if it could/should be fmt.mime.lower(), to ensure everything is lowercase)

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitely like your list comprehension better than my original one. That's just me rusty in my pythons. Agree on other thoughts as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ugh, yeah, that was ugly what I was trying to do. bbf694d is correct version

README.md Show resolved Hide resolved
Originally recolor was called and every type of input was passed through
gdaldem, but we discovered this is bad for geotiffs because they can be single
band values and we don't want to split those into 4 color images.

DAS-1480
Copy link
Member

@owenlittlejohns owenlittlejohns left a comment

Choose a reason for hiding this comment

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

Thanks for digging into this so much. Really glad to see some unit tests added, too. Nice!

from harmony.message import Message


class TestRecolor(TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding some tests - these look great!

if colormap is None and ('png' in fmt.mime or 'jpeg' in fmt.mime):

# Don't color tiffs
colorable_mime_types = ['image/png', 'image/jpeg']
Copy link
Member

Choose a reason for hiding this comment

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

Even though this variable is only being used once, I like it because it makes it really clear what the next line is checking for. (Also it's easy to update the list without having to make the line below jump through formatting hoops for line length)

@flamingbear flamingbear merged commit c02ecf6 into main Jun 16, 2022
@flamingbear flamingbear deleted the mhs/DAS-1480/regression-test-and-debugging-instructions branch June 16, 2022 21:13
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.

2 participants