-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't crash raster shader with nan or inf values (fix #15444)
(cherry-picked from 34ebe12)
- Loading branch information
1 parent
0feca4c
commit a1f8a59
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
"""QGIS Unit tests for QgsColorRampShader. | ||
.. note:: This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
""" | ||
|
||
__author__ = 'Nyall Dawson' | ||
__date__ = '17/08/2016' | ||
__copyright__ = 'Copyright 2016, The QGIS Project' | ||
# This will get replaced with a git SHA1 when you do a git archive | ||
__revision__ = '$Format:%H$' | ||
|
||
import qgis # NOQA | ||
|
||
|
||
from qgis.PyQt.QtGui import QColor | ||
|
||
from qgis.core import (QgsColorRampShader) | ||
from qgis.testing import unittest | ||
|
||
|
||
class TestQgsRasterColorRampShader(unittest.TestCase): | ||
|
||
def testNan(self): | ||
shader = QgsColorRampShader() | ||
|
||
item1 = QgsColorRampShader.ColorRampItem(1, QColor(0, 0, 0)) | ||
item2 = QgsColorRampShader.ColorRampItem(2, QColor(255, 255, 255)) | ||
shader.setColorRampItemList([item1, item2]) | ||
self.assertFalse(shader.shade(float('NaN'))[0]) | ||
self.assertFalse(shader.shade(float("inf"))[0]) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |