<commit_before># -*- coding: utf-8 -*-

import itertools

import scipy
import scipy.linalg
import scipy.optimize

from base import Minimizer
from linesearch import ScipyLineSearch


# Things left to do:
#
# - update initial diagonal inverse hessian as in minfunc
# - figure out what the corrections are
# - damped update


class Lbfgs(Minimizer):

    def __init__(self, wrt, f, fprime, initial_hessian_diag=1,
                 n_factors=10, line_search=None,
                 args=None, stop=1, verbose=False):
        super(Lbfgs, self).__init__(wrt, args=args, stop=stop, verbose=verbose)

        self.f = f
        self.fprime = fprime
        self.initial_hessian_diag = initial_hessian_diag
        self.n_factors = n_factors
        if line_search is not None:
            self.line_search = line_search
        else:
            self.line_search = ScipyLineSearch(<commit_msg>Always use WolfeLineSearch with Lbfgs.<commit_after># -*- coding: utf-8 -*-

import itertools

import scipy
import scipy.linalg
import scipy.optimize

from base import Minimizer
from linesearch import WolfeLineSearch


# Things left to do:
#
# - update initial diagonal inverse hessian as in minfunc
# - figure out what the corrections are
# - damped update


class Lbfgs(Minimizer):

    def __init__(self, wrt, f, fprime, initial_hessian_diag=1,
                 n_factors=10, line_search=None,
                 args=None, stop=1, verbose=False):
        super(Lbfgs, self).__init__(wrt, args=args, stop=stop, verbose=verbose)

        self.f = f
        self.fprime = fprime
        self.initial_hessian_diag = initial_hessian_diag
        self.n_factors = n_factors
        if line_search is not None:
            self.line_search = line_search
        else:
            self.line_search = WolfeLineSearch(
{'fraction_non_alphanumeric': 0.07966573816155989, 'fraction_numerical': 0.005571030640668524, 'mean_word_length': 2.789029535864979, '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': '603528', 'n_tokens_mistral': 587, 'n_tokens_neox': 558, 'n_words': 153}