python - Why is pyDatalog not terminating? -
i'm taking @ pydatalog , created quick conversion program loosely based on blog entry:
convert_length.py:
from pydatalog import pydatalog pydatalog.create_terms(','.join(( 'scale', 'convert', 'from', 'to', 'intermediate', 'value', 'x', 'y'))) scale['meter', 'aln'] = 1.684132 scale['meter', 'angstrom'] = 1e+10 scale['meter', 'centimeter'] = 100 scale['meter', 'millimeter'] = 1000 scale['meter', 'inch'] = 39.370079 scale['light year', 'meter'] = 9.461e+15 scale['astronomical unit', 'meter'] = 1.496e+11 scale['foot', 'inch'] = 12 scale['yard', 'foot'] = 3 scale['mile', 'yard'] = 1760 scale['meter', 'm'] = 1 scale['centimeter', 'cm'] = 1 scale['millimeter', 'mm'] = 1 scale['light year', 'ly'] = 1 scale['astronomical unit', 'au'] = 1 scale[from, to] = 1/scale[to, from] scale[from, to] = scale[from, intermediate] * scale[intermediate, to] convert[value, from, to] = value * scale[from, to]
things start in shell last print statement hangs:
python 3.5.2 (default, jul 5 2016, 12:43:10) type "copyright", "credits" or "license" more information. ipython 5.1.0 -- enhanced interactive python. ? -> introduction , overview of ipython's features. %quickref -> quick reference. -> python's own system. object? -> details 'object', use 'object??' details. in [1]: run convert_length.py in [2]: print(x.in_(range(2))) x - 0 1 in [3]: print((y == convert[1, 'cm', 'inch'])) y ------------------- 0.39370078999999997 in [4]: print(x.in_(range(2)) & (y == convert[1, 'cm', 'inch']))
... , haven't substituted x in 1 see couple of values yet!
(scratch) ~/wk/pydatalog $ pip freeze | grep -i pydatalog pydatalog==0.17.1
am doing wrong?
wiki
Comments
Post a Comment