Skip to content

Commit

Permalink
dotnet format/spellchecking (#5988)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelgsharp committed Nov 5, 2021
1 parent cc5e639 commit 0577957
Show file tree
Hide file tree
Showing 332 changed files with 1,273 additions and 1,189 deletions.
20 changes: 19 additions & 1 deletion .editorconfig
Expand Up @@ -306,6 +306,10 @@ dotnet_diagnostic.IDE2004.severity = warning
dotnet_diagnostic.CA1822.severity = suggestion

[test/**/*.cs]
# IDE0044: Don't force readonly for tests
dotnet_diagnostic.IDE0044.severity = none
dotnet_style_readonly_field = false

# MSML_GeneralName: This name should be PascalCased
dotnet_diagnostic.MSML_GeneralName.severity = none

Expand All @@ -322,4 +326,18 @@ dotnet_diagnostic.MSML_ExtendBaseTestClass.severity = none

# The MSML_RelaxTestNaming suppressor for VSTHRD200 is not active for CodeAnalyzer.Tests, so we disable it altogether.
# VSTHRD200: Use "Async" suffix for async methods
dotnet_diagnostic.VSTHRD200.severity = none
dotnet_diagnostic.VSTHRD200.severity = none

[docs/**/*.cs]
# IDE0073: Dont want license file header in samples
dotnet_diagnostic.IDE0073.severity = none
file_header_template = unset

# IDE0044: Don't force readonly for samples
dotnet_diagnostic.IDE0044.severity = none
dotnet_style_readonly_field = false

[test/Microsoft.ML.TestFrameworkCommon/Utility/*.cs]
# IDE0073: Dont want license file header in code we are using from elsewhere
dotnet_diagnostic.IDE0073.severity = none
file_header_template = unset
1 change: 1 addition & 0 deletions Directory.Build.props
Expand Up @@ -17,6 +17,7 @@
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<LangVersion>latest</LangVersion>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>

<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions docs/samples/Microsoft.ML.AutoML.Samples/RankingExperiment.cs
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using Microsoft.ML.Data;
using System.Text;
using Microsoft.ML.AutoML.Samples.DataStructures;
using Microsoft.ML.Data;

namespace Microsoft.ML.AutoML.Samples
{
Expand Down
Expand Up @@ -2,15 +2,15 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ML;
using static Microsoft.ML.DataOperationsCatalog;
using System.Linq;
using Microsoft.ML.Data;
using System.IO.Compression;
using System.Threading;
using System.Net;
using Microsoft.ML.Vision;
using static Microsoft.ML.DataOperationsCatalog;

namespace Samples.Dynamic
{
Expand Down
Expand Up @@ -18,7 +18,7 @@ class CustomMappingWithInMemoryCustomType
// AlienBody members to produce a SuperAlienHero entity with a "Name" member of type
// string and a single "Merged" member of type AlienBody, where the merger is just
// the addition of the various members of AlienBody.
static public void Example()
public static void Example()
{
var mlContext = new MLContext();
// Build in-memory data.
Expand Down
Expand Up @@ -7,7 +7,7 @@ namespace Samples.Dynamic
{
class ConvertToGrayScaleInMemory
{
static public void Example()
public static void Example()
{
var mlContext = new MLContext();
// Create an image list.
Expand Down
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.ML;
using Microsoft.ML.Transforms.TimeSeries;
using System.IO;

namespace Samples.Dynamic
{
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.Data.Analysis/ArrowStringDataFrameColumn.cs
Expand Up @@ -20,9 +20,9 @@ namespace Microsoft.Data.Analysis
/// </summary>
public partial class ArrowStringDataFrameColumn : DataFrameColumn, IEnumerable<string>
{
private IList<ReadOnlyDataFrameBuffer<byte>> _dataBuffers;
private IList<ReadOnlyDataFrameBuffer<int>> _offsetsBuffers;
private IList<ReadOnlyDataFrameBuffer<byte>> _nullBitMapBuffers;
private readonly IList<ReadOnlyDataFrameBuffer<byte>> _dataBuffers;
private readonly IList<ReadOnlyDataFrameBuffer<int>> _offsetsBuffers;
private readonly IList<ReadOnlyDataFrameBuffer<byte>> _nullBitMapBuffers;

/// <summary>
/// Constructs an empty <see cref="ArrowStringDataFrameColumn"/> with the given <paramref name="name"/>.
Expand All @@ -40,7 +40,7 @@ public ArrowStringDataFrameColumn(string name) : base(name, 0, typeof(string))
/// </summary>
/// <param name="name">The name of the column.</param>
/// <param name="values">The Arrow formatted string values in this column.</param>
/// <param name="offsets">The Arrow formatted offets in this column.</param>
/// <param name="offsets">The Arrow formatted offsets in this column.</param>
/// <param name="nullBits">The Arrow formatted null bits in this column.</param>
/// <param name="length">The length of the column.</param>
/// <param name="nullCount">The number of <see langword="null" /> values in this column.</param>
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.Data.Analysis/DataFrame.IO.cs
Expand Up @@ -293,10 +293,10 @@ private static DataFrameColumn CreateColumn(Type kind, string[] columnNames, int

private class WrappedStreamReaderOrStringReader
{
private Stream _stream;
private long _initialPosition;
private Encoding _encoding;
private string _csvString;
private readonly Stream _stream;
private readonly long _initialPosition;
private readonly Encoding _encoding;
private readonly string _csvString;

public WrappedStreamReaderOrStringReader(Stream stream, Encoding encoding)
{
Expand Down
32 changes: 16 additions & 16 deletions src/Microsoft.Data.Analysis/DataFrame.Join.cs
Expand Up @@ -142,7 +142,7 @@ public DataFrame Join(DataFrame other, string leftSuffix = "_left", string right
return ret;
}

private static bool IsAnyNullValueInColumns (IReadOnlyCollection<DataFrameColumn> columns, long index)
private static bool IsAnyNullValueInColumns(IReadOnlyCollection<DataFrameColumn> columns, long index)
{
foreach (var column in columns)
{
Expand Down Expand Up @@ -176,19 +176,19 @@ private static HashSet<long> Merge(DataFrame retainedDataFrame, DataFrame supple
throw new ArgumentNullException(nameof(supplemetaryJoinColumnNames));

if (retainedJoinColumnNames.Length != supplemetaryJoinColumnNames.Length)
throw new ArgumentException(Strings.MismatchedArrayLengths, nameof(retainedJoinColumnNames));
throw new ArgumentException(Strings.MismatchedArrayLengths, nameof(retainedJoinColumnNames));


HashSet<long> intersection = calculateIntersection ? new HashSet<long>() : null;

// Get occurrences of values in columns used for join in the retained and supplementary dataframes
Dictionary<long, ICollection<long>> occurrences = null;
Dictionary<long, long> retainedIndicesReverseMapping = null;

HashSet<long> supplementaryJoinColumnsNullIndices = new HashSet<long>();

for (int colNameIndex = 0; colNameIndex < retainedJoinColumnNames.Length; colNameIndex++)

for (int colNameIndex = 0; colNameIndex < retainedJoinColumnNames.Length; colNameIndex++)
{
DataFrameColumn shrinkedRetainedColumn = retainedDataFrame.Columns[retainedJoinColumnNames[colNameIndex]];

Expand All @@ -211,7 +211,7 @@ private static HashSet<long> Merge(DataFrame retainedDataFrame, DataFrame supple
retainedIndicesReverseMapping = newRetainedIndicesReverseMapping;
shrinkedRetainedColumn = shrinkedRetainedColumn.Clone(new Int64DataFrameColumn("Indices", shrinkedRetainedIndices));
}

DataFrameColumn supplementaryColumn = supplementaryDataFrame.Columns[supplemetaryJoinColumnNames[colNameIndex]];

//Find occurrenses on current step (join column)
Expand All @@ -222,7 +222,7 @@ private static HashSet<long> Merge(DataFrame retainedDataFrame, DataFrame supple
newOccurrences = newOccurrences.ToDictionary(kvp => retainedIndicesReverseMapping[kvp.Key], kvp => kvp.Value);

supplementaryJoinColumnsNullIndices.UnionWith(supplementaryColumnNullIndices);

// shrink join result on current column by previous join columns (if any)
// (we have to remove occurrences that doesn't exist in previous columns, because JOIN happens only if ALL left and right columns in JOIN are matched)
if (occurrences != null)
Expand All @@ -242,7 +242,7 @@ private static HashSet<long> Merge(DataFrame retainedDataFrame, DataFrame supple

occurrences = newOccurrences;
}

retainedRowIndices = new Int64DataFrameColumn("RetainedIndices");
supplementaryRowIndices = new Int64DataFrameColumn("SupplementaryIndices");

Expand Down Expand Up @@ -280,18 +280,18 @@ private static HashSet<long> Merge(DataFrame retainedDataFrame, DataFrame supple
}
}
else
{
{
foreach (long row in supplementaryJoinColumnsNullIndices)
{
retainedRowIndices.Append(i);
supplementaryRowIndices.Append(row);
}
}
}

return intersection;
}

public DataFrame Merge(DataFrame other, string[] leftJoinColumns, string[] rightJoinColumns, string leftSuffix = "_left", string rightSuffix = "_right", JoinAlgorithm joinAlgorithm = JoinAlgorithm.Left)
{
if (other == null)
Expand Down Expand Up @@ -335,7 +335,7 @@ public DataFrame Merge(DataFrame other, string[] leftJoinColumns, string[] right
else if (joinAlgorithm == JoinAlgorithm.FullOuter)
{
//In full outer join we would like to retain data from both side, so we do it into 2 steps: one first we do LEFT JOIN and then add lost data from the RIGHT side

//Step 1
//Do LEFT JOIN
isLeftDataFrameRetained = true;
Expand All @@ -347,7 +347,7 @@ public DataFrame Merge(DataFrame other, string[] leftJoinColumns, string[] right
var retainedJoinColumns = isLeftDataFrameRetained ? leftJoinColumns : rightJoinColumns;

var intersection = Merge(retainedDataFrame, supplementaryDataFrame, retainedJoinColumns, supplementaryJoinColumns, out retainedRowIndices, out supplementaryRowIndices, calculateIntersection: true);

//Step 2
//Do RIGHT JOIN to retain all data from supplementary DataFrame too (take into account data intersection from the first step to avoid duplicates)
for (long i = 0; i < supplementaryDataFrame.Columns.RowCount; i++)
Expand All @@ -365,9 +365,9 @@ public DataFrame Merge(DataFrame other, string[] leftJoinColumns, string[] right
}
else
throw new NotImplementedException(nameof(joinAlgorithm));

DataFrame ret = new DataFrame();

//insert columns from left dataframe (this)
for (int i = 0; i < this.Columns.Count; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Data.Analysis/DataFrameColumn.cs
Expand Up @@ -244,7 +244,7 @@ public virtual DataFrameColumn Sort(bool ascending = true)
ret.Add(i, otherRowIndices);
}
}

return ret;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.Data.Analysis/DataFrameColumnCollection.cs
Expand Up @@ -13,11 +13,11 @@ namespace Microsoft.Data.Analysis
/// </summary>
public class DataFrameColumnCollection : Collection<DataFrameColumn>
{
private Action ColumnsChanged;
private readonly Action ColumnsChanged;

private List<string> _columnNames = new List<string>();
private readonly List<string> _columnNames = new List<string>();

private Dictionary<string, int> _columnNameToIndexDictionary = new Dictionary<string, int>(StringComparer.Ordinal);
private readonly Dictionary<string, int> _columnNameToIndexDictionary = new Dictionary<string, int>(StringComparer.Ordinal);

internal long RowCount { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.Data.Analysis/GroupBy.cs
Expand Up @@ -101,9 +101,9 @@ IEnumerator IEnumerable.GetEnumerator()

#endregion

private int _groupByColumnIndex;
private IDictionary<TKey, ICollection<long>> _keyToRowIndicesMap;
private DataFrame _dataFrame;
private readonly int _groupByColumnIndex;
private readonly IDictionary<TKey, ICollection<long>> _keyToRowIndicesMap;
private readonly DataFrame _dataFrame;

public GroupBy(DataFrame dataFrame, int groupByColumnIndex, IDictionary<TKey, ICollection<long>> keyToRowIndices)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs
Expand Up @@ -20,7 +20,7 @@ namespace Microsoft.Data.Analysis
public partial class PrimitiveDataFrameColumn<T> : DataFrameColumn, IEnumerable<T?>
where T : unmanaged
{
private PrimitiveColumnContainer<T> _columnContainer;
private readonly PrimitiveColumnContainer<T> _columnContainer;

internal PrimitiveColumnContainer<T> ColumnContainer => _columnContainer;

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Data.Analysis/StringDataFrameColumn.cs
Expand Up @@ -17,7 +17,7 @@ namespace Microsoft.Data.Analysis
/// <remarks> Is NOT Arrow compatible </remarks>
public partial class StringDataFrameColumn : DataFrameColumn, IEnumerable<string>
{
private List<List<string>> _stringBuffers = new List<List<string>>(); // To store more than intMax number of strings
private readonly List<List<string>> _stringBuffers = new List<List<string>>(); // To store more than intMax number of strings

public StringDataFrameColumn(string name, long length = 0) : base(name, length, typeof(string))
{
Expand Down

0 comments on commit 0577957

Please sign in to comment.