Skip to content

Commit

Permalink
Merge pull request #597 from EnMAP-Box/588-rename-exampledata-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
jakimowb authored Sep 5, 2023
2 parents 3eb31e3 + dc3d74b commit ffaf3d2
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion enmapbox/coreapps/metadataeditorapp/metadatakeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def initListLength(self, obj, value):
def setValue(self, value):

def convertOrFail(value):
if type(value) != self.mType:
if type(value) is not self.mType:
try:
value = self.mType(value)
except Exception as ex:
Expand Down
6 changes: 3 additions & 3 deletions enmapbox/exampledata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from os.path import dirname, join

aerial = join(dirname(__file__), 'aerial_potsdam.tif')
hires = join(dirname(__file__), 'aerial_potsdam.tif')
enmap = join(dirname(__file__), 'enmap_potsdam.tif')
landcover_potsdam_point = join(dirname(__file__), 'landcover_potsdam_point.gpkg')
landcover_potsdam_polygon = join(dirname(__file__), 'landcover_potsdam_polygon.gpkg')
landcover_point = join(dirname(__file__), 'landcover_potsdam_point.gpkg')
landcover_polygon = join(dirname(__file__), 'landcover_potsdam_polygon.gpkg')
4 changes: 2 additions & 2 deletions enmapbox/gui/enmapboxgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1879,9 +1879,9 @@ def niceLayerOrder(lyr: QgsMapLayer) -> (int, int):
lyrs = [lyr for lyr in sorted(lyrs, key=niceLayerOrder)]

# quick fix for issue #555
from enmapbox.exampledata import enmap, aerial
from enmapbox.exampledata import enmap, hires
lyrNames = [basename(lyr.source()) for lyr in lyrs]
a, b = lyrNames.index(basename(aerial)), lyrNames.index(basename(enmap))
a, b = lyrNames.index(basename(hires)), lyrNames.index(basename(enmap))
lyrs[b], lyrs[a] = lyrs[a], lyrs[b] # we just switch positions

for lyr in lyrs:
Expand Down
12 changes: 6 additions & 6 deletions tests/src/core/test_datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
from qgis.core import QgsProject, QgsMapLayer, QgsRasterLayer, QgsVectorLayer, QgsRasterRenderer, QgsRasterDataProvider
from qgis.gui import QgsMapCanvas

from enmapbox.exampledata import enmap, hires, landcover_polygon, library_gpkg, enmap_srf_library
from enmapbox.exampledata import enmap, hires, landcover_polygon
from enmapbox.gui.datasources.datasources import SpatialDataSource, DataSource, RasterDataSource, VectorDataSource, \
FileDataSource
from enmapbox.gui.datasources.manager import DataSourceManager, DataSourceManagerPanelUI, DataSourceFactory
from enmapbox.testing import TestObjects, EnMAPBoxTestCase
from enmapboxtestdata import classifierDumpPkl
from enmapboxtestdata import classifierDumpPkl, library_berlin, enmap_srf_library


class DataSourceTests(EnMAPBoxTestCase):
Expand Down Expand Up @@ -82,7 +82,7 @@ def test_subdatasets(self):
def createTestSources(self) -> list:

# return [library, self.wfsUri, self.wmsUri, enmap, landcover_polygons]
return [library_gpkg, enmap, landcover_polygon]
return [library_berlin, enmap, landcover_polygon]

def createOGCSources(self) -> list:
# todo: add WCS
Expand Down Expand Up @@ -146,7 +146,7 @@ def test_DataSourcePanelUI(self):
dsm = DataSourceManager()
panel = DataSourceManagerPanelUI()
panel.connectDataSourceManager(dsm)
uris = [library_gpkg, enmap, landcover_polygon]
uris = [library_berlin, enmap, landcover_polygon]
dsm.addDataSources(uris)
self.showGui(panel)

Expand Down Expand Up @@ -192,14 +192,14 @@ def test_node_updates(self):
self.assertTrue(ds2.updateTime() > t0_2)

def test_DataSourceModel(self):
from enmapbox.exampledata import enmap, landcover_polygon, library_gpkg, enmap_srf_library

sources = [enmap,
enmap,
landcover_polygon,
landcover_polygon,
enmap_srf_library,
enmap_srf_library,
library_gpkg,
library_berlin,
classifierDumpPkl]

