diff --git a/src/TorchSharp/Tensor/Tensor.cs b/src/TorchSharp/Tensor/Tensor.cs
index 512dc4c11..8cfb10e98 100644
--- a/src/TorchSharp/Tensor/Tensor.cs
+++ b/src/TorchSharp/Tensor/Tensor.cs
@@ -5784,8 +5784,7 @@ public Tensor rot90(long k = 1, (long, long)? dims = null)
dims = (0, 1);
}
- var res =
- LibTorchSharp.THSTensor_rot90(Handle, k, dims.Value.Item1, dims.Value.Item2);
+ var res = LibTorchSharp.THSTensor_rot90(Handle, k, dims.Value.Item1, dims.Value.Item2);
if (res == IntPtr.Zero) { CheckForErrors(); }
return new Tensor(res);
}
diff --git a/src/TorchSharp/Tensor/TensorExtensionMethods.cs b/src/TorchSharp/Tensor/TensorExtensionMethods.cs
index 534ac25cd..e54f89372 100644
--- a/src/TorchSharp/Tensor/TensorExtensionMethods.cs
+++ b/src/TorchSharp/Tensor/TensorExtensionMethods.cs
@@ -44,18 +44,21 @@ public static TensorStringStyle TensorStringStyle {
/// Enable scientific notation.
public static void set_printoptions(
int precision,
- int linewidth = 100,
- string newLine = "\n",
+ int? linewidth = null,
+ string? newLine = null,
bool sci_mode = false)
{
torch.floatFormat = sci_mode ? $"E{precision}" : $"F{precision}";
- torch.newLine = newLine;
- torch.lineWidth = linewidth;
+ if (newLine is not null)
+ torch.newLine = newLine;
+ if (linewidth.HasValue)
+ torch.lineWidth = linewidth.Value;
}
///
/// Set options for printing.
///
+ /// The default string formatting style used by ToString(), print(), and str()
///
/// The format string to use for floating point values.
/// See: https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings
@@ -63,13 +66,19 @@ public static void set_printoptions(
/// The number of characters per line for the purpose of inserting line breaks (default = 100).
/// The string to use to represent new-lines. Starts out as 'Environment.NewLine'
public static void set_printoptions(
- string floatFormat = "g5",
- int linewidth = 100,
- string newLine = "\n")
+ TensorStringStyle? style = null,
+ string? floatFormat = null,
+ int? linewidth = null,
+ string? newLine = null)
{
- torch.floatFormat = floatFormat;
- torch.newLine = newLine;
- torch.lineWidth = linewidth;
+ if (style.HasValue)
+ torch._style = style.Value;
+ if (floatFormat is not null)
+ torch.floatFormat = floatFormat;
+ if (newLine is not null)
+ torch.newLine = newLine;
+ if (linewidth.HasValue)
+ torch.lineWidth = linewidth.Value;
}
public const TensorStringStyle julia = TensorStringStyle.Julia;