Skip to content

Commit fec21ca

Browse files
committed
Restore source files after history cleanup.
1 parent 5ad1c11 commit fec21ca

90 files changed

Lines changed: 3134 additions & 1336 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/Integration.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,9 @@ on:
44
pull_request:
55
branches: [ main ]
66

7-
env:
8-
dotnet-version: '9.0.x'
9-
107
jobs:
118
CI:
12-
runs-on: windows-latest
13-
env:
9+
uses: HydrologicEngineeringCenter/dotnet-workflows/.github/workflows/integration.yml@main
10+
with:
1411
dotnet-version: '9.0.x'
15-
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 0
21-
22-
- name: Setup .NET Core SDK ${{ env.dotnet-version }}
23-
uses: actions/setup-dotnet@v4
24-
with:
25-
dotnet-version: ${{ env.dotnet-version }}
26-
27-
- name: Test Solution
28-
run: dotnet test --nologo -c Release
12+
run-tests: true

.github/workflows/Release.yml

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Snapshot
1+
name: Release
22

33
on:
44
push:
@@ -7,39 +7,11 @@ on:
77

88
jobs:
99
build:
10-
runs-on: windows-latest
11-
12-
env:
13-
dotnet-version: '9.0.x'
14-
15-
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v2
18-
with:
19-
fetch-depth: 0
20-
21-
- name: Setup .NET Core SDK ${{ env.dotnet-version }}
22-
uses: actions/setup-dotnet@v4
23-
with:
24-
dotnet-version: ${{ env.dotnet-version }}
25-
26-
- name: Test
27-
run: dotnet test -c Release
28-
29-
- name: Create version number
30-
shell: pwsh
31-
run: |
32-
$TAG = $env:GITHUB_REF -replace 'refs/tags/', ''
33-
$VERSION = $TAG -replace '^v', ''
34-
echo "VERSION=$VERSION" >> $env:GITHUB_ENV
35-
36-
- name: Pack
37-
shell: pwsh
38-
run: |
39-
# Use the snapshot version from the previous step
40-
dotnet pack --configuration Release /p:PackageVersion=${{ env.VERSION }}
41-
42-
- name: Publish
43-
shell: pwsh
44-
run: dotnet nuget push "**/*.nupkg" --api-key ${{ secrets.NEXUS_NUGET_APIKEY }} --source "https://www.hec.usace.army.mil/nexus/repository/fda-nuget/" --skip-duplicate
45-
10+
uses: HydrologicEngineeringCenter/dotnet-workflows/.github/workflows/release.yml@main
11+
with:
12+
dotnet-version: '9.0.x'
13+
project-names: 'Numerics'
14+
run-tests: true
15+
nuget-source: 'https://www.hec.usace.army.mil/nexus/repository/consequences-nuget-public/'
16+
secrets:
17+
NUGET_API_KEY: ${{ secrets.NEXUS_NUGET_APIKEY }}

.github/workflows/Snapshot.yml

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,12 @@ on:
66

