Move matplotlib to an optional dependency (#243)

* removed matplotlib

Signed-off-by: Amit Sharma <amit_sharma@live.com>

* added new req file

Signed-off-by: Amit Sharma <amit_sharma@live.com>
This commit is contained in:
Amit Sharma 2021-03-02 20:06:00 +05:30 коммит произвёл GitHub
Родитель 832311e103
Коммит d3245908b1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 71 добавлений и 56 удалений

1
.github/workflows/python-package.yml поставляемый
Просмотреть файл

@ -28,6 +28,7 @@ jobs:
python -m pip install --upgrade pip
pip install flake8 pytest twine
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-plotting.txt ]; then pip install -r requirements-plotting.txt; fi
pip install causalml nbformat jupyter
pip install econml
- name: Lint with flake8

Просмотреть файл

@ -3,8 +3,6 @@ import logging
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import math
import statsmodels.api as sm
@ -86,6 +84,8 @@ class AddUnobservedCommonCause(CausalRefuter):
self.logger.debug(refute)
results_matrix[i][j] = refute.estimated_effect # Populate the results
import matplotlib
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(6,5))
left, bottom, width, height = 0.1, 0.1, 0.8, 0.8
ax = fig.add_axes([left, bottom, width, height])
@ -115,6 +115,8 @@ class AddUnobservedCommonCause(CausalRefuter):
self.logger.debug(refute)
outcomes[i] = refute.estimated_effect # Populate the results
import matplotlib
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(6,5))
left, bottom, width, height = 0.1, 0.1, 0.8, 0.8
ax = fig.add_axes([left, bottom, width, height])
@ -142,6 +144,8 @@ class AddUnobservedCommonCause(CausalRefuter):
self.logger.debug(refute)
outcomes[i] = refute.estimated_effect # Populate the results
import matplotlib
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(6,5))
left, bottom, width, height = 0.1, 0.1, 0.8, 0.8
ax = fig.add_axes([left, bottom, width, height])

Просмотреть файл

@ -1,5 +1,4 @@
import numpy as np
import matplotlib.pyplot as plt
from dowhy.interpreters.visual_interpreter import VisualInterpreter
from dowhy.causal_estimators.propensity_score_weighting_estimator import PropensityScoreWeightingEstimator
@ -83,6 +82,7 @@ class ConfounderDistributionInterpreter(VisualInterpreter):
title1 = "Distribution of " + self.var_name + " before applying the weights"
title2 = "Distribution of " + self.var_name + " after applying the weights"
import matplotlib.pyplot as plt
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=self.fig_size)
iterable = zip([barplot_df_before, barplot_df_after], [ax1, ax2], [title1, title2])
for plot_df, ax, title in iterable:

Просмотреть файл

@ -1,6 +1,5 @@
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from dowhy.interpreters.visual_interpreter import VisualInterpreter
from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator
@ -61,6 +60,8 @@ class PropensityBalanceInterpreter(VisualInterpreter):
mean_diff_strata["sample"]="PropensityAdjusted"
mean_diff_overall["sample"] = "Unadjusted"
plot_df = pd.concat([mean_diff_overall, mean_diff_strata])
import matplotlib.pyplot as plt
plt.style.use("seaborn-white")
fig, ax = plt.subplots(1,1)
for label, subdf in plot_df.groupby('common_cause_id'):

Просмотреть файл

@ -0,0 +1 @@
matplotlib

Просмотреть файл

@ -3,7 +3,6 @@ scipy
statsmodels
pandas>=0.24
networkx>=2.0
matplotlib
sympy>=1.4
scikit-learn
pydot>=1.4

Просмотреть файл

@ -19,6 +19,14 @@ with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
with open(path.join(here, 'requirements.txt'), encoding='utf-8') as f:
install_requires = f.read().splitlines()
# Plotting packages are optional to install
extras = ["plotting"]
extras_require = dict()
for e in extras:
req_file = "requirements-{0}.txt".format(e)
with open(req_file) as f:
extras_require[e] = [line.strip() for line in f]
# Loading version number
with open(path.join(here, 'dowhy', 'VERSION')) as version_file:
version = version_file.read().strip()
@ -45,6 +53,7 @@ setup(
packages=find_packages(exclude=['docs', 'tests']),
python_requires='>=3.5',
install_requires=install_requires,
extras_require=extras_require,
include_package_data=True,
package_data={'dowhy':['VERSION']}
)