コード例 #1
0
ファイル: test_group.py プロジェクト: tovrstra/h5py
 def test_create(self):
     """ Create new soft link by assignment """
     g = self.f.create_group('new')
     sl = SoftLink('/new')
     self.f['alias'] = sl
     g2 = self.f['alias']
     self.assertEqual(g, g2)
コード例 #2
0
ファイル: test_group.py プロジェクト: tovrstra/h5py
    def test_copy_soft_links(self):

        self.f1['bar'] = [1, 2, 3]
        foo = self.f1.create_group('foo')
        foo['baz'] = SoftLink('/bar')

        self.f1.copy(foo, 'qux', expand_soft=True)
        self.f2.copy(foo, 'foo', expand_soft=True)
        del self.f1['bar']

        self.assertIsInstance(self.f1['qux'], Group)
        self.assertArrayEqual(self.f1['qux/baz'], np.array([1, 2, 3]))

        self.assertIsInstance(self.f2['/foo'], Group)
        self.assertArrayEqual(self.f2['foo/baz'], np.array([1, 2, 3]))
コード例 #3
0
ファイル: test_group.py プロジェクト: tovrstra/h5py
    def test_get_link_class(self):
        """ Get link classes """
        default = object()

        sl = SoftLink('/mongoose')
        el = ExternalLink('somewhere.hdf5', 'mongoose')

        self.f.create_group('hard')
        self.f['soft'] = sl
        self.f['external'] = el

        out_hl = self.f.get('hard', default, getlink=True, getclass=True)
        out_sl = self.f.get('soft', default, getlink=True, getclass=True)
        out_el = self.f.get('external', default, getlink=True, getclass=True)

        self.assertEqual(out_hl, HardLink)
        self.assertEqual(out_sl, SoftLink)
        self.assertEqual(out_el, ExternalLink)
コード例 #4
0
ファイル: test_group.py プロジェクト: tovrstra/h5py
    def test_get_link(self):
        """ Get link values """
        sl = SoftLink('/mongoose')
        el = ExternalLink('somewhere.hdf5', 'mongoose')

        self.f.create_group('hard')
        self.f['soft'] = sl
        self.f['external'] = el

        out_hl = self.f.get('hard', getlink=True)
        out_sl = self.f.get('soft', getlink=True)
        out_el = self.f.get('external', getlink=True)

        #TODO: redo with SoftLink/ExternalLink built-in equality
        self.assertIsInstance(out_hl, HardLink)
        self.assertIsInstance(out_sl, SoftLink)
        self.assertEqual(out_sl._path, sl._path)
        self.assertIsInstance(out_el, ExternalLink)
        self.assertEqual(out_el._path, el._path)
        self.assertEqual(out_el._filename, el._filename)
コード例 #5
0
ファイル: test_group.py プロジェクト: tovrstra/h5py
 def test_exc(self):
     """ Opening dangling soft link results in KeyError """
     self.f['alias'] = SoftLink('new')
     with self.assertRaises(KeyError):
         self.f['alias']
コード例 #6
0
ファイル: test_group.py プロジェクト: tovrstra/h5py
 def test_srepr(self):
     """ SoftLink path repr """
     sl = SoftLink('/foo')
     self.assertIsInstance(repr(sl), basestring)
コード例 #7
0
ファイル: test_group.py プロジェクト: tovrstra/h5py
 def test_spath(self):
     """ SoftLink path attribute """
     sl = SoftLink('/foo')
     self.assertEqual(sl.path, '/foo')