py-why / dowhy

DoWhy is a Python library for causal inference that supports explicit modeling and testing of causal assumptions. DoWhy is based on a unified language for causal inference, combining causal graphical models and potential outcomes frameworks.
https://www.pywhy.org/dowhy
MIT License
7.01k stars 922 forks source link

Reliance on deprecated code should be removed / soft-imported #961

Closed adam2392 closed 1 year ago

adam2392 commented 1 year ago

Describe the bug Currently, dowhy contains hard imports of deprecated code that has since been removed in 1.25.0.

Traceback (most recent call last):
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.9/lib/python3.9/site-packages/sphinx/cmd/build.py", line 281, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.9/lib/python3.9/site-packages/sphinx/application.py", line 349, in build
    self.events.emit('build-finished', None)
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.9/lib/python3.9/site-packages/sphinx/events.py", line 94, in emit
    results.append(listener.handler(self.app, *args))
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.9/lib/python3.9/site-packages/sphinx_gallery/gen_gallery.py", line 852, in summarize_failing_examples
    raise ExtensionError(fail_message)
sphinx.errors.ExtensionError: Here is a summary of the problems encountered when running the examples

Unexpected failing examples:
/home/circleci/project/examples/plot_pc_alg.py failed leaving traceback:
Traceback (most recent call last):
  File "/home/circleci/project/examples/plot_pc_alg.py", line 30, in <module>
    from dowhy import gcm
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.9/lib/python3.9/site-packages/dowhy/gcm/__init__.py", line 12, in <module>
    from .influence import arrow_strength, intrinsic_causal_influence
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.9/lib/python3.9/site-packages/dowhy/gcm/influence.py", line 25, in <module>
    from dowhy.gcm.uncertainty import estimate_entropy_of_probabilities, estimate_variance
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.9/lib/python3.9/site-packages/dowhy/gcm/uncertainty.py", line 7, in <module>
    from numpy.dual import det
ModuleNotFoundError: No module named 'numpy.dual'

Expected behavior Dowhy should be expected to work with future version of numpy seamlessly unless there are strict dependencies wrt numba. I don't see any reason to use numpy.dual directly when numpy handles these issues upstream:

Moreover https://github.com/py-why/dowhy/blob/961ffc63732982bec12503926c6077c8daec7dcc/pyproject.toml#L53 seems strict.

Version information:

Additional context ref: https://github.com/numpy/numpy/pull/23480

bloebp commented 1 year ago

Addressed in https://github.com/py-why/dowhy/pull/963