Skip to content

Commit

Permalink
Fix some warnings in tests (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
maffoo authored Nov 21, 2021
1 parent 94a7abe commit 4a1f3bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions labrad/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(self, func, lr_ID, lr_name, returns, unflatten, **params):
# unpack tuples, so this case is not allowed: The first argument
# cannot be a tuple or '?' tag if the second argument is optional.

argspec = inspect.getargspec(self.func)
argspec = inspect.getfullargspec(self.func)
args = argspec.args[2:] # Skip 'self' and context data arguments.

if inspect.isgeneratorfunction(func):
Expand Down Expand Up @@ -224,8 +224,8 @@ def messageHandler(lr_ID, lr_name=None, returns=[], lr_num_params=2, **params):
strings of allowed types.
"""
def decorated(f):
args, varargs, varkw, defaults = inspect.getargspec(f)
args = args[lr_num_params:]
argspec = inspect.getfullargspec(f)
args, defaults = argspec.args[lr_num_params:], argspec.defaults

# handle generators as defer.inlineCallbacks
if inspect.isgeneratorfunction(f):
Expand Down
2 changes: 1 addition & 1 deletion labrad/node/server_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def from_string(conf, filename=None, path=None, platform=sys.platform):
if isinstance(conf, bytes):
conf = conf.decode('utf-8')
scp = ConfigParser()
scp.readfp(io.StringIO(conf))
scp.read_file(io.StringIO(conf))

# general information
name = scp.get('info', 'name', raw=True)
Expand Down
6 changes: 3 additions & 3 deletions labrad/test/extraction_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def timeIt(f, *a, **kw):
return result

def extractAverage(packets):
data = ''.join(packets)
Is, Qs = np.fromstring(data, dtype='<i2').reshape(-1, 2).astype(int).T
data = b''.join(packets)
Is, Qs = np.frombuffer(data, dtype='<i2').reshape(-1, 2).astype(int).T
return (Is, Qs)

def extract(packets):
Expand All @@ -29,7 +29,7 @@ def extract(packets):
mac = '01:23:45:67:89:ab'
eth = 1

packets = [(mac, mac, eth, '\x00'*44) for _ in range(9000)]
packets = [(mac, mac, eth, b'\x00' * 44) for _ in range(9000)]
data, t, endianness = types.flatten(packets)

timeIt(extract, packets)
Expand Down
6 changes: 3 additions & 3 deletions labrad/types/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def parseSingleType(s):
s.strip(WHITESPACE)
return t

COMMENTS = re.compile('\{[^\{\}]*\}')
COMMENTS = re.compile(r'\{[^\{\}]*\}')

def stripComments(s):
"""Remove comments from a type tag.
Expand Down Expand Up @@ -1222,9 +1222,9 @@ def unflattenNDlist(s, dims):
def _unflatten_as_array(self, s, endianness, elem, dims, size):
"""Unflatten to numpy array."""
def make(t, width):
a = np.fromstring(s.get(size*width), dtype=np.dtype(t))
a = np.frombuffer(s.get(size*width), dtype=np.dtype(t))
if endianness != SYSTEM_BYTE_ORDER:
a.byteswap(True) # inplace
a = a.byteswap(inplace=False)
return a

if elem == TBool(): a = make('bool', 1)
Expand Down

0 comments on commit 4a1f3bb

Please sign in to comment.