Skip to content

Commit

Permalink
Merge pull request pandas-dev#489 from manahl/issue-488
Browse files Browse the repository at this point in the history
Change numpy.fromstring to numpy.frombuffer due to deprecation
  • Loading branch information
bmoscon authored Jan 11, 2018
2 parents 4ab17c5 + c5f1452 commit d974ebd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions arctic/serialization/numpy_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ def objify(self, doc, columns=None):

for col in cols:
d = decompress(doc[DATA][doc[METADATA][LENGTHS][col][0]: doc[METADATA][LENGTHS][col][1] + 1])
d = np.fromstring(d, doc[METADATA][DTYPE][col])
d = np.frombuffer(d, doc[METADATA][DTYPE][col])

if MASK in doc[METADATA] and col in doc[METADATA][MASK]:
mask_data = decompress(doc[METADATA][MASK][col])
mask = np.fromstring(mask_data, 'bool')
mask = np.frombuffer(mask_data, 'bool')
d = ma.masked_array(d, mask)
data[col] = d

Expand Down
2 changes: 1 addition & 1 deletion arctic/store/_ndarray_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def _do_read(self, collection, version, symbol, index_range=None):
symbol, version['version'], segment_count, i + 1, collection.database.name + '.' + collection.name))

dtype = self._dtype(version['dtype'], version.get('dtype_metadata', {}))
rtn = np.fromstring(data, dtype=dtype).reshape(version.get('shape', (-1)))
rtn = np.frombuffer(data, dtype=dtype).reshape(version.get('shape', (-1)))
return rtn

def _promote_types(self, dtype, dtype_str):
Expand Down
4 changes: 2 additions & 2 deletions arctic/store/_pandas_ndarray_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _segment_index(self, recarr, existing_index, start, new_segments):
dtype=INDEX_DTYPE)
# append to existing index if exists
if existing_index:
existing_index_arr = np.fromstring(decompress(existing_index), dtype=INDEX_DTYPE)
existing_index_arr = np.frombuffer(decompress(existing_index), dtype=INDEX_DTYPE)
if start > 0:
existing_index_arr = existing_index_arr[existing_index_arr['index'] < start]
index = np.concatenate((existing_index_arr, index))
Expand All @@ -74,7 +74,7 @@ def _index_range(self, version, symbol, date_range=None, **kwargs):
with the date_range. As the segment index is (id -> last datetime)
we need to take care in choosing the correct chunks. """
if date_range and 'segment_index' in version:
index = np.fromstring(decompress(version['segment_index']), dtype=INDEX_DTYPE)
index = np.frombuffer(decompress(version['segment_index']), dtype=INDEX_DTYPE)
dtcol = self._datetime64_index(index)
if dtcol and len(index):
dts = index[dtcol]
Expand Down
8 changes: 4 additions & 4 deletions arctic/tickstore/tickstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def _read_bucket(self, doc, column_set, column_dtypes, include_symbol, include_i
rtn = {}
if doc[VERSION] != 3:
raise ArcticException("Unhandled document version: %s" % doc[VERSION])
rtn[INDEX] = np.cumsum(np.fromstring(decompress(doc[INDEX]), dtype='uint64'))
rtn[INDEX] = np.cumsum(np.frombuffer(decompress(doc[INDEX]), dtype='uint64'))
doc_length = len(rtn[INDEX])
column_set.update(doc[COLUMNS].keys())

Expand All @@ -444,7 +444,7 @@ def _read_bucket(self, doc, column_set, column_dtypes, include_symbol, include_i
for c in column_set:
try:
coldata = doc[COLUMNS][c]
mask = np.fromstring(decompress(coldata[ROWMASK]), dtype='uint8')
mask = np.frombuffer(decompress(coldata[ROWMASK]), dtype='uint8')
union_mask = union_mask | mask
except KeyError:
rtn[c] = None
Expand All @@ -460,10 +460,10 @@ def _read_bucket(self, doc, column_set, column_dtypes, include_symbol, include_i
try:
coldata = doc[COLUMNS][c]
dtype = np.dtype(coldata[DTYPE])
values = np.fromstring(decompress(coldata[DATA]), dtype=dtype)
values = np.frombuffer(decompress(coldata[DATA]), dtype=dtype)
self._set_or_promote_dtype(column_dtypes, c, dtype)
rtn[c] = self._empty(rtn_length, dtype=column_dtypes[c])
rowmask = np.unpackbits(np.fromstring(decompress(coldata[ROWMASK]),
rowmask = np.unpackbits(np.frombuffer(decompress(coldata[ROWMASK]),
dtype='uint8'))[:doc_length].astype('bool')
rowmask = rowmask[union_mask]
rtn[c][rowmask] = values
Expand Down

0 comments on commit d974ebd

Please sign in to comment.