model = DataSourceManager()
Expand Down
6 changes: 3 additions & 3 deletions tests/src/core/test_docksanddatasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import tempfile
import unittest

from enmapbox.exampledata import landcover_polygon, library_gpkg, enmap, hires
from enmapbox.exampledata import landcover_polygon, enmap, hires
from enmapbox.gui.datasources.datasources import VectorDataSource, RasterDataSource
from enmapbox.gui.datasources.manager import DataSourceManager
from enmapbox.gui.dataviews.dockmanager import DockManager, SpeclibDockTreeNode, MapDockTreeNode, \
Expand All @@ -26,7 +26,7 @@
from enmapbox.qgispluginsupport.qps.pyqtgraph.pyqtgraph.dockarea.Dock import Dock as pgDock
from enmapbox.qgispluginsupport.qps.speclib.core import is_spectral_library
from enmapbox.testing import EnMAPBoxTestCase, TestObjects
from enmapboxtestdata import classificationDatasetAsPklFile
from enmapboxtestdata import classificationDatasetAsPklFile, library_berlin
from qgis.PyQt.QtWidgets import QApplication
from qgis.core import QgsProject, QgsVectorLayer, QgsRasterLayer, QgsLayerTreeModel, QgsLayerTree
from qgis.gui import QgsMapCanvas, QgsLayerTreeView
Expand All @@ -50,7 +50,7 @@ def onSignal(dataSource):

DSM.addDataSources(enmap)
DSM.addDataSources(landcover_polygon)
DSM.addDataSources(library_gpkg)
DSM.addDataSources(library_berlin)

self.assertTrue(len(signalArgs) == 3)
self.assertIsInstance(signalArgs[0], RasterDataSource)
Expand Down
5 changes: 3 additions & 2 deletions tests/src/core/test_mapcanvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
import unittest

from enmapbox.gui.enmapboxgui import EnMAPBox
from enmapbox.exampledata import enmap, hires, landcover_polygon, library_gpkg
from enmapbox.exampledata import enmap, hires, landcover_polygon
from enmapbox.gui.dataviews.dockmanager import MapDockTreeNode
from enmapbox.gui.dataviews.docks import MapDock
from enmapbox.gui.mapcanvas import CanvasLink, MapCanvas, KEY_LAST_CLICKED, LINK_ON_CENTER
from enmapbox.qgispluginsupport.qps.maptools import CursorLocationMapTool, MapTools
from enmapbox.testing import EnMAPBoxTestCase
from enmapbox.testing import TestObjects
from enmapboxtestdata import library_berlin
from qgis.PyQt.QtCore import QMimeData, QUrl
from qgis.PyQt.QtGui import QKeyEvent
from qgis.PyQt.QtWidgets import QMenu, QAction
Expand Down Expand Up @@ -162,7 +163,7 @@ def test_dropEvents(self):
mapDock = MapDock()
node = MapDockTreeNode(mapDock)
mapCanvas = mapDock.mapCanvas()
allFiles = [enmap, hires, landcover_polygon, library_gpkg]
allFiles = [enmap, hires, landcover_polygon, library_berlin]
spatialFiles = [enmap, hires, landcover_polygon]

md = QMimeData()
Expand Down
5 changes: 3 additions & 2 deletions tests/src/core/test_mimedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
import enmapbox.gui.mimedata as mimedata
from enmapbox import DIR_EXAMPLEDATA
from enmapbox.gui.enmapboxgui import EnMAPBox
from enmapbox.exampledata import enmap, hires, library_gpkg, landcover_polygon
from enmapbox.exampledata import enmap, hires, landcover_polygon
from enmapbox.testing import EnMAPBoxTestCase
from enmapboxtestdata import library_berlin
from qgis.PyQt.QtCore import QMimeData, QByteArray, QUrl, Qt, QPoint
from qgis.PyQt.QtGui import QDropEvent
from qgis.PyQt.QtWidgets import QApplication
Expand Down Expand Up @@ -65,7 +66,7 @@ def test_datasourcehandling(self):
from enmapbox.gui.datasources.datasources import DataSource
from enmapbox.gui.datasources.manager import DataSourceFactory

dataSources = DataSourceFactory.create([enmap, hires, library_gpkg, landcover_polygon])
dataSources = DataSourceFactory.create([enmap, hires, library_berlin, landcover_polygon])
dataSourceObjectIDs = [id(ds) for ds in dataSources]

