@@ -44,32 +44,41 @@ public static TensorStringStyle TensorStringStyle {
44
44
/// <param name="sci_mode">Enable scientific notation.</param>
45
45
public static void set_printoptions (
46
46
int precision ,
47
- int linewidth = 100 ,
48
- string newLine = " \n " ,
47
+ int ? linewidth = null ,
48
+ string ? newLine = null ,
49
49
bool sci_mode = false )
50
50
{
51
51
torch . floatFormat = sci_mode ? $ "E{ precision } " : $ "F{ precision } ";
52
- torch . newLine = newLine ;
53
- torch . lineWidth = linewidth ;
52
+ if ( newLine is not null )
53
+ torch . newLine = newLine ;
54
+ if ( linewidth . HasValue )
55
+ torch . lineWidth = linewidth . Value ;
54
56
}
55
57
56
58
/// <summary>
57
59
/// Set options for printing.
58
60
/// </summary>
61
+ /// <param name="style">The default string formatting style used by ToString(), print(), and str()</param>
59
62
/// <param name="floatFormat">
60
63
/// The format string to use for floating point values.
61
64
/// See: https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings
62
65
/// </param>
63
66
/// <param name="linewidth">The number of characters per line for the purpose of inserting line breaks (default = 100).</param>
64
67
/// <param name="newLine">The string to use to represent new-lines. Starts out as 'Environment.NewLine'</param>
65
68
public static void set_printoptions (
66
- string floatFormat = "g5" ,
67
- int linewidth = 100 ,
68
- string newLine = "\n " )
69
+ TensorStringStyle ? style = null ,
70
+ string ? floatFormat = null ,
71
+ int ? linewidth = null ,
72
+ string ? newLine = null )
69
73
{
70
- torch . floatFormat = floatFormat ;
71
- torch . newLine = newLine ;
72
- torch . lineWidth = linewidth ;
74
+ if ( style . HasValue )
75
+ torch . _style = style . Value ;
76
+ if ( floatFormat is not null )
77
+ torch . floatFormat = floatFormat ;
78
+ if ( newLine is not null )
79
+ torch . newLine = newLine ;
80
+ if ( linewidth . HasValue )
81
+ torch . lineWidth = linewidth . Value ;
73
82
}
74
83
75
84
public const TensorStringStyle julia = TensorStringStyle . Julia ;
0 commit comments