From 56ea6d529dd12fa9909ae66d6f13fa1fc5e3b2ed Mon Sep 17 00:00:00 2001 From: Brian Guarraci Date: Thu, 20 Jul 2023 14:18:57 -0600 Subject: [PATCH] fix apply for nested arrays --- klongpy/dyads.py | 4 ++-- tests/test_extra_suite.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/klongpy/dyads.py b/klongpy/dyads.py index a93204e..bc1da56 100644 --- a/klongpy/dyads.py +++ b/klongpy/dyads.py @@ -166,8 +166,8 @@ def eval_dyad_at_index(klong, a, b): """ if isinstance(a, (KGFn, KGSym)): - # TODO: fix arity - return klong.eval(KGCall(a, b.tolist() if np.isarray(b) else b, arity=2)) + b = [x for x in b] if np.isarray(b) else b + return klong.eval(KGCall(a, b, arity=1)) j = isinstance(a,str) a = str_to_chr_arr(a) if j else a if is_list(b): diff --git a/tests/test_extra_suite.py b/tests/test_extra_suite.py index 5e56643..e536452 100644 --- a/tests/test_extra_suite.py +++ b/tests/test_extra_suite.py @@ -11,9 +11,10 @@ class TestExtraCoreSuite(unittest.TestCase): def assert_eval_cmp(self, a, b, klong=None): self.assertTrue(eval_cmp(a, b, klong=klong)) - @unittest.skip def test_apply_range(self): klong = KlongInterpreter() + r = klong("{x}@,!100") + self.assertTrue(kg_equal(r, np.arange(100))) klong("avg::{(+/x)%#x}") r = klong("avg@,!100") self.assertEqual(r,49.5)