-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Reformatting ModelOperations and DataOperations samples to width 85 #3923
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
Conversation
@@ -35,11 +36,15 @@ public static void Example() | |||
model = mlContext.Model.Load(file, out DataViewSchema schema); | |||
|
|||
// Create a prediction engine from the model for feeding new data. | |||
var engine = mlContext.Model.CreatePredictionEngine<Data, Transformation>(model); | |||
var engine = mlContext.Model.CreatePredictionEngine<Data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eerhardt Is it ok to break generics like this or should all of it be in the same line as its corresponding class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC: @natke
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix it so that I split before the "<" in a later pull request. Thanks!
I kind of think that is too small. In dotnet/spark we are using 100. What's the reasoning for 85? |
@@ -25,7 +25,8 @@ public static void Example() | |||
var outputColumnName = nameof(Transformation.Key); | |||
|
|||
// Transform. | |||
ITransformer model = mlContext.Transforms.Conversion.MapValueToKey(outputColumnName, inputColumnName).Fit(dataView); | |||
ITransformer model = mlContext.Transforms.Conversion.MapValueToKey( | |||
outputColumnName, inputColumnName).Fit(dataView); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For cases like this, I would rather we break per method call, than to break between a method and its parameter list.
For example:
// If you have chained method calls, line-break each method call
Enumerable.Range(0, numRows)
.Select(i => i.ToString())
.ToArray();
That is much more readable than:
object o = foo.methodCall(
methodCallArg1, methodCallArg2).OtherMethodCall(arg3)
@@ -9,6 +9,7 @@ public static class Program | |||
|
|||
internal static void RunAll() | |||
{ | |||
// Samples counter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the usefulness of this comment? If those words make a better name, it would be better to rename the variable with those words, than to add a comment like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I meant to delete that. That was for an earlier test.
@natke asked for 85 characters to ensure that a horizontal scrollbar is not needed on the docs webpage. |
Ah, ok then I understand why 85 characters is better, it needs to be hosted inside a page with other things around it. Thanks for the explanation. |
*Updated to include DataOperations samples as well |
docs/samples/Microsoft.ML.Samples/Dynamic/DataOperations/Cache.cs
Outdated
Show resolved
Hide resolved
Co-Authored-By: Justin Ormont <[email protected]>
Got rid of test comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Width of lines looks good.
Looks like there are quite a few places with extra whitespace at the beginning of the line
docs/samples/Microsoft.ML.Samples/Dynamic/DataOperations/DataViewEnumerable.cs
Outdated
Show resolved
Hide resolved
docs/samples/Microsoft.ML.Samples/Dynamic/DataOperations/DataViewEnumerable.cs
Show resolved
Hide resolved
var rowEnumerableIgnoreMissing = mlContext.Data.CreateEnumerable<SampleTemperatureDataWithLatitude>(data, | ||
reuseRowObject: true, ignoreMissingColumns: true); | ||
// We can now examine the records in the IDataView. We first create an | ||
// enumerable of rows in the IDataView. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed. Some tt files have certain indentations that insure that the comments in the cs files align.
Fixed extra whitespace
Fixed extra whitespace
Fixed extra whitespace
Fixed whitespace
Fixed whitespace
Fixed whitespace
Fixed whitespace
Fixed whitespace
Fixed whitespace
Fixed whitespace
Fixed whitespace
Fixed whitespace
Fixed whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! A couple of places where there is an extra carriage return
@@ -21,7 +23,9 @@ public static void Example() | |||
Console.WriteLine($"Date\tTemperature"); | |||
foreach (var row in enumerableOfData) | |||
{ | |||
Console.WriteLine($"{row.Date.ToString("d")}\t{row.Temperature}"); | |||
Console.WriteLine( | |||
$"{row.Date.ToString("d")}\t{row.Temperature}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra carriage return here?
Console.WriteLine($"Date\tTemperature"); | ||
foreach (var row in enumerable) | ||
{ | ||
Console.WriteLine($"{row.Date.ToString("d")}\t{row.Temperature}"); | ||
Console.WriteLine( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra carriage return?
@@ -16,7 +18,9 @@ string Example = @"// Create a new context for ML.NET operations. It can be used | |||
Console.WriteLine($""Date\tTemperature""); | |||
foreach (var row in enumerableOfData) | |||
{ | |||
Console.WriteLine($""{row.Date.ToString(""d"")}\t{row.Temperature}""); | |||
Console.WriteLine( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra carriage return?
Console.WriteLine($""Date\tTemperature""); | ||
foreach (var row in enumerable) | ||
{ | ||
Console.WriteLine($""{row.Date.ToString(""d"")}\t{row.Temperature}""); | ||
Console.WriteLine( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra carriage return?
Fixed extra carriage returns
Fixed extra carriage returns
…otnet#3923) * Added a comment. * reformatted ModelOperations samples to width 85 * Fixed commented-on parts of MachineOperations & reformatted DataOperations * Update docs/samples/Microsoft.ML.Samples/Dynamic/DataOperations/Cache.cs Co-Authored-By: Justin Ormont <[email protected]> * Update Program.cs Got rid of test comment * Update DataViewEnumerable.tt Fixed extra whitespace * Update DataViewEnumerable.cs Fixed extra whitespace * Update DataViewEnumerable.tt Fixed extra whitespace * Update FilterRowsByColumn.tt Fixed whitespace * Update ShuffleRows.tt Fixed whitespace * Update TakeRows.tt Fixed whitespace * Update TakeRows.cs Fixed whitespace * Update SkipRows.cs Fixed whitespace * Update SkipRows.tt Fixed whitespace * Update ShuffleRows.cs Fixed whitespace * Update ShuffleRows.cs Fixed whitespace * Update ShuffleRows.cs * Update ShuffleRows.tt * Update SkipRows.tt * Update SkipRows.cs * Update FilterRowsByColumn.cs Fixed whitespace * Update FilterRowsByColumn.cs Fixed whitespace * Update DataViewEnumerable.cs * Update FilterRowsByColumn.cs Fixed extra carriage returns * Update FilterRowsByColumn.tt Fixed extra carriage returns * Update FilterRowsByColumn.cs * Update FilterRowsByColumn.tt
Guidelines followed:
-85 characters per line
-Use 4 spaces for indentation
-Dot and open parentheses stay on same line as function
-If not a preexisting line under line that we break, add an extra line after it
-Don't indent comments
-Don't break a comment if it represents output
-Don't break links
-If applicable, break right before $
-Keep math op together
Fix for issue #3478