Skip to content

Commit

Permalink
Fixed bugs in EventStatistics
Browse files Browse the repository at this point in the history
Closes #127.

- Fixes bug with auth url
- Fixes a bug with detmining valid ranges to calculate stats on
- Fixes a regression that no longer inserts date into downloaded file names by giving file segment a date directly from metadata
- Adds an event statistics default configuration file
- Additionally fixes a bug in the directory info parser for dealing with badly formed paths
- Additionally, completey rewrote the Range class so that it keeps tracks of whether its points are closed or open
- Additionally, removed TestSettings file since it mainly contained settings that weren't used. If we need one I expect it will be regenerated at some later point
  • Loading branch information
atruskie committed Mar 11, 2018
1 parent 2490369 commit 02573e0
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 108 deletions.
1 change: 1 addition & 0 deletions AudioAnalysis.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EUnitTestFramework_002ESettings_002EMigrations_002ERemoveBuildPolicyAlwaysMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionDefault/ActivateOnRun/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionDefault/LogSeverity/@EntryValue">TRACE</s:String>
<s:Int64 x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionDefault/OutputLineNumberLimit/@EntryValue">1000</s:Int64>
<s:Boolean x:Key="/Default/ReSpeller/UserDictionaries/=en_005Fus/@KeyIndexDefined">True</s:Boolean>
Expand Down
30 changes: 0 additions & 30 deletions TestSettings.testsettings

This file was deleted.

2 changes: 1 addition & 1 deletion src/AcousticWorkbench/UrlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static Uri GetLoginUri(this IApi api)

public static Uri GetSessionValidateUri(this IApi api)
{
return api.Base("security/new");
return api.Base("security/user");
}

public static Uri GetListenUri(this IApi api, long audioRecordingId, double startOffsetSeconds, double? endOffsetSeconds = null)
Expand Down
63 changes: 36 additions & 27 deletions src/Acoustics.Shared/Extensions/RangeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,41 @@ public static Range<double> Grow(
{
var limitMagnitude = limits.Size();

if (growAmount + range.Size() > limitMagnitude)
var newMagnitude = growAmount + range.Size();
if (newMagnitude > limitMagnitude)
{
return limits;
}

var halfGrow = growAmount / 2.0;

var newMin = range.Minimum - halfGrow;
var newMax = range.Maximum + halfGrow;

if (newMin < limits.Minimum)
{
newMax = limits.Minimum + newMagnitude;
newMin = limits.Minimum;
}
else if (newMax > limits.Maximum)
{
newMin = limits.Maximum - newMagnitude;
newMax = limits.Maximum;
}

// round the lower bound
if (roundDigits.HasValue)
{
newMin = Math.Round(newMin, roundDigits.Value, MidpointRounding.AwayFromZero);
}

var newMax = range.Maximum + halfGrow;

// round the upper bound
if (roundDigits.HasValue)
{
newMax = Math.Round(newMax, roundDigits.Value, MidpointRounding.AwayFromZero);
}

if (newMin < limits.Minimum)
{
newMax += limits.Minimum - newMin;
newMin = limits.Minimum;
}
else if (newMax > limits.Maximum)
{
newMin -= newMax - limits.Maximum;
newMax = limits.Maximum;
}

return new Range<double>(newMin, newMax);
return new Range<double>(newMin, newMax, range.Topology);
}

public static double Center(this Range<double> range)
Expand All @@ -89,12 +89,18 @@ public static TimeSpan Size(this Range<TimeSpan> range)

public static Range<double> Shift(this Range<double> range, double shift)
{
return new Range<double>(range.Minimum + shift, range.Maximum + shift);
return new Range<double>(
range.Minimum + shift,
range.Maximum + shift,
range.Topology);
}

public static Range<TimeSpan> Shift(this Range<TimeSpan> range, TimeSpan shift)
{
return new Range<TimeSpan>(range.Minimum.Add(shift), range.Maximum.Add(shift));
return new Range<TimeSpan>(
range.Minimum.Add(shift),
range.Maximum.Add(shift),
range.Topology);
}

public static Range<double> Add(this Range<double> rangeA, Range<double> rangeB)
Expand All @@ -103,7 +109,8 @@ public static Range<double> Add(this Range<double> rangeA, Range<double> rangeB)

return new Range<double>(
rangeA.Minimum + rangeB.Minimum,
rangeA.Maximum + rangeB.Maximum);
rangeA.Maximum + rangeB.Maximum,
rangeA.CombineTopology(rangeB));
}

public static Range<double> Subtract(this Range<double> rangeA, Range<double> rangeB)
Expand All @@ -112,7 +119,8 @@ public static Range<double> Subtract(this Range<double> rangeA, Range<double> ra

return new Range<double>(
rangeA.Minimum - rangeB.Maximum,
rangeA.Maximum - rangeB.Minimum);
rangeA.Maximum - rangeB.Minimum,
rangeA.CombineTopology(rangeB));
}

public static Range<double> Multiply(this Range<double> rangeA, Range<double> rangeB)
Expand All @@ -126,7 +134,8 @@ public static Range<double> Multiply(this Range<double> rangeA, Range<double> ra

return new Range<double>(
Maths.Min(a1b1, a1b2, a2b1, a2b2),
Maths.Max(a1b1, a1b2, a2b1, a2b2));
Maths.Max(a1b1, a1b2, a2b1, a2b2),
rangeA.CombineTopology(rangeB));
}

public static Range<double> Divide(this Range<double> rangeA, Range<double> rangeB)
Expand All @@ -149,25 +158,25 @@ public static Range<double> Invert(this Range<double> range)
return new Range<double>(1 / range.Maximum, double.PositiveInfinity);
}

return new Range<double>(1 / range.Maximum, 1 / range.Minimum);
return new Range<double>(1 / range.Maximum, 1 / range.Minimum, range.Topology);
}

public static Range<T> AsRange<T>(this (T Minimum, T Maximum) pair)
public static Range<T> AsRange<T>(this (T Minimum, T Maximum) pair, Topology topology = Topology.Default)
where T : struct, IComparable<T>
{
return new Range<T>(pair.Minimum, pair.Maximum);
return new Range<T>(pair.Minimum, pair.Maximum, topology);
}

public static Range<T> To<T>(this T Minimum, T Maximum)
public static Range<T> To<T>(this T minimum, T maximum, Topology topology = Topology.Default)
where T : struct, IComparable<T>
{
return new Range<T>(Minimum, Maximum);
return new Range<T>(minimum, maximum, topology);
}

public static Range<T> AsRangeFromZero<T>(this T maximum)
public static Range<T> AsRangeFromZero<T>(this T maximum, Topology topology = Topology.Default)
where T : struct, IComparable<T>
{
return new Range<T>(default(T), maximum);
return new Range<T>(default(T), maximum, topology);
}
}
}
Loading

0 comments on commit 02573e0

Please sign in to comment.