<commit_before>"""This is the Bokeh charts interface. It gives you a high level API to build
complex plot is a simple way.

This is the main Chart class which is able to build several plots using the low
level Bokeh API. It setups all the plot characteristics and lets you plot
different chart types, taking OrderedDict as the main input. It also supports
the generation of several outputs (file, server, notebook).
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2012 - 2014, Continuum Analytics, Inc. All rights reserved.
#
# Powered by the Bokeh Development Team.
#
# The full license is in the file LICENSE.txt, distributed with this software.
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

from __future__ import absolute_import

import warnings
from six import iteritems
from collections import defaultdict
import numpy as np

from ..core.enums import enumeration, LegendLocation
from ..document import Document
from ..embed import file_html
from ..models import (
    CategoricalAxis, DatetimeAxis, Grid, Legend, LinearAxis, Plot,
    HoverTool, FactorRange
)
from ..plotting import DEFAULT_TOOLS
from ..plotting.helpers import _process_tools_arg
from ..core.properties import (Auto, Bool, Either, Enum, Int, Float,
                          String, Tuple, Override)
from ..resources import INLINE
from ..util.browser import view
from ..util.notebook import publish_display_data
from ..util.deprecate import deprecated

#-----------------------------------------------------------------------------
# Classes and functions
#-----------------------------------------------------------------------------

Scale = enumeration('linear', 'categorical', 'datetime')

class ChartDefaults(object):
    def apply(self, chart):
        """Apply this defaults to a chart."""

        if not isinstance(chart, Chart):
            raise ValueError("ChartsDefaults should be only used on Chart \
            objects but it's being used on %s instead." % chart)

        for k in chart.properties_with_values(include_defaults=True):
            if k == 'tools':
                value = getattr(self, k, True)
                if getattr(chart, '_tools', None) is None:
                    chart._tools = value
            else:
                if hasattr(self, k):
                    setattr(chart, k, getattr(self, k))

defaults = ChartDefaults()

class Chart(Plot):
    """ The main Chart class, the core of the ``Bokeh.charts`` interface.

    """

    __view_model__ = "Plot"
    __subtype__ = "Chart"

    legend = Either(Bool, Enum(LegendLocation), Tuple(Float, Float), help="""
    A location where the legend should draw itself.
    """)

    xgrid = Bool(True, help="""
    Whether to draw an x-grid.
    """)

    ygrid = Bool(True, help="""
    Whether to draw an y-grid.
    """)

    xlabel = String(None, help="""
    A label for the x-axis. (default: None)
    """)

    ylabel = String(None, help="""
    A label for the y-axis. (default: None)
    """)

    xscale = Either(Auto, Enum(Scale), help="""
    What kind of scale to use for the x-axis.
    """)

    yscale = Either(Auto, Enum(Scale), help="""
    What kind of scale to use for the y-axis.
    """)

    width = Int(600, help="""
    Width of the rendered chart, in pixels.
    """)

    height = Int(400, help="""
    Height of the rendered chart, in pixels.
    """)

    title_text_font_size = Override(default={ 'value' : '14pt' })

    responsive = Override(default=False)

    _defaults = defaults

    __deprecated_attributes__ = ('filename', 'server', 'notebook')

    def __init__(self, *args, **kwargs):
        # pop tools as it is also a property that doesn't match the argument
        # supported types
        tools = kwargs.pop('tools', None)
        super(Chart, self).__init__(*args, **kwargs)
        defaults.apply(self)
        if tools is not None:
            self._tools = tools

        self._glyphs = []
        self._built = False

        self._builders = []
        self._renderer_map = []
        self._ranges = defaultdict(list)
        self._labels = defaultdict(list)
        self._scales = defaultdict(list)
        self._tooltips = []

        self.create_tools(self._tools)

    def add_renderers(self, builder, renderers):
        self.renderers += renderers<commit_msg>Force title text font size to be serialized on charts<commit_after>"""This is the Bokeh charts interface. It gives you a high level API to build
complex plot is a simple way.

