Skip to content

Commit

Permalink
Bump YamlDotNet from 13.4.0 to 13.5.2 (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Oct 9, 2023
1 parent b694a8c commit edb1e99
Show file tree
Hide file tree
Showing 36 changed files with 1,246 additions and 1,271 deletions.
2 changes: 1 addition & 1 deletion BadMedicine.Core/BadMedicine.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Copyright>Copyright 2019</Copyright>
<PackageId>HIC.BadMedicine</PackageId>
<Authors>Health Informatics Centre - University of Dundee</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<StartupObject></StartupObject>
<ApplicationIcon />
Expand Down
20 changes: 10 additions & 10 deletions BadMedicine.Core/BucketList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace BadMedicine
/// <typeparam name="T"></typeparam>
public class BucketList<T>
{

readonly List<T> _buckets = new List<T>();
readonly List<int> _probabilities = new List<int>();

Expand All @@ -26,9 +26,9 @@ public T GetRandom(Random r)
//cache the total
_total = _total??_probabilities.Sum();

int toPick = r.Next(0, _total.Value);
var toPick = r.Next(0, _total.Value);

for (int i = 0; i < _probabilities.Count; i++)
for (var i = 0; i < _probabilities.Count; i++)
{
toPick -= _probabilities[i];
if (toPick < 0)
Expand All @@ -37,7 +37,7 @@ public T GetRandom(Random r)

throw new Exception("Could not GetRandom");
}


/// <summary>
/// Returns a random bucket from the element indices provided (based on the probability of each bucket)
Expand All @@ -49,21 +49,21 @@ public T GetRandom(IEnumerable<int> usingOnlyIndices, Random r)
{
var idx = usingOnlyIndices.ToList();

int total = idx.Sum(t=>_probabilities[t]);
int toPick = r.Next(0, total);
var total = idx.Sum(t=>_probabilities[t]);

var toPick = r.Next(0, total);

foreach (int i in idx)
foreach (var i in idx)
{
toPick -= _probabilities[i];
if (toPick < 0)
return _buckets[i];
}

throw new Exception("Could not GetRandom");
}



/// <summary>
/// Adds a new bucket to the list which will be returned using the total <paramref name="probability"/> ratio (relative
Expand Down
2 changes: 1 addition & 1 deletion BadMedicine.Core/Datasets/Appointment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Appointment
/// <param name="r"></param>
public Appointment(Person testPerson, Random r)
{
Identifier = "APPT_" + Guid.NewGuid();
Identifier = $"APPT_{Guid.NewGuid()}";
StartDate = testPerson.GetRandomDateDuringLifetime(r);
}
}
Expand Down
6 changes: 3 additions & 3 deletions BadMedicine.Core/Datasets/Biochemistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public Biochemistry(Random rand) : base(rand)
/// <inheritdoc/>
public override object[] GenerateTestDataRow(Person p)
{
object[] results = new object[13];
var results = new object[13];

var randomSample = new BiochemistryRecord(r);

BiochemistryRecord randomSample = new BiochemistryRecord(r);

results[0] = p.CHI;
results[1] = randomSample.Healthboard;
results[2] = p.GetRandomDateDuringLifetime(r);
Expand Down
24 changes: 12 additions & 12 deletions BadMedicine.Core/Datasets/BiochemistryRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class BiochemistryRecord

/// <include file='../../Datasets.doc.xml' path='Datasets/Biochemistry/Field[@name="Result"]'/>
public string Result;

/// <include file='../../Datasets.doc.xml' path='Datasets/Biochemistry/Field[@name="ReadCodeValue"]'/>
public string ReadCodeValue;

Expand Down Expand Up @@ -82,35 +82,35 @@ public BiochemistryRecord(Random r)
QuantityUnit = row.QuantityUnit;
RangeHighValue = row.RangeHighValue.HasValue ? row.RangeHighValue.ToString():"NULL";
RangeLowValue = row.RangeLowValue.HasValue ? row.RangeLowValue.ToString():"NULL";

Healthboard = row.hb_extract;
ReadCodeValue = row.ReadCodeValue;
}



private string GetRandomLabNumber(Random r )
{
if(r.Next(0,2)==0)
return "CC" + r.Next(0, 1000000);
return $"CC{r.Next(0, 1000000)}";

return "BC" + r.Next(0, 1000000);
return $"BC{r.Next(0, 1000000)}";
}
private void Initialize()
{
using (DataTable dt = new DataTable())
using (var dt = new DataTable())
{
dt.Columns.Add("RecordCount",typeof(int));

DataGenerator.EmbeddedCsvToDataTable(typeof(BiochemistryRecord),"Biochemistry.csv",dt);

_bucketList = new BucketList<BiochemistryRandomDataRow>();

foreach (DataRow row in dt.Rows)
_bucketList.Add((int)row["RecordCount"], new BiochemistryRandomDataRow(row));
}
}

private class BiochemistryRandomDataRow
{
public string LocalClinicalCodeValue;
Expand All @@ -134,10 +134,10 @@ public BiochemistryRandomDataRow(DataRow row)
ArithmeticComparator =(string) row["ArithmeticComparator"];
Interpretation =(string) row["Interpretation"];
QuantityUnit =(string) row["QuantityUnit"];

RangeHighValue = double.TryParse(row["RangeHighValue"].ToString(),out var rangeLow) ? rangeLow:(double?) null;
RangeLowValue = double.TryParse(row["RangeLowValue"].ToString(),out var rangeHigh) ? rangeHigh:(double?) null;

QVAverage = double.TryParse(row["QVAverage"].ToString(),out var min) ? min:(double?) null;
QVStandardDev = double.TryParse(row["QVStandardDev"].ToString(),out var dev) ? dev:(double?) null;

Expand All @@ -153,7 +153,7 @@ internal string GetQVResult(Random r)
{
if(QVAverage.HasValue && QVStandardDev.HasValue)
return new Normal(QVAverage.Value, QVStandardDev.Value,r).Sample().ToString();

return null;
}
}
Expand Down
10 changes: 5 additions & 5 deletions BadMedicine.Core/Datasets/CarotidArteryScan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public CarotidArteryScan(Random rand) : base(rand)
/// <inheritdoc/>
public override object[] GenerateTestDataRow(Person p)
{
object[] results = new object[68];
var results = new object[68];

var appointment = new Appointment(p,r);

results[0] = appointment.Identifier; //RECORD_NUMBER
results[1] = 0; //R_CC_STEN_A
results[2] = 0; //R_CC_STEN_B
Expand Down Expand Up @@ -74,7 +74,7 @@ public override object[] GenerateTestDataRow(Person p)
results[43] = Swap(Math.Max(1, GetGaussianInt(-5, 9)), new[] { 6, 7, 8 }, 1); //L_CC_STENOSIS (lots of 1's some non ones but no 6,7 or 8s
results[44] = GetGaussian(0,2); //L_CC_PEAK_SYS
results[45] = GetGaussian(0,0.09); //L_GetGaussian(0,2);
results[46] = Swap(GetGaussianInt(1,8),new[]{7},9); //L_IC_STENOSIS
results[46] = Swap(GetGaussianInt(1,8),new[]{7},9); //L_IC_STENOSIS
results[47] = GetGaussian(0,4); //L_IC_PEAK_SYS
results[48] = GetGaussian(0,4); //L_IC_END_DIA
results[49] = Math.Max(1, GetGaussianInt(0, 9)); //L_EC_STENOSIS
Expand Down Expand Up @@ -177,5 +177,5 @@ protected override string[] GetHeaders()
"R_IC_END_DIA" //67
};
}
}
}
}
Loading

0 comments on commit edb1e99

Please sign in to comment.