def test_get_fieldstructure(self):
        # Test get_fieldstructure

        # No nested fields
        ndtype = np.dtype([('A', '|S3'), ('B', float)])
        test = get_fieldstructure(ndtype)
        assert_equal(test, {'A': [], 'B': []})

        # One 1-nested field
        ndtype = np.dtype([('A', int), ('B', [('BA', float), ('BB', '|S1')])])
        test = get_fieldstructure(ndtype)
        assert_equal(test, {
            'A': [],
            'B': [],
            'BA': [
                'B',
            ],
            'BB': ['B']
        })

        # One 2-nested fields
        ndtype = np.dtype([('A', int),
                           ('B', [('BA', int),
                                  ('BB', [('BBA', int), ('BBB', int)])])])
        test = get_fieldstructure(ndtype)
        control = {
            'A': [],
            'B': [],
            'BA': ['B'],
            'BB': ['B'],
            'BBA': ['B', 'BB'],
            'BBB': ['B', 'BB']
        }
        assert_equal(test, control)
Example #2
0
    def test_get_fieldstructure(self):
        # Test get_fieldstructure

        # No nested fields
        ndtype = np.dtype([("A", "|S3"), ("B", float)])
        test = get_fieldstructure(ndtype)
        assert_equal(test, {"A": [], "B": []})

        # One 1-nested field
        ndtype = np.dtype([("A", int), ("B", [("BA", float), ("BB", "|S1")])])
        test = get_fieldstructure(ndtype)
        assert_equal(test, {"A": [], "B": [], "BA": ["B"], "BB": ["B"]})

        # One 2-nested fields
        ndtype = np.dtype([("A", int), ("B", [("BA", int), ("BB", [("BBA", int), ("BBB", int)])])])
        test = get_fieldstructure(ndtype)
        control = {"A": [], "B": [], "BA": ["B"], "BB": ["B"], "BBA": ["B", "BB"], "BBB": ["B", "BB"]}
        assert_equal(test, control)
Example #3
0
    def test_get_fieldstructure(self):
        # Test get_fieldstructure

        # No nested fields
        ndtype = np.dtype([("A", "|S3"), ("B", float)])
        test = get_fieldstructure(ndtype)
        assert_equal(test, {"A": [], "B": []})

        # One 1-nested field
        ndtype = np.dtype([("A", int), ("B", [("BA", float), ("BB", "|S1")])])
        test = get_fieldstructure(ndtype)
        assert_equal(
            test,
            {
                "A": [],
                "B": [],
                "BA": [
                    "B",
                ],
                "BB": ["B"],
            },
        )

        # One 2-nested fields
        ndtype = np.dtype([("A", int),
                           ("B", [("BA", int),
                                  ("BB", [("BBA", int), ("BBB", int)])])])
        test = get_fieldstructure(ndtype)
        control = {
            "A": [],
            "B": [],
            "BA": ["B"],
            "BB": ["B"],
            "BBA": ["B", "BB"],
            "BBB": ["B", "BB"],
        }
        assert_equal(test, control)

        # 0 fields
        ndtype = np.dtype([])
        test = get_fieldstructure(ndtype)
        assert_equal(test, {})
Example #4
0
    def test_get_fieldstructure(self):
        # Test get_fieldstructure

        # No nested fields
        ndtype = np.dtype([('A', '|S3'), ('B', float)])
        test = get_fieldstructure(ndtype)
        assert_equal(test, {'A': [], 'B': []})

        # One 1-nested field
        ndtype = np.dtype([('A', int), ('B', [('BA', float), ('BB', '|S1')])])
        test = get_fieldstructure(ndtype)
        assert_equal(test, {'A': [], 'B': [], 'BA': ['B', ], 'BB': ['B']})

        # One 2-nested fields
        ndtype = np.dtype([('A', int),
                           ('B', [('BA', int),
                                  ('BB', [('BBA', int), ('BBB', int)])])])
        test = get_fieldstructure(ndtype)
        control = {'A': [], 'B': [], 'BA': ['B'], 'BB': ['B'],
                   'BBA': ['B', 'BB'], 'BBB': ['B', 'BB']}
        assert_equal(test, control)