Mojo-Numerics-and-Algorithms-group / NuMojo

NuMojo is a library for numerical computing in Mojo 🔥 similar to numpy in Python.
Apache License 2.0
102 stars 15 forks source link

[lib] Implement the `__repr__` method. #64

Closed forFudan closed 3 months ago

forFudan commented 3 months ago

Implement the __repr__ method that computes the "official" string representation of NDArray. An example is:

fn main() raises:
    var A = NDArray[DType.int8](List[Scalar[DType.int8]](14,97,-59,-4,112,), shape=List[Int](5,))
    print(repr(A))

It prints what can be used to construct the array itself:

    NDArray[DType.int8](List[Scalar[DType.int8]](14,97,-59,-4,112,), shape=List[Int](5,))