Skip to content

Commit

Permalink
Merge pull request #48 from VirtualPhotonics/feature/lm-ck-release-pr…
Browse files Browse the repository at this point in the history
…eparation

Feature/lm ck release preparation
  • Loading branch information
Lisa Malenfant committed Aug 29, 2022
2 parents aafde45 + 701dfe8 commit cb9001e
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 250 deletions.
4 changes: 2 additions & 2 deletions BuildTestRelease.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$mccl_version = "6.2.0"
$matlab_version = "7.0.0"
$mccl_version = "7.0.0"
$matlab_version = "8.0.0"

Invoke-Expression ".\BuildTestReleaseMCCL.ps1 $mccl_version"
Invoke-Expression ".\BuildTestReleaseMATLAB.ps1 $matlab_version"
Expand Down
7 changes: 2 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ The Virtual Photonics Technology Initiative was established by the Laser Microbe
## Virtual Tissue Simulator (VTS)
The primary vehicle for the accomplishment of these goals is the ongoing development of the Virtual Tissue Simulator (VTS). The VTS is being designed as a modular and scalable platform to provide an integrated suite of computational tools to define, solve, visualize, and analyze relevant forward and inverse radiative transport problems in Biomedical Optics. We intend to develop specific Application ToolKits (ATKs) that will provide a user-interface customized for the simulation of issues specific to an application domain. Examples include Small Animal Imaging and Fiber Optic Probe development.

