diff --git a/docs/src/pyexamples.rst b/docs/src/pyexamples.rst index e92d05fd9..cff5caf34 100755 --- a/docs/src/pyexamples.rst +++ b/docs/src/pyexamples.rst @@ -74,7 +74,7 @@ But lets start looking at the at the manual way: :: import time - from sls_detector import Eiger + from slsdet import Eiger d = Eiger() n = 10 @@ -114,7 +114,7 @@ hang around until the main process exits. import time from multiprocessing import Process - from sls_detector import Eiger + from slsdet import Eiger def acquire(): """ diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index c79485fd7..54bf66c59 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -434,7 +434,7 @@ std::string CmdProxy::Exptime(int action) { if (gateIndex == -1 && det->getDetectorType().squash() == defs::MYTHEN3) { auto t = det->getExptimeForAllGates({det_id}); - if (args.size() == 0) { + if (args.empty()) { os << OutString(t) << '\n'; } else if (args.size() == 1) { os << OutString(t, args[0]) << '\n'; @@ -448,7 +448,7 @@ std::string CmdProxy::Exptime(int action) { } else { t = det->getExptime(gateIndex, {det_id}); } - if (args.size() == 0) { + if (args.empty()) { os << OutString(t) << '\n'; } else if (args.size() == 1) { os << OutString(t, args[0]) << '\n'; @@ -932,11 +932,11 @@ std::string CmdProxy::DacValues(int action) { auto it = t.cbegin(); os << ToString(*it) << ' ' << OutString(det->getDAC(*it++, mv, {det_id})) - << (args.size() > 0 ? " mv" : ""); + << (!args.empty() ? " mv" : ""); while (it != t.cend()) { os << ", " << ToString(*it) << ' ' << OutString(det->getDAC(*it++, mv, {det_id})) - << (args.size() > 0 ? " mv" : ""); + << (!args.empty() ? " mv" : ""); } os << "]\n"; } else if (action == defs::PUT_ACTION) { @@ -955,7 +955,7 @@ std::string CmdProxy::ReceiverStatus(int action) { if (action == defs::HELP_ACTION) { os << "running, idle]\n\tReceiver listener status." << '\n'; } else if (action == defs::GET_ACTION) { - if (args.size() != 0) { + if (!args.empty()) { WrongNumberOfParameters(0); } auto t = det->getReceiverStatus({det_id}); @@ -977,7 +977,7 @@ std::string CmdProxy::DetectorStatus(int action) { "idle]\n\tDetector status." << '\n'; } else if (action == defs::GET_ACTION) { - if (args.size() != 0) { + if (!args.empty()) { WrongNumberOfParameters(0); } auto t = det->getDetectorStatus({det_id}); @@ -1003,7 +1003,7 @@ std::string CmdProxy::UDPDestinationIP(int action) { << '\n'; } else if (action == defs::GET_ACTION) { auto t = det->getDestinationUDPIP({det_id}); - if (args.size() != 0) { + if (!args.empty()) { WrongNumberOfParameters(0); } os << OutString(t) << '\n'; @@ -1045,7 +1045,7 @@ std::string CmdProxy::UDPDestinationIP2(int action) { << '\n'; } else if (action == defs::GET_ACTION) { auto t = det->getDestinationUDPIP2({det_id}); - if (args.size() != 0) { + if (!args.empty()) { WrongNumberOfParameters(0); } os << OutString(t) << '\n'; @@ -1753,7 +1753,7 @@ std::string CmdProxy::GateDelay(int action) { // vector of gate delays if (gateIndex == -1) { auto t = det->getGateDelayForAllGates({det_id}); - if (args.size() == 0) { + if (args.empty()) { os << OutString(t) << '\n'; } else if (args.size() == 1) { os << OutString(t, args[0]) << '\n'; @@ -1762,7 +1762,7 @@ std::string CmdProxy::GateDelay(int action) { // single gate delay else { auto t = det->getGateDelay(gateIndex, {det_id}); - if (args.size() == 0) { + if (args.empty()) { os << OutString(t) << '\n'; } else if (args.size() == 1) { os << OutString(t, args[0]) << '\n'; @@ -2212,7 +2212,7 @@ std::string CmdProxy::AdditionalJsonHeader(int action) { "listening to receiver zmq packets. Empty value deletes header. " << '\n'; } else if (action == defs::GET_ACTION) { - if (args.size() != 0) { + if (!args.empty()) { WrongNumberOfParameters(0); } auto t = det->getAdditionalJsonHeader({det_id}); diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index cf4a94c8c..06af4dfa7 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -25,7 +25,7 @@ os << HLPSTR << '\n'; \ else if (action == slsDetectorDefs::GET_ACTION) { \ auto t = det->GETFCN({det_id}); \ - if (args.size() == 0) { \ + if (args.empty()) { \ os << OutString(t) << '\n'; \ } else if (args.size() == 1) { \ os << OutString(t, args[0]) << '\n'; \ @@ -65,7 +65,7 @@ os << HLPSTR << '\n'; \ else if (action == slsDetectorDefs::GET_ACTION) { \ auto t = det->GETFCN({det_id}); \ - if (args.size() == 0) { \ + if (args.empty()) { \ os << OutString(t) << '\n'; \ } else if (args.size() == 1) { \ os << OutString(t, args[0]) << '\n'; \ @@ -88,7 +88,7 @@ if (action == slsDetectorDefs::HELP_ACTION) \ os << HLPSTR << '\n'; \ else if (action == slsDetectorDefs::GET_ACTION) { \ - if (args.size() != 0) { \ + if (!args.empty()) { \ WrongNumberOfParameters(0); \ } \ auto t = det->GETFCN({det_id}); \ @@ -113,7 +113,7 @@ if (action == slsDetectorDefs::HELP_ACTION) \ os << HLPSTR << '\n'; \ else if (action == slsDetectorDefs::GET_ACTION) { \ - if (args.size() != 0) { \ + if (!args.empty()) { \ WrongNumberOfParameters(0); \ } \ auto t = det->GETFCN({det_id}); \ @@ -139,7 +139,7 @@ if (action == slsDetectorDefs::HELP_ACTION) \ os << HLPSTR << '\n'; \ else if (action == slsDetectorDefs::GET_ACTION) { \ - if (args.size() != 0) { \ + if (!args.empty()) { \ WrongNumberOfParameters(0); \ } \ auto t = det->GETFCN({det_id}); \ @@ -165,7 +165,7 @@ if (action == slsDetectorDefs::HELP_ACTION) \ os << HLPSTR << '\n'; \ else if (action == slsDetectorDefs::GET_ACTION) { \ - if (args.size() != 0) { \ + if (!args.empty()) { \ WrongNumberOfParameters(0); \ } \ auto t = det->GETFCN({det_id}); \ @@ -194,7 +194,7 @@ if (action == slsDetectorDefs::HELP_ACTION) \ os << HLPSTR << '\n'; \ else if (action == slsDetectorDefs::GET_ACTION) { \ - if (args.size() != 0) { \ + if (!args.empty()) { \ WrongNumberOfParameters(0); \ } \ auto t = det->GETFCN(); \ @@ -220,7 +220,7 @@ if (action == slsDetectorDefs::HELP_ACTION) \ os << HLPSTR << '\n'; \ else if (action == slsDetectorDefs::GET_ACTION) { \ - if (args.size() != 0) { \ + if (!args.empty()) { \ WrongNumberOfParameters(0); \ } \ auto t = det->GETFCN(INDEX, {det_id}); \ @@ -316,7 +316,7 @@ else if (action == slsDetectorDefs::GET_ACTION) { \ throw sls::RuntimeError("Cannot get"); \ } else if (action == slsDetectorDefs::PUT_ACTION) { \ - if (args.size() != 0) { \ + if (!args.empty()) { \ WrongNumberOfParameters(0); \ } \ det->SETFCN(); \ @@ -337,7 +337,7 @@ else if (action == slsDetectorDefs::GET_ACTION) { \ throw sls::RuntimeError("Cannot get"); \ } else if (action == slsDetectorDefs::PUT_ACTION) { \ - if (args.size() != 0) { \ + if (!args.empty()) { \ WrongNumberOfParameters(0); \ } \ det->SETFCN({det_id}); \ @@ -380,7 +380,7 @@ if (action == slsDetectorDefs::HELP_ACTION) \ os << HLPSTR << '\n'; \ else if (action == slsDetectorDefs::GET_ACTION) { \ - if (args.size() != 0) { \ + if (!args.empty()) { \ WrongNumberOfParameters(0); \ } \ auto t = det->GETFCN({det_id}); \ @@ -401,7 +401,7 @@ if (action == slsDetectorDefs::HELP_ACTION) \ os << HLPSTR << '\n'; \ else if (action == slsDetectorDefs::GET_ACTION) { \ - if (args.size() != 0) { \ + if (!args.empty()) { \ WrongNumberOfParameters(0); \ } \ auto t = det->GETFCN({det_id}); \ @@ -421,7 +421,7 @@ if (action == slsDetectorDefs::HELP_ACTION) \ os << HLPSTR << '\n'; \ else if (action == slsDetectorDefs::GET_ACTION) { \ - if (args.size() != 0) { \ + if (!args.empty()) { \ WrongNumberOfParameters(0); \ } \ auto t = det->GETFCN(VAL, {det_id}); \ diff --git a/slsDetectorSoftware/src/DetectorImpl.h b/slsDetectorSoftware/src/DetectorImpl.h index 54832e468..7e0613cee 100644 --- a/slsDetectorSoftware/src/DetectorImpl.h +++ b/slsDetectorSoftware/src/DetectorImpl.h @@ -87,7 +87,7 @@ class DetectorImpl : public virtual slsDetectorDefs { std::vector positions, typename NonDeduced::type... Args) { - if (detectors.size() == 0) + if (detectors.empty()) throw sls::RuntimeError("No detectors added"); if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) { @@ -115,7 +115,7 @@ class DetectorImpl : public virtual slsDetectorDefs { std::vector positions, typename NonDeduced::type... Args) const { - if (detectors.size() == 0) + if (detectors.empty()) throw sls::RuntimeError("No detectors added"); if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) { @@ -143,7 +143,7 @@ class DetectorImpl : public virtual slsDetectorDefs { std::vector positions, typename NonDeduced::type... Args) { - if (detectors.size() == 0) + if (detectors.empty()) throw sls::RuntimeError("No detectors added"); if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) { @@ -168,7 +168,7 @@ class DetectorImpl : public virtual slsDetectorDefs { std::vector positions, typename NonDeduced::type... Args) const { - if (detectors.size() == 0) + if (detectors.empty()) throw sls::RuntimeError("No detectors added"); if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) { diff --git a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp index e41bea6b4..1014bcc60 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp @@ -407,7 +407,7 @@ TEST_CASE("threshold", "[.cmd][.new]") { auto prev_threshold = det.getThresholdEnergy(); auto prev_energies = det.getTrimEnergies().tsquash("inconsistent trim energies to test"); - if (prev_energies.size() != 0) { + if (!prev_energies.empty()) { std::ostringstream oss1, oss2; proxy.Call("threshold", {"4500", "standard"}, -1, PUT, oss1); REQUIRE(oss1.str() == "threshold [4500, standard]\n"); @@ -436,7 +436,7 @@ TEST_CASE("thresholdnotb", "[.cmd][.new]") { auto prev_threshold = det.getThresholdEnergy(); auto prev_energies = det.getTrimEnergies().tsquash("inconsistent trim energies to test"); - if (prev_energies.size() != 0) { + if (!prev_energies.empty()) { std::ostringstream oss1, oss2; proxy.Call("thresholdnotb", {"4500 standard"}, -1, PUT, oss1); REQUIRE(oss1.str() == "thresholdnotb [4500 standard]\n"); diff --git a/slsSupportLib/tests/test-string_utils.cpp b/slsSupportLib/tests/test-string_utils.cpp index 48045d68a..97d52d7c7 100644 --- a/slsSupportLib/tests/test-string_utils.cpp +++ b/slsSupportLib/tests/test-string_utils.cpp @@ -57,7 +57,7 @@ TEST_CASE("Remove char from string") { TEST_CASE("Remove char from empty string") { char str[50] = {}; sls::removeChar(str, 'e'); - REQUIRE(std::string(str) == ""); + REQUIRE(std::string(str).empty()); } TEST_CASE("Many characters in a row") {