Skip to content

Commit 4fb6b22

Browse files
author
Oren (electricessence)
committed
Updated packaging.
1 parent 5bf9a7b commit 4fb6b22

11 files changed

+71
-107
lines changed

source/DynamicArithmetic.cs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
/*!
2-
* @author electricessence / https://github.com/electricessence/
3-
* Licensing: MIT https://github.com/electricessence/Open/blob/dotnet-core/LICENSE.md
4-
*/
5-
6-
using System;
7-
1+
using System;
82

93
namespace Open.Arithmetic.Dynamic
104
{
@@ -15,31 +9,19 @@ public static class DynamicArithmetic
159
{
1610
public static T1 AddValue<T1, T2>(this T1 a, T2 b)
1711
where T1 : struct, IComparable
18-
where T2 : struct, IComparable
19-
{
20-
return (dynamic)a + b;
21-
}
12+
where T2 : struct, IComparable => (dynamic)a + b;
2213

2314
public static T1 SubtractValue<T1, T2>(this T1 a, T2 b)
2415
where T1 : struct, IComparable
25-
where T2 : struct, IComparable
26-
{
27-
return (dynamic)a - b;
28-
}
16+
where T2 : struct, IComparable => (dynamic)a - b;
2917

3018
public static T1 MultiplyBy<T1, T2>(this T1 a, T2 b)
3119
where T1 : struct, IComparable
32-
where T2 : struct, IComparable
33-
{
34-
return (dynamic)a * b;
35-
}
20+
where T2 : struct, IComparable => (dynamic)a * b;
3621

3722
public static T1 DivideBy<T1, T2>(this T1 a, T2 b)
3823
where T1 : struct, IComparable
39-
where T2 : struct, IComparable
40-
{
41-
return (dynamic)a / b;
42-
}
24+
where T2 : struct, IComparable => (dynamic)a / b;
4325

4426
public static T PowerOf<T>(this T a, uint power)
4527
where T : struct, IComparable
@@ -55,7 +37,5 @@ public static T PowerOf<T>(this T a, uint power)
5537

5638
return result;
5739
}
58-
59-
6040
}
6141
}

source/LISCENSE.md renamed to source/LICENSE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22

3-
## Copyright (c) 2017 Oren J. Ferrari
3+
## Copyright (c) 2020 electricessence (Oren F.) All rights reserved
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
21+
THE SOFTWARE.

source/MathExtensions.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
/*!
2-
* @author electricessence / https://github.com/electricessence/
3-
* Licensing: MIT https://github.com/electricessence/Open/blob/dotnet-core/LICENSE.md
4-
*/
5-
6-
using System;
1+
using System;
72
using System.Collections.Generic;
83
using System.Diagnostics.Contracts;
94

