Skip to content

Commit

Permalink
Update Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
jas88 committed Dec 7, 2023
1 parent 93aaa0c commit 3080e54
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
12 changes: 7 additions & 5 deletions BadMedicine.Core/Datasets/DataGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace BadMedicine.Datasets;

/// <summary>
/// Base class for all randomly generated datasets. Handles generating random datatypes and writing
/// Base class for all randomly generated datasets. Handles generating random data types and writing
/// out to csv etc.
/// </summary>
public abstract class DataGenerator : IDataGenerator
Expand Down Expand Up @@ -95,19 +95,21 @@ public void GenerateTestDataFile(IPersonCollection cohort, FileInfo target, int
/// Returns a random <see cref="Person"/> that <see cref="IsEligible"/> for this dataset. If nobody is eligible then returns a random person.
/// </summary>
/// <param name="people"></param>
/// <param name="r"></param>
/// <param name="random"></param>
/// <returns></returns>
public Person GetRandomEligiblePerson(Person[] people, Random r)
public Person GetRandomEligiblePerson(Person[] people, Random random=null)
{
random ??= r;

if (people.Length == 0)
throw new ArgumentException("Must pass at least 1 person to GetRandomEligiblePerson", nameof(people));

var eligible = people.Where(IsEligible).ToArray();

return
eligible.Length != 0 ? eligible[r.Next(eligible.Length)]
eligible.Length != 0 ? eligible[random.Next(eligible.Length)]
//if nobody is eligible then everyone is!
: people[r.Next(people.Length)];
: people[random.Next(people.Length)];
}

/// <inheritdoc/>
Expand Down
3 changes: 1 addition & 2 deletions BadMedicine.Core/Datasets/DataGeneratorFactory.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace BadMedicine.Datasets;

/// <summary>
/// Finds Types and Creates instances of <see cref="IDataGenerator"/> implementations
/// </summary>
public class DataGeneratorFactory
public static class DataGeneratorFactory
{
/// <summary>
/// Trivial type wrapper as workaround for https://github.com/dotnet/sdk/issues/27997
Expand Down
1 change: 0 additions & 1 deletion BadMedicine/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Improve BucketList performance
- Some bugfixes change random data generation, cross-version consistency not preserved
- Add Equ 2.3.0
- BadMedicine itself now AOT/trim clean, but dependencies are not

## [1.1.2] - 2022-11-22

### Dependencies
Expand Down

0 comments on commit 3080e54

Please sign in to comment.