This is the main Chart class which is able to build several plots using the low
level Bokeh API. It setups all the plot characteristics and lets you plot
different chart types, taking OrderedDict as the main input. It also supports
the generation of several outputs (file, server, notebook).
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2012 - 2014, Continuum Analytics, Inc. All rights reserved.
#
# Powered by the Bokeh Development Team.
#
# The full license is in the file LICENSE.txt, distributed with this software.
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

from __future__ import absolute_import

import warnings
from six import iteritems
from collections import defaultdict
import numpy as np

from ..core.enums import enumeration, LegendLocation
from ..document import Document
from ..embed import file_html
from ..models import (
    CategoricalAxis, DatetimeAxis, Grid, Legend, LinearAxis, Plot,
    HoverTool, FactorRange
)
from ..plotting import DEFAULT_TOOLS
from ..plotting.helpers import _process_tools_arg
from ..core.properties import (Auto, Bool, Either, Enum, Int, Float,
                          String, Tuple, Override)
from ..resources import INLINE
from ..util.browser import view
from ..util.notebook import publish_display_data
from ..util.deprecate import deprecated

#-----------------------------------------------------------------------------
# Classes and functions
#-----------------------------------------------------------------------------

Scale = enumeration('linear', 'categorical', 'datetime')

class ChartDefaults(object):
    def apply(self, chart):
        """Apply this defaults to a chart."""

        if not isinstance(chart, Chart):
            raise ValueError("ChartsDefaults should be only used on Chart \
            objects but it's being used on %s instead." % chart)

        for k in chart.properties_with_values(include_defaults=True):
            if k == 'tools':
                value = getattr(self, k, True)
                if getattr(chart, '_tools', None) is None:
                    chart._tools = value
            else:
                if hasattr(self, k):
                    setattr(chart, k, getattr(self, k))

defaults = ChartDefaults()

class Chart(Plot):
    """ The main Chart class, the core of the ``Bokeh.charts`` interface.

    """

    __view_model__ = "Plot"
    __subtype__ = "Chart"

    legend = Either(Bool, Enum(LegendLocation), Tuple(Float, Float), help="""
    A location where the legend should draw itself.
    """)

    xgrid = Bool(True, help="""
    Whether to draw an x-grid.
    """)

    ygrid = Bool(True, help="""
    Whether to draw an y-grid.
    """)

    xlabel = String(None, help="""
    A label for the x-axis. (default: None)
    """)

    ylabel = String(None, help="""
    A label for the y-axis. (default: None)
    """)

    xscale = Either(Auto, Enum(Scale), help="""
    What kind of scale to use for the x-axis.
    """)

    yscale = Either(Auto, Enum(Scale), help="""
    What kind of scale to use for the y-axis.
    """)

    width = Int(600, help="""
    Width of the rendered chart, in pixels.
    """)

    height = Int(400, help="""
    Height of the rendered chart, in pixels.
    """)

    title_text_font_size = Override(default={ 'value' : '14pt' })

    responsive = Override(default=False)

    _defaults = defaults

    __deprecated_attributes__ = ('filename', 'server', 'notebook')

    def __init__(self, *args, **kwargs):
        # pop tools as it is also a property that doesn't match the argument
        # supported types
        tools = kwargs.pop('tools', None)
        super(Chart, self).__init__(*args, **kwargs)
        defaults.apply(self)
        if tools is not None:
            self._tools = tools

        # TODO (bev) have to force serialization of overriden defaults on subtypes for now
        self.title_text_font_size = "10pt"
        self.title_text_font_size = "14pt"

        self._glyphs = []
        self._built = False

        self._builders = []
        self._renderer_map = []
        self._ranges = defaultdict(list)
        self._labels = defaultdict(list)
        self._scales = defaultdict(list)
        self._tooltips = []

        self.create_tools(self._tools)

    def add_renderers(self, builder, renderers):
        self.renderers += renderers
{'fraction_non_alphanumeric': 0.19299568965517241, 'fraction_numerical': 0.003879310344827586, 'mean_word_length': 1.9491579281855735, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6499669', 'n_tokens_mistral': 2480, 'n_tokens_neox': 2355, 'n_words': 867}