<commit_before># -*- coding: utf-8 -*-
"""
Created on Tue Jun  6 08:59:11 2017

@author: danaukes
using information from: http://lpsa.swarthmore.edu/NumInt/NumIntFourth.html
http://depa.fquim.unam.mx/amyd/archivero/DormandPrince_19856.pdf
"""
import numpy

class Integrator(object):

    def __init__(self,f,x0,t,tol = 1e-7,h_min = None):
        self.f = f
        self.t = t
        self.h = t[1]-t[0]
        self.tol = tol
        self.h_min = h_min or self.h*1e-3
        self.h_max = self.h
        self.x0 = x0
    
    def run(self,args = None):
        x = []
        x.append(self.x0)
        for time in self.t:
            x.append(self.step(time,x[-1],args = args))
        return numpy.array(x)[1:]
    
class RK4(Integrator):
    def step(self,t,x,args = None):
        h = self.h
        f = self.f
        
        args = args or []
        
        x = numpy.array(x)
        
        k1 = numpy.array(f(x,t,*args))
        k2 = numpy.array(f((x+k1*(h/2)),t+h/2,*args))
        k3 = numpy.array(f((x+k2*(h/2)),t+h/2,*args))
        k4 = numpy.array(f((x+k3*h),t+h,*args))        
        
        x1 = x+(k1+2*k2+2*k3+k4)/6*h
    
        return x1

class DoPri(Integrator):
    def step(self,t,x,args = None):
        h = self.h
        f = self.f
        
        args = args or []
        <commit_msg>added exception to dopri<commit_after># -*- coding: utf-8 -*-
"""
Created on Tue Jun  6 08:59:11 2017

@author: danaukes
using information from: http://lpsa.swarthmore.edu/NumInt/NumIntFourth.html
http://depa.fquim.unam.mx/amyd/archivero/DormandPrince_19856.pdf
"""
import numpy

class Integrator(object):

    def __init__(self,f,x0,t,tol = 1e-7,h_min = None):
        self.f = f
        self.t = t
        self.h = t[1]-t[0]
        self.tol = tol
        self.h_min = h_min or self.h*1e-3
        self.h_max = self.h
        self.x0 = x0
    
    def run(self,args = None):
        x = []
        x.append(self.x0)
        for time in self.t:
            x.append(self.step(time,x[-1],args = args))
        return numpy.array(x)[1:]
    
class RK4(Integrator):
    def step(self,t,x,args = None):
        h = self.h
        f = self.f
        
        args = args or []
        
        x = numpy.array(x)
        
        k1 = numpy.array(f(x,t,*args))
        k2 = numpy.array(f((x+k1*(h/2)),t+h/2,*args))
        k3 = numpy.array(f((x+k2*(h/2)),t+h/2,*args))
        k4 = numpy.array(f((x+k3*h),t+h,*args))        
        
        x1 = x+(k1+2*k2+2*k3+k4)/6*h
    
        return x1

class DoPri(Integrator):
    def step(self,t,x,args = None):
        raise(Exception('not working yet'))
        h = self.h
        f = self.f
        
        args = args or []
        
{'fraction_non_alphanumeric': 0.16376435716932197, 'fraction_numerical': 0.037050759540570584, 'mean_word_length': 1.7692307692307692, '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': '4866277', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1068, 'n_words': 190}