Skip to content

Commit 6c91a7a

Browse files
authored
Merge pull request #12 from briangu/codex/fix-missing-return-value-in-eval-monad-list
Fix eval_monad_list return
2 parents ae0242b + 014f4c9 commit 6c91a7a

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

AGENTS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Repo guidelines
2+
3+
To run the test suite, first install dependencies:
4+
5+
```
6+
pip3 install ".[full]"
7+
```
8+
9+
Then run:
10+
11+
```
12+
python3 -m unittest
13+
```
14+

klongpy/monads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def eval_monad_list(a):
218218
if isinstance(a, KGChar):
219219
return str(a)
220220
if isinstance(a, KGSym):
221-
np.asarray([a],dtype=object) # np interpets ':foo" as ':fo"
221+
return np.asarray([a],dtype=object) # np interprets ':foo" as ':fo"
222222
return np.asarray([a])
223223

224224

tests/test_eval_monad_list.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import unittest
2+
import numpy as np
3+
4+
from klongpy import KlongInterpreter
5+
from klongpy.core import KGSym
6+
from tests.utils import kg_equal
7+
8+
9+
class TestEvalMonadList(unittest.TestCase):
10+
11+
def setUp(self):
12+
self.klong = KlongInterpreter()
13+
14+
def test_int(self):
15+
r = self.klong(',1')
16+
self.assertTrue(kg_equal(r, np.asarray([1])))
17+
18+
def test_symbol(self):
19+
r = self.klong(',:foo')
20+
self.assertTrue(r.dtype == object)
21+
self.assertEqual(len(r), 1)
22+
self.assertEqual(r[0], KGSym('foo'))
23+
24+
def test_string(self):
25+
r = self.klong(',"xyz"')
26+
self.assertTrue(kg_equal(r, np.asarray(['xyz'], dtype=object)))
27+
28+
def test_list(self):
29+
r = self.klong(',[1]')
30+
self.assertTrue(kg_equal(r, np.asarray([[1]], dtype=object)))
31+
32+
33+
if __name__ == '__main__':
34+
unittest.main()

0 commit comments

Comments
 (0)