# Path: argos/repo/memoryrtis.py
# class ArrayRti(BaseRti):
#     """ Represents a numpy array (or None for undefined/unopened nodes)
#     """
#     _defaultIconGlyph = RtiIconFactory.ARRAY
# 
#     def __init__(self, array, nodeName='', iconColor=ICON_COLOR_MEMORY, fileName='', attributes=None):
#         """ Constructor.
#             :param array: the underlying array. May be undefined (None)
#             :type array: numpy.ndarray or None
#         """
#         super(ArrayRti, self).__init__(nodeName=nodeName, iconColor=iconColor, fileName=fileName)
#         check_is_an_array(array, allow_none=True)
#         self._array = array
#         self._attributes = {} if attributes is None else attributes
# 
# 
#     @property
#     def attributes(self):
#         """ The attribute dictionary.
# 
#             Reimplemented from BaseRti: the attribute dictionary is stored per-object.
#         """
#         return self._attributes
# 
# 
#     @property
#     def _isStructured(self):
#         """ Returns True if the variable has a structured type, otherwise returns False.
#         """
#         return self._array is not None and bool(self._array.dtype.names)
# 
# 
#     def hasChildren(self):
#         """ Returns True if the variable has a structured type, otherwise returns False.
#         """
#         return self._isStructured
# 
# 
#     @property
#     def isSliceable(self):
#         """ Returns True if the underlying array is not None.
#         """
#         return self._array is not None
# 
# 
#     def __getitem__(self, index):
#         """ Called when using the RTI with an index (e.g. rti[0]).
#             Passes the index through to the underlying array.
#         """
#         # Will only be called if self.isSliceable is True, so self._array will not be None
#         return self._array.__getitem__(index)
# 
# 
#     @property
#     def nDims(self):
#         """ The number of dimensions of the underlying array
#         """
#         # Will only be called if self.isSliceable is True, so self._array will not be None
#         return self._array.ndim
# 
# 
#     @property
#     def arrayShape(self):
#         """ Returns the shape of the underlying array.
#         """
#         # Will only be called if self.isSliceable is True, so self._array will not be None
#         return self._array.shape
# 
# 
#     @property
#     def dimensionality(self):
#         """ String that describes if the RTI is an array, scalar, field, etc.
#         """
#         return "array"
# 
# 
#     @property
#     def elementTypeName(self):
#         """ String representation of the element type.
#         """
#         if self._array is None:
#             return super(ArrayRti, self).elementTypeName
#         else:
#             dtype =  self._array.dtype
#             return '<structured>' if dtype.names else str(dtype)
# 
# 
#     @property
#     def missingDataValue(self):
#         """ Returns the value to indicate missing data.
#         """
#         return getMissingDataValue(self._array)
# 
# 
#     def _fetchAllChildren(self):
#         """ Fetches all fields that this variable contains.
#             Only variables with a structured data type can have fields.
#         """
#         assert self.canFetchChildren(), "canFetchChildren must be True"
# 
#         childItems = []
# 
#         # Add fields in case of an array of structured type.
#         if self._isStructured:
#             for fieldName in self._array.dtype.names:
#                 childItem = FieldRti(self._array, nodeName=fieldName, iconColor=self.iconColor,
#                                      fileName=self.fileName)
#                 childItems.append(childItem)
# 
#         return childItems
# 
# 
#     @property
#     def summary(self):
#         """ Returns a summary of the contents of the RTI.  E.g. 'array 20 x 30' elements.
#         """
#         if self.isSliceable:
#             return shapeToSummary(self.arrayShape)
#         else:
#             return ""


import unittest
import numpy as np
from numpy.testing import assert_array_equal
from argos.repo.memoryrtis import ArrayRti
#!/usr/bin/env python
# -*- coding: utf-8 -*-






class TestUntypedCtis(unittest.TestCase):

    def setUp(self):
        self.arr = np.arange(24).reshape(6, 4)
        self.rti = ArrayRti(self.arr, 'my array')



