Browse Source

Give a slightly more clear error on bad array sizes

tags/nilmdb-1.5.2
Jim Paris 8 years ago
parent
commit
4ce059b920
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      nilmdb/client/numpyclient.py

+ 6
- 3
nilmdb/client/numpyclient.py View File

@@ -162,9 +162,12 @@ class StreamInserterNumpy(nilmdb.client.client.StreamInserter):
elif array.ndim == 2:
# Convert to structured array
sarray = numpy.zeros(array.shape[0], dtype=self._dtype)
sarray['timestamp'] = array[:,0]
# Need the squeeze in case sarray['data'] is 1 dimensional
sarray['data'] = numpy.squeeze(array[:,1:])
try:
sarray['timestamp'] = array[:,0]
# Need the squeeze in case sarray['data'] is 1 dimensional
sarray['data'] = numpy.squeeze(array[:,1:])
except (IndexError, ValueError):
raise ValueError("wrong number of fields for this data type")
array = sarray
else:
raise ValueError("wrong number of dimensions in array")


Loading…
Cancel
Save