@@ -90,7 +85,7 @@ public static long PowerOf(this long @base, int power)
9085
/// <returns>32 bit integer</returns>
9186
public static int AsInteger(this bool[] source)
9287
{
93-
if (source == null) throw new NullReferenceException();
88+
if (source is null) throw new NullReferenceException();
9489
if (source.Length > 32) throw new ArgumentOutOfRangeException(nameof(source), source, "Array cannot be greater than 32 bits.");
9590
Contract.EndContractBlock();
9691

@@ -110,7 +105,7 @@ public static int AsInteger(this bool[] source)
110105
/// <returns>64 bit integer</returns>
111106
public static long AsLong(this bool[] source)
112107
{
113-
if (source == null) throw new NullReferenceException();
108+
if (source is null) throw new NullReferenceException();
114109
if (source.Length > 64) throw new ArgumentOutOfRangeException(nameof(source), source, "Array cannot be greater than 64 bits.");
115110
Contract.EndContractBlock();
116111

@@ -132,7 +127,7 @@ public static long AsLong(this bool[] source)
132127
public static double Product(this IEnumerable<double> source,
133128
double defaultValueIfNoElements = double.NaN)
134129
{
135-
if (source == null)
130+
if (source is null)
136131
throw new NullReferenceException();
137132
Contract.EndContractBlock();
138133

@@ -157,7 +152,7 @@ public static double Product(this IEnumerable<double> source,
157152
public static double AverageDouble(this IEnumerable<double> source,
158153
double defaultValueIfNoElements = double.NaN)
159154
{
160-
if (source == null)
155+
if (source is null)
161156
throw new NullReferenceException();
162157
Contract.EndContractBlock();
163158

@@ -184,7 +179,7 @@ public static double AverageDouble(this IEnumerable<double> source,
184179
/// <returns>The resultant quotiient.</returns>
185180
public static double Quotient(this IEnumerable<double> source)
186181
{
187-
if (source == null)
182+
if (source is null)
188183
throw new NullReferenceException();
189184
Contract.EndContractBlock();
190185

@@ -222,7 +217,7 @@ public static double Quotient(this IEnumerable<double> source)
222217
/// <returns>The resultant quotient.</returns>
223218
public static double QuotientOf(this IEnumerable<double> divisors, double numerator)
224219
{
225-
if (divisors == null)
220+
if (divisors is null)
226221
throw new NullReferenceException();
227222
Contract.EndContractBlock();
228223

source/Open.Arithmetic.csproj

Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,44 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<Description>Simple set of arithmetic extensions.
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
5+
<LangVersion>latest</LangVersion>
6+
<Nullable>enable</Nullable>
7+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
8+
<Authors>electricessence</Authors>
9+
<Description>Simple set of arithmetic extensions.
610

711
Part of the "Open" set of libraries.</Description>
8-
<Authors>electricessence</Authors>
9-
<Company />
10-
<Product />
11-
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
12-
<PackageLicenseUrl></PackageLicenseUrl>
13-
<Copyright>https://github.com/electricessence/Open.Arithmetic/blob/master/LISCENSE.md</Copyright>
14-
<PackageProjectUrl>https://github.com/electricessence/Open.Arithmetic/</PackageProjectUrl>
15-
<RepositoryUrl>https://github.com/electricessence/Open.Arithmetic/</RepositoryUrl>
16-
<RepositoryType>git</RepositoryType>
17-
<PackageTags>dotnet, dotnet-core, dotnetcore, cs, math, dynamic, arithmetic, triangular, statistical, variance, covariance, correlation</PackageTags>
18-
<Version>1.4.0</Version>
19-
<PackageReleaseNotes></PackageReleaseNotes>
20-
<PackageLicenseExpression>MIT</PackageLicenseExpression>
21-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
22-
<IncludeSymbols>true</IncludeSymbols>
23-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
24-
</PropertyGroup>
25-
26-
<ItemGroup>
27-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
28-
</ItemGroup>
29-
30-
31-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
32-
<LangVersion>latest</LangVersion>
33-
</PropertyGroup>
34-
35-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
36-
<LangVersion>latest</LangVersion>
37-
</PropertyGroup>
38-
39-
<ItemGroup>
40-
<None Remove=".git" />
41-
<None Remove=".gitignore" />
42-
<None Remove="LISCENSE.md" />
43-
<None Remove="README.md" />
44-
</ItemGroup>
45-
46-
<ItemGroup>
47-
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
48-
</ItemGroup>
12+
<PackageTags>math;dynamic;arithmetic;triangular;statistical;variance;covariance;correlation</PackageTags>
13+
<Copyright>© electricessence (Oren F.) All rights reserved.</Copyright>
14+
<PackageProjectUrl>https://github.com/Open-NET-Libraries/Open.Arithmetic/</PackageProjectUrl>
15+
<RepositoryUrl>https://github.com/Open-NET-Libraries/Open.Arithmetic/</RepositoryUrl>
16+
<RepositoryType>git</RepositoryType>
17+
<Version>1.5.0</Version>
18+
<PackageReleaseNotes></PackageReleaseNotes>
19+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
20+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
21+
<IncludeSymbols>true</IncludeSymbols>
22+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
23+
<PackageIcon>logo.png</PackageIcon>
24+
</PropertyGroup>
25+
26+
<ItemGroup>
27+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<None Remove=".git" />
32+
<None Remove=".gitignore" />
33+
<None Include="logo.png">
34+
<Pack>True</Pack>
35+
<PackagePath></PackagePath>
36+
</None>
37+
</ItemGroup>
38+
39+
<ItemGroup>
40+
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
41+
42+
</ItemGroup>
4943

5044
</Project>

source/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Open.Arithmetic
2+
23
Simple set of arithmetic extensions.

source/Statistical.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static class Statistical
1616
/// <returns>The variance of a set of numbers.</returns>
1717
public static double Variance(this IEnumerable<double> source, bool sample = false)
1818
{
19-
if (source == null)
19+
if (source is null)
2020
throw new NullReferenceException();
2121
Contract.EndContractBlock();
2222

@@ -61,9 +61,9 @@ public static double Variance(this IEnumerable<double> source, bool sample = fal
6161
/// <returns>The resultant product of each related entry.</returns>
6262
public static IEnumerable<double> Products(this IEnumerable<double> source, IEnumerable<double> target)
6363
{
64-
if (source == null)
64+
if (source is null)
6565
throw new NullReferenceException();
66-
if (target == null)
66+
if (target is null)
6767
throw new ArgumentNullException(nameof(target));
6868
Contract.EndContractBlock();
6969

@@ -94,9 +94,9 @@ public static IEnumerable<double> Products(this IEnumerable<double> source, IEnu
9494
/// <returns>The variance of a set of numbers.</returns>
9595
public static double Covariance(this IEnumerable<double> source, IEnumerable<double> target, bool sample = false)
9696
{
97-
if (source == null)
97+
if (source is null)
9898
throw new NullReferenceException();
99-
if (target == null)
99+
if (target is null)
100100
throw new ArgumentNullException(nameof(target));
101101
Contract.EndContractBlock();
102102

@@ -144,9 +144,9 @@ public static double Correlation(double covariance, double sourceVariance, doubl
144144

145145
public static double Correlation(double covariance, IEnumerable<double> source, IEnumerable<double> target)
146146
{
147-
if (source == null)
147+
if (source is null)
148148
throw new NullReferenceException();
149-
if (target == null)
149+
if (target is null)
150150
throw new ArgumentNullException();
151151
Contract.EndContractBlock();
152152

@@ -155,9 +155,9 @@ public static double Correlation(double covariance, IEnumerable<double> source,
155155

156156
public static double Correlation(this IEnumerable<double> source, IEnumerable<double> target)
157157
{
158-
if (source == null)
158+
if (source is null)
159159
throw new NullReferenceException();
160-
if (target == null)
160+
if (target is null)
161161
throw new ArgumentNullException();
162162
Contract.EndContractBlock();
163163

source/Triangular.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
/*!
2-
* @author electricessence / https://github.com/electricessence/
3-
* Licensing: MIT https://github.com/electricessence/Genetic-Algorithm-Platform/blob/master/LICENSE.md
4-
*/
5-
6-
using System;
1+
using System;
72
using System.Collections.Generic;
83
using System.Diagnostics.Contracts;
94
using System.Linq;
105

116
namespace Open.Arithmetic
127
{
13-
148
public static class Triangular
159
{
1610
public static readonly short MaxInt16 = Reverse(short.MaxValue);

source/logo.png

54.6 KB
Loading

tests/Open.Arithmetic.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
@@ -15,9 +15,9 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
19-
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
20-
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
18+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
19+
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
20+
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
2121
</ItemGroup>
2222

2323
<ItemGroup>

tests/Statistical.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public void Variance()
2121
var sum = VarianceSample.Sum();
2222
var mean = sum / count;
2323
var expected = VarianceSample.Select(s => Math.Pow(s - mean, 2)).Sum() / (count - 0);
24-
Assert.IsTrue(
25-
expected.IsPreciseEqual(VarianceSample.Variance(), true));
24+
var actual = VarianceSample.Variance();
25+
Assert.IsTrue(expected.IsNearEqual(actual, 10));
2626
expected = VarianceSample.Select(s => Math.Pow(s - mean, 2)).Sum() / (count - 1);
27-
Assert.IsTrue(
28-
expected.IsPreciseEqual(VarianceSample.Variance(true), true));
27+
actual = VarianceSample.Variance(true);
28+
Assert.IsTrue(expected.IsNearEqual(actual, 10));
2929
}
3030

3131
private readonly double[] CovarianceSampleX =

tests/logo.png

54.6 KB
Loading

0 commit comments

Comments
 (0)