Skip to content

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

Merged
merged 28 commits into from
Jun 28, 2019

Conversation

sierralee51
Copy link
Contributor

@sierralee51 sierralee51 commented Jun 27, 2019

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

@dnfclas
Copy link

dnfclas commented Jun 27, 2019

CLA assistant check
All CLA requirements met.

@@ -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,
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC: @natke

Copy link
Contributor Author

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!

@codemzs codemzs requested review from codemzs and eerhardt June 27, 2019 17:23
@sierralee51 sierralee51 requested a review from natke June 27, 2019 17:32
@eerhardt
Copy link
Member

85 characters per line

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);
Copy link
Member

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.
Copy link
Member

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.

Copy link
Contributor Author

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.

@sierralee51
Copy link
Contributor Author

85 characters per line

I kind of think that is too small. In dotnet/spark we are using 100. What's the reasoning for 85?

@natke asked for 85 characters to ensure that a horizontal scrollbar is not needed on the docs webpage.

@eerhardt
Copy link
Member

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.

@sierralee51 sierralee51 changed the title Reformatting ModelOperations samples to width 85 Reformatting ModelOperations and DataOperations samples to width 85 Jun 27, 2019
@sierralee51
Copy link
Contributor Author

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

*Updated to include DataOperations samples as well

@codemzs codemzs requested review from eerhardt and wschin June 28, 2019 17:14
Copy link
Contributor

@natke natke left a 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

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra whitespace

Copy link
Contributor Author

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
Copy link
Contributor

@natke natke left a 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}");
Copy link
Contributor

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(
Copy link
Contributor

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(
Copy link
Contributor

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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra carriage return?

@sierralee51 sierralee51 merged commit 17c9155 into dotnet:master Jun 28, 2019
Dmitry-A pushed a commit to Dmitry-A/machinelearning that referenced this pull request Jul 24, 2019
…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
@ghost ghost locked as resolved and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants