Add linter, fix linter warnigns, uncomment tests
This commit is contained in:
parent
6665edfcee
commit
7c1b6ea3fc
|
@ -0,0 +1,9 @@
|
|||
disabled_rules:
|
||||
- file_length
|
||||
- identifier_name
|
||||
- line_length
|
||||
- trailing_comma
|
||||
|
||||
opt_in_rules:
|
||||
- closure_spacing
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
# Surge [![Build Status](https://travis-ci.org/mattt/Surge.svg?branch=master)](https://travis-ci.org/mattt/Surge) [![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/mattt/Surge/blob/master/LICENSE) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
|
||||
# Surge
|
||||
[![Build Status](https://travis-ci.org/mattt/Surge.svg?branch=master)](https://travis-ci.org/mattt/Surge) [![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/mattt/Surge/blob/master/LICENSE) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
|
||||
|
||||
Surge is a Swift library that uses the Accelerate framework to provide high-performance functions for matrix math, digital signal processing, and image manipulation.
|
||||
|
||||
|
|
|
@ -390,7 +390,6 @@ public func dot<X: ContinuousCollection, Y: ContinuousCollection>(_ x: X, _ y: Y
|
|||
return result
|
||||
}
|
||||
|
||||
|
||||
public func dot<X: ContinuousCollection, Y: ContinuousCollection>(_ x: X, _ y: Y) -> Double where X.Iterator.Element == Double, Y.Iterator.Element == Double {
|
||||
precondition(x.count == y.count, "Vectors must have equal count")
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ extension Matrix: CustomStringConvertible {
|
|||
var description = ""
|
||||
|
||||
for i in 0..<rows {
|
||||
let contents = (0..<columns).map{"\(self[i, $0])"}.joined(separator: "\t")
|
||||
let contents = (0..<columns).map({ "\(self[i, $0])" }).joined(separator: "\t")
|
||||
|
||||
switch (i, rows) {
|
||||
case (0, 1):
|
||||
|
@ -152,7 +152,6 @@ public func ==<T> (lhs: Matrix<T>, rhs: Matrix<T>) -> Bool {
|
|||
return lhs.rows == rhs.rows && lhs.columns == rhs.columns && lhs.grid == rhs.grid
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
|
||||
public func add(_ x: Matrix<Float>, _ y: Matrix<Float>) -> Matrix<Float> {
|
||||
|
@ -386,14 +385,14 @@ public func / (lhs: Matrix<Float>, rhs: Matrix<Float>) -> Matrix<Float> {
|
|||
|
||||
public func / (lhs: Matrix<Double>, rhs: Double) -> Matrix<Double> {
|
||||
var result = Matrix<Double>(rows: lhs.rows, columns: lhs.columns, repeatedValue: 0.0)
|
||||
result.grid = lhs.grid / rhs;
|
||||
return result;
|
||||
result.grid = lhs.grid / rhs
|
||||
return result
|
||||
}
|
||||
|
||||
public func / (lhs: Matrix<Float>, rhs: Float) -> Matrix<Float> {
|
||||
var result = Matrix<Float>(rows: lhs.rows, columns: lhs.columns, repeatedValue: 0.0)
|
||||
result.grid = lhs.grid / rhs;
|
||||
return result;
|
||||
result.grid = lhs.grid / rhs
|
||||
return result
|
||||
}
|
||||
|
||||
postfix operator ′
|
||||
|
|
|
@ -52,7 +52,6 @@ public func withUnsafeMutablePointersAndCountsTo<A: ContinuousMutableCollection>
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: 2 Parameter
|
||||
|
||||
/// Invokes the given closure with pointers to the given arguments (2 parameter version).
|
||||
|
@ -129,7 +128,6 @@ public func withUnsafeMutablePointersAndCountsTo<A: ContinuousMutableCollection,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: 3 Parameter
|
||||
|
||||
/// Invokes the given closure with pointers to the given arguments (3 parameter version).
|
||||
|
|
|
@ -25,7 +25,7 @@ import Accelerate
|
|||
public func pow<X: ContinuousCollection, Y: ContinuousCollection>(_ x: X, _ y: Y) -> [Float] where X.Iterator.Element == Float, Y.Iterator.Element == Float {
|
||||
var results = [Float](repeating: 0.0, count: numericCast(x.count))
|
||||
results.withUnsafeMutableBufferPointer { pointer in
|
||||
withUnsafePointersAndCountsTo(x, y) { xp, xc, yp, yc in
|
||||
withUnsafePointersAndCountsTo(x, y) { xp, xc, yp, _ in
|
||||
vvpowf(pointer.baseAddress!, xp, yp, [Int32(xc)])
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public func pow<X: ContinuousCollection, Y: ContinuousCollection>(_ x: X, _ y: Y
|
|||
public func pow<X: ContinuousCollection, Y: ContinuousCollection>(_ x: X, _ y: Y) -> [Double] where X.Iterator.Element == Double, Y.Iterator.Element == Double {
|
||||
var results = [Double](repeating: 0.0, count: numericCast(x.count))
|
||||
results.withUnsafeMutableBufferPointer { pointer in
|
||||
withUnsafePointersAndCountsTo(x, y) { xp, xc, yp, yc in
|
||||
withUnsafePointersAndCountsTo(x, y) { xp, xc, yp, _ in
|
||||
vvpow(pointer.baseAddress!, xp, yp, [Int32(xc)])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,6 +235,7 @@
|
|||
F8A1E1A619917A79009735E2 /* Frameworks */,
|
||||
F8A1E1A719917A79009735E2 /* Headers */,
|
||||
F8A1E1A819917A79009735E2 /* Resources */,
|
||||
61AA2D731F78CF4E00B28C43 /* Lint */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
@ -302,6 +303,24 @@
|
|||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
61AA2D731F78CF4E00B28C43 /* Lint */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = Lint;
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, `brew install swiftlint` or download from https://github.com/realm/SwiftLint\"\nfi";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
F84A6AAA19A9A72F007B53E1 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
|
|
|
@ -37,6 +37,19 @@
|
|||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>AuxiliaryTests</key>
|
||||
<dict>
|
||||
<key>test_copysign()</key>
|
||||
<dict>
|
||||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
|
||||
<dict>
|
||||
<key>baselineAverage</key>
|
||||
<real>3.4883e-05</real>
|
||||
<key>baselineIntegrationDisplayName</key>
|
||||
<string>Sep 24, 2017, 11:04:17 PM</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>ExponentialTests</key>
|
||||
<dict>
|
||||
<key>test_exp()</key>
|
||||
|
@ -62,6 +75,36 @@
|
|||
</dict>
|
||||
<key>HyperbolicTests</key>
|
||||
<dict>
|
||||
<key>test_acosh()</key>
|
||||
<dict>
|
||||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
|
||||
<dict>
|
||||
<key>baselineAverage</key>
|
||||
<real>0.00014254</real>
|
||||
<key>baselineIntegrationDisplayName</key>
|
||||
<string>Sep 24, 2017, 11:04:17 PM</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>test_asinh()</key>
|
||||
<dict>
|
||||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
|
||||
<dict>
|
||||
<key>baselineAverage</key>
|
||||
<real>8.0483e-05</real>
|
||||
<key>baselineIntegrationDisplayName</key>
|
||||
<string>Sep 24, 2017, 11:04:17 PM</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>test_atanh()</key>
|
||||
<dict>
|
||||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
|
||||
<dict>
|
||||
<key>baselineAverage</key>
|
||||
<real>0.00012056</real>
|
||||
<key>baselineIntegrationDisplayName</key>
|
||||
<string>Sep 24, 2017, 11:04:17 PM</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>test_cosh()</key>
|
||||
<dict>
|
||||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
|
||||
|
@ -95,6 +138,36 @@
|
|||
</dict>
|
||||
<key>TrigonometricTests</key>
|
||||
<dict>
|
||||
<key>test_acos()</key>
|
||||
<dict>
|
||||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
|
||||
<dict>
|
||||
<key>baselineAverage</key>
|
||||
<real>0.00015664</real>
|
||||
<key>baselineIntegrationDisplayName</key>
|
||||
<string>Sep 24, 2017, 11:06:27 PM</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>test_asin()</key>
|
||||
<dict>
|
||||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
|
||||
<dict>
|
||||
<key>baselineAverage</key>
|
||||
<real>0.00012768</real>
|
||||
<key>baselineIntegrationDisplayName</key>
|
||||
<string>Sep 24, 2017, 11:06:27 PM</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>test_atan()</key>
|
||||
<dict>
|
||||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
|
||||
<dict>
|
||||
<key>baselineAverage</key>
|
||||
<real>0.00014418</real>
|
||||
<key>baselineIntegrationDisplayName</key>
|
||||
<string>Sep 24, 2017, 11:06:27 PM</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>test_cos()</key>
|
||||
<dict>
|
||||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
|
||||
|
|
|
@ -26,7 +26,7 @@ class AuxiliaryTests: XCTestCase {
|
|||
let n = 10000
|
||||
|
||||
func test_copysign() {
|
||||
let signs = [Double]((0..<n).map {$0 % 2 == 0 ? 1.0 : -1.0})
|
||||
let signs = Array((0..<n).map({ $0 % 2 == 0 ? 1.0 : -1.0 }))
|
||||
|
||||
var magnitudes = [Double]()
|
||||
for _ in (0..<n).enumerated() {
|
||||
|
|
|
@ -59,7 +59,6 @@ class ConvolutionTests: XCTestCase {
|
|||
let d3f: [Float] = [0, 1, 1]
|
||||
let e3f: [Float] = [0, 0, 0, 0, 0, 0, 0]
|
||||
|
||||
|
||||
XCTAssertArrayFloatEqualWithAccuracy(calcArray: conv(a1f, a2f), a3f, floatAccuracy)
|
||||
XCTAssertArrayFloatEqualWithAccuracy(calcArray: conv(b1f, b2f), b3f, floatAccuracy)
|
||||
XCTAssertArrayFloatEqualWithAccuracy(calcArray: conv(c1f, c2f), c3f, floatAccuracy)
|
||||
|
|
|
@ -40,18 +40,18 @@ class HyperbolicTests: XCTestCase {
|
|||
measureAndValidateMappedFunctionWithAccuracy(source: values, member: tanh, mapped: tanh, accuracy: 0.0001)
|
||||
}
|
||||
|
||||
// func test_asinh() {
|
||||
// let values = map(0...n){_ in drand48()}
|
||||
// measureAndValidateMappedFunctionWithAccuracy(values, member: asinh, mapped: asinh, accuracy: 0.0001)
|
||||
// }
|
||||
//
|
||||
// func test_acosh() {
|
||||
// let values = map(0...n){_ in drand48()}
|
||||
// measureAndValidateMappedFunctionWithAccuracy(values, member: acosh, mapped: acosh, accuracy: 0.0001)
|
||||
// }
|
||||
//
|
||||
// func test_atanh() {
|
||||
// let values = map(0...n){_ in drand48()}
|
||||
// measureAndValidateMappedFunctionWithAccuracy(values, member: atanh, mapped: atanh, accuracy: 0.0001)
|
||||
// }
|
||||
func test_asinh() {
|
||||
let values = (0...n).map { _ in drand48() }
|
||||
measureAndValidateMappedFunctionWithAccuracy(source: values, member: asinh, mapped: asinh, accuracy: 0.0001)
|
||||
}
|
||||
|
||||
func test_acosh() {
|
||||
let values = (0...n).map { _ in 1 + drand48() }
|
||||
measureAndValidateMappedFunctionWithAccuracy(source: values, member: acosh, mapped: acosh, accuracy: 0.0001)
|
||||
}
|
||||
|
||||
func test_atanh() {
|
||||
let values = (0...n).map { _ in drand48() }
|
||||
measureAndValidateMappedFunctionWithAccuracy(source: values, member: atanh, mapped: atanh, accuracy: 0.0001)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,18 +40,18 @@ class TrigonometricTests: XCTestCase {
|
|||
measureAndValidateMappedFunctionWithAccuracy(source: values, member: tan, mapped: tan, accuracy: 0.0001)
|
||||
}
|
||||
|
||||
// func test_asin() {
|
||||
// let values = map(0...n){_ in drand48()}
|
||||
// measureAndValidateMappedFunctionWithAccuracy(values, member: asin, mapped: asin, accuracy: 0.0001)
|
||||
// }
|
||||
//
|
||||
// func test_acos() {
|
||||
// let values = map(0...n){_ in drand48()}
|
||||
// measureAndValidateMappedFunctionWithAccuracy(values, member: acos, mapped: acos, accuracy: 0.0001)
|
||||
// }
|
||||
//
|
||||
// func test_atan() {
|
||||
// let values = map(0...n){_ in drand48()}
|
||||
// measureAndValidateMappedFunctionWithAccuracy(values, member: atan, mapped: atan, accuracy: 0.0001)
|
||||
// }
|
||||
func test_asin() {
|
||||
let values = (0...n).map { _ in drand48() }
|
||||
measureAndValidateMappedFunctionWithAccuracy(source: values, member: asin, mapped: asin, accuracy: 0.0001)
|
||||
}
|
||||
|
||||
func test_acos() {
|
||||
let values = (0...n).map { _ in drand48() }
|
||||
measureAndValidateMappedFunctionWithAccuracy(source: values, member: acos, mapped: acos, accuracy: 0.0001)
|
||||
}
|
||||
|
||||
func test_atan() {
|
||||
let values = (0...n).map { _ in drand48() }
|
||||
measureAndValidateMappedFunctionWithAccuracy(source: values, member: atan, mapped: atan, accuracy: 0.0001)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ extension XCTestCase {
|
|||
actual = mapped(source)
|
||||
}
|
||||
|
||||
for (i, _) in source.enumerated() {
|
||||
XCTAssertEqual(actual[i], expected[i], accuracy: accuracy)
|
||||
for (i, j) in zip(actual.indices, expected.indices) {
|
||||
XCTAssertEqual(actual[i], expected[j], accuracy: accuracy)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue