Skip to content

Commit 177ad78

Browse files
committed
fix keyword and clean up ndarry printing
1 parent 24eb5aa commit 177ad78

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

numojo/core/ndarray.mojo

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,7 +2584,7 @@ struct NDArray[dtype: DType = DType.float64](
25842584
self._setitem_slice_scalar(slice_list, scalar)
25852585

25862586
def __setitem__(
2587-
mut self, *slices: Variant[Slice, Int], val: Scalar[Self.dtype]
2587+
mut self, *slices: Variant[Slice, Int], scalar: Scalar[Self.dtype]
25882588
) raises:
25892589
"""Sets elements selected by mixed integer/slice indices to a scalar.
25902590
@@ -3865,20 +3865,25 @@ struct NDArray[dtype: DType = DType.float64](
38653865
)
38663866
else:
38673867
try:
3868+
var order: String
3869+
if self.is_c_contiguous():
3870+
order = "C"
3871+
elif self.is_f_contiguous():
3872+
order = "F"
3873+
else:
3874+
order = "non-contiguous"
38683875
writer.write(
38693876
self._array_to_string(0, 0)
38703877
+ "\n"
38713878
+ String(self.ndim)
3872-
+ "D-array Shape"
3873-
+ String(self.shape)
3874-
+ " Strides"
3875-
+ String(self.strides)
3879+
+ "D-array Shape: "
3880+
+ self.shape.__str__()
3881+
+ " Strides: "
3882+
+ self.strides.__str__()
38763883
+ " DType: "
38773884
+ _concise_dtype_str(self.dtype)
3878-
+ " C-cont: "
3879-
+ String(self.is_c_contiguous())
3880-
+ " F-cont: "
3881-
+ String(self.is_f_contiguous())
3885+
+ " order: "
3886+
+ order
38823887
+ " own data: "
38833888
+ String(self.flags.OWNDATA)
38843889
)

0 commit comments

Comments
 (0)