<commit_before># Copyright 2015 Novo Nordisk Foundation Center for Biosustainability, DTU.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from cameo.util import partition


__all__ = ['plot_production_envelope']

from cameo import config, util

try:
    # import matplotlib.pyplot as plt

    def plot_production_envelope_ipython_matplotlib(envelope, objective, key, grid=None, width=None, height=None,
                                                    title=None, points=None, points_colors=None, axis_font_size=None):
        pass
        # plt.plot(envelope["objective_upper_bound"], envelope[key], title="Production envelop")
        # plt.xlabel("growth")
        # plt.ylabel(key)

except ImportError:

    def plot_production_envelope_ipython_matplotlib(envelope, objective, key, grid=None, width=None, height=None,
                                                    title=None, points=None, points_colors=None, axis_font_size=None):
        pass

try:
    from bokeh import plotting
    from bokeh.models import GridPlot

    def plot_production_envelope_ipython_bokeh(envelope, objective, key, grid=None, width=None, height=None,
                                               title=None, points=None, points_colors=None, axis_font_size=None):

        p = plotting.figure(title=title if title is not None else "Production envelope",
                            tools="save",
                            plot_width=width if width is not None else 700,
                            plot_height=height if height is not None else 700)
        p.xaxis.axis_label = key
        p.yaxis.axis_label = objective

        ub = envelope["objective_upper_bound"].values
        lb = envelope["objective_lower_bound"].values
        var = envelope[key].values

        x = [0] + [v for v in var] + list(reversed([v for v in var]))
        y = [0] + [v for v in lb] + list(reversed([v for v in ub]))

        p.patch(x=x, y=y, color="#99d8c9", alpha=0.3)

        if "label" in envelope.columns:
            p.text(envelope["label"].values, var, ub)
        p.line(var, ub, color="blue")
        p.line(var, lb, color="blue")
        if ub[-1] != lb[-1]:
            p.line((var[-1], var[-1]), (ub[-1], lb[-1]), color="blue")

        if axis_font_size is not None:
            p.xaxis.axis_label_text_font_size = axis_font_size
            p.yaxis.axis_label_text_font_size = axis_font_size

        if points is not None:
            p.scatter(*points, color="green" if points_colors is None else points_colors)

        if grid is not None:
            grid.append(p)
        else:
            plotting.show(p)

except ImportError:

    def plot_production_envelope_ipython_bokeh(envelope, objective, key, grid=None, width=None, height=None,
                                               title=None, points=None, points_colors=None, axis_font_size=None):
        pass

try:
    from bashplotlib import scatterplot

    def plot_production_envelope_cli(envelope, objective, key, grid=None, width=None, height=None,
                                               title=None, points=None, points_colors=None, axis_font_size=None):
        scatterplot.plot_scatter(None, envelope[key], envelope["objective_upper_bound"], "*")

except ImportError:
    def plot_production_envelope_cli(envelope, objective, key, grid=None, width=None, height=None,
                                               title=None, points=None, points_colors=None, axis_font_size=None):
        pass


def plot_production_envelope(envelope, objective, key, grid=None, width=None, height=None, title=None,
                             points=None, points_colors=None, axis_font_size=None):<commit_msg>Create blank functions if there is incompatibilities<commit_after># Copyright 2015 Novo Nordisk Foundation Center for Biosustainability, DTU.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from cameo.util import partition


__all__ = ['plot_production_envelope']

from cameo import config, util

try:
    # import matplotlib.pyplot as plt

    def plot_production_envelope_ipython_matplotlib(envelope, objective, key, grid=None, width=None, height=None,
                                                    title=None, points=None, points_colors=None, axis_font_size=None):
        pass
        # plt.plot(envelope["objective_upper_bound"], envelope[key], title="Production envelop")
        # plt.xlabel("growth")
        # plt.ylabel(key)

except:

    def plot_production_envelope_ipython_matplotlib(envelope, objective, key, grid=None, width=None, height=None,
                                                    title=None, points=None, points_colors=None, axis_font_size=None):
        pass

try:
    from bokeh import plotting
    from bokeh.models import GridPlot

    def plot_production_envelope_ipython_bokeh(envelope, objective, key, grid=None, width=None, height=None,
                                               title=None, points=None, points_colors=None, axis_font_size=None):

        p = plotting.figure(title=title if title is not None else "Production envelope",
                            tools="save",
                            plot_width=width if width is not None else 700,
                            plot_height=height if height is not None else 700)
        p.xaxis.axis_label = key
        p.yaxis.axis_label = objective

        ub = envelope["objective_upper_bound"].values
        lb = envelope["objective_lower_bound"].values
        var = envelope[key].values

        x = [0] + [v for v in var] + list(reversed([v for v in var]))
        y = [0] + [v for v in lb] + list(reversed([v for v in ub]))

        p.patch(x=x, y=y, color="#99d8c9", alpha=0.3)

        if "label" in envelope.columns:
            p.text(envelope["label"].values, var, ub)
        p.line(var, ub, color="blue")
        p.line(var, lb, color="blue")
        if ub[-1] != lb[-1]:
            p.line((var[-1], var[-1]), (ub[-1], lb[-1]), color="blue")

        if axis_font_size is not None:
            p.xaxis.axis_label_text_font_size = axis_font_size
            p.yaxis.axis_label_text_font_size = axis_font_size

        if points is not None:
            p.scatter(*points, color="green" if points_colors is None else points_colors)

        if grid is not None:
            grid.append(p)
        else:
            plotting.show(p)

except:

    def plot_production_envelope_ipython_bokeh(envelope, objective, key, grid=None, width=None, height=None,
                                               title=None, points=None, points_colors=None, axis_font_size=None):
        pass

try:
    from bashplotlib import scatterplot

    def plot_production_envelope_cli(envelope, objective, key, grid=None, width=None, height=None,
                                               title=None, points=None, points_colors=None, axis_font_size=None):
        scatterplot.plot_scatter(None, envelope[key], envelope["objective_upper_bound"], "*")

except:
    def plot_production_envelope_cli(envelope, objective, key, grid=None, width=None, height=None,
                                               title=None, points=None, points_colors=None, axis_font_size=None):
        pass


def plot_production_envelope(envelope, objective, key, grid=None, width=None, height=None, title=None,
                             points=None, points_colors=None, axis_font_size=None):
{'fraction_non_alphanumeric': 0.09460919678232681, 'fraction_numerical': 0.006723496218033378, 'mean_word_length': 2.572041166380789, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '221549', 'n_tokens_mistral': 2389, 'n_tokens_neox': 2322, 'n_words': 662}