77
jobs:
88
build:
9-
runs-on: windows-latest
10-
11-
env:
12-
dotnet-version: '9.0.x'
13-
14-
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v2
17-
with:
18-
fetch-depth: 0
19-
20-
- name: Setup .NET Core SDK ${{ env.dotnet-version }}
21-
uses: actions/setup-dotnet@v4
22-
with:
23-
dotnet-version: ${{ env.dotnet-version }}
24-
25-
- name: Test
26-
run: dotnet test -c Release
27-
28-
- name: Get version from built assembly and set snapshot version
29-
id: set-version
30-
shell: powershell
31-
run: |
32-
# Get the assembly version from the built DLL. It's already built from the test step.
33-
$assemblyPath = "Numerics/bin/Release/net8.0/Numerics.dll"
34-
35-
# Load the assembly and get its version
36-
$assembly = [System.Reflection.Assembly]::LoadFrom((Resolve-Path $assemblyPath).Path)
37-
$assemblyVersion = $assembly.GetName().Version
38-
39-
# Extract major.minor.patch from assembly version
40-
$baseVersion = "$($assemblyVersion.Major).$($assemblyVersion.Minor).$($assemblyVersion.Build)"
41-
42-
# Create snapshot version with GitHub run number
43-
$snapshotVersion = "${baseVersion}.${{ github.run_number }}-dev"
44-
45-
# Output the version for use in next steps
46-
echo "SNAPSHOT_VERSION=$snapshotVersion" | Out-File -FilePath $env:GITHUB_ENV -Append
47-
echo "BASE_VERSION=$baseVersion" | Out-File -FilePath $env:GITHUB_ENV -Append
48-
49-
# Also set as step output
50-
echo "version=$snapshotVersion" >> $env:GITHUB_OUTPUT
51-
echo "base_version=$baseVersion" >> $env:GITHUB_OUTPUT
52-
53-
# Display the version
54-
Write-Host "Assembly Version: $assemblyVersion"
55-
Write-Host "Base Version: $baseVersion"
56-
Write-Host "Snapshot Version: $snapshotVersion"
57-
58-
- name: Pack
59-
run: |
60-
# Use the snapshot version from the previous step
61-
dotnet pack --configuration Release /p:PackageVersion=$env:SNAPSHOT_VERSION
62-
Write-Host "Created package with version: $env:SNAPSHOT_VERSION"
63-
shell: powershell
64-
65-
- name: Publish
66-
run: dotnet nuget push "**/*.nupkg" --api-key ${{ secrets.NEXUS_NUGET_APIKEY }} --source "https://www.hec.usace.army.mil/nexus/repository/fda-nuget/" --skip-duplicate
9+
uses: HydrologicEngineeringCenter/dotnet-workflows/.github/workflows/snapshot.yml@main
10+
with:
11+
dotnet-version: '9.0.x'
12+
project-names: 'Numerics'
13+
version: '1.0.0'
14+
run-tests: true
15+
nuget-source: 'https://www.hec.usace.army.mil/nexus/repository/consequences-nuget-public/'
16+
secrets:
17+
NUGET_API_KEY: ${{ secrets.NEXUS_NUGET_APIKEY }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,4 @@ MigrationBackup/
370370

371371
#Numerics Specific
372372
/TestResults
373+
/.claude/settings.local.json

Numerics/Data/Interpolation/CubicSpline.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31+
using System;
32+
using System.Collections.Generic;
33+
3134
namespace Numerics.Data
3235
{
3336
/// <summary>
@@ -75,7 +78,7 @@ public CubicSpline(IList<double> xValues, IList<double> yValues, SortOrder sortO
7578
/// <summary>
7679
/// Stores the array of second derivatives.
7780
/// </summary>
78-
private double[] y2 = Array.Empty<double>();
81+
private double[] y2 = null!;
7982

8083
/// <summary>
8184
/// Auxiliary routine to set the second derivatives. If you make changes to the x- or y-values, then you need to call this routine afterwards.

Numerics/Data/Paired Data/OrderedPairedData.cs

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,19 @@ public class OrderedPairedData : IList<Ordinate>, INotifyCollectionChanged
105105
private List<Ordinate> _ordinates;
106106

107107
/// <inheritdoc/>
108-
public event NotifyCollectionChangedEventHandler CollectionChanged;
108+
public event NotifyCollectionChangedEventHandler? CollectionChanged;
109+
110+
/// <summary>
111+
/// Gets or sets a value indicating whether collection changed events are suppressed.
112+
/// </summary>
113+
/// <remarks>
114+
/// <para>
115+
/// Set this to <c>true</c> before performing a batch of mutations and then
116+
/// call <see cref="RaiseCollectionChangedReset"/> when the batch is complete.
117+
/// This avoids firing an event for every individual mutation.
118+
/// </para>
119+
/// </remarks>
120+
public bool SuppressCollectionChanged { get; set; } = false;
109121

110122
/// <summary>
111123
/// Represents if the paired dataset has valid ordinates and order.
@@ -265,20 +277,24 @@ public OrderedPairedData(XElement el)
265277
{
266278
// Get Strictness
267279
bool strict = false;
268-
if (el.Attribute(nameof(StrictX)) != null) { bool.TryParse(el.Attribute(nameof(StrictX)).Value, out strict); }
280+
var strictXAttr = el.Attribute(nameof(StrictX));
281+
if (strictXAttr != null) { bool.TryParse(strictXAttr.Value, out strict); }
269282
StrictX = strict;
270283

271284
strict = false;
272-
if (el.Attribute(nameof(StrictY)) != null) { bool.TryParse(el.Attribute(nameof(StrictY)).Value, out strict); }
285+
var strictYAttr = el.Attribute(nameof(StrictY));
286+
if (strictYAttr != null) { bool.TryParse(strictYAttr.Value, out strict); }
273287
StrictY = strict;
274288

275289
// Get Order
276290
SortOrder order = SortOrder.None;
277-
if (el.Attribute(nameof(OrderX)) != null) { Enum.TryParse(el.Attribute(nameof(OrderX)).Value, out order); }
291+
var orderXAttr = el.Attribute(nameof(OrderX));
292+
if (orderXAttr != null) { Enum.TryParse(orderXAttr.Value, out order); }
278293
OrderX = order;
279294

280295
order = SortOrder.None;
281-
if (el.Attribute(nameof(OrderY)) != null) { Enum.TryParse(el.Attribute(nameof(OrderY)).Value, out order); }
296+
var orderYAttr = el.Attribute(nameof(OrderY));
297+
if (orderYAttr != null) { Enum.TryParse(orderYAttr.Value, out order); }
282298
OrderY = order;
283299

284300
// Ordinates
@@ -299,6 +315,22 @@ public OrderedPairedData(XElement el)
299315

300316
#region Methods
301317

318+
/// <summary>
319+
/// Raises a <see cref="NotifyCollectionChangedAction.Reset"/> event
320+
/// unconditionally, regardless of the <see cref="SuppressCollectionChanged"/> flag.
321+
/// </summary>
322+
/// <remarks>
323+
/// <para>
324+
/// Call this after a bulk operation once <see cref="SuppressCollectionChanged"/>
325+
/// has been set back to <c>false</c> (or while still <c>true</c> if desired)
326+
/// to notify listeners that the collection has changed.
327+
/// </para>
328+
/// </remarks>
329+
public void RaiseCollectionChangedReset()
330+
{
331+
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
332+
}
333+
302334
/// <summary>
303335
/// Get or set the ordinate at a specified index.
304336
/// </summary>
@@ -321,14 +353,11 @@ public Ordinate this[int index]
321353
{
322354
if (OrdinateValid(index) == true) { Validate(); }
323355
}
324-
//
325-
//We might need to add this check if performance suffers
326-
//if (SupressCollectionChanged == false)
327-
//{
328-
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, value, oldValue));
329-
//}
356+
if (SuppressCollectionChanged == false)
357+
{
358+
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, value, oldValue, index));
359+
}
330360
}
331-
332361
}
333362
}
334363

