Skip to content

Commit

Permalink
Merge pull request #1676 from germasch/pr/python-fix-localarray-selec…
Browse files Browse the repository at this point in the history
…tion

python/hl: fix read() with selection of LocalArrays
  • Loading branch information
williamfgc authored Aug 13, 2019
2 parents 0fa6aee + e38ec22 commit 3a3491e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion bindings/Python/py11File.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ pybind11::array File::DoRead(const std::string &name, const Dims &_start,
variable.SetStepSelection({stepStart, stepCount});
}

m_Stream->Read(name, pyArray.mutable_data(), blockID);
if (!m_Stream->m_Engine)
{
throw std::logic_error("no engine available in DoRead()");
}
m_Stream->m_Engine->Get(variable, pyArray.mutable_data(), Mode::Sync);

return pyArray;
}
Expand Down
4 changes: 2 additions & 2 deletions source/adios2/toolkit/format/bp3/BP3Deserializer.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void BP3Deserializer::SetVariableBlockInfo(
helper::DimsToString(blockInfo.Count) +
" (requested) is out of bounds of (available) local"
" Count " +
helper::DimsToString(blockCharacteristics.Shape) +
helper::DimsToString(readInCount) +
" , when reading local array variable " + variableName +
", in call to Get");
}
Expand Down Expand Up @@ -340,7 +340,7 @@ void BP3Deserializer::SetVariableBlockInfo(
helper::DimsToString(blockInfo.Count) +
" (requested) is out of bounds of (available) "
"Shape " +
helper::DimsToString(blockCharacteristics.Shape) +
helper::DimsToString(readInShape) +
" , when reading global array variable " +
variableName + ", in call to Get");
}
Expand Down
4 changes: 2 additions & 2 deletions source/adios2/toolkit/format/bp4/BP4Deserializer.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void BP4Deserializer::SetVariableBlockInfo(
helper::DimsToString(blockInfo.Count) +
" (requested) is out of bounds of (available) local"
" Count " +
helper::DimsToString(blockCharacteristics.Shape) +
helper::DimsToString(readInCount) +
" , when reading local array variable " + variableName +
", in call to Get");
}
Expand Down Expand Up @@ -341,7 +341,7 @@ void BP4Deserializer::SetVariableBlockInfo(
helper::DimsToString(blockInfo.Count) +
" (requested) is out of bounds of (available) "
"Shape " +
helper::DimsToString(blockCharacteristics.Shape) +
helper::DimsToString(readInShape) +
" , when reading global array variable " +
variableName + ", in call to Get");
}
Expand Down
8 changes: 4 additions & 4 deletions testing/adios2/bindings/python/TestHighLevelAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ def test_LocalValueDefault(self):
val = fh.read("local_value", (), ())
self.assertTrue(np.array_equal(val, local_values[t]))

@unittest.expectedFailure
def test_LocalArray(self):
with adios2.open(filename, 'r') as fh:
for fh_step in fh:
t = fh_step.current_step()
for b in range(n_blocks):
val = fh_step.read("local_array", (1, 1), (4, 2), b)
self.assertTrue(np.array_equal(val, local_arrays[t][b]))
self.assertTrue(np.array_equal(
val, local_arrays[t][b][1:6, 1:3]))

def test_LocalArrayDefault(self):
with adios2.open(filename, 'r') as fh:
Expand Down Expand Up @@ -148,12 +148,12 @@ def test_LocalValueDefault(self):
val = fh.read("local_value", (), (), 1, 2)
self.assertTrue(np.array_equal(val, local_values[1:3]))

@unittest.expectedFailure
def test_LocalArray(self):
with adios2.open(filename, 'r') as fh:
for b in range(n_blocks):
val = fh.read("local_array", (1, 1), (4, 2), 1, 2, b)
self.assertTrue(np.array_equal(val, local_arrays[1:3][b]))
self.assertTrue(np.array_equal(
val, local_arrays[1:3, b, 1:5, 1:3]))


if __name__ == '__main__':
Expand Down

0 comments on commit 3a3491e

Please sign in to comment.