Skip to content

Commit 037bbec

Browse files
Take the two review notes from #664 (#678)
Both were left by the Copilot reviewer on #664, which merged before I had read them. SolverRegressionTest had `using PeterO.Numbers;` and never named a type from it -- the EDecimal occurrences are all property accesses on a Real, which need no using. Removed. The library builds with TreatWarningsAsErrors, so an unused using is worth not leaving lying about. DivergesInMagnitude was flagged for calling Limit up to three times. The three are distinct and the || short-circuits, so there was nothing to cache, but there was a real waste next to it: at an infinite destination there is only one side to approach from, so the two one-sided limits are both pointless and meaningless there. They are now only asked for when the destination is finite. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 8d4af56 commit 037bbec

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎Sources/AngouriMath/Functions/Continuous/Limits/Transformations.cs‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,17 @@ private static bool IsInfiniteNode(Entity expr)
6666
/// <c>g(x) * (f(x) - 1)</c>, which is well defined from either side.
6767
/// </remarks>
6868
private static bool DivergesInMagnitude(Entity power, Variable x, Entity dest)
69-
=> IsInfiniteNode(power.Limit(x, dest))
70-
|| (IsInfiniteNode(power.Limit(x, dest, ApproachFrom.Left))
71-
&& IsInfiniteNode(power.Limit(x, dest, ApproachFrom.Right)));
69+
{
70+
if (IsInfiniteNode(power.Limit(x, dest)))
71+
return true;
72+
// Only worth asking one side at a time where there are two sides to ask about.
73+
// Approaching an infinite destination there is only one, so the two further
74+
// limits would be wasted work and would not mean anything either.
75+
if (IsInfiniteNode(dest))
76+
return false;
77+
return IsInfiniteNode(power.Limit(x, dest, ApproachFrom.Left))
78+
&& IsInfiniteNode(power.Limit(x, dest, ApproachFrom.Right));
79+
}
7280

7381
private static bool IsFiniteNode(Entity expr)
7482
=> !IsInfiniteNode(expr) && expr != MathS.NaN;

‎Sources/Tests/UnitTests/Common/SolverRegressionTest.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
using AngouriMath;
99
using AngouriMath.Extensions;
10-
using PeterO.Numbers;
1110
using Xunit;
1211

1312
namespace AngouriMath.Tests.Common

0 commit comments

Comments
 (0)