Skip to content

Commit bfaea1f

Browse files
committed
[sonar] more issue fixing
1 parent c2ac931 commit bfaea1f

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

src/bindings/python/dtlmod_python.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ PYBIND11_MODULE(dtlmod, m)
8383
"Create the DTL (no return)")
8484
.def_static("create", py::overload_cast<const std::string&>(&DTL::create),
8585
py::call_guard<py::gil_scoped_release>(), py::arg("filename"), "Create the DTL (no return)")
86-
.def_static("connect", py::overload_cast<>(&DTL::connect), py::call_guard<py::gil_scoped_release>(),
86+
.def_static("connect", &DTL::connect, py::call_guard<py::gil_scoped_release>(),
8787
"Connect an Actor to the DTL")
88-
.def_static("disconnect", py::overload_cast<>(&DTL::disconnect), py::call_guard<py::gil_scoped_release>(),
88+
.def_static("disconnect", &DTL::disconnect, py::call_guard<py::gil_scoped_release>(),
8989
"Disconnect an Actor from the DTL")
9090
.def_property_readonly("has_active_connections", &DTL::has_active_connections,
9191
"Check whether some simulated actors are currently connected to the DTL (read-only)")

test/python/dtl_file_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def sub_test_actor():
198198

199199
this_actor.info("Check local size of var_sub. Should be 3,200,000,000 bytes")
200200
assert var_sub.local_size == 8 * 20000 * 20000
201-
assert math.isclose(Engine.clock, 42.469851)
201+
assert math.isclose(Engine.clock, 42.469851, abs_tol=1e-6)
202202
this_actor.info("Close the engine")
203203
engine.close()
204204
this_actor.info("Disconnect from the DTL")

test/python/dtl_stream.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def setup_platform():
1818
prod_host = zone.add_host("prod_host", "1Gf")
1919
prod_host.core_count = 2
2020
cons_host = zone.add_host("cons_host", "1Gf")
21-
prod_disk = prod_host.add_disk("prod_disk", "1kBps", "2kBps")
22-
cons_disk = cons_host.add_disk("cons_disk", "1kBps", "2kBps")
21+
prod_host.add_disk("prod_disk", "1kBps", "2kBps")
22+
cons_host.add_disk("cons_disk", "1kBps", "2kBps")
2323

2424
pfs_server = zone.add_host("pfs_server", "1Gf")
2525
pfs_disks = []
@@ -43,7 +43,7 @@ def setup_platform():
4343
return e, prod_host, cons_host
4444

4545
def run_test_incorrect_stream_settings():
46-
e, prod_host, cons_host = setup_platform()
46+
e, prod_host, _ = setup_platform()
4747
def test_producer_actor():
4848
this_actor.info("Connect to the DTL")
4949
dtl = DTL.connect()
@@ -77,7 +77,7 @@ def test_producer_actor():
7777
e.run()
7878

7979
def run_test_publish_file_stream_open_close():
80-
e, prod_host, cons_host = setup_platform()
80+
e, prod_host, _ = setup_platform()
8181
def test_producer_actor():
8282
this_actor.info("Connect to the DTL")
8383
dtl = DTL.connect()

test/python/dtl_variable.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ def define_variable():
3131
this_actor.info("Create a stream")
3232
stream = dtl.add_stream("Stream")
3333
this_actor.info("Create a scalar int variable")
34-
var = stream.define_variable("scalar", ctypes.sizeof(ctypes.c_int))
34+
stream.define_variable("scalar", ctypes.sizeof(ctypes.c_int))
3535
this_actor.info("Create a 3D variable")
36-
var3D = stream.define_variable("var3D", (64, 64, 64), (0, 0, 0), (64, 64, 64),
36+
var3d = stream.define_variable("var3d", (64, 64, 64), (0, 0, 0), (64, 64, 64),
3737
ctypes.sizeof(ctypes.c_double))
3838
this_actor.info("Check name")
39-
assert var3D.name == "var3D"
39+
assert var3d.name == "var3d"
4040
this_actor.info("Check size: should be 64^3 times 8 as elements are double")
41-
assert var3D.global_size == (64 * 64 * 64 * 8)
42-
this_actor.info("Remove variable named 'var3D'. It is known, should be true")
43-
assert stream.remove_variable("var3D") == True
41+
assert var3d.global_size == (64 * 64 * 64 * 8)
42+
this_actor.info("Remove variable named 'var3d'. It is known, should be true")
43+
assert stream.remove_variable("var3d") == True
4444
this_actor.info("Remove variable named 'var2D'. It is unknown, should be false")
4545
assert stream.remove_variable("var2D") == False
4646

@@ -60,13 +60,13 @@ def inconsistent_variable_definition():
6060
stream = dtl.add_stream("Stream")
6161
this_actor.info("Create a 3D variable with only two offsets, should fail.")
6262
try:
63-
stream.define_variable("var3D", (64, 64, 64), (0, 0), (64, 64, 64), ctypes.sizeof(ctypes.c_double))
63+
stream.define_variable("var3d", (64, 64, 64), (0, 0), (64, 64, 64), ctypes.sizeof(ctypes.c_double))
6464
assert False, "Expected InconsistentVariableDefinitionException was not raised"
6565
except InconsistentVariableDefinitionException:
6666
pass # Test passes
6767
this_actor.info("Create a 3D variable with only two element counts, should fail.")
6868
try:
69-
stream.define_variable("var3D", (64, 64, 64), (0, 0, 0), (64, 64), ctypes.sizeof(ctypes.c_double))
69+
stream.define_variable("var3d", (64, 64, 64), (0, 0, 0), (64, 64), ctypes.sizeof(ctypes.c_double))
7070
assert False, "Expected InconsistentVariableDefinitionException was not raised"
7171
except InconsistentVariableDefinitionException:
7272
pass # Test passes
@@ -97,21 +97,21 @@ def multi_define_variable():
9797
except MultipleVariableDefinitionException:
9898
pass # Test passes
9999
this_actor.info("Define a new 3D variable")
100-
stream.define_variable("var3D", (64, 64, 64), (0, 0, 0), (64, 64, 64), ctypes.sizeof(ctypes.c_double))
100+
stream.define_variable("var3d", (64, 64, 64), (0, 0, 0), (64, 64, 64), ctypes.sizeof(ctypes.c_double))
101101
this_actor.info("Try to redefine var2 as a 2D variable, which should fail")
102102
try:
103-
stream.define_variable("var3D", (64, 64), (0, 0), (64, 64), ctypes.sizeof(ctypes.c_double))
103+
stream.define_variable("var3d", (64, 64), (0, 0), (64, 64), ctypes.sizeof(ctypes.c_double))
104104
assert False, "Expected MultipleVariableDefinitionException was not raised"
105105
except MultipleVariableDefinitionException:
106106
pass # Test passes
107107
this_actor.info("Try to redefine var as a 3D int variable, which should fail")
108108
try:
109-
stream.define_variable("var3D", (64, 64, 64), (0, 0, 0), (64, 64, 64), ctypes.sizeof(ctypes.c_int)),
109+
stream.define_variable("var3d", (64, 64, 64), (0, 0, 0), (64, 64, 64), ctypes.sizeof(ctypes.c_int)),
110110
assert False, "Expected MultipleVariableDefinitionException was not raised"
111111
except MultipleVariableDefinitionException:
112112
pass # Test passes
113113
this_actor.info("Try to redefine starts and counts which should work")
114-
var = stream.define_variable("var3D", (64, 64, 64), (16, 16, 16), (32, 32, 32), ctypes.sizeof(ctypes.c_double))
114+
var = stream.define_variable("var3d", (64, 64, 64), (16, 16, 16), (32, 32, 32), ctypes.sizeof(ctypes.c_double))
115115
this_actor.info("Check local and global sizes")
116116
assert var.local_size == 32 * 32 * 32 * 8
117117
assert var.global_size == 64 * 64 * 64 * 8
@@ -190,7 +190,7 @@ def inquire_variable_local():
190190
this_actor.info("Create a stream")
191191
stream = dtl.add_stream("Stream")
192192
this_actor.info("Create a 3D variable")
193-
var = stream.define_variable("var", (64, 64, 64), (0, 0, 0), (64, 64, 64), ctypes.sizeof(ctypes.c_double))
193+
stream.define_variable("var", (64, 64, 64), (0, 0, 0), (64, 64, 64), ctypes.sizeof(ctypes.c_double))
194194
this_actor.info("Inquire this variable and store it in var2")
195195
var2 = stream.inquire_variable("var")
196196
this_actor.info("Check name and size of the inquired variable")
@@ -217,7 +217,7 @@ def inquire_variable_remote_producer():
217217
this_actor.info("Create a stream")
218218
stream = dtl.add_stream("Stream")
219219
this_actor.info("Create a 3D variable")
220-
var = stream.define_variable("var", (64, 64, 64), (0, 0, 0), (64, 64, 64), ctypes.sizeof(ctypes.c_double))
220+
stream.define_variable("var", (64, 64, 64), (0, 0, 0), (64, 64, 64), ctypes.sizeof(ctypes.c_double))
221221
this_actor.info("Disconnect the actor from the DTL")
222222
DTL.disconnect()
223223

test/test_util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ static void DO_TEST_WITH_FORK(const std::function<void()> &lambda) {
1010
ASSERT_EQ(exit_code, 0);
1111
} else {
1212
lambda();
13-
exit((::testing::Test::HasFailure() ? 255 : 0));
13+
exit(::testing::Test::HasFailure() ? 255 : 0);
1414
}
1515
}
1616

0 commit comments

Comments
 (0)