Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Daniel Scheffler
geoarray
Commits
951d99a9
Commit
951d99a9
authored
Apr 09, 2018
by
Daniel Scheffler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed unequal return value of __getitem__ depending on is_inmem.
parent
38ad0f90
Pipeline
#2883
passed with stages
in 1 minute and 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
12 deletions
+31
-12
geoarray/baseclasses.py
geoarray/baseclasses.py
+6
-1
tests/test_geoarray.py
tests/test_geoarray.py
+25
-11
No files found.
geoarray/baseclasses.py
View file @
951d99a9
...
...
@@ -761,7 +761,7 @@ class GeoArray(object):
R
,
C
,
B
=
ds
.
RasterYSize
,
ds
.
RasterXSize
,
ds
.
RasterCount
del
ds
# convert getitem_params to subset area to be read #
#
# convert getitem_params to subset area to be read #
rS
,
rE
,
cS
,
cE
,
bS
,
bE
,
bL
=
[
None
]
*
7
# populate rS, rE, cS, cE, bS, bE, bL
...
...
@@ -861,6 +861,11 @@ class GeoArray(object):
del
ds
# 3D to 2D conversion in case out_arr can be represented by a 2D array (avoids shapes like (1,2,2
# NOTE: -> numpy also returns a 2D array in that case
if
1
in
out_arr
.
shape
:
out_arr
=
out_arr
.
reshape
(
*
[
i
for
i
in
out_arr
.
shape
if
i
!=
1
])
# only set self.arr if the whole cube has been read (in order to avoid sudden shape changes)
if
out_arr
.
shape
==
self
.
shape
:
self
.
arr
=
out_arr
...
...
tests/test_geoarray.py
View file @
951d99a9
...
...
@@ -36,6 +36,7 @@ from unittest import TestLoader
import
matplotlib
from
typing
import
Iterable
from
importlib
import
util
import
tempfile
# Imports regarding the created python module.
from
py_tools_ds.geo.vector
import
geometry
...
...
@@ -56,9 +57,8 @@ tests_path = os.path.abspath(path.join(__file__, "..", ".."))
class
Test_GeoarrayAppliedOnPathArray
(
unittest
.
TestCase
):
"""
The class "Test_GeoarrayAppliedOnPathArray" tests the basic functions of the
"GeoArray"-class from which the other functions depend on. The functions that
are being tested are stated in the docstrings located at the beginning of each
test. Note that the function set_gdalDataset_meta is tested indirectly by a
"GeoArray"-class from which the other functions depend.
Note that the function set_gdalDataset_meta is tested indirectly by a
couple of tests in the test case (a notation is applied).
Since the "GeoArray"-class can be instanced with a file path or with a numpy
...
...
@@ -326,6 +326,28 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
# TODO: add further tests
def
test___getitem__consistency
(
self
):
testarr
=
np
.
zeros
((
2
,
2
,
2
))
testarr
[
0
,
:,
:]
=
[[
11
,
12
],
[
13
,
14
]]
testarr
[
1
,
:,
:]
=
[[
21
,
22
],
[
23
,
24
]]
gA_inmem
=
GeoArray
(
testarr
)
inmem_res
=
gA_inmem
[
0
,
:,
:]
with
tempfile
.
TemporaryDirectory
()
as
tf
:
gA_inmem
.
save
(
os
.
path
.
join
(
tf
,
'test.bsq'
))
gA_notinmem
=
GeoArray
(
os
.
path
.
join
(
tf
,
'test.bsq'
))
notinmem_res
=
gA_notinmem
[
0
,
:,
:]
self
.
assertEqual
(
inmem_res
.
ndim
,
notinmem_res
.
ndim
)
self
.
assertEqual
(
inmem_res
.
shape
,
notinmem_res
.
shape
)
def
test_numpy_array
(
self
):
arr
=
np
.
array
(
self
.
testtiff
)
self
.
assertIsInstance
(
arr
,
np
.
ndarray
)
self
.
assertEqual
(
arr
.
shape
,
self
.
testtiff
.
shape
)
###################################
# Test case: Test_GeoarrayFunctions
...
...
@@ -333,14 +355,6 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
class
Test_GeoarrayFunctions
(
unittest
.
TestCase
):
"""
*** !!!
Note that the class "Test_GeoarrayFunctions" is NOT complete. Furthermore,
part of the tests that are contained in this test case are not completely
independent - some dependencies that can be found in the source code of the
function that is being tested is not yet considered. A respective comment
can be found at the beginning of the affected tests in the "TODO"-statement. ***
The class "Test_GeoarrayFunctions" is the second test case of the
"test_geoarray"-script and tests the functions of the "GeoArray"-class that are
not yet tested in the first test case. Since the basic functions on which most
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment