Skip to content

Commit 95a00da

Browse files
committed
default newline
1 parent b31789d commit 95a00da

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/TorchSharp/Tensor/Tensor.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6523,9 +6523,6 @@ public string ToString(TensorStringStyle style,
65236523
var nl = newLine is null ? torch.newLine : newLine;
65246524
var fmt = fltFormat is null ? torch.floatFormat : fltFormat;
65256525

6526-
if (String.IsNullOrEmpty(newLine))
6527-
newLine = Environment.NewLine;
6528-
65296526
if (device_type == DeviceType.META)
65306527
return ToMetadataString();
65316528

src/TorchSharp/Tensor/TensorExtensionMethods.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public static Modules.Parameter AsParameter(this Tensor tensor)
148148
///
149149
/// Primarily intended for use in interactive notebooks.
150150
/// </remarks>
151-
public static string str(this Tensor tensor, string? fltFormat = null, int? width = null, string? newLine = "\n", CultureInfo? cultureInfo = null, TensorStringStyle style = TensorStringStyle.Default)
151+
public static string str(this Tensor tensor, string? fltFormat = null, int? width = null, string? newLine = null, CultureInfo? cultureInfo = null, TensorStringStyle style = TensorStringStyle.Default)
152152
{
153153
return tensor.ToString(style, fltFormat, width, cultureInfo, newLine);
154154
}
@@ -172,7 +172,7 @@ public static string str(this Tensor tensor, string? fltFormat = null, int? widt
172172
///
173173
/// Primarily intended for use in interactive notebooks.
174174
/// </remarks>
175-
public static string jlstr(this Tensor tensor, string? fltFormat = null, int? width = null, string? newLine = "\n", CultureInfo? cultureInfo = null)
175+
public static string jlstr(this Tensor tensor, string? fltFormat = null, int? width = null, string? newLine = null, CultureInfo? cultureInfo = null)
176176
{
177177
return tensor.ToString(TensorStringStyle.Julia, fltFormat, width, cultureInfo, newLine);
178178
}
@@ -214,7 +214,7 @@ public static string metastr(this Tensor tensor)
214214
///
215215
/// Primarily intended for use in interactive notebooks.
216216
/// </remarks>
217-
public static string npstr(this Tensor tensor, string? fltFormat = "g5", int? width = 100, string? newLine = "\n", CultureInfo? cultureInfo = null)
217+
public static string npstr(this Tensor tensor, string? fltFormat = "g5", int? width = 100, string? newLine = null, CultureInfo? cultureInfo = null)
218218
{
219219
return tensor.ToString(TensorStringStyle.Numpy, fltFormat, width, cultureInfo, newLine);
220220
}
@@ -238,7 +238,7 @@ public static string npstr(this Tensor tensor, string? fltFormat = "g5", int? wi
238238
///
239239
/// Primarily intended for use in interactive notebooks.
240240
/// </remarks>
241-
public static string cstr(this Tensor tensor, string? fltFormat = "g5", int? width = 100, string? newLine = "\n", CultureInfo? cultureInfo = null)
241+
public static string cstr(this Tensor tensor, string? fltFormat = "g5", int? width = 100, string? newLine = null, CultureInfo? cultureInfo = null)
242242
{
243243
return tensor.ToString(TensorStringStyle.CSharp, fltFormat, width, cultureInfo, newLine);
244244
}
@@ -259,7 +259,7 @@ public static string cstr(this Tensor tensor, string? fltFormat = "g5", int? wid
259259
/// The style to use -- either 'default,' 'metadata,' 'julia,' or 'numpy'
260260
/// </param>
261261
/// <returns></returns>
262-
public static Tensor print(this Tensor t, string? fltFormat = "g5", int? width = 100, string? newLine = "\n", CultureInfo? cultureInfo = null, TensorStringStyle style = TensorStringStyle.Default)
262+
public static Tensor print(this Tensor t, string? fltFormat = "g5", int? width = 100, string? newLine = null, CultureInfo? cultureInfo = null, TensorStringStyle style = TensorStringStyle.Default)
263263
{
264264
Console.WriteLine(t.ToString(style, fltFormat, width, cultureInfo, newLine));
265265
return t;

test/TorchSharpTest/TestTorchTensor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public void TestToString1()
287287
public void TestTensorDefaultPrint()
288288
{
289289
Tensor t = torch.zeros(2, 2);
290-
string expectedOutput = t.ToString(TensorStringStyle.Default, "g5", 100, null, "\n") + Environment.NewLine;
290+
string expectedOutput = t.ToString(TensorStringStyle.Default) + Environment.NewLine;
291291
var originalOut = Console.Out;
292292
using (var sw = new StringWriter())
293293
{

0 commit comments

Comments
 (0)