<commit_before>import Foundation
import Cocoa

class DateController : NSObject, CPTPlotDataSource {
    private let oneDay : Double = 24 * 60 * 60;

    @IBOutlet var hostView : CPTGraphHostingView? = nil

    private var graph : CPTXYGraph? = nil

    private var plotData = [Double]()

    // MARK: - Initialization

    override func awakeFromNib()
    {
        self.plotData = newPlotData()

        // If you make sure your dates are calculated at noon, you shouldn't have to
        // worry about daylight savings. If you use midnight, you will have to adjust
        // for daylight savings time.
        let refDate = DateFormatter().date(from: "12:00 Oct 29, 2009")

        // Create graph
        let newGraph = CPTXYGraph(frame: .zero)

        let theme = CPTTheme(named: kCPTDarkGradientTheme)
        newGraph.apply(theme)

        if let host = self.hostView {
            host.hostedGraph = newGraph;
        }

        // Setup scatter plot space
        let plotSpace = newGraph.defaultPlotSpace as! CPTXYPlotSpace

        plotSpace.xRange = CPTPlotRange(location:0.0, length:NSNumber.init(value: oneDay * 5.0))
        plotSpace.yRange = CPTPlotRange(location:1.0, length:3.0)

        // Axes
        let axisSet = newGraph.axisSet as! CPTXYAxisSet
        if let x = axisSet.xAxis {
            x.majorIntervalLength   = NSNumber.init(value: oneDay)
            x.orthogonalPosition    = 2.0
            x.minorTicksPerInterval = 0;
            let dateFormatter = DateFormatter()
            dateFormatter.dateStyle = .short
            let timeFormatter = CPTTimeFormatter(dateFormatter:dateFormatter)
            timeFormatter.referenceDate = refDate;
            x.labelFormatter            = timeFormatter;
        }

        if let y = axisSet.yAxis {
            y.majorIntervalLength   = 0.5
            y.minorTicksPerInterval = 5
            y.orthogonalPosition    = oneDay

            y.labelingPolicy = .none
        }

        // Create a plot that uses the data source method
        let dataSourceLinePlot = CPTScatterPlot(frame: .zero)
        dataSourceLinePlot.identifier = "Date Plot"

        if let lineStyle = dataSourceLinePlot.dataLineStyle?.mutableCopy() as? CPTMutableLineStyle {
            lineStyle.lineWidth              = 3.0
            lineStyle.lineColor              = .green()
            dataSourceLinePlot.dataLineStyle = lineStyle
        }

        dataSourceLinePlot.dataSource = self
        newGraph.add(dataSourceLinePlot)

        self.graph = newGraph
    }

    func newPlotData() -> [Double]
    {
        var newData = [Double]()

        for _ in 0 ..< 5 {
            newData.append(1.2 * Double(arc4random()) / Double(UInt32.max) + 1.2)
        }

        return newData
    }

    // MARK: - Plot Data Source Methods

    func numberOfRecords(for plot: CPTPlot) -> UInt    {
        return UInt(self.plotData.count)
    }

    func number(for plot: CPTPlot, field: UInt, record: UInt) -> Any?
    {
        switch CPTScatterPlotField(rawValue: Int(field))! {
        case .X:
            return (oneDay * Double(record)) as NSNumber
            
        case .Y:
            return self.plotData[Int(record)] as NSNumber
        }
    }
}
<commit_msg>Updated the Swift example apps with Swift 3.0 changes in Xcode 8 beta 6.<commit_after>import Foundation
import Cocoa

class DateController : NSObject, CPTPlotDataSource {
    private let oneDay : Double = 24 * 60 * 60;

    @IBOutlet var hostView : CPTGraphHostingView? = nil

    private var graph : CPTXYGraph? = nil

    private var plotData = [Double]()

    // MARK: - Initialization

    override func awakeFromNib()
    {
        self.plotData = newPlotData()

        // If you make sure your dates are calculated at noon, you shouldn't have to
        // worry about daylight savings. If you use midnight, you will have to adjust
        // for daylight savings time.
        let refDate = DateFormatter().date(from: "12:00 Oct 29, 2009")

        // Create graph
        let newGraph = CPTXYGraph(frame: .zero)

        let theme = CPTTheme(named: kCPTDarkGradientTheme)
        newGraph.apply(theme)

        if let host = self.hostView {
            host.hostedGraph = newGraph;
        }

        // Setup scatter plot space
        let plotSpace = newGraph.defaultPlotSpace as! CPTXYPlotSpace

        plotSpace.xRange = CPTPlotRange(location:0.0, length:NSNumber.init(value: oneDay * 5.0))
        plotSpace.yRange = CPTPlotRange(location:1.0, length:3.0)

        // Axes
        let axisSet = newGraph.axisSet as! CPTXYAxisSet
        if let x = axisSet.xAxis {
            x.majorIntervalLength   = NSNumber.init(value: oneDay)
            x.orthogonalPosition    = 2.0
            x.minorTicksPerInterval = 0;
            let dateFormatter = DateFormatter()
            dateFormatter.dateStyle = .short
            let timeFormatter = CPTTimeFormatter(dateFormatter:dateFormatter)
            timeFormatter.referenceDate = refDate;
            x.labelFormatter            = timeFormatter;
        }

        if let y = axisSet.yAxis {
            y.majorIntervalLength   = 0.5
            y.minorTicksPerInterval = 5
            y.orthogonalPosition    = NSNumber.init(value: oneDay)

            y.labelingPolicy = .none
        }

        // Create a plot that uses the data source method
        let dataSourceLinePlot = CPTScatterPlot(frame: .zero)
        dataSourceLinePlot.identifier = NSString.init(string: "Date Plot")

        if let lineStyle = dataSourceLinePlot.dataLineStyle?.mutableCopy() as? CPTMutableLineStyle {
            lineStyle.lineWidth              = 3.0
            lineStyle.lineColor              = .green()
            dataSourceLinePlot.dataLineStyle = lineStyle
        }

        dataSourceLinePlot.dataSource = self
        newGraph.add(dataSourceLinePlot)

        self.graph = newGraph
    }

    func newPlotData() -> [Double]
    {
        var newData = [Double]()

        for _ in 0 ..< 5 {
            newData.append(1.2 * Double(arc4random()) / Double(UInt32.max) + 1.2)
        }

        return newData
    }

    // MARK: - Plot Data Source Methods

    func numberOfRecords(for plot: CPTPlot) -> UInt    {
        return UInt(self.plotData.count)
    }

    func number(for plot: CPTPlot, field: UInt, record: UInt) -> Any?
    {
        switch CPTScatterPlotField(rawValue: Int(field))! {
        case .X:
            return (oneDay * Double(record)) as NSNumber
            
        case .Y:
            return self.plotData[Int(record)] as NSNumber
        }
    }
}

{'fraction_non_alphanumeric': 0.08589704538531831, 'fraction_numerical': 0.013097776424002438, 'mean_word_length': 1.985, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5517327', 'n_tokens_mistral': 2003, 'n_tokens_neox': 1842, 'n_words': 485}