From ff3740e74064a4029b0bea2471bc472d1e071c99 Mon Sep 17 00:00:00 2001 From: Brian Rogers Date: Sat, 21 Dec 2019 08:57:22 -0800 Subject: [PATCH 1/2] Project cleanup - Add .editorconfig with custom rules (to match current style) - Simplify .gitignore file - Update .sln to VS 2019 format - Update .csproj files to SDK style(*) - Remove unnecessary usings and unused parameters - Remove AssemblyInfo.cs files in favor of .csproj properties - Remove custom nuspec/package files in favor of .csproj properties(**) - Remove packages.config in favor of PackageReference items - Update package references to latest versions - Increment version to 1.0.9 (*) https://docs.microsoft.com/en-us/dotnet/core/tools/csproj (**) To create the NuGet package use `dotnet pack -c Release` --- .editorconfig | 122 ++++++++++++++++++ .gitignore | 73 +---------- TDigest.CMD/Program.cs | 5 +- TDigest.CMD/Properties/AssemblyInfo.cs | 36 ------ TDigest.CMD/TDigest.CMD.csproj | 65 +--------- TDigest.Tests/Properties/AssemblyInfo.cs | 36 ------ TDigest.Tests/TDigest.Tests.csproj | 91 ++----------- TDigest.Tests/Tests.cs | 1 - TDigest.sln | 20 ++- TDigest/Extensions.cs | 3 - TDigest/Properties/AssemblyInfo.cs | 36 ------ TDigest/TDigest.cs | 68 ++++------ TDigest/TDigest.csproj | 81 ++---------- TDigest/TDigest.nuspec | 17 --- TDigest/ext/TDigest.1.0.7/TDigest.nuspec | 20 --- TDigest/ext/TDigest.1.0.7/[Content_Types].xml | 8 -- TDigest/ext/TDigest.1.0.7/_rels/.rels | 5 - TDigest/ext/TDigest.1.0.7/content/LICENSE.txt | 21 --- .../34bcb6defab9462e8f05d5a3dab0a2c1.psmdcp | 9 -- TDigest/packages.config | 4 - packages/repositories.config | 4 - 21 files changed, 196 insertions(+), 529 deletions(-) create mode 100644 .editorconfig delete mode 100644 TDigest.CMD/Properties/AssemblyInfo.cs delete mode 100644 TDigest.Tests/Properties/AssemblyInfo.cs delete mode 100644 TDigest/Properties/AssemblyInfo.cs delete mode 100644 TDigest/TDigest.nuspec delete mode 100644 TDigest/ext/TDigest.1.0.7/TDigest.nuspec delete mode 100644 TDigest/ext/TDigest.1.0.7/[Content_Types].xml delete mode 100644 TDigest/ext/TDigest.1.0.7/_rels/.rels delete mode 100644 TDigest/ext/TDigest.1.0.7/content/LICENSE.txt delete mode 100644 TDigest/ext/TDigest.1.0.7/package/services/metadata/core-properties/34bcb6defab9462e8f05d5a3dab0a2c1.psmdcp delete mode 100644 TDigest/packages.config delete mode 100644 packages/repositories.config diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..93c3ef4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,122 @@ +# To learn more about .editorconfig see https://aka.ms/editorconfigdocs +############################### +# Core EditorConfig Options # +############################### +# All files +[*] +indent_style = space +# Code files +[*.{cs,csx,vb,vbx}] +indent_size = 4 +insert_final_newline = true +charset = utf-8-bom +############################### +# .NET Coding Conventions # +############################### +[*.{cs,vb}] +# Organize usings +dotnet_sort_system_directives_first = true +# this. preferences +dotnet_style_qualification_for_field = false:silent +dotnet_style_qualification_for_property = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_event = false:silent +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent +dotnet_style_readonly_field = true:suggestion +# Expression-level preferences +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +# CSharp and Visual Basic code quality settings +dotnet_code_quality_unused_parameters = non_public:suggestion +############################### +# Naming Conventions # +############################### +# Style Definitions +dotnet_naming_style.pascal_case_style.capitalization = pascal_case +# Use PascalCase for constant fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.applicable_accessibilities = * +dotnet_naming_symbols.constant_fields.required_modifiers = const +############################### +# C# Coding Conventions # +############################### +[*.cs] +# var preferences +csharp_style_var_for_built_in_types = true:silent +csharp_style_var_when_type_is_apparent = true:silent +csharp_style_var_elsewhere = true:silent +# Expression-bodied members +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent +# Pattern matching preferences +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +# Null-checking preferences +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion +# Modifier preferences +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion +# Expression-level preferences +csharp_prefer_braces = true:silent +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_pattern_local_over_anonymous_function = true:suggestion +csharp_style_inlined_variable_declaration = true:silent +# Unused value preferences +csharp_style_unused_value_expression_statement_preference = discard_variable:silent +csharp_style_unused_value_assignment_preference = unused_local_variable:suggestion +############################### +# C# Formatting Rules # +############################### +# New line preferences +csharp_new_line_before_open_brace = none +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true +# Indentation preferences +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left +# Space preferences +csharp_space_after_cast = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_around_binary_operators = before_and_after +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +# Wrapping preferences +csharp_preserve_single_line_statements = true +csharp_preserve_single_line_blocks = true diff --git a/.gitignore b/.gitignore index ad60f19..39dd7e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,67 +1,8 @@ .vs/ -packages/ -TDigest.CMD/bin/ -TDigest.CMD/obj/ -TDigest.Tests/bin/ -TDigest.Tests/obj/ -TDigest/bin/ -TDigest/obj/ -Performance.psess -Report150613.vsp -TDigest.CMD.psess -TDigest.CMD/bin/Release/TDigest.CMD.vshost.exe -TDigest.CMD/bin/Release/TDigest.CMD.vshost.exe.config -TDigest.CMD/bin/Release/TDigest.CMD.vshost.exe.manifest -TDigest.CMD/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -TDigest.CMD/obj/Debug/TDigest.CMD.csproj.FileListAbsolute.txt -TDigest.CMD/obj/Debug/TDigest.CMD.csprojResolveAssemblyReference.cache -TDigest.CMD/obj/Debug/TDigest.CMD.exe -TDigest.CMD/obj/Debug/TDigest.CMD.instr.pdb -TDigest.CMD/obj/Debug/TDigest.CMD.pdb -TDigest.CMD/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs -TDigest.CMD/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs -TDigest.CMD/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs -TDigest.CMD/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache -TDigest.CMD/obj/Release/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs -TDigest.CMD/obj/Release/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs -TDigest.CMD/obj/Release/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs -TDigest.CMD150614.vspx -TDigest.Tests/bin/Debug/C5.dll -TDigest.Tests/bin/Debug/TDigest.dll -TDigest.Tests/bin/Debug/TDigest.pdb -TDigest.Tests/bin/Debug/TDigest.Tests.dll -TDigest.Tests/bin/Debug/TDigest.Tests.pdb -TDigest.Tests/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -TDigest.Tests/obj/Debug/TDigest.Tests.csproj.FileListAbsolute.txt -TDigest.Tests/obj/Debug/TDigest.Tests.csprojResolveAssemblyReference.cache -TDigest.Tests/obj/Debug/TDigest.Tests.dll -TDigest.Tests/obj/Debug/TDigest.Tests.pdb -TDigest.Tests/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs -TDigest.Tests/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs -TDigest.Tests/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs -TDigest.Tests/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache -TDigest.Tests/obj/Release/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs -TDigest.Tests/obj/Release/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs -TDigest.Tests/obj/Release/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs -TDigest.v12.suo -TDigest/bin/Debug/C5.dll -TDigest/bin/Debug/TDigest.dll -TDigest/bin/Debug/TDigest.dll.config -TDigest/bin/Debug/TDigest.instr.pdb -TDigest/bin/Debug/TDigest.pdb -TDigest/bin/Debug/TDigest.vshost.exe -TDigest/bin/Debug/TDigest.vshost.exe.config -TDigest/bin/Debug/TDigest.vshost.exe.manifest -TDigest/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -TDigest/obj/Debug/TDigest.csproj.FileListAbsolute.txt -TDigest/obj/Debug/TDigest.csprojResolveAssemblyReference.cache -TDigest/obj/Debug/TDigest.dll -TDigest/obj/Debug/TDigest.instr.pdb -TDigest/obj/Debug/TDigest.pdb -TDigest/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs -TDigest/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs -TDigest/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs -TDigest/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache -TDigest/obj/Release/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs -TDigest/obj/Release/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs -TDigest/obj/Release/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs +[Pp]ackages/ +[Bb]in/ +[Oo]bj/ +*.psess +*.vsp +*.vspx +*.suo diff --git a/TDigest.CMD/Program.cs b/TDigest.CMD/Program.cs index c9f9799..f2e07be 100644 --- a/TDigest.CMD/Program.cs +++ b/TDigest.CMD/Program.cs @@ -1,13 +1,10 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StatsLib.CMD { class Program { - static void Main(string[] args) { + static void Main() { Random r = new Random(); TDigest digestA = new TDigest(); diff --git a/TDigest.CMD/Properties/AssemblyInfo.cs b/TDigest.CMD/Properties/AssemblyInfo.cs deleted file mode 100644 index 460b13f..0000000 --- a/TDigest.CMD/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TDigest.CMD")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TDigest.CMD")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("6f4d29ff-d8f5-4d28-b99f-ad9e4f432aab")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TDigest.CMD/TDigest.CMD.csproj b/TDigest.CMD/TDigest.CMD.csproj index b7f2efd..d8e0f86 100644 --- a/TDigest.CMD/TDigest.CMD.csproj +++ b/TDigest.CMD/TDigest.CMD.csproj @@ -1,64 +1,13 @@ - - - + - Debug - AnyCPU - {9965BA5F-9FA3-46C3-BD89-ACF58D2887C8} Exe - Properties - TDigest.CMD - TDigest.CMD - v4.5 - 512 + net45 + 1.0.0 + $(AssemblyName) + Copyright © 2015 + false - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - {909364f5-4f9a-444d-be6a-ce2a6ef592b0} - TDigest - + - - \ No newline at end of file diff --git a/TDigest.Tests/Properties/AssemblyInfo.cs b/TDigest.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index a49e738..0000000 --- a/TDigest.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TDigest.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TDigest.Tests")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("1ba653f1-b73f-4d97-bbb4-47a6321ecd2e")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TDigest.Tests/TDigest.Tests.csproj b/TDigest.Tests/TDigest.Tests.csproj index 41cfda4..2af76c7 100644 --- a/TDigest.Tests/TDigest.Tests.csproj +++ b/TDigest.Tests/TDigest.Tests.csproj @@ -1,89 +1,16 @@ - - + - Debug - AnyCPU - {7BCAFD59-C058-4E80-BE5A-B842522C951E} - Library - Properties - TDigest.Tests - TDigest.Tests - v4.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest + net45 + 1.0.0 + $(AssemblyName) + Copyright © 2015 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - + + + - - {909364f5-4f9a-444d-be6a-ce2a6ef592b0} - TDigest - + - - - - - False - - - False - - - False - - - False - - - - - - - \ No newline at end of file diff --git a/TDigest.Tests/Tests.cs b/TDigest.Tests/Tests.cs index e4708d4..0e62507 100644 --- a/TDigest.Tests/Tests.cs +++ b/TDigest.Tests/Tests.cs @@ -1,6 +1,5 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Diagnostics; using System.Collections.Generic; using System.Linq; diff --git a/TDigest.sln b/TDigest.sln index c634dba..0f701de 100644 --- a/TDigest.sln +++ b/TDigest.sln @@ -1,13 +1,18 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TDigest", "TDigest\TDigest.csproj", "{909364F5-4F9A-444D-BE6A-CE2A6EF592B0}" +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29613.14 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TDigest", "TDigest\TDigest.csproj", "{909364F5-4F9A-444D-BE6A-CE2A6EF592B0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TDigest.Tests", "TDigest.Tests\TDigest.Tests.csproj", "{7BCAFD59-C058-4E80-BE5A-B842522C951E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TDigest.Tests", "TDigest.Tests\TDigest.Tests.csproj", "{7BCAFD59-C058-4E80-BE5A-B842522C951E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TDigest.CMD", "TDigest.CMD\TDigest.CMD.csproj", "{9965BA5F-9FA3-46C3-BD89-ACF58D2887C8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TDigest.CMD", "TDigest.CMD\TDigest.CMD.csproj", "{9965BA5F-9FA3-46C3-BD89-ACF58D2887C8}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7BA5CE8A-8138-40E0-87E2-468AC5F3B061}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -31,6 +36,9 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {74267437-EA43-4CBE-923F-60ABAE4391F0} + EndGlobalSection GlobalSection(Performance) = preSolution HasPerformanceSessions = true EndGlobalSection diff --git a/TDigest/Extensions.cs b/TDigest/Extensions.cs index a4c7958..c17fe10 100644 --- a/TDigest/Extensions.cs +++ b/TDigest/Extensions.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StatsLib { public static class Extensions { diff --git a/TDigest/Properties/AssemblyInfo.cs b/TDigest/Properties/AssemblyInfo.cs deleted file mode 100644 index 3e22d91..0000000 --- a/TDigest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TDigest")] -[assembly: AssemblyDescription("Streaming Percentile Estimation")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TDigest")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("bbd6edb5-a7b0-4597-ba6e-25f050ae58d1")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.7.0")] -[assembly: AssemblyFileVersion("1.0.7.0")] diff --git a/TDigest/TDigest.cs b/TDigest/TDigest.cs index 9f7c0ed..b2d006d 100644 --- a/TDigest/TDigest.cs +++ b/TDigest/TDigest.cs @@ -1,11 +1,7 @@ using C5; using System; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics; namespace StatsLib { @@ -20,7 +16,7 @@ public class TDigest { /// of objects added to the digest unless custom weights are used. /// public double Count { - get { return _count; } + get { return _count; } } /// @@ -48,7 +44,7 @@ public int CentroidCount { /// The Average /// public double Average { - get { return _count > 0 ? _newAvg : 0; } + get { return _count > 0 ? _newAvg : 0; } } /// @@ -93,7 +89,7 @@ public static TDigest Merge(TDigest a, TDigest b) { public TDigest(double accuracy = 0.02, double compression = 25) { if (accuracy <= 0) throw new ArgumentOutOfRangeException("Accuracy must be greater than 0"); if (compression < 15) throw new ArgumentOutOfRangeException("Compression constant must be 15 or greater"); - + _centroids = new TreeDictionary(); _rand = new Random(); _count = 0; @@ -105,9 +101,8 @@ public TDigest(double accuracy = 0.02, double compression = 25) { /// Construct a TDigest from a serialized string of Bytes created by the Serialize() method /// /// - public TDigest(byte[] serialized) - : this() - { + public TDigest(byte[] serialized) + : this() { if (serialized == null) throw new ArgumentNullException("Serialized parameter cannot be null"); if ((serialized.Length - 48) % 16 != 0) { @@ -121,7 +116,7 @@ public TDigest(byte[] serialized) Min = BitConverter.ToDouble(serialized, 32); Max = BitConverter.ToDouble(serialized, 40); - var centroids = Enumerable.Range(0, (serialized.Length-48)/16) + var centroids = Enumerable.Range(0, (serialized.Length - 48) / 16) .Select(i => new { Mean = BitConverter.ToDouble(serialized, i * 16 + 48), Count = BitConverter.ToDouble(serialized, i * 16 + 8 + 48) @@ -196,7 +191,7 @@ public void Add(double value, double weight = 1) { if (toAdd.Update(weight, toAdd.Mean, out oldMean)) { ReInsertCentroid(oldMean, toAdd); - } + } } } @@ -219,71 +214,57 @@ public double Quantile(double quantile) { throw new InvalidOperationException("Cannot call Quantile() method until first Adding values to the digest"); } - if (_centroids.Count == 1) - { + if (_centroids.Count == 1) { return _centroids.First().Value.Mean; } double index = quantile * _count; - if (index < 1) - { + if (index < 1) { return Min; } - if (index > Count-1) - { + if (index > Count - 1) { return Max; } Centroid currentNode = _centroids.First().Value; Centroid lastNode = _centroids.Last().Value; double currentWeight = currentNode.Count; - if (currentWeight == 2 && index <= 2) - { + if (currentWeight == 2 && index <= 2) { // first node is a double weight with one sample at min, sou we can infer location of other sample return 2 * currentNode.Mean - Min; } - if (_centroids.Last().Value.Count == 2 && index > Count - 2) - { + if (_centroids.Last().Value.Count == 2 && index > Count - 2) { // likewise for last centroid return 2 * lastNode.Mean - Max; } double weightSoFar = currentWeight / 2.0; - if (index < weightSoFar) - { + if (index < weightSoFar) { return WeightedAvg(Min, weightSoFar - index, currentNode.Mean, index - 1); } - foreach (Centroid nextNode in _centroids.Values.Skip(1)) - { + foreach (Centroid nextNode in _centroids.Values.Skip(1)) { double nextWeight = nextNode.Count; double dw = (currentWeight + nextWeight) / 2.0; - if (index < weightSoFar + dw) - { + if (index < weightSoFar + dw) { double leftExclusion = 0; double rightExclusion = 0; - if (currentWeight == 1) - { - if (index < weightSoFar + 0.5) - { + if (currentWeight == 1) { + if (index < weightSoFar + 0.5) { return currentNode.Mean; } - else - { + else { leftExclusion = 0.5; } } - if (nextWeight == 1) - { - if (index >= weightSoFar + dw - 0.5) - { + if (nextWeight == 1) { + if (index >= weightSoFar + dw - 0.5) { return nextNode.Mean; } - else - { + else { rightExclusion = 0.5; } } @@ -304,10 +285,9 @@ public double Quantile(double quantile) { return WeightedAvg(currentNode.Mean, w2, Max, w1); } - private double WeightedAvg(double m1, double w1, double m2, double w2) - { + private double WeightedAvg(double m1, double w1, double m2, double w2) { double total = w1 + w2; - double ret = m1 * w1/total + m2 * w2/total; + double ret = m1 * w1 / total + m2 * w2 / total; return ret; } @@ -359,7 +339,7 @@ private double ComputeCentroidQuantile(Centroid centroid) { foreach (Centroid c in _centroids.Values) { if (c.Mean > centroid.Mean) break; - sum += c.Count; + sum += c.Count; } double denom = _count; diff --git a/TDigest/TDigest.csproj b/TDigest/TDigest.csproj index ebbc098..60bd9ad 100644 --- a/TDigest/TDigest.csproj +++ b/TDigest/TDigest.csproj @@ -1,77 +1,20 @@ - - - + - Release - AnyCPU - {909364F5-4F9A-444D-BE6A-CE2A6EF592B0} - Library - Properties StatsLib - TDigest - v4.5 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - + net45 true - - Key.snk + 1.0.9 + Streaming Percentile Estimation + $(AssemblyName) + Copyright © 2019 + Graham Henry + MIT + https://github.com/quantumtunneling/T-Digest.NET + Updated package dependencies + Streaming Percentile Quantile Estimation - - ..\packages\C5.2.3.0.1\lib\net40\C5.dll - True - - - - - - - - - - - - - - - - - - - - - + - - \ No newline at end of file diff --git a/TDigest/TDigest.nuspec b/TDigest/TDigest.nuspec deleted file mode 100644 index 1f7eb9b..0000000 --- a/TDigest/TDigest.nuspec +++ /dev/null @@ -1,17 +0,0 @@ - - - - $id$ - $version$ - $title$ - Graham Henry - Graham Henry - https://licenses.nuget.org/MIT - https://github.com/quantumtunneling/T-Digest.NET - false - $description$ - Added support for Strong name signing - Copyright 2019 - Streaming Percentile Quantile Estimation - - \ No newline at end of file diff --git a/TDigest/ext/TDigest.1.0.7/TDigest.nuspec b/TDigest/ext/TDigest.1.0.7/TDigest.nuspec deleted file mode 100644 index 1e1526b..0000000 --- a/TDigest/ext/TDigest.1.0.7/TDigest.nuspec +++ /dev/null @@ -1,20 +0,0 @@ - - - - TDigest - 1.0.7 - TDigest - Graham Henry - Graham Henry - false - https://licenses.nuget.org/MIT - https://github.com/quantumtunneling/T-Digest.NET - Streaming Percentile Estimation - Added support for Strong name signing - Copyright 2019 - Streaming Percentile Quantile Estimation - - - - - \ No newline at end of file diff --git a/TDigest/ext/TDigest.1.0.7/[Content_Types].xml b/TDigest/ext/TDigest.1.0.7/[Content_Types].xml deleted file mode 100644 index 7b4ce96..0000000 --- a/TDigest/ext/TDigest.1.0.7/[Content_Types].xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/TDigest/ext/TDigest.1.0.7/_rels/.rels b/TDigest/ext/TDigest.1.0.7/_rels/.rels deleted file mode 100644 index 52c8c5d..0000000 --- a/TDigest/ext/TDigest.1.0.7/_rels/.rels +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/TDigest/ext/TDigest.1.0.7/content/LICENSE.txt b/TDigest/ext/TDigest.1.0.7/content/LICENSE.txt deleted file mode 100644 index 9a0512d..0000000 --- a/TDigest/ext/TDigest.1.0.7/content/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Graham Henry - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/TDigest/ext/TDigest.1.0.7/package/services/metadata/core-properties/34bcb6defab9462e8f05d5a3dab0a2c1.psmdcp b/TDigest/ext/TDigest.1.0.7/package/services/metadata/core-properties/34bcb6defab9462e8f05d5a3dab0a2c1.psmdcp deleted file mode 100644 index 25d7019..0000000 --- a/TDigest/ext/TDigest.1.0.7/package/services/metadata/core-properties/34bcb6defab9462e8f05d5a3dab0a2c1.psmdcp +++ /dev/null @@ -1,9 +0,0 @@ - - - Graham Henry - Streaming Percentile Estimation - TDigest - 1.0.7 - Streaming Percentile Quantile Estimation - NuGet, Version=4.9.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;Microsoft Windows NT 6.2.9200.0;.NET Framework 4.6 - \ No newline at end of file diff --git a/TDigest/packages.config b/TDigest/packages.config deleted file mode 100644 index ea9cb3f..0000000 --- a/TDigest/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/packages/repositories.config b/packages/repositories.config deleted file mode 100644 index cb41b0e..0000000 --- a/packages/repositories.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From 581e3e9e6a8253491873da6997c4d16134abdafa Mon Sep 17 00:00:00 2001 From: Brian Rogers Date: Sun, 22 Dec 2019 11:10:56 -0800 Subject: [PATCH 2/2] Add benchmark project --- TDigest.Benchmarks/Program.cs | 40 ++++++++++++++++++++ TDigest.Benchmarks/TDigest.Benchmarks.csproj | 17 +++++++++ TDigest.sln | 6 +++ 3 files changed, 63 insertions(+) create mode 100644 TDigest.Benchmarks/Program.cs create mode 100644 TDigest.Benchmarks/TDigest.Benchmarks.csproj diff --git a/TDigest.Benchmarks/Program.cs b/TDigest.Benchmarks/Program.cs new file mode 100644 index 0000000..19ee35f --- /dev/null +++ b/TDigest.Benchmarks/Program.cs @@ -0,0 +1,40 @@ +using System; +using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Running; + +namespace StatsLib.Benchmarks { + class Program { + static void Main() { + BenchmarkRunner.Run(); + } + } + + [SimpleJob(RuntimeMoniker.Net461)] + [MemoryDiagnoser] + public class SortedDigest { + [Params(1_000, 10_000, 100_000)] + public int N { get; set; } + + [Params(true, false)] + public bool Asc { get; set; } + + [Benchmark] + public double Build() { + TDigest digest = new TDigest(); + double denominator = N; + for (int i = 0; i < N; ++i) { + // Add normalized values in interval [0.0, 1.0) + int numerator = Asc ? i : (N - i - 1); + digest.Add(numerator / denominator); + } + + double count = digest.Count; + if (count != N) { + throw new InvalidOperationException($"Bad benchmark; digest.Count ({count}) != N ({N})"); + } + + return count; + } + } +} diff --git a/TDigest.Benchmarks/TDigest.Benchmarks.csproj b/TDigest.Benchmarks/TDigest.Benchmarks.csproj new file mode 100644 index 0000000..e41f3b3 --- /dev/null +++ b/TDigest.Benchmarks/TDigest.Benchmarks.csproj @@ -0,0 +1,17 @@ + + + Exe + net461 + 1.0.0 + $(AssemblyName) + Copyright © 2019 + false + full + + + + + + + + \ No newline at end of file diff --git a/TDigest.sln b/TDigest.sln index 0f701de..15bc40a 100644 --- a/TDigest.sln +++ b/TDigest.sln @@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .editorconfig = .editorconfig EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TDigest.Benchmarks", "TDigest.Benchmarks\TDigest.Benchmarks.csproj", "{1D25EACA-348A-4697-897E-57635514FE19}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -32,6 +34,10 @@ Global {9965BA5F-9FA3-46C3-BD89-ACF58D2887C8}.Debug|Any CPU.Build.0 = Debug|Any CPU {9965BA5F-9FA3-46C3-BD89-ACF58D2887C8}.Release|Any CPU.ActiveCfg = Release|Any CPU {9965BA5F-9FA3-46C3-BD89-ACF58D2887C8}.Release|Any CPU.Build.0 = Release|Any CPU + {1D25EACA-348A-4697-897E-57635514FE19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1D25EACA-348A-4697-897E-57635514FE19}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1D25EACA-348A-4697-897E-57635514FE19}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1D25EACA-348A-4697-897E-57635514FE19}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE