async def test_eval_wrap(self): start = time.perf_counter() task = asyncio.create_task( self.async_session.evaluate_wrap(wlexpr("Pause[.1]; Range[3]"))) timer = time.perf_counter() - start self.assertTrue(timer < 0.1) res = await task numpy.assert_array_equal(res.get(), numpy.arange(1, 4))
async def test_eval_wxf(self): start = time.perf_counter() task = asyncio.create_task( self.async_session.evaluate_wxf(wlexpr("Pause[.1]; Range[3]"))) timer = time.perf_counter() - start self.assertTrue(timer < 0.1) wxf = await task res = binary_deserialize(wxf) numpy.assert_array_equal(res, numpy.arange(1, 4))
async def test_eval_wlsymbol(self): start = time.perf_counter() task = asyncio.create_task( self.async_session.evaluate( wl.CompoundExpression(wl.Pause(0.1), wl.Range(2)))) timer = time.perf_counter() - start self.assertTrue(timer < 0.1) res = await task numpy.assert_array_equal(res, numpy.arange(1, 3))
async def test_evaluate_string_concurrently(self): task1 = asyncio.ensure_future( self.cloud_session_async.evaluate("Range[1]")) task2 = asyncio.ensure_future( self.cloud_session_async.evaluate_wrap("Range[2]")) res1, res2 = await asyncio.gather(task1, task2) numpy.assert_array_equal(res1, numpy.arange(1, 2)) res2 = await res2.result numpy.assert_array_equal(res2, numpy.arange(1, 3))
def test_uint32_RA(self): pa = numpy.array([0, (1 << 32) - 1], numpy.uint32).view(numpy.PackedArray) res = binary_deserialize(export(pa, target_format="wxf")) numpy.assert_array_equal(res, numpy.array([0, (1 << 32) - 1], numpy.int64))
def ensure_roundtrip(pa): wxf = export(pa, target_format="wxf") res = binary_deserialize(wxf) numpy.assert_array_equal(res, pa)
def test_numpy_1d_array(self): arr = numpy.array([0, 1], "uint8") wxf = export(arr, target_format="wxf") res = binary_deserialize(wxf) numpy.assert_array_equal(res, arr)
def test_evaluate_range_future(self): res = self.cloud_session.evaluate_future("Range[3]") numpy.assert_array_equal(res.result(), numpy.arange(1, 4))
def test_evaluate_strings_future(self): res1 = self.cloud_session.evaluate_future("Range[1]") res2 = self.cloud_session.evaluate_future("Range[2]") numpy.assert_array_equal(res1.result(), numpy.arange(1, 2)) numpy.assert_array_equal(res2.result(), numpy.arange(1, 3))
def test_evaluate_function_wl(self): f = self.cloud_session.function(wl.Range) numpy.assert_array_equal(f(3), numpy.arange(1, 4))
def test_evaluate_wrap(self): res = self.cloud_session.evaluate_wrap(wl.Range(2)) self.assertTrue(res.success) numpy.assert_array_equal(res.get(), numpy.arange(1, 3))
def test_evaluate_wl_expr(self): res = self.cloud_session.evaluate(wl.Range(2)) numpy.assert_array_equal(res, numpy.arange(1, 3))
def test_evaluate_string(self): res = self.cloud_session.evaluate("Range[3]") numpy.assert_array_equal(res, numpy.arange(1, 4))
async def test_evaluate_string(self): res1 = await self.cloud_session_async.evaluate("Range[1]") res2 = await self.cloud_session_async.evaluate("Range[2]") numpy.assert_array_equal(res1, numpy.arange(1, 2)) numpy.assert_array_equal(res2, numpy.arange(1, 3))
async def test_evaluate_function_wl(self): f = self.cloud_session_async.function(wl.Range) res = await f(3) numpy.assert_array_equal(res, numpy.arange(1, 4))
async def test_evaluate_wrap(self): res = await self.cloud_session_async.evaluate_wrap(wl.Range(2)) self.assertTrue(await res.success) numpy.assert_array_equal(await res.get(), numpy.arange(1, 3))