Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate sympy.Intersection error on Interval and Range with floats #80

Closed
fsaad opened this issue May 16, 2020 · 1 comment
Closed

Comments

@fsaad
Copy link
Collaborator

fsaad commented May 16, 2020

When running spn.prob(GPA <= 0.0) on Indian GPA, error is encountered at this line
https://github.com/probcomp/sum-product-dsl/blob/aafed1006b8f28708290911dbf946765139dd495/src/spn.py#L961

Note the use of 0.0 instead of 0 in the conditioning event.

It appears to be an error from Sympy.

>>> sympy.Intersection(sympy.Range(10,11,1), sympy.Interval(-sympy.oo, 0.0))
Traceback (most recent call last):
  File "/home/fsaad/sum-product-dsl/.venv/lib/python3.6/site-packages/sympy/core/compatibility.py", line 410, in as_int
    raise TypeError
TypeError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fsaad/sum-product-dsl/.venv/lib/python3.6/site-packages/sympy/sets/fancysets.py", line 426, in __new__
    for w in (start, stop, step)]
  File "/home/fsaad/sum-product-dsl/.venv/lib/python3.6/site-packages/sympy/sets/fancysets.py", line 426, in <listcomp>
    for w in (start, stop, step)]
  File "/home/fsaad/sum-product-dsl/.venv/lib/python3.6/site-packages/sympy/core/compatibility.py", line 416, in as_int
    raise ValueError('%s is not an integer' % (n,))
ValueError: 1.00000000000000 is not an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fsaad/sum-product-dsl/.venv/lib/python3.6/site-packages/sympy/sets/sets.py", line 1213, in __new__
    return simplify_intersection(args)
  File "/home/fsaad/sum-product-dsl/.venv/lib/python3.6/site-packages/sympy/sets/sets.py", line 1966, in simplify_intersection
    new_set = intersection_sets(s, t)
  File "/home/fsaad/sum-product-dsl/.venv/lib/python3.6/site-packages/sympy/multipledispatch/dispatcher.py", line 198, in __call__
    return func(*args, **kwargs)
  File "/home/fsaad/sum-product-dsl/.venv/lib/python3.6/site-packages/sympy/sets/handlers/intersection.py", line 104, in intersection_sets
    return intersection_sets(a, Range(start, end + 1))
  File "/home/fsaad/sum-product-dsl/.venv/lib/python3.6/site-packages/sympy/sets/fancysets.py", line 431, in __new__
    [0, 1/10, 1/5].'''))
ValueError: 
Finite arguments to Range must be integers; `imageset` can define
other cases, e.g. use `imageset(i, i/10, Range(3))` to give [0, 1/10,
1/5].
@fsaad
Copy link
Collaborator Author

fsaad commented May 26, 2020

sympy/sympy#18421

Fixed in sympy 1.6, consider upgrading?

@fsaad fsaad closed this as completed in 9a83f3a May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant