Skip to content

Commit

Permalink
fix: replace np.fromstring by np.frombuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
peppsac committed Sep 27, 2018
1 parent a53fb71 commit 0f0e77d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions py3dtiles/b3dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class B3dmHeader(TileHeader):

def __init__(self):
self.type = TileType.BATCHED3DMODEL
self.magic_value = "b3dm"
self.magic_value = b"b3dm"
self.version = 1
self.tile_byte_length = 0
self.ft_json_byte_length = 0
Expand All @@ -85,7 +85,7 @@ def __init__(self):
self.bt_length = 0 # number of models in the batch

def to_array(self):
header_arr = np.fromstring(self.magic_value, np.uint8)
header_arr = np.frombuffer(self.magic_value, np.uint8)

header_arr2 = np.array([self.version,
self.tile_byte_length,
Expand Down
2 changes: 1 addition & 1 deletion py3dtiles/feature_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def to_array(self):
json_str = json.dumps(jsond).replace(" ", "")
n = len(json_str) + 28
json_str += ' '*(4 - n % 4)
return np.fromstring(json_str, dtype=np.uint8)
return np.frombuffer(json_str.encode('utf-8'), dtype=np.uint8)

def to_json(self):
jsond = {}
Expand Down
2 changes: 1 addition & 1 deletion py3dtiles/gltf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def to_array(self): # glb

return np.concatenate((binaryHeader.view(np.uint8),
jsonChunkHeader.view(np.uint8),
np.fromstring(scene, dtype=np.uint8),
np.frombuffer(scene.encode('utf-8'), dtype=np.uint8),
binChunkHeader.view(np.uint8),
self.body,
padding))
Expand Down
4 changes: 2 additions & 2 deletions py3dtiles/pnts.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PntsHeader(TileHeader):

def __init__(self):
self.type = TileType.POINTCLOUD
self.magic_value = "pnts"
self.magic_value = b"pnts"
self.version = 1
self.tile_byte_length = 0
self.ft_json_byte_length = 0
Expand All @@ -82,7 +82,7 @@ def __init__(self):
self.bt_bin_byte_length = 0

def to_array(self):
header_arr = np.fromstring(self.magic_value, np.uint8)
header_arr = np.frombuffer(self.magic_value, np.uint8)

header_arr2 = np.array([self.version,
self.tile_byte_length,
Expand Down

0 comments on commit 0f0e77d

Please sign in to comment.