## Downloads
To download the latest version, click [here](https://github.com/VirtualPhotonics/VTS/wiki/Downloads)

## Releases and Source Codes
To access all releases and source code, click [here](https://github.com/VirtualPhotonics/VTS/releases).
## Downloads and Latest Releases
To access the latest release, past releases and downloads, click [here](https://github.com/VirtualPhotonics/VTS/releases).

## Getting Started and Documentation
To access getting started instructions in Linux, Mac or Windows, click
Expand Down
16 changes: 0 additions & 16 deletions readme.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/Vts.Benchmark/Vts.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<AssemblyName>mc</AssemblyName>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<RootNamespace>Vts.MonteCarlo.CommandLineApplication</RootNamespace>
<AssemblyVersion>6.2.0.0</AssemblyVersion>
<FileVersion>6.2.0.0</FileVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<FileVersion>7.0.0.0</FileVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Company>Virtual Photonics Technology Initiative</Company>
<Product>MCCL</Product>
Expand All @@ -20,7 +20,7 @@
<RepositoryUrl>https://github.com/VirtualPhotonics/VTS</RepositoryUrl>
<PackageTags>C#;Monte-Carlo</PackageTags>
<RepositoryType>Git</RepositoryType>
<Version>6.2.0</Version>
<Version>7.0.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
22 changes: 0 additions & 22 deletions src/Vts.MonteCarlo.CommandLineApplication/readme.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<RootNamespace>Vts.MonteCarlo.PostProcessor</RootNamespace>
<AssemblyName>mc_post</AssemblyName>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<AssemblyVersion>6.2.0.0</AssemblyVersion>
<FileVersion>6.2.0.0</FileVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<FileVersion>7.0.0.0</FileVersion>
<Authors>David Cuccia; Carole Hayakawa; Lisa Malenfant; Janaka Ranasinghesagara; Jennifer Nguyen; Adam Gardner; Michele Martinelli</Authors>
<Company>Virtual Photonics Technology Initiative</Company>
<Product>MCPP</Product>
Expand All @@ -20,7 +20,7 @@
<RepositoryType>Git</RepositoryType>
<PackageTags>C#;Monte-Carlo</PackageTags>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>6.2.0</Version>
<Version>7.0.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
86 changes: 0 additions & 86 deletions src/Vts.Test/IO/FileIOTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,6 @@ public void validate_read_array_from_binary_in_resources_without_parameter_dimen
Assert.IsTrue(Math.Abs(data[2] - 0.052445) < 0.000001);
}

[Test]
public void validate_read_from_binary_in_resources()
{
var name = Assembly.GetExecutingAssembly().FullName;
var assemblyName = new AssemblyName(name).Name;
double data;
data = FileIO.ReadFromBinaryInResources<double>(
"Resources/fileiotest/binarydbl", assemblyName);
Assert.AreEqual(10, data);
}

[Test]
public void validate_read_from_binary_in_resources_custom()
{
Expand All @@ -221,25 +210,6 @@ public void validate_read_from_binary_custom()
Assert.AreEqual(16, arrayRead[1]);
}

[Test]
public void validate_read_from_binary_stream()
{
var name = Assembly.GetExecutingAssembly().FullName;
var assemblyName = new AssemblyName(name).Name;
int size = 100;
double[] arrayWritten;
// read file from resources and write it so that can be read in
arrayWritten = (double[])FileIO.ReadArrayFromBinaryInResources<double>
("Resources/fileiotest/ROfRho", assemblyName, size);
FileIO.WriteToBinary<double[]>(arrayWritten, "array5");
double[] arrayRead;
using (Stream stream = StreamFinder.GetFileStream("array5", FileMode.Open))
{
arrayRead = FileIO.ReadFromBinaryStream<double[]>(stream);
}
Assert.IsTrue(Math.Abs(arrayRead[2] - 0.052445) < 0.000001);
}

[Test]
public void validate_read_from_json()
{
Expand Down Expand Up @@ -334,44 +304,6 @@ public void validate_write_scalar_value_to_binary_and_read_scalar_value_from_bin
Assert.AreEqual(11, data);
}

[Test]
public void validate_write_to_binary_and_read_from_binary()
{
double[] array = new double[3] { 4.0, 5.0, 6.0 };
FileIO.WriteToBinary(array, "array2");
Assert.IsTrue(FileIO.FileExists("array2"));
Assert.IsTrue(new FileInfo("array2").Length != 0);
var data = FileIO.ReadFromBinary<double[]>("array2");
Assert.AreEqual(4.0, data[0]);
}

[Test]
public void Validate_write_to_binary_stream_throws_exception()
{
Assert.Throws<ArgumentNullException>(() =>
{
using (Stream stream = new MemoryStream(8))
{
FileIO.WriteToBinaryStream<double[]>(null, stream);
}
});
}

[Test]
public void validate_write_2D_array_to_binary_and_read_from_binary()
{
var array = new double[,]
{
{1D, 2D},
{3D, 4D}
};
FileIO.WriteToBinary(array, "2darray");
Assert.IsTrue(FileIO.FileExists("2darray"));
Assert.IsTrue(new FileInfo("2darray").Length != 0);
var data = FileIO.ReadFromBinary<double[,]>("2darray");
Assert.AreEqual(2D, data[0, 1]);
}

[Test]
public void validate_write_to_binary_custom()
{
Expand All @@ -382,24 +314,6 @@ public void validate_write_to_binary_custom()
Assert.IsTrue(new FileInfo("array3").Length != 0);
}

[Test]
public void validate_write_to_binary_stream_and_read_from_binary_stream()
{
// first create stream, write array, validate written and close stream
double[] array = new double[3] { 10, 11, 12 };
Stream streamWrite = StreamFinder.GetFileStream("array4", FileMode.Create);
FileIO.WriteToBinaryStream(array, streamWrite);
Assert.IsNotNull(streamWrite);
Assert.IsTrue(FileIO.FileExists("array4"));
Assert.IsTrue(new FileInfo("array4").Length != 0);
streamWrite.Close();
// then open stream, read array, validate values and close stream
Stream streamRead = StreamFinder.GetFileStream("array4", FileMode.Open);
var data = FileIO.ReadFromBinaryStream<double[]>(streamRead);
Assert.AreEqual(10, data[0]);
streamRead.Close();
}

[Test]
public void validate_write_to_json()
{
Expand Down
42 changes: 29 additions & 13 deletions src/Vts.Test/MonteCarlo/Factories/DetectorFactoryTests.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using System;
using MathNet.Numerics.Random;
using Moq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
// using the following for user-defined ROfXDetector implementation
using System.Runtime.Serialization;
using Vts.Common;
using Vts.IO;
using Vts.MonteCarlo;
using Vts.MonteCarlo.Detectors;
using Vts.MonteCarlo.Factories;

// using the following for user-defined ROfXDetector implementation
using System.Runtime.Serialization;
using MathNet.Numerics.Random;
using Moq;
using Vts.IO;
using Vts.MonteCarlo.Helpers;
using Vts.MonteCarlo.IO;
using Vts.MonteCarlo.PhotonData;
Expand All @@ -37,6 +36,7 @@ public class DetectorFactoryTests
{
"file.txt" // file that captures screen output of MC simulation
};

/// <summary>
/// clear all generated folders and files
/// </summary>
Expand All @@ -46,18 +46,25 @@ public void Clear_folders_and_files()
{
foreach (var folder in listOfTestGeneratedFolders)
{
FileIO.DeleteDirectory(folder);
if (Directory.Exists(folder))
{
FileIO.DeleteDirectory(folder);
}
}
foreach (var file in listOfTestGeneratedFiles)
{
FileIO.FileDelete(file);
if (File.Exists(file))
{
FileIO.FileDelete(file);
}
}
}

/// <summary>
/// Simulate null return of GetDetector(s)
/// </summary>
[Test]
public void Demonstate_GetDetectors_null_return_on_empty_list()
public void Demonstrate_GetDetectors_null_return_on_empty_list()
{
IEnumerable<IDetectorInput> emptyDetectorList = null;
Assert.IsNull(DetectorFactory.GetDetectors(
Expand Down Expand Up @@ -120,6 +127,7 @@ public void Demonstrate_fluent_mc_creation()
[Test]
public void Demonstrate_user_defined_detector_usage()
{
// Add detector to ConventionBasedConverter _classInfoDictionary
DetectorFactory.RegisterDetector(
typeof (ROfXDetectorInput), typeof (ROfXDetector));
var detectorInput = new ROfXDetectorInput
Expand All @@ -141,9 +149,17 @@ public void Demonstrate_user_defined_detector_usage()
Assert.IsTrue(detectorExists);
var firstValue = ((ROfXDetector)detector).Mean.FirstOrDefault();
Assert.IsTrue(firstValue != 0);

// write detector to folder "user_defined_detector"
DetectorIO.WriteDetectorToFile(detector, "user_defined_detector");
DetectorIO.ReadDetectorFromFile("user_defined_detector", "");

// read detector filename="My First R(x) Detector" from folder "user_defined_detector"
var detectorFromFile = DetectorIO.ReadDetectorFromFile(detectorInput.Name, "user_defined_detector");
Assert.IsNotNull(detectorFromFile);
Assert.AreEqual(detector.Name, detectorFromFile.Name);
Assert.AreEqual(detector.TallyType, detectorFromFile.TallyType);
}

/// <summary>
/// tests to verify exception returns from RegisterDetector
/// </summary>
Expand Down
34 changes: 31 additions & 3 deletions src/Vts/IO/ConventionBasedConverter.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq;

namespace Vts.IO
{
Expand All @@ -16,6 +16,7 @@ public class ConventionBasedConverter<TInterface> : JsonCreationConverter<TInter
private readonly string _typeCategoryString;
private readonly IDictionary<string, VtsClassInfo> _classInfoDictionary;
private readonly ServiceProvider _serviceProvider;
private readonly List<ServiceProvider> _userDefinedServiceProviders = new List<ServiceProvider>();

/// <summary>
/// Internal class for holding on to necessary class info for future instantiation
Expand Down Expand Up @@ -114,10 +115,37 @@ protected override TInterface Create(Type objectType, JObject jObject)
var classInfo = _classInfoDictionary[classPrefixString];

var classInstance = (TInterface)_serviceProvider.GetService(classInfo.ClassType);

if (classInstance != null) return classInstance;
foreach (var instance in _userDefinedServiceProviders.Select(provider => (TInterface)provider.GetService(classInfo.ClassType)).Where(instance => instance != null))
{
return instance;
}

return classInstance;
}

/// <summary>
///
/// </summary>
/// <param name="objectType"></param>
/// <param name="className"></param>
/// <param name="classPrefixString"></param>
public void AddUserDefinedServices(Type objectType, string className, string classPrefixString)
{
var classInfo = new VtsClassInfo
{
ClassName = className,
ClassPrefixString = classPrefixString,
ClassType = objectType
};
_classInfoDictionary.Add(classPrefixString, classInfo);
var services = new ServiceCollection();
services.AddTransient(classInfo.ClassType);
var serviceProvider = services.BuildServiceProvider();
_userDefinedServiceProviders.Add(serviceProvider);
}

/// <summary>
/// method to determine if field exists
/// </summary>
Expand Down
Loading

0 comments on commit cb9001e

Please sign in to comment.