def test_DecisionMatrixPlotter_wheatmap_default_axis( decision_matrix, fig_test, fig_ref ): dm = decision_matrix( seed=42, min_alternatives=3, max_alternatives=3, min_criteria=3, max_criteria=3, ) plotter = plot.DecisionMatrixPlotter(dm=dm) test_ax = fig_test.subplots() with mock.patch("matplotlib.pyplot.gca", return_value=test_ax): plotter.wheatmap() # EXPECTED labels = [ f"{c} {o.to_string()}" for c, o in zip(dm.criteria, dm.objectives) ] weights = dm.weights.to_frame().T exp_ax = fig_ref.subplots() sns.heatmap(weights, ax=exp_ax, annot=True, cmap=plt.cm.get_cmap()) exp_ax.set_xticklabels(labels) exp_ax.set_xlabel("Criteria") size = fig_ref.get_size_inches() / [1, 5] fig_ref.set_size_inches(size)
def test_DecisionMatrixPlotter_wheatmap(decision_matrix, fig_test, fig_ref): dm = decision_matrix( seed=42, min_alternatives=3, max_alternatives=3, min_criteria=3, max_criteria=3, ) plotter = plot.DecisionMatrixPlotter(dm=dm) test_ax = fig_test.subplots() plotter.wheatmap(ax=test_ax) # EXPECTED labels = [ f"{c} {o.to_string()}" for c, o in zip(dm.criteria, dm.objectives) ] weights = dm.weights.to_frame().T exp_ax = fig_ref.subplots() sns.heatmap(weights, ax=exp_ax, annot=True, cmap=plt.cm.get_cmap()) exp_ax.set_xticklabels(labels) exp_ax.set_xlabel("Criteria")
def test_DecisionMatrixPlotter_box(decision_matrix, orient, fig_test, fig_ref): dm = decision_matrix( seed=42, min_alternatives=3, max_alternatives=3, min_criteria=3, max_criteria=3, ) plotter = plot.DecisionMatrixPlotter(dm=dm) test_ax = fig_test.subplots() plotter.box(ax=test_ax, orient=orient) # EXPECTED labels = [ f"{c} {o.to_string()}" for c, o in zip(dm.criteria, dm.objectives) ] exp_ax = fig_ref.subplots() sns.boxplot(data=dm.matrix, ax=exp_ax, orient=orient) if orient == "v": exp_ax.set_xticklabels(labels) exp_ax.set_xlabel("Criteria") elif orient == "h": exp_ax.set_yticklabels(labels) exp_ax.set_ylabel("Criteria")
def test_DecisionMatrixPlotter_wbar(decision_matrix, fig_test, fig_ref): dm = decision_matrix( seed=42, min_alternatives=3, max_alternatives=3, min_criteria=3, max_criteria=3, ) plotter = plot.DecisionMatrixPlotter(dm=dm) test_ax = fig_test.subplots() plotter.wbar(ax=test_ax) # EXPECTED labels = [ f"{c} {o.to_string()}" for c, o in zip(dm.criteria, dm.objectives) ] weights = dm.weights.to_frame().T exp_ax = fig_ref.subplots() weights.plot.bar(ax=exp_ax) exp_ax.set_xlabel("Alternatives") exp_ax.legend(labels)
def test_DecisionMatrixPlotter_wogive(decision_matrix, fig_test, fig_ref): dm = decision_matrix( seed=42, min_alternatives=3, max_alternatives=3, min_criteria=3, max_criteria=3, ) plotter = plot.DecisionMatrixPlotter(dm=dm) test_ax = fig_test.subplots() plotter.wogive(ax=test_ax) # EXPECTED weights = dm.weights.to_frame() exp_ax = fig_ref.subplots() sns.ecdfplot(data=weights, ax=exp_ax)
def test_DecisionMatrixPlotter_ogive(decision_matrix, fig_test, fig_ref): dm = decision_matrix( seed=42, min_alternatives=3, max_alternatives=3, min_criteria=3, max_criteria=3, ) plotter = plot.DecisionMatrixPlotter(dm=dm) test_ax = fig_test.subplots() plotter.ogive(ax=test_ax) # EXPECTED labels = [ f"{c} {o.to_string()}" for c, o in zip(dm.criteria, dm.objectives) ] exp_ax = fig_ref.subplots() sns.ecdfplot(data=dm.matrix, ax=exp_ax) exp_ax.legend(labels)