Skip to content

Commit

Permalink
Fix some numpy 1.16 compatibility issues.
Browse files Browse the repository at this point in the history
FutureWarning: arrays to stack must be passed as a "sequence" type such as list or tuple. Support for non-sequence iterables such as generators is deprecated as of NumPy 1.16 and will raise an error in the future.

FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different
PiperOrigin-RevId: 265922609
  • Loading branch information
tewalds committed Aug 28, 2019
1 parent 73c2039 commit 6cb28eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions pysc2/lib/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,15 +1150,15 @@ def or_zeros(layer, size):
if aif.feature_dimensions:
with sw("feature_screen"):
out["feature_screen"] = named_array.NamedNumpyArray(
np.stack(or_zeros(f.unpack(obs.observation),
aif.feature_dimensions.screen)
for f in SCREEN_FEATURES),
np.stack([or_zeros(f.unpack(obs.observation),
aif.feature_dimensions.screen)
for f in SCREEN_FEATURES]),
names=[ScreenFeatures, None, None])
with sw("feature_minimap"):
out["feature_minimap"] = named_array.NamedNumpyArray(
np.stack(or_zeros(f.unpack(obs.observation),
aif.feature_dimensions.minimap)
for f in MINIMAP_FEATURES),
np.stack([or_zeros(f.unpack(obs.observation),
aif.feature_dimensions.minimap)
for f in MINIMAP_FEATURES]),
names=[MinimapFeatures, None, None])

if aif.rgb_dimensions:
Expand Down
2 changes: 1 addition & 1 deletion pysc2/lib/np_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def summarize_array_diffs(lhs, rhs):
result = []
indices = np.transpose(np.nonzero(lhs - rhs))
for row in indices:
index = list(np.array([e]) for e in row.tolist())
index = tuple(np.array([e]) for e in row.tolist())
lhs_element = lhs[index]
rhs_element = rhs[index]
result.append("{}: {} -> {}".format(
Expand Down
8 changes: 4 additions & 4 deletions pysc2/tests/render_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ def or_zeros(layer, size):
rgb_screen = features.Feature.unpack_rgb_image(obs.render_data.map)
rgb_minimap = features.Feature.unpack_rgb_image(obs.render_data.minimap)
fl_screen = np.stack(
or_zeros(f.unpack(obs), interface.feature_layer.resolution)
for f in features.SCREEN_FEATURES)
[or_zeros(f.unpack(obs), interface.feature_layer.resolution)
for f in features.SCREEN_FEATURES])
fl_minimap = np.stack(
or_zeros(f.unpack(obs), interface.feature_layer.minimap_resolution)
for f in features.MINIMAP_FEATURES)
[or_zeros(f.unpack(obs), interface.feature_layer.minimap_resolution)
for f in features.MINIMAP_FEATURES])

# Right shapes.
self.assertEqual(rgb_screen.shape, (256, 256, 3))
Expand Down

0 comments on commit 6cb28eb

Please sign in to comment.