Skip to content
Open
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
6 changes: 3 additions & 3 deletions igor/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ class Structure (_struct.Struct):

You can also read out from strings:

>>> d = experiment.unpack(b.tostring())
>>> d = experiment.unpack(b.tobytes())
>>> pprint(d)
{'runs': [{'data': array([[1543, 2057, 2571],
[3085, 3599, 4113]]),
Expand All @@ -447,9 +447,9 @@ class Structure (_struct.Struct):
values are filled in with their defaults.

>>> experiment.pack_into(buffer=b, data=d)
>>> b.tostring()[:17]
>>> b.tobytes()[:17]
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10'
>>> b.tostring()[17:]
>>> b.tobytes()[17:]
'\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !'
>>> run0 = d['runs'].pop(0)
>>> b = experiment.pack(data=d)
Expand Down
2 changes: 1 addition & 1 deletion igor/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def hex_bytes(buffer, spaces=None):
hex_bytes = ['{:02x}'.format(_ord(x)) for x in buffer]
if spaces is None:
return ''.join(hex_bytes)
elif spaces is 1:
elif spaces == 1:
return ' '.join(hex_bytes)
for i in range(len(hex_bytes)//spaces):
hex_bytes.insert((spaces+1)*(i+1)-1, ' ')
Expand Down