Skip to content

Commit

Permalink
Upgrade to Swift 5
Browse files Browse the repository at this point in the history
Move PersonaKit Dependencies to Podspec
Remove unused Dependency
Bump Version to 2.3.2
  • Loading branch information
jpbernius committed May 16, 2019
1 parent 39dcb7c commit 75676cb
Show file tree
Hide file tree
Showing 16 changed files with 1,763 additions and 2,183 deletions.
3 changes: 2 additions & 1 deletion CUU.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'CUU'
s.version = '2.3.1'
s.version = '2.3.2'
s.summary = 'CUU is a framework to help analyzing the usage of your applications.'

# This description is used to generate tags and improve search results.
Expand All @@ -27,6 +27,7 @@ CUU is a project to help analyzing the usage of your app by providing functional
s.source = { :git => 'https://github.com/cures-hub/cures-cuu-sdk.git', :tag => s.version.to_s }

s.ios.deployment_target = '11.0'
s.ios.dependency 'ReachabilitySwift'

s.source_files = 'CUU/Classes/**/*.{swift,xcdatamodeld,mlmodel}'
s.resources = 'CUU/Assets/*', 'CUU/Classes/InteractionKit/Core/CoreData/IKData.xcdatamodeld', 'CUU/Classes/BehaviorKit/Models/CoreData/BKData.xcdatamodeld'
Expand Down
52 changes: 26 additions & 26 deletions CUU/Classes/BehaviorKit/Helper/SigmaDistrib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public extension Sigma {
Sigma.centralMoment([3, -1, 1, 4.1, 4.1, 0.7], order: 3) // -1.5999259259

*/
public static func centralMoment(_ values: [Double], order: Int) -> Double? {
static func centralMoment(_ values: [Double], order: Int) -> Double? {
let count = Double(values.count)
if count == 0 { return nil }
guard let averageVal = average(values) else { return nil }
Expand Down Expand Up @@ -100,7 +100,7 @@ public extension Sigma {
Sigma.coefficientOfVariationSample([1, 12, 19.5, -5, 3, 8]) // 1.3518226672

*/
public static func coefficientOfVariationSample(_ values: [Double]) -> Double? {
static func coefficientOfVariationSample(_ values: [Double]) -> Double? {
if values.count < 2 { return nil }
guard let stdDev = Sigma.standardDeviationSample(values) else { return nil }
guard let avg = average(values) else { return nil }
Expand Down Expand Up @@ -148,7 +148,7 @@ public extension Sigma {
Sigma.covarianceSample(x: x, y: y) // 5.03

*/
public static func covarianceSample(x: [Double], y: [Double]) -> Double? {
static func covarianceSample(x: [Double], y: [Double]) -> Double? {
let xCount = Double(x.count)
let yCount = Double(y.count)

Expand Down Expand Up @@ -201,7 +201,7 @@ public extension Sigma {
Sigma.covariancePopulation(x: x, y: y) // 4.19166666666667

*/
public static func covariancePopulation(x: [Double], y: [Double]) -> Double? {
static func covariancePopulation(x: [Double], y: [Double]) -> Double? {
let xCount = Double(x.count)
let yCount = Double(y.count)

Expand Down Expand Up @@ -258,7 +258,7 @@ public extension Sigma {
Sigma.frequencies([1, 2, 3, 4, 5, 4, 4, 3, 5]) // [2:1, 3:2, 4:3, 5:2, 1:1]

*/
public static func frequencies(_ values: [Double]) -> ([Double: Int]) {
static func frequencies(_ values: [Double]) -> ([Double: Int]) {
var counts: [Double: Int] = [:]

for item in values {
Expand Down Expand Up @@ -304,7 +304,7 @@ public extension Sigma {
Sigma.kurtosisA([2, 1, 3, 4.1, 19, 1.5]) // 5.4570693277

*/
public static func kurtosisA(_ values: [Double]) -> Double? {
static func kurtosisA(_ values: [Double]) -> Double? {
let count = Double(values.count)
if count < 4 { return nil }

Expand Down Expand Up @@ -341,7 +341,7 @@ public extension Sigma {
Sigma.kurtosisB([2, 1, 3, 4.1, 19, 1.5]) // 4.0138523409

*/
public static func kurtosisB(_ values: [Double]) -> Double? {
static func kurtosisB(_ values: [Double]) -> Double? {
if values.isEmpty { return nil }
guard let moment4 = centralMoment(values, order: 4) else { return nil }
guard let moment2 = centralMoment(values, order: 2) else { return nil }
Expand Down Expand Up @@ -374,7 +374,7 @@ public extension Sigma {
Sigma.median([1, 12, 19.5, 3, -5]) // 3

*/
public static func median(_ values: [Double]) -> Double? {
static func median(_ values: [Double]) -> Double? {
let count = Double(values.count)
if count == 0 { return nil }
let sorted = Sigma.sort(values)
Expand Down Expand Up @@ -405,7 +405,7 @@ public extension Sigma {
Sigma.medianLow([1, 12, 19.5, 10, 3, -5]) // 3

*/
public static func medianLow(_ values: [Double]) -> Double? {
static func medianLow(_ values: [Double]) -> Double? {
let count = Double(values.count)
if count == 0 { return nil }
let sorted = values.sorted { $0 < $1 }
Expand Down Expand Up @@ -433,7 +433,7 @@ public extension Sigma {
Sigma.medianHigh([1, 12, 19.5, 10, 3, -5]) // 10

*/
public static func medianHigh(_ values: [Double]) -> Double? {
static func medianHigh(_ values: [Double]) -> Double? {
let count = Double(values.count)
if count == 0 { return nil }
let sorted = values.sorted { $0 < $1 }
Expand Down Expand Up @@ -472,7 +472,7 @@ public extension Sigma {
Sigma.normalDistribution(x: -1, μ: 0, σ: 1) // 0.1586552539314570

*/
public static func normalDistribution(x: Double, μ: Double = 0, σ: Double = 1) -> Double? {
static func normalDistribution(x: Double, μ: Double = 0, σ: Double = 1) -> Double? {
if σ <= 0 { return nil }
let z = (x - μ) / σ
return 0.5 * erfc(-z * 0.5.squareRoot())
Expand Down Expand Up @@ -510,7 +510,7 @@ public extension Sigma {
Sigma.normalDensity(x: 0, μ: 0, σ: 1) // 0.3989422804014327

*/
public static func normalDensity(x: Double, μ: Double = 0, σ: Double = 1) -> Double? {
static func normalDensity(x: Double, μ: Double = 0, σ: Double = 1) -> Double? {
if σ <= 0 { return nil }
return (1 / sqrt(2 * pow(σ,2) * Double.pi)) * pow(M_E, (-( pow(x - μ, 2) / (2 * pow(σ, 2)) )))
}
Expand All @@ -535,7 +535,7 @@ public extension Sigma {
Sigma.normalQuantile(p: 0.025, μ: 0, σ: 1) // -1.9599639845400538

*/
public static func normalQuantile(p: Double, μ: Double = 0, σ: Double = 1) -> Double? {
static func normalQuantile(p: Double, μ: Double = 0, σ: Double = 1) -> Double? {
return qnorm(p: p, mu: μ, sigma: σ)
}

Expand Down Expand Up @@ -700,7 +700,7 @@ public extension Sigma {
Sigma.pearson(x: x, y: y) // 0.843760859352745

*/
public static func pearson(x: [Double], y: [Double]) -> Double? {
static func pearson(x: [Double], y: [Double]) -> Double? {
if let cov = Sigma.covariancePopulation(x: x, y: y),
let σx = Sigma.standardDeviationPopulation(x),
let σy = Sigma.standardDeviationPopulation(y) {
Expand Down Expand Up @@ -743,7 +743,7 @@ public extension Sigma {
Sigma.percentile1(values: [35, 20, 50, 40, 15], percentile: 0.4) // Result: 29

*/
public static func percentile(_ data: [Double], percentile: Double) -> Double? {
static func percentile(_ data: [Double], percentile: Double) -> Double? {
return Sigma.quantiles.method7(data, probability: percentile)
}
}
Expand Down Expand Up @@ -776,7 +776,7 @@ public extension Sigma {
http://stat.ethz.ch/R-manual/R-devel/library/stats/html/quantile.html

*/
public static let quantiles = SigmaQuantiles()
static let quantiles = SigmaQuantiles()
}

public class SigmaQuantiles {
Expand Down Expand Up @@ -994,7 +994,7 @@ import Foundation
public extension Sigma {

/// Determines how the ranks for the equal values ('ties') are calculated.
public enum RankTieMethod {
enum RankTieMethod {
/**

Calculates the average rank:
Expand Down Expand Up @@ -1056,7 +1056,7 @@ public extension Sigma {
Sigma.rank([2, 3, 6, 5, 3]) // [1.0, 2.5, 5.0, 4.0, 2.5]

*/
public static func rank(_ values: [Double], ties: RankTieMethod = .average) -> [Double] {
static func rank(_ values: [Double], ties: RankTieMethod = .average) -> [Double] {
var rank: Double
let start = 1.0

Expand Down Expand Up @@ -1244,7 +1244,7 @@ public extension Sigma {
Sigma.skewnessA([4, 2.1, 8, 21, 1]) // 1.6994131524

*/
public static func skewnessA(_ values: [Double]) -> Double? {
static func skewnessA(_ values: [Double]) -> Double? {
let count = Double(values.count)
if count < 3 { return nil }
guard let moment3 = centralMoment(values, order: 3) else { return nil }
Expand Down Expand Up @@ -1274,7 +1274,7 @@ public extension Sigma {
Sigma.skewnessB([4, 2.1, 8, 21, 1]) // 1.1400009992

*/
public static func skewnessB(_ values: [Double]) -> Double? {
static func skewnessB(_ values: [Double]) -> Double? {
if values.count < 3 { return nil }
guard let stdDev = standardDeviationPopulation(values) else { return nil }
if stdDev == 0 { return nil }
Expand Down Expand Up @@ -1318,7 +1318,7 @@ public extension Sigma {
Sigma.standardDeviationSample([1, 12, 19.5, -5, 3, 8]) // 8.674195447801869

*/
public static func standardDeviationSample(_ values: [Double]) -> Double? {
static func standardDeviationSample(_ values: [Double]) -> Double? {
if let varianceSample = varianceSample(values) {
return sqrt(varianceSample)
}
Expand Down Expand Up @@ -1350,7 +1350,7 @@ public extension Sigma {
Sigma.standardDeviationPopulation([1, 12, 19.5, -5, 3, 8]) // 8.67419544780187

*/
public static func standardDeviationPopulation(_ values: [Double]) -> Double? {
static func standardDeviationPopulation(_ values: [Double]) -> Double? {
if let variancePopulation = variancePopulation(values) {
return sqrt(variancePopulation)
}
Expand Down Expand Up @@ -1400,7 +1400,7 @@ public extension Sigma {
Sigma.standardErrorOfTheMean([1, 12, 19.5, -5, 3, 8]) // 3.5412254627

*/
public static func standardErrorOfTheMean(_ values: [Double]) -> Double? {
static func standardErrorOfTheMean(_ values: [Double]) -> Double? {
let count = Double(values.count)
if count == 0 { return nil }
guard let stdev = standardDeviationSample(values) else { return nil }
Expand Down Expand Up @@ -1440,7 +1440,7 @@ public extension Sigma {
Sigma.uniqueValues([2, 1, 3, 4, 5, 4, 3, 5]) // [2, 3, 4, 5, 1]

*/
public static func uniqueValues(_ values: [Double]) -> [Double] {
static func uniqueValues(_ values: [Double]) -> [Double] {
return Array(Set(values))
}
}
Expand Down Expand Up @@ -1479,7 +1479,7 @@ public extension Sigma {
Sigma.varianceSample([1, 12, 19.5, -5, 3, 8]) // 75.24166667

*/
public static func varianceSample(_ values: [Double]) -> Double? {
static func varianceSample(_ values: [Double]) -> Double? {
let count = Double(values.count)
if count < 2 { return nil }

Expand Down Expand Up @@ -1518,7 +1518,7 @@ public extension Sigma {
Sigma.variancePopulation([1, 12, 19.5, -5, 3, 8]) // 62.70138889

*/
public static func variancePopulation(_ values: [Double]) -> Double? {
static func variancePopulation(_ values: [Double]) -> Double? {
let count = Double(values.count)
if count == 0 { return nil }

Expand Down
2 changes: 1 addition & 1 deletion CUU/Classes/CUUCore/CUUStartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class CUUStartView: UIView, CUUStartViewOptionDelegate {
}
} else {
if selectedOptions.contains(option) && allowedOptions.contains(option) {
if let index = selectedOptions.index(of: option) {
if let index = selectedOptions.firstIndex(of: option) {
selectedOptions.remove(at: index)
}
}
Expand Down
6 changes: 3 additions & 3 deletions CUU/Classes/InteractionKit/Helper/Array+PKUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
import Foundation

public extension Array where Element: Hashable {
public var histogram: [Element: Int] {
var histogram: [Element: Int] {
return self.reduce(into: [:]) { counts, elem in counts[elem, default: 0] += 1 }
}
}

public extension Collection where Element: BinaryFloatingPoint {
public var average: Element {
var average: Element {
return self.reduce(0, +) / Element(0.distance(to: self.count))
}
}

public extension Collection {
public func count(where test: (Element) throws -> Bool) rethrows -> Int {
func count(where test: (Element) throws -> Bool) rethrows -> Int {
return try self.filter(test).count
}
}
2 changes: 1 addition & 1 deletion CUU/Classes/InteractionKit/Helper/UIView+IKUtils.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
public extension UIView {

public var subviewCount: Int {
var subviewCount: Int {
if (self.subviews.count == 0) {
return 1
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
public extension UIViewController {

public var typeName: String {
var typeName: String {
return String(describing: type(of: self))
}

public var instanceIdentifier: String {
var instanceIdentifier: String {
let pointer = Unmanaged.passUnretained(self).toOpaque()
let address = String(describing: pointer)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Foundation
import Reachability

class PKReachabilityPolicy: PKLocationDetectionPolicy {
let reachability: Reachability
Expand Down
4 changes: 0 additions & 4 deletions CUU/Classes/PersonaKit/PKSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,3 @@ extension PKSession {
return numberOfShortVisits > 0
}
}

extension PKSession: Identifiable {
static let idKey = \PKSession.sessionId
}
Loading

0 comments on commit 75676cb

Please sign in to comment.