<commit_before>//
//  ChartRendererBase.swift
//  Charts
//
//  Created by <NAME> on 3/3/15.
//
//  Copyright 2015 <NAME> & <NAME>
//  A port of MPAndroidChart for iOS
//  Licensed under Apache License 2.0
//
//  https://github.com/danielgindi/ios-charts
//

import Foundation

public class ChartRendererBase: NSObject
{
    /// the component that handles the drawing area of the chart and it's offsets
    public var viewPortHandler: ChartViewPortHandler!;
    internal var _minX: Int = 0;
    internal var _maxX: Int = 0;
    
    public override init()
    {
        super.init();
    }
    
    public init(viewPortHandler: ChartViewPortHandler)
    {
        super.init();
        self.viewPortHandler = viewPortHandler;
    }

    /// Returns true if the specified value fits in between the provided min and max bounds, false if not.
    internal func fitsBounds(val: Float, min: Float, max: Float) -> Bool
    {
        if (val < min || val > max)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    
    /// Calculates the minimum and maximum x-value the chart can currently display (with the given zoom level).
    internal func calcXBounds(trans: ChartTransformer!)
    {
        var minx = trans.getValueByTouchPoint(CGPoint(x: viewPortHandler.contentLeft, y: 0.0)).x;
        var maxx = trans.getValueByTouchPoint(CGPoint(x: viewPortHandler.contentRight, y: 0.0)).x;
        
        if (isnan(minx))
        {
            minx = 0;
        }
        if (isnan(maxx))
        {
            maxx = 0;
        }
        
        if (!isinf(minx))
        {
            _minX = Int(minx);
        }
        if (!isinf(maxx))
        {
            _maxX = Int(ceil(maxx));
        }
    }
}<commit_msg>Do no allow negative indexes here<commit_after>//
//  ChartRendererBase.swift
//  Charts
//
//  Created by <NAME>indi on 3/3/15.
//
//  Copyright 2015 <NAME> & <NAME>
//  A port of MPAndroidChart for iOS
//  Licensed under Apache License 2.0
//
//  https://github.com/danielgindi/ios-charts
//

import Foundation

public class ChartRendererBase: NSObject
{
    /// the component that handles the drawing area of the chart and it's offsets
    public var viewPortHandler: ChartViewPortHandler!;
    internal var _minX: Int = 0;
    internal var _maxX: Int = 0;
    
    public override init()
    {
        super.init();
    }
    
    public init(viewPortHandler: ChartViewPortHandler)
    {
        super.init();
        self.viewPortHandler = viewPortHandler;
    }

    /// Returns true if the specified value fits in between the provided min and max bounds, false if not.
    internal func fitsBounds(val: Float, min: Float, max: Float) -> Bool
    {
        if (val < min || val > max)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    
    /// Calculates the minimum and maximum x-value the chart can currently display (with the given zoom level).
    internal func calcXBounds(trans: ChartTransformer!)
    {
        var minx = trans.getValueByTouchPoint(CGPoint(x: viewPortHandler.contentLeft, y: 0.0)).x;
        var maxx = trans.getValueByTouchPoint(CGPoint(x: viewPortHandler.contentRight, y: 0.0)).x;
        
        if (isnan(minx))
        {
            minx = 0;
        }
        if (isnan(maxx))
        {
            maxx = 0;
        }
        
        if (!isinf(minx))
        {
            _minX = max(0, Int(minx));
        }
        if (!isinf(maxx))
        {
            _maxX = max(0, Int(ceil(maxx)));
        }
    }
}
{'fraction_non_alphanumeric': 0.10714285714285714, 'fraction_numerical': 0.010602678571428572, 'mean_word_length': 1.8228346456692914, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '6432036', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1083, 'n_words': 311}