<commit_before>"""
This file demonstrates a bokeh applet, which can be viewed directly
on a bokeh-server. See the README.md file in this directory for
instructions on running.
"""

import logging
logging.basicConfig(level=logging.DEBUG)

import numpy as np

from bokeh.plotting import line
from bokeh.objects import Plot, ColumnDataSource, Range1d
from bokeh.properties import Instance
from bokeh.server.app import bokeh_app
from bokeh.server.utils.plugins import object_page
from bokeh.widgetobjects import HBox, Slider, TextInput, VBoxForm

class SlidersApp(HBox):
    extra_generated_classes = [["SlidersApp", "SlidersApp", "HBox"]]

    inputs = Instance(VBoxForm)

    text = Instance(TextInput)

    offset = Instance(Slider)
    amplitude = Instance(Slider)
    phase = Instance(Slider)
    freq = Instance(Slider)

    plot = Instance(Plot)
    source = Instance(ColumnDataSource)

    @classmethod
    def create(cls):
        """
        This function is called once, and is responsible for
        creating all objects (plots, datasources, etc)
        """
        obj = cls()

        obj.source = ColumnDataSource(data=dict(x=[], y=[]))

        obj.text = TextInput(
            title="title", name='title', value='my sin wave'
        )

        obj.offset = Slider(
            title="offset", name='offset',
            value=0.0, start=-5.0, end=5.0
        )
        obj.amplitude = Slider(
            title="amplitude", name='amplitude',
            value=1.0, start=-5.0, end=5.0
        )
        obj.phase = Slider(
            title="phase", name='phase',
            value=0.0, start=0.0, end=2*np.pi
        )
        obj.freq = Slider(
            title="frequency", name='frequency',
            value=1.0, start=0.1, end=3.0
        )

        obj.plot = line('x', 'y', source=obj.source,
                        plot_width=400, plot_height=400,
                        line_width=3, line_alpha=0.6,
                        title=obj.text.value,
                        x_range=[0, 4*np.pi], y_range=[-2.5, 2.5]
        )

        obj.update_data()

        obj.inputs = VBoxForm(
            children=[
                obj.text, obj.offset, obj.amplitude, obj.phase, obj.freq
            ]
        )

        obj.children.append(obj.inputs)
        obj.children.append(obj.plot)

        return obj

    def setup_events(self):
        super(SlidersApp, self).setup_events()
        if not self.text:
            return
        self.text.on_change('value', self, 'input_change')
        for w in ["offset", "amplitude", "phase", "freq"]:
            print self.offset
            getattr(self, w).on_change('value', self, 'input_change')
<commit_msg>slider range tweak<commit_after>"""
This file demonstrates a bokeh applet, which can be viewed directly
on a bokeh-server. See the README.md file in this directory for
instructions on running.
"""

import logging
logging.basicConfig(level=logging.DEBUG)

import numpy as np

from bokeh.plotting import line
from bokeh.objects import Plot, ColumnDataSource, Range1d
from bokeh.properties import Instance
from bokeh.server.app import bokeh_app
from bokeh.server.utils.plugins import object_page
from bokeh.widgetobjects import HBox, Slider, TextInput, VBoxForm

class SlidersApp(HBox):
    extra_generated_classes = [["SlidersApp", "SlidersApp", "HBox"]]

    inputs = Instance(VBoxForm)

    text = Instance(TextInput)

    offset = Instance(Slider)
    amplitude = Instance(Slider)
    phase = Instance(Slider)
    freq = Instance(Slider)

    plot = Instance(Plot)
    source = Instance(ColumnDataSource)

    @classmethod
    def create(cls):
        """
        This function is called once, and is responsible for
        creating all objects (plots, datasources, etc)
        """
        obj = cls()

        obj.source = ColumnDataSource(data=dict(x=[], y=[]))

        obj.text = TextInput(
            title="title", name='title', value='my sin wave'
        )

        obj.offset = Slider(
            title="offset", name='offset',
            value=0.0, start=-5.0, end=5.0
        )
        obj.amplitude = Slider(
            title="amplitude", name='amplitude',
            value=1.0, start=-5.0, end=5.0
        )
        obj.phase = Slider(
            title="phase", name='phase',
            value=0.0, start=0.0, end=2*np.pi
        )
        obj.freq = Slider(
            title="frequency", name='frequency',
            value=1.0, start=0.1, end=5.1
        )

        obj.plot = line('x', 'y', source=obj.source,
                        plot_width=400, plot_height=400,
                        line_width=3, line_alpha=0.6,
                        title=obj.text.value,
                        x_range=[0, 4*np.pi], y_range=[-2.5, 2.5]
        )

        obj.update_data()

        obj.inputs = VBoxForm(
            children=[
                obj.text, obj.offset, obj.amplitude, obj.phase, obj.freq
            ]
        )

        obj.children.append(obj.inputs)
        obj.children.append(obj.plot)

        return obj

    def setup_events(self):
        super(SlidersApp, self).setup_events()
        if not self.text:
            return
        self.text.on_change('value', self, 'input_change')
        for w in ["offset", "amplitude", "phase", "freq"]:
            print self.offset
            getattr(self, w).on_change('value', self, 'input_change')

{'fraction_non_alphanumeric': 0.11924725172349543, 'fraction_numerical': 0.014533258803801007, 'mean_word_length': 2.1373465809468146, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5514848', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1630, 'n_words': 386}