Example #1
0
    def test_attach(self):
        '''
        Tests the following:
        
        1. Attaching to a registered pdarray
        2. The registered and attached pdarrays are equal
        3. The attached pdarray is deleted server-side following
           unregister of registered pdarray and invocation of 
           ak.clear()
        4. method invocation on cleared attached array raises RuntimeError
        '''
        ar_array = self.a_array.register('test_int64_a')
        aar_array = ak.attach_pdarray('test_int64_a')

        self.assertEqual(ar_array.name, aar_array.name)
        self.assertTrue(
            (ar_array.to_ndarray() == aar_array.to_ndarray()).all())

        ak.disconnect()
        ak.connect(server=ArkoudaTest.server, port=ArkoudaTest.port)
        aar_array = ak.attach_pdarray('test_int64_a')

        self.assertEqual(ar_array.name, aar_array.name)
        self.assertTrue(
            (ar_array.to_ndarray() == aar_array.to_ndarray()).all())

        ar_array.unregister()
        ak.clear()

        with self.assertRaises(RuntimeError):
            str(aar_array)

        with self.assertRaises(RuntimeError):
            repr(aar_array)
Example #2
0
 def test_attach_weak_binding(self):
     """
     Ultimately pdarrayclass issues delete calls to the server when a bound object goes out of scope, if you bind
     to a server object more than once and one of those goes out of scope it affects all other references to it.
     """
     cleanup()
     a = ak.ones(3, dtype=ak.int64).register("a_reg")
     self.assertTrue(str(a), "Expected to pass")
     b = ak.attach_pdarray("a_reg")
     b.unregister()
     b = None  # Force out of scope
     with self.assertRaises(RuntimeError):
         str(a)