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

Python clean-ups #2492

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions testing/adios2/bindings/python/TestBPReadMultisteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,34 +225,34 @@ def check_name(name, name_list):

for i in range(0, 3):
for j in range(0, Nx):
if(inI8[i][j] != i):
if inI8[i][j] != i:
raise ValueError('failed reading I8')

if(inI16[i][j] != i):
if inI16[i][j] != i:
raise ValueError('failed reading I16')

if(inI32[i][j] != i):
if inI32[i][j] != i:
raise ValueError('failed reading I32')

if(inI64[i][j] != i):
if inI64[i][j] != i:
raise ValueError('failed reading I64')

if(inU8[i][j] != i):
if inU8[i][j] != i:
raise ValueError('failed reading U8')

if(inU16[i][j] != i):
if inU16[i][j] != i:
raise ValueError('failed reading U16')

if(inU32[i][j] != i):
if inU32[i][j] != i:
raise ValueError('failed reading U32')

if(inU64[i][j] != i):
if inU64[i][j] != i:
raise ValueError('failed reading U64')

if(inR32[i][j] != i):
if inR32[i][j] != i:
raise ValueError('failed reading R32')

if(inR64[i][j] != i):
if inR64[i][j] != i:
raise ValueError('failed reading R64')


Expand Down
2 changes: 1 addition & 1 deletion testing/adios2/bindings/python/TestBPWriteRead2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
ibpStream = ioRead.Open('HeatMap2D_py.bp', adios2.Mode.Read, MPI.COMM_SELF)
var_inTemperature = ioRead.InquireVariable("temperature2D")

if(var_inTemperature is False):
if var_inTemperature is False:
raise ValueError('var_inTemperature is False')

assert var_inTemperature is not None
Expand Down
39 changes: 19 additions & 20 deletions testing/adios2/bindings/python/TestBPWriteReadString.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

#
# Distributed under the OSI-approved Apache License, Version 2.0. See
# accompanying file Copyright.txt for details.
Expand All @@ -14,32 +13,32 @@

class TestAdiosWriteReadString(unittest.TestCase):

def test_adios_read_string(self):
def TestAdiosWriteReadString(self):
# MPI
comm = MPI.COMM_WORLD
the_string = 'hello adios'
bpfilename = 'string_test.bp'
theString = 'hello adios'
bpFilename = 'string_test.bp'
varname = 'mystringvar'
N_steps = 10
NSteps = 10
adios = adios2.ADIOS(comm)
ioWrite = adios.DeclareIO('ioWriter')
ad_engine = ioWrite.Open(bpfilename, adios2.Mode.Write)
var_mystringvar = ioWrite.DefineVariable(varname)
for step in range(N_steps):
ad_engine.BeginStep()
ad_engine.Put(var_mystringvar, the_string + str(step))
ad_engine.EndStep()
ad_engine.Close()
adEngine = ioWrite.Open(bpFilename, adios2.Mode.Write)
varMyStringVar = ioWrite.DefineVariable(varname)
for step in range(NSteps):
adEngine.BeginStep()
adEngine.Put(varMyStringVar, theString + str(step))
adEngine.EndStep()
adEngine.Close()

ioRead = adios.DeclareIO('ioReader')
ad_engine = ioRead.Open(bpfilename, adios2.Mode.Read)
var_read_mystringvar = ioRead.InquireVariable(varname)
for step in range(N_steps):
ad_engine.BeginStep()
result = ad_engine.Get(var_read_mystringvar)
ad_engine.EndStep()
self.assertEqual(result, the_string + str(step))
ad_engine.Close()
adEngine = ioRead.Open(bpFilename, adios2.Mode.Read)
varReadMyStringVar = ioRead.InquireVariable(varname)
for step in range(NSteps):
adEngine.BeginStep()
result = adEngine.Get(varReadMyStringVar)
adEngine.EndStep()
self.assertEqual(result, theString + str(step))
adEngine.Close()


if __name__ == '__main__':
Expand Down
18 changes: 8 additions & 10 deletions testing/adios2/bindings/python/TestBPWriteReadTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def check_name(name, name_list):


def check_array(np1, np2, hint):
if((np1 == np2).all() is False):
if (np1 == np2).all() is False:
print("InData: " + str(np1))
print("Data: " + str(np2))
raise ValueError('Array read failed ' + str(hint))
Expand Down Expand Up @@ -95,13 +95,11 @@ def check_array(np1, np2, hint):
attR64 = ioWriter.DefineAttribute("attrR64", data.R64)

ioWriter.SetEngine("BPFile")
ioParams = {}
ioParams['Threads'] = '1'
ioParams['InitialBufferSize'] = '17Kb'
ioParams = {'Threads': '1', 'InitialBufferSize': '17Kb'}
ioWriter.SetParameters(ioParams)

engineType = ioWriter.EngineType()
if(engineType != "BPFile"):
if engineType != "BPFile":
raise ValueError(str(engineType) +
' incorrect engine type, should be BPFile')

Expand Down Expand Up @@ -172,11 +170,11 @@ def check_array(np1, np2, hint):
check_object(attrR64, "attrR64")

attrStringData = attrString.DataString()
if(attrStringData[0] != "one"):
if attrStringData[0] != "one":
raise ValueError('attrStringData[0] failed')
if(attrStringData[1] != "two"):
if attrStringData[1] != "two":
raise ValueError('attrStringData[1] failed')
if(attrStringData[2] != "three"):
if attrStringData[2] != "three":
raise ValueError('attrStringData[2] failed')

attrI8Data = attrI8.Data()
Expand Down Expand Up @@ -245,7 +243,7 @@ def check_array(np1, np2, hint):


result = adios.RemoveIO('writer')
if(result is False):
if result is False:
raise ValueError('Could not remove IO writer')

assert (reader.Steps() == nsteps)
Expand All @@ -255,7 +253,7 @@ def check_array(np1, np2, hint):

ioReader.RemoveAllVariables()
varStr = ioReader.InquireVariable("varStr")
if(varStr is True):
if varStr is True:
raise ValueError('Could remove reader variables')

adios.RemoveAllIOs()
Expand Down
Loading