jjjkkkjjj / Matft

Numpy-like library in swift. (Multi-dimensional Array, ndarray, matrix and vector library)
BSD 3-Clause "New" or "Revised" License
134 stars 21 forks source link

ToArray doesn't respect slices #47

Closed Ykid closed 11 months ago

Ykid commented 1 year ago

Thank you for providing such a nice library. I've found some cases which might potentially be buggy. Could you help take a look?

Here is the test case

import Matft

final class MatftTest: XCTestCase {
    func testMatftCase1() throws {
        let a = MfArray([], mftype: .Float)
    }

    func testMatftCase2() throws {
        let b = MfArray([], mftype: .Float, shape: [0])
    }

    func testMatftCase3() throws {
        let a = MfArray([
            [1,2,3],
            [4,5,6]
        ], mftype: .Float)
        XCTAssertEqual(a[1], MfArray([4,5,6], mftype: .Float))
        XCTAssertEqual(a[1].toArray() as! [Float], [4.0,5,6])  //XCTAssertEqual failed: ("[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]") is not equal to ("[4.0, 5.0, 6.0]")
    }
}

Thanks!

jjjkkkjjj commented 1 year ago

@Ykid Thank you for reporting the bug! I'll check them later!

jjjkkkjjj commented 11 months ago

@Ykid Sorry for late update. I've just fixed this bug. Please check it!!