Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update newline character #1419

Merged
merged 17 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test null newline should be environment newline
  • Loading branch information
alinpahontu2912 authored Nov 28, 2024
commit df7a5db4c2de2160cc5aea616fa9cd6b8b2ef842
2 changes: 1 addition & 1 deletion src/TorchSharp/Tensor/TensorExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public static string cstr(this Tensor tensor, string? fltFormat = "g5", int? wid
/// The style to use -- either 'default,' 'metadata,' 'julia,' or 'numpy'
/// </param>
/// <returns></returns>
public static Tensor print(this Tensor t, string? fltFormat = "g5", int? width = 100, string? newLine = "\n", CultureInfo? cultureInfo = null, TensorStringStyle style = TensorStringStyle.Default)
public static Tensor print(this Tensor t, string? fltFormat = "g5", int? width = 100, string? newLine = null, CultureInfo? cultureInfo = null, TensorStringStyle style = TensorStringStyle.Default)
{
Console.WriteLine(t.ToString(style, fltFormat, width, cultureInfo, newLine));
return t;
Expand Down
5 changes: 2 additions & 3 deletions test/TorchSharpTest/TestTorchTensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,14 @@ public void TestToString1()
public void TestTensorPrint()
alinpahontu2912 marked this conversation as resolved.
Show resolved Hide resolved
{
Tensor t = torch.zeros(2, 2);
string expectedOutput = t.ToString(TensorStringStyle.Default, "g5", 100, null, "\n");
string expectedOutput = t.ToString(TensorStringStyle.Default, "g5", 100, null, Environment.NewLine);
using (var sw = new StringWriter())
{
Console.SetOut(sw);
t.print();
var result = sw.ToString().Trim();
var result = sw.ToString();
Assert.Equal(expectedOutput, result);
}

}

[Fact]
Expand Down