Skip to content

Instantly share code, notes, and snippets.

@takluyver
takluyver / h5py_strings.py
Created Oct 15, 2020
Read HDF5 strings as str with h5py 2.x and 3.0
View h5py_strings.py
"""Read HDF5 strings to Python str
h5py 3.0 changed the APIs for storing and reading strings.
This shows how to read strings as Python 3 str if you need
to support both old and new h5py.
"""
import h5py
import numpy as np
f = h5py.File('foo.h5', 'r')
@takluyver
takluyver / cache_format_options.py
Created Aug 27, 2019
Karabo data cache format experimentation
View cache_format_options.py
import json
import h5py
import numpy as np
def read_json(path):
with open(path) as f:
loaded_data = json.load(f)
res = {}
for info in loaded_data:
@takluyver
takluyver / VDS issue.ipynb
Created Apr 9, 2019
HDF5 virtual dataset access issue
View VDS issue.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@takluyver
takluyver / atomicity_issue_pull.py
Created Dec 7, 2018
Pyzmq multipart atomicity issue
View atomicity_issue_pull.py
import os
from time import monotonic
import zmq
# Set up a PULL socket
ctx = zmq.Context()
sock = ctx.socket(zmq.PULL)
sock.set_hwm(1)
sock.connect("tcp://127.0.0.1:8541")
@takluyver
takluyver / pull.py
Created Dec 7, 2018
ZMQ push/pull HWM experiment
View pull.py
import zmq
# Set up the socket
ctx = zmq.Context()
sock = ctx.socket(zmq.PULL)
sock.set_hwm(1)
sock.setsockopt(zmq.RCVBUF, 16 * 1024)
sock.connect("tcp://127.0.0.1:8541")
print("RCVHWM", sock.getsockopt(zmq.RCVHWM))
@takluyver
takluyver / Twitter archive.ipynb
Created Aug 4, 2018
Inspecting archived tweets
View Twitter archive.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View github-py.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Wide tables.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.