Skip to content

Commit

Permalink
Remove printouts
Browse files Browse the repository at this point in the history
  • Loading branch information
austinschneider committed Oct 21, 2024
1 parent 591f272 commit de98902
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
16 changes: 0 additions & 16 deletions projects/serialization/public/SIREN/serialization/ByteString.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,12 @@ std::vector<char> to_byte_string(T const & obj) {
}

std::string bytes_to_hex_string(std::vector<char> const & bytes) {
std::cout << "bytes_to_hex_string" << std::endl;
std::cout << "bytes.size(): " << bytes.size() << std::endl;
std::ostringstream oss;
oss << std::hex << std::setfill('0');
for (char const & byte : bytes) {
oss << std::setw(2) << (unsigned int)std::uint8_t(byte);
}
std::string s = oss.str();
std::cout << "s.size(): " << s.size() << std::endl;
if(not (s.size() % 2 == 0))
throw std::runtime_error("s.size() % 2 != 0");
if(not (s.size() == 2 * bytes.size()))
Expand All @@ -52,11 +49,9 @@ std::string bytes_to_hex_string(std::vector<char> const & bytes) {

template<typename T>
T from_byte_string(std::vector<char> const & byte_string) {
std::cout << "from_byte_string" << std::endl;
std::string str(byte_string.begin(), byte_string.end());
if(not (str.size() == byte_string.size()))
throw std::runtime_error("str.size() != byte_string.size()");
std::cout << "str.size(): " << str.size() << std::endl;
std::istringstream iss(str, std::ios::binary);
std::shared_ptr<T> obj(cereal::access::construct<T>());
{
Expand All @@ -66,13 +61,10 @@ T from_byte_string(std::vector<char> const & byte_string) {
size_t n_bytes = iss.tellg();
if(not (n_bytes == str.size()))
throw std::runtime_error("n_bytes != str.size()");
std::cout << "obj: " << obj << std::endl;
return *obj;
}

std::vector<char> hex_string_to_bytes(std::string const & hex_string) {
std::cout << "hex_string_to_bytes" << std::endl;
std::cout << "hex_string.size(): " << hex_string.size() << std::endl;
std::vector<char> bytes;
for (size_t i = 0; i < hex_string.size(); i += 2) {
std::string byte_string = hex_string.substr(i, 2);
Expand All @@ -81,32 +73,24 @@ std::vector<char> hex_string_to_bytes(std::string const & hex_string) {
}
if(not (bytes.size() == hex_string.size() / 2))
throw std::runtime_error("bytes.size() != hex_string.size() / 2");
std::cout << "bytes.size(): " << bytes.size() << std::endl;
return bytes;
}

template<typename T>
pybind11::tuple pickle_save(T const & cpp_obj) {
std::vector<char> byte_string = to_byte_string(cpp_obj);
std::string hex_string = bytes_to_hex_string(byte_string);
std::cout << "Pickle save" << std::endl;
std::cout << "hex_string.size(): " << hex_string.size() << std::endl;
return pybind11::make_tuple(hex_string);
}

template<typename T>
T pickle_load(pybind11::tuple t) {
std::cout << "pickle_load" << std::endl;
std::cout << "t.size(): " << t.size() << std::endl;
if (t.size() != 1) {
throw std::runtime_error("Invalid state!");
}
std::string hex_string = t[0].cast<std::string>();
std::cout << "hex_string.size(): " << hex_string.size() << std::endl;
std::vector<char> byte_string = hex_string_to_bytes(hex_string);
std::cout << "byte_string.size(): " << byte_string.size() << std::endl;
T res = from_byte_string<T>(byte_string);
std::cout << "res: " << res << std::endl;
return res;
}

Expand Down
2 changes: 0 additions & 2 deletions python/Injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ def __setstate__(self, state):
self.__injector = _Injector.__new__(_Injector) # Create an empty instance
if self.__injector is None:
raise TypeError("Failed to create C++ Injector object")
print(self.__injector)
self.__injector.__setstate__(injector_state)
print(self.__injector)
self.__number_of_events = self.__injector.EventsToInject()
self.__detector_model = self.__injector.GetDetectorModel()
primary_process = self.__injector.GetPrimaryProcess()
Expand Down

0 comments on commit de98902

Please sign in to comment.