@@ -427,7 +456,8 @@ public bool Remove(Ordinate item)
427456
if (itemIndex == -1) return false;
428457
_ordinates.RemoveAt(itemIndex);
429458
Validate();
430-
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, itemIndex));
459+
if (SuppressCollectionChanged == false)
460+
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, itemIndex));
431461
return true;
432462
}
433463

@@ -441,7 +471,8 @@ public void RemoveAt(int index)
441471
var item = _ordinates[index];
442472
_ordinates.RemoveAt(index);
443473
Validate();
444-
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index));
474+
if (SuppressCollectionChanged == false)
475+
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index));
445476
}
446477

447478
/// <summary>
@@ -456,7 +487,8 @@ public void RemoveRange(int index, int count)
456487
for (int i = index; i < count; i++) { items.Add(_ordinates[i]); }
457488
_ordinates.RemoveRange(index, count);
458489
Validate();
459-
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, items, index));
490+
if (SuppressCollectionChanged == false)
491+
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, items, index));
460492
}
461493

462494
/// <summary>
@@ -467,7 +499,8 @@ public void Add(Ordinate item)
467499
{
468500
_ordinates.Add(item);
469501
IsValid = OrdinateValid(_ordinates.Count - 1);
470-
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, _ordinates.Count - 1));
502+
if (SuppressCollectionChanged == false)
503+
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, _ordinates.Count - 1));
471504
}
472505