# Path: argos/repo/memoryrtis.py
# class ArrayRti(BaseRti):
#     """ Represents a numpy array (or None for undefined/unopened nodes)
#     """
#     _defaultIconGlyph = RtiIconFactory.ARRAY
# 
#     def __init__(self, array, nodeName='', iconColor=ICON_COLOR_MEMORY, fileName='', attributes=None):
#         """ Constructor.
#             :param array: the underlying array. May be undefined (None)
#             :type array: numpy.ndarray or None
#         """
#         super(ArrayRti, self).__init__(nodeName=nodeName, iconColor=iconColor, fileName=fileName)
#         check_is_an_array(array, allow_none=True)
#         self._array = array
#         self._attributes = {} if attributes is None else attributes
# 
# 
#     @property
#     def attributes(self):
#         """ The attribute dictionary.
# 
#             Reimplemented from BaseRti: the attribute dictionary is stored per-object.
#         """
#         return self._attributes
# 
# 
#     @property
#     def _isStructured(self):
#         """ Returns True if the variable has a structured type, otherwise returns False.
#         """
#         return self._array is not None and bool(self._array.dtype.names)
# 
# 
#     def hasChildren(self):
#         """ Returns True if the variable has a structured type, otherwise returns False.
#         """
#         return self._isStructured
# 
# 
#     @property
#     def isSliceable(self):
#         """ Returns True if the underlying array is not None.
#         """
#         return self._array is not None
# 
# 
#     def __getitem__(self, index):
#         """ Called when using the RTI with an index (e.g. rti[0]).
#             Passes the index through to the underlying array.
#         """
#         # Will only be called if self.isSliceable is True, so self._array will not be None
#         return self._array.__getitem__(index)
# 
# 
#     @property
#     def nDims(self):
#         """ The number of dimensions of the underlying array
#         """
#         # Will only be called if self.isSliceable is True, so self._array will not be None
#         return self._array.ndim
# 
# 
#     @property
#     def arrayShape(self):
#         """ Returns the shape of the underlying array.
#         """
#         # Will only be called if self.isSliceable is True, so self._array will not be None
#         return self._array.shape
# 
# 
#     @property
#     def dimensionality(self):
#         """ String that describes if the RTI is an array, scalar, field, etc.
#         """
#         return "array"
# 
# 
#     @property
#     def elementTypeName(self):
#         """ String representation of the element type.
#         """
#         if self._array is None:
#             return super(ArrayRti, self).elementTypeName
#         else:
#             dtype =  self._array.dtype
#             return '<structured>' if dtype.names else str(dtype)
# 
# 
#     @property
#     def missingDataValue(self):
#         """ Returns the value to indicate missing data.
#         """
#         return getMissingDataValue(self._array)
# 
# 
#     def _fetchAllChildren(self):
#         """ Fetches all fields that this variable contains.
#             Only variables with a structured data type can have fields.
#         """
#         assert self.canFetchChildren(), "canFetchChildren must be True"
# 
#         childItems = []
# 
#         # Add fields in case of an array of structured type.
#         if self._isStructured:
#             for fieldName in self._array.dtype.names:
#                 childItem = FieldRti(self._array, nodeName=fieldName, iconColor=self.iconColor,
#                                      fileName=self.fileName)
#                 childItems.append(childItem)
# 
#         return childItems
# 
# 
#     @property
#     def summary(self):
#         """ Returns a summary of the contents of the RTI.  E.g. 'array 20 x 30' elements.
#         """
#         if self.isSliceable:
#             return shapeToSummary(self.arrayShape)
#         else:
#             return ""


# Path: tests/test_rti.py
import unittest
import numpy as np
from numpy.testing import assert_array_equal
from argos.repo.memoryrtis import ArrayRti

#!/usr/bin/env python
# -*- coding: utf-8 -*-






class TestUntypedCtis(unittest.TestCase):

    def setUp(self):
        self.arr = np.arange(24).reshape(6, 4)
        self.rti = ArrayRti(self.arr, 'my array')



    def test_indexing(self):