Skip to content

Commit e1cfb89

Browse files
Merge pull request #73 from brandonwillard/fix-etuple-strings
Fix etuplization of strings
2 parents 28843b7 + f164b19 commit e1cfb89

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

symbolic_pymc/etuple.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from collections import Sequence
77

8+
from cons.core import ConsPair
9+
810
from multipledispatch import dispatch
911

1012
from kanren.term import operator, arguments
@@ -242,7 +244,7 @@ def etuplize(x, shallow=False, return_bad_args=False):
242244
op = None
243245
args = x
244246

245-
if not isinstance(args, Sequence) or isinstance(args, str):
247+
if not isinstance(args, ConsPair):
246248
if return_bad_args:
247249
return x
248250
else:

tests/tensorflow/test_unify.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from unification import unify, reify, var
66

7-
from symbolic_pymc.tensorflow.meta import (TFlowOpName, mt, TFlowMetaTensorShape)
7+
from symbolic_pymc.tensorflow.meta import (TFlowOpName, mt, TFlowMetaTensorShape, TFlowOpName)
88
from symbolic_pymc.etuple import (ExpressionTuple, etuple, etuplize)
99

1010
from tests.tensorflow import run_in_graph_mode
@@ -14,6 +14,11 @@
1414
@pytest.mark.usefixtures("run_with_tensorflow")
1515
@run_in_graph_mode
1616
def test_etuple_term():
17+
18+
str_type = TFlowOpName("blah")
19+
assert etuplize(str_type, return_bad_args=True) == str_type
20+
assert etuplize("blah", return_bad_args=True) == "blah"
21+
1722
a = tf.compat.v1.placeholder(tf.float64, name='a')
1823
b = tf.compat.v1.placeholder(tf.float64, name='b')
1924

0 commit comments

Comments
 (0)