Ejemplo n.º 1
0
    def build_function(self, head, arg_list, **kwargs):
        """Create a Python object from head and args.

        This function can be conveniently overloaded to create specific Python objects
        from various heads. e.g: DateObject, Complex, etc.
        """
        return WLFunction(head, *arg_list)
 def test_silenced_msg(self):
     off = self.kernel_session.evaluate("Off[Power::infy]")
     self.assertEqual(off, None)
     res = self.kernel_session.evaluate_wrap("1/0")
     self.assertEqual(res.get(), WLFunction(WLSymbol(b"DirectedInfinity")))
     self.assertTrue(res.success)
     on = self.kernel_session.evaluate("On[Power::infy]")
     self.assertEqual(on, None)
Ejemplo n.º 3
0
 def test_evaluate_future_string_disable(self):
     with WolframCloudSession(credentials=self.sak,
                              server=self.server,
                              inputform_string_evaluation=False) as session:
         res = session.evaluate_future("Range[3]")
         self.assertEqual(res.result(), "Range[3]")
         func = session.function_future("f")
         res = func("abc")
         self.assertEqual(res.result(), WLFunction("f", "abc"))
Ejemplo n.º 4
0
 def test_evaluate_future_string_disable(self):
     with WolframCloudSession(credentials=self.sak,
                              server=self.server,
                              inputform_string_evaluation=False) as session:
         res = session.evaluate_future('Range[3]')
         self.assertEqual(res.result(), 'Range[3]')
         func = session.function_future('f')
         res = func('abc')
         self.assertEqual(res.result(), WLFunction('f', 'abc'))
 async def test_evaluate_string_disable(self):
     async with WolframCloudAsyncSession(
             credentials=self.sak,
             server=self.server,
             inputform_string_evaluation=False) as session:
         res = await session.evaluate("Range[3]")
         self.assertEqual(res, "Range[3]")
         cor = session.function("f")
         res = await cor("abc")
         self.assertEqual(res, WLFunction("f", "abc"))
 async def test_evaluate_string_disable(self):
     async with WolframCloudAsyncSession(
             credentials=self.sak,
             server=self.server,
             inputform_string_evaluation=False) as session:
         res = await session.evaluate('Range[3]')
         self.assertEqual(res, 'Range[3]')
         cor = session.function('f')
         res = await cor('abc')
         self.assertEqual(res, WLFunction('f', 'abc'))
 def test_one_msg(self):
     res = self.kernel_session.evaluate("1/0")
     self.assertEqual(res, WLFunction(WLSymbol(b"DirectedInfinity")))
 def test_built_in_symbols_as_func(self):
     func_null = self.kernel_session.function("Null")
     res = func_null(5)
     self.assertEqual(res, WLFunction(None, 5))
 def test_many_failures(self):
     res = self.kernel_session.evaluate('ImportString["[1,2", "RawJSON"]; 1/0')
     self.assertEqual(res, WLFunction(WLSymbol(b"DirectedInfinity")))
Ejemplo n.º 10
0
 async def inner(*args, **opts):
     return await self.evaluate(
         WLFunction(normalized_expr, *args, **opts))
Ejemplo n.º 11
0
 def inner(*args, **opts):
     return self.evaluate_future(
         WLFunction(normalized_expr, *args, **opts))