# Path: pysc2/lib/named_array.py
# class NamedDict(dict):
# class NamedNumpyArray(np.ndarray):
#   def __init__(self, *args, **kwargs):
#   def __new__(cls, values, names, *args, **kwargs):
#   def __array_finalize__(self, obj):
#   def __getattr__(self, name):
#   def __setattr__(self, name, value):
#   def __getitem__(self, indices):
#   def __setitem__(self, indices, value):
#   def __getslice__(self, i, j):  # deprecated, but still needed...
#   def __setslice__(self, i, j, seq):  # deprecated, but still needed...
#   def __repr__(self):
#   def __reduce__(self):
#   def __setstate__(self, state):
#   def _indices(self, indices):
#   def _get_index(self, dim, index):
# _NULL_SLICE = slice(None, None, None)


import collections
import pickle
import enum
import numpy as np
from absl.testing import absltest
from absl.testing import parameterized
from pysc2.lib import named_array

    with self.assertRaises(IndexError):
      a[..., 0, ...]  # pylint: disable=pointless-statement

  def test_string(self):
    a = named_array.NamedNumpyArray([1, 3, 6], ["a", "b", "c"], dtype=np.int32)
    self.assertEqual(str(a), "[1 3 6]")
    self.assertEqual(repr(a), ("NamedNumpyArray([1, 3, 6], ['a', 'b', 'c'], "
                               "dtype=int32)"))

    a = named_array.NamedNumpyArray([[1, 3], [6, 8]], [None, ["a", "b"]])
    self.assertEqual(str(a), "[[1 3]\n [6 8]]")
    self.assertEqual(repr(a), ("NamedNumpyArray([[1, 3],\n"
                               "                 [6, 8]], [None, ['a', 'b']])"))

    a = named_array.NamedNumpyArray([[1, 3], [6, 8]], [["a", "b"], None])
    self.assertEqual(str(a), "[[1 3]\n [6 8]]")
    self.assertEqual(repr(a), ("NamedNumpyArray([[1, 3],\n"
                               "                 [6, 8]], [['a', 'b'], None])"))

    a = named_array.NamedNumpyArray([0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                    [str(i) for i in range(13)], dtype=np.int32)
    numpy_repr = np.array_repr(a)
    if "\n" in numpy_repr:  # ie numpy > 1.14
      self.assertEqual(repr(a), """
NamedNumpyArray([ 0,  0,  0, 50,  0,  0,  0,  0,  0,  0,  0,  0,  0],
                ['0', '1', '2', '3', '4', '...', '8', '9', '10', '11', '12'],
                dtype=int32)""".strip())  # Keep the middle newlines.
    else:
      self.assertEqual(repr(a), (

# Path: pysc2/lib/named_array.py
# class NamedDict(dict):
# class NamedNumpyArray(np.ndarray):
#   def __init__(self, *args, **kwargs):
#   def __new__(cls, values, names, *args, **kwargs):
#   def __array_finalize__(self, obj):
#   def __getattr__(self, name):
#   def __setattr__(self, name, value):
#   def __getitem__(self, indices):
#   def __setitem__(self, indices, value):
#   def __getslice__(self, i, j):  # deprecated, but still needed...
#   def __setslice__(self, i, j, seq):  # deprecated, but still needed...
#   def __repr__(self):
#   def __reduce__(self):
#   def __setstate__(self, state):
#   def _indices(self, indices):
#   def _get_index(self, dim, index):
# _NULL_SLICE = slice(None, None, None)


# Path: pysc2/lib/named_array_test.py
import collections
import pickle
import enum
import numpy as np
from absl.testing import absltest
from absl.testing import parameterized
from pysc2.lib import named_array


    with self.assertRaises(IndexError):
      a[..., 0, ...]  # pylint: disable=pointless-statement

  def test_string(self):
    a = named_array.NamedNumpyArray([1, 3, 6], ["a", "b", "c"], dtype=np.int32)
    self.assertEqual(str(a), "[1 3 6]")
    self.assertEqual(repr(a), ("NamedNumpyArray([1, 3, 6], ['a', 'b', 'c'], "
                               "dtype=int32)"))

    a = named_array.NamedNumpyArray([[1, 3], [6, 8]], [None, ["a", "b"]])
    self.assertEqual(str(a), "[[1 3]\n [6 8]]")
    self.assertEqual(repr(a), ("NamedNumpyArray([[1, 3],\n"
                               "                 [6, 8]], [None, ['a', 'b']])"))

    a = named_array.NamedNumpyArray([[1, 3], [6, 8]], [["a", "b"], None])
    self.assertEqual(str(a), "[[1 3]\n [6 8]]")
    self.assertEqual(repr(a), ("NamedNumpyArray([[1, 3],\n"
                               "                 [6, 8]], [['a', 'b'], None])"))

    a = named_array.NamedNumpyArray([0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                                    [str(i) for i in range(13)], dtype=np.int32)
    numpy_repr = np.array_repr(a)
    if "\n" in numpy_repr:  # ie numpy > 1.14
      self.assertEqual(repr(a), """
NamedNumpyArray([ 0,  0,  0, 50,  0,  0,  0,  0,  0,  0,  0,  0,  0],
                ['0', '1', '2', '3', '4', '...', '8', '9', '10', '11', '12'],
                dtype=int32)""".strip())  # Keep the middle newlines.
    else:
      self.assertEqual(repr(a), (

          "NamedNumpyArray("