Skip to content

Commit 8499a26

Browse files
committed
Change display of null tensors
They where displayed with narrower columns than others. For instance, before this commit: ```lua > torch.Tensor(2,2):zero() 0 0 0 0 [torch.DoubleTensor of dimension 2x2] > torch.Tensor(2,2):fill(1) 1 1 1 1 [torch.DoubleTensor of dimension 2x2] ``` This is because `log10()` is used to determine number width in base 10 but the case where it is 0 is handled differently.
1 parent 2ed44eb commit 8499a26

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Tensor.lua

+4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ local function Storage__printformat(self)
2323
local expMin = tensor:min()
2424
if expMin ~= 0 then
2525
expMin = math.floor(math.log10(expMin)) + 1
26+
else
27+
expMin = 1
2628
end
2729
local expMax = tensor:max()
2830
if expMax ~= 0 then
2931
expMax = math.floor(math.log10(expMax)) + 1
32+
else
33+
expMax = 1
3034
end
3135

3236
local format

0 commit comments

Comments
 (0)