473506
/// <summary>
@@ -480,17 +513,26 @@ public void Insert(int index, Ordinate item)
480513
_ordinates.Insert(index, item);
481514
// only need to set valid state if it is true. if it is already false then inserting can't make it true.
482515
if (IsValid) IsValid = OrdinateValid(index);
483-
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
516+
if (SuppressCollectionChanged == false)
517+
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
484518
}
485519

486520
/// <summary>
487521
/// Removes all ordinates form the collection and sets count to zero.
488522
/// </summary>
489523
public void Clear()
490524
{
525+
if (_ordinates.Count == 0)
526+
return;
527+
528+
bool wasSuppressed = SuppressCollectionChanged;
529+
SuppressCollectionChanged = true;
491530
_ordinates.Clear();
531+
SuppressCollectionChanged = wasSuppressed;
532+
492533
IsValid = true;
493-
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
534+
if (SuppressCollectionChanged == false)
535+
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
494536
}
495537

496538
/// <summary>
@@ -612,7 +654,7 @@ IEnumerator IEnumerable.GetEnumerator()
612654
/// </summary>
613655
/// <param name="obj">The object to compare with the current object.</param>
614656
/// <returns>True if the specified object is equal to the current object; otherwise, False.</returns>
615-
public override bool Equals(object obj)
657+
public override bool Equals(object? obj)
616658
{
617659
if (obj is OrderedPairedData other)
618660
{
@@ -1432,7 +1474,7 @@ private double TriangleArea(Ordinate point1, Ordinate point2, Ordinate point3)
14321474
/// and number of points in the search region.</returns>
14331475
public OrderedPairedData LangSimplify(double tolerance, int lookAhead)
14341476
{
1435-
if (_ordinates == null | lookAhead <= 1 | tolerance <= 0)
1477+
if (_ordinates == null || lookAhead <= 1 || tolerance <= 0)
14361478
return this;
14371479

14381480
List<Ordinate> ordinates = new List<Ordinate>();

Numerics/Data/Paired Data/Ordinate.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ public Ordinate(double xValue, double yValue)
7979
public Ordinate(XElement xElement)
8080
{
8181
double x = 0, y = 0;
82-
if (xElement.Attribute(nameof(X)) != null) double.TryParse(xElement.Attribute(nameof(X)).Value, NumberStyles.Any, CultureInfo.InvariantCulture, out x);
83-
if (xElement.Attribute(nameof(Y)) != null) double.TryParse(xElement.Attribute(nameof(Y)).Value, NumberStyles.Any, CultureInfo.InvariantCulture, out y);
82+
var xAttribute = xElement.Attribute(nameof(X));
83+
var yAttribute = xElement.Attribute(nameof(Y));
84+
if (xAttribute != null) double.TryParse(xAttribute.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out x);
85+
if (yAttribute != null) double.TryParse(yAttribute.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out y);
8486
X = x;
8587
Y = y;
8688
IsValid = true;
@@ -367,7 +369,7 @@ public Ordinate Transform(Transform xTransform, Transform yTransform)
367369
/// </summary>
368370
/// <param name="obj">The object to compare with the current object.</param>
369371
/// <returns>True if the specified object is equal to the current object; otherwise, False.</returns>
370-
public override bool Equals(object obj)
372+
public override bool Equals(object? obj)
371373
{
372374
if (obj is Ordinate other)
373375
{

0 commit comments

Comments
 (0)