Skip to content

Commit

Permalink
fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dastrobu committed Dec 22, 2021
1 parent 11ce168 commit a68875c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: norio-nomura/action-swiftlint@3.2.1
with:
args: --strict
test:
strategy:
matrix:
Expand Down
4 changes: 2 additions & 2 deletions Sources/NdArray/basic_functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public func abs<K: SignedNumeric, T: NdArray<K>>(_ a: T) -> T where K: Comparabl
// Double

public func abs<T: NdArray<Double>>(_ a: T, out b: T) {
a.apply1d(other: b, f1d: { n in
a.apply1d(other: b, f1d: { _ in
vDSP_vabsD(a.data, a.strides[0], b.data, b.strides[0], vDSP_Length(a.shape[0]))
}, fContiguous: { n in
vDSP_vabsD(a.data, 1, b.data, 1, vDSP_Length(n))
Expand All @@ -33,7 +33,7 @@ public func abs<T: NdArray<Double>>(_ a: T) -> T {
// Float

public func abs<T: NdArray<Float>>(_ a: T, out b: T) {
a.apply1d(other: b, f1d: { n in
a.apply1d(other: b, f1d: { _ in
vDSP_vabs(a.data, a.strides[0], b.data, b.strides[0], vDSP_Length(a.shape[0]))
}, fContiguous: { n in
vDSP_vabs(a.data, 1, b.data, 1, vDSP_Length(n))
Expand Down
11 changes: 5 additions & 6 deletions Tests/NdArrayTests/NdArrayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@ final class NdArrayTests: XCTestCase {
}

func testNdArrayShouldCopyCorrectlyWhenStrideIsNotSizeOfT() {
// swiftlint:disable:next nesting type_name
struct S: Equatable {
struct MyType: Equatable {
let i: Int
let b: Bool
}

XCTAssertNotEqual(MemoryLayout<S>.size, MemoryLayout<S>.stride)
let a = NdArray<S>([S(i: 0, b: true), S(i: 1, b: false)])
let b = NdArray<S>(copy: a)
XCTAssertEqual(b.dataArray, [S(i: 0, b: true), S(i: 1, b: false)])
XCTAssertNotEqual(MemoryLayout<MyType>.size, MemoryLayout<MyType>.stride)
let a = NdArray<MyType>([MyType(i: 0, b: true), MyType(i: 1, b: false)])
let b = NdArray<MyType>(copy: a)
XCTAssertEqual(b.dataArray, [MyType(i: 0, b: true), MyType(i: 1, b: false)])
}

func testDescription() {
Expand Down

0 comments on commit a68875c

Please sign in to comment.