<commit_before>from __future__ import division

from travwave import navigation, solver, discretization

class BifurcationDiagram(object):

    def __init__(self, equation, boundary_condition, size = 32, doublings = 1, correction_rate = 10):
        self.equation = equation
        self.boundary = boundary_condition
        self.doublings = doublings
        self.size = size
        self.correction_rate = correction_rate

        self.discretization = discretization.Discretization(self.equation, size = 256)
        solve = solver.Solver(self.discretization, boundary = self.boundary)
        nav = navigation.Navigator(solve.solve, size = self.size, doublings = self.doublings, correction_rate = self.correction_rate)
        initial_guess = self.discretization.compute_initial_guess(.01)
        initial_velocity = self.discretization.bifurcation_velocity()
        step = 0.005
        p1 = (initial_velocity, 0)
        p0 = (initial_velocity, -step)

        nav.initialize(initial_guess, p1, p0)
        self.navigation = nav

    def plot_diagram(self):
        from matplotlib.pyplot import plot, xlabel, ylabel
        import numpy as np
        nav = self.navigation
        parameters = [result['current'] for result in nav]
        aparameters = np.array(parameters)
        sizes = [len(result['solution']) for result in nav]
        plot(aparameters[:,0], aparameters[:,1], '.--')
        for i,s in enumerate(sizes):
            if s > 50:
                plot(aparameters[i,0], aparameters[i,1], 'o', color='green')
            if s > 100:<commit_msg>todo: navigation step should not be hardcoded that parameter also has an effect on performances<commit_after>from __future__ import division

from travwave import navigation, solver, discretization

class BifurcationDiagram(object):

    def __init__(self, equation, boundary_condition, size = 32, doublings = 1, correction_rate = 10):
        self.equation = equation
        self.boundary = boundary_condition
        self.doublings = doublings
        self.size = size
        self.correction_rate = correction_rate

        self.discretization = discretization.Discretization(self.equation, size = 256)
        solve = solver.Solver(self.discretization, boundary = self.boundary)
        nav = navigation.Navigator(solve.solve, size = self.size, doublings = self.doublings, correction_rate = self.correction_rate)
        initial_guess = self.discretization.compute_initial_guess(.01)
        initial_velocity = self.discretization.bifurcation_velocity()
        step = 0.005 # should not be hard coded!
        p1 = (initial_velocity, 0)
        p0 = (initial_velocity, -step)

        nav.initialize(initial_guess, p1, p0)
        self.navigation = nav

    def plot_diagram(self):
        from matplotlib.pyplot import plot, xlabel, ylabel
        import numpy as np
        nav = self.navigation
        parameters = [result['current'] for result in nav]
        aparameters = np.array(parameters)
        sizes = [len(result['solution']) for result in nav]
        plot(aparameters[:,0], aparameters[:,1], '.--')
        for i,s in enumerate(sizes):
            if s > 50:
                plot(aparameters[i,0], aparameters[i,1], 'o', color='green')
            if s > 100:
{'fraction_non_alphanumeric': 0.09741856177012907, 'fraction_numerical': 0.017209588199139522, 'mean_word_length': 2.907563025210084, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1160587', 'n_tokens_mistral': 1005, 'n_tokens_neox': 934, 'n_words': 236}