md = mimedata.fromDataSourceList(dataSources)
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/test_speclibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
from qgis.core import QgsFeature

from enmapbox.gui.enmapboxgui import EnMAPBox
from enmapbox.exampledata import enmap, enmap_srf_library
from enmapbox.exampledata import enmap
from enmapbox.gui.dataviews.docks import SpectralLibraryDock
from enmapbox.gui.mapcanvas import MapCanvas
from enmapbox.qgispluginsupport.qps.speclib.core.spectralprofile import encodeProfileValueDict
from enmapbox.qgispluginsupport.qps.utils import fid2pixelindices, SpatialPoint
from enmapbox.testing import EnMAPBoxTestCase
from qgis.gui import QgsMapLayerComboBox
from qgis.core import QgsRasterLayer, QgsVectorLayer
from enmapboxtestdata import fraction_polygon_l3, fraction_point_singletarget
from enmapboxtestdata import fraction_polygon_l3, fraction_point_singletarget, enmap_srf_library


class TestSpeclibs(EnMAPBoxTestCase):
Expand Down
5 changes: 2 additions & 3 deletions tests/src/core/test_spectral_processing.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest

from enmapboxtestdata import library_berlin
from qgis.core import QgsVectorLayer

from enmapbox.gui.enmapboxgui import EnMAPBox
from enmapbox.gui.dataviews.docks import DockTypes, SpectralLibraryDock
from enmapbox.qgispluginsupport.qps.speclib.gui.spectrallibrarywidget import SpectralLibraryWidget
from enmapbox.testing import EnMAPBoxTestCase
from enmapbox.exampledata import library_gpkg


class TestSpectralProcessing(EnMAPBoxTestCase):
Expand All @@ -19,10 +19,9 @@ def tearDown(self):

@unittest.skipIf(EnMAPBoxTestCase.runsInCI(), 'blocking dialog')
def test_spectralProcessingDialog(self):

EMB = EnMAPBox(load_core_apps=True, load_other_apps=False)
# EMB.loadExampleData()
speclib = QgsVectorLayer(library_gpkg, 'Speclib')
speclib = QgsVectorLayer(library_berlin, 'Speclib')
speclib.startEditing()
SLD: SpectralLibraryDock = EMB.createDock(DockTypes.SpectralLibraryDock, speclib=speclib)
SLW: SpectralLibraryWidget = SLD.speclibWidget()
Expand Down
10 changes: 5 additions & 5 deletions tests/src/enmapboxtestdata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pathlib
import platform
import warnings
from os.path import join, dirname, abspath
Expand All @@ -10,9 +11,9 @@

# Berlin example data
# ...this is the old example dataset, which we still need for unittests
_subdir = 'exampledata/berlin'
_subdir = pathlib.Path('exampledata/berlin')
enmap_berlin = join(_root, _subdir, 'enmap_berlin.bsq')
enmap_srf_library = join(dirname(__file__), 'enmap_srf_library.gpkg')
enmap_srf_library = join(_root, _subdir, 'enmap_srf_library.gpkg')
hires_berlin = join(_root, _subdir, 'hires_berlin.bsq')
landcover_berlin_point = join(_root, _subdir, 'landcover_berlin_point.gpkg')
landcover_berlin_polygon = join(_root, _subdir, 'landcover_berlin_polygon.gpkg')
Expand All @@ -21,10 +22,9 @@

# Potsdam example data
# ...current example dataset is placed under enmapbox.exampledata
aerial_potsdam = enmapbox.exampledata.aerial
enmap_potsdam = enmapbox.exampledata.enmap
landcover_potsdam_polygon = enmapbox.exampledata.landcover_potsdam_polygon
landcover_potsdam_point = enmapbox.exampledata.landcover_potsdam_point
landcover_potsdam_polygon = enmapbox.exampledata.landcover_polygon
landcover_potsdam_point = enmapbox.exampledata.landcover_point

# connect old shortcuts (requested by @jakimow)
enmap = enmap_berlin
Expand Down
2 changes: 1 addition & 1 deletion tests/src/otherapps/test_ensomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def has_package(name: str):
try:
__import__(name)
return True
except ModuleNotFoundError:
except (ModuleNotFoundError, SystemError):
return False


Expand Down

0 comments on commit ffaf3d2

Please sign in to comment.