Skip to content

Commit

Permalink
PR review code clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
hayakawa16 committed Feb 28, 2024
1 parent 7a86d09 commit 6f8a824
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void validate_underlying_multilayer_tissue_definition()
var result = SimulationInputValidation.ValidateInput(input);
Assert.IsFalse(result.IsValid);
}

/// <summary>
/// Test to check that infinite cylinders have non-zero axis definitions.
/// </summary>
Expand Down Expand Up @@ -231,6 +232,7 @@ public void validate_infinite_cylinders_are_within_tissue_layer()
var result = SimulationInputValidation.ValidateInput(input);
Assert.IsFalse(result.IsValid);
}

/// <summary>
/// Test to check that infinite cylinders refractive index matches refractive index of surrounding layer
/// </summary>
Expand Down Expand Up @@ -276,6 +278,7 @@ public void validate_infinite_cylinders_refractive_index_matches_that_of_surroun
var result = SimulationInputValidation.ValidateInput(input);
Assert.IsFalse(result.IsValid);
}

/// <summary>
/// Test to check two layer tissue with one layer enclosing concentric infinite cylinders works
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void validate_underlying_multilayer_tissue_definition()
var result = SimulationInputValidation.ValidateInput(input);
Assert.IsFalse(result.IsValid);
}

/// <summary>
/// Test to check that infinite cylinders have non-zero axis definitions.
/// </summary>
Expand Down Expand Up @@ -87,6 +88,7 @@ public void validate_infinite_cylinder_has_nonzero_radii()
var result = SimulationInputValidation.ValidateInput(input);
Assert.IsFalse(result.IsValid);
}

/// <summary>
/// Test to check that at least one tissue layer is defined
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void Verify_OnBoundary_method_returns_correct_result()
result = _infiniteCylinderTissueRegion.OnBoundary(new Position(0, 0, 2.0));
Assert.IsFalse(result);
}

/// <summary>
/// Validate method SurfaceNormal return correct normal vector. Should be outward directed normal.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public void Verify_GetNeighborRegionIndex_method_returns_correct_result()
index = _tissue.GetNeighborRegionIndex(photon);
Assert.AreEqual(2, index);
}

/// <summary>
/// Test to make sure that shortest distance to layer boundary or infinite cylinders is correct
/// </summary>
Expand Down Expand Up @@ -281,6 +282,5 @@ public void Verify_GetAngleRelativeToBoundaryNormal_method_returns_correct_resul
var cosTheta = _tissue.GetAngleRelativeToBoundaryNormal(photon);
Assert.AreEqual(1,cosTheta);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using Vts.Common;
using Vts.IO;
using Vts.MonteCarlo;
Expand Down Expand Up @@ -88,6 +87,7 @@ public void Validate_deserialized_class_is_correct()

Assert.AreEqual(iCloned.Regions[1].RegionOP.Mua, i.Regions[1].RegionOP.Mua);
}

/// <summary>
/// verify MultiConcentricInfiniteCylinderTissueInput deserializes correctly when using FileIO
/// </summary>
Expand Down Expand Up @@ -124,6 +124,7 @@ public void Validate_deserialized_class_is_correct_when_using_FileIO()

Assert.AreEqual(iCloned.Regions[1].RegionOP.Mua, i.Regions[1].RegionOP.Mua);
}

/// <summary>
/// verify CreateTissue generates ITissue
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void Verify_GetReflectedDirection_method_returns_correct_result()
Assert.AreEqual(0, reflectedDir.Uy);
Assert.IsTrue(Math.Abs(reflectedDir.Uz + 1/Math.Sqrt(2)) < 1e-7);
}

/// <summary>
/// Validate method GetReflectedDirection returns correct direction.
/// </summary>
Expand Down Expand Up @@ -172,6 +173,7 @@ public void Verify_GetRefractedDirection_method_returns_correct_result()
refractedDir.Uy * refractedDir.Uy +
refractedDir.Uz * refractedDir.Uz) - 1 < 1e-6);
}

/// <summary>
/// Validate method GetAngleRelativeToBoundaryNormal return correct value. Note that this
/// gets called by Photon method CrossRegionOrReflect. All return values
Expand Down Expand Up @@ -207,6 +209,5 @@ public void Verify_GetAngleRelativeToBoundaryNormal_method_returns_correct_resul
dirCosine = _tissueWithEllipsoid.GetAngleRelativeToBoundaryNormal(photon);
Assert.AreEqual(1, dirCosine);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void Validate_default_constructor()
Assert.AreEqual(1.0, cylinder.Center.Z);
Assert.AreEqual(50.0, layers[1].Center.Z);
}

/// <summary>
/// verify SingleInfiniteCylinderTissueInput deserializes correctly
/// </summary>
Expand Down Expand Up @@ -73,6 +74,7 @@ public void Validate_deserialized_class_is_correct()

Assert.AreEqual(iCloned.Regions[1].RegionOP.Mua, i.Regions[1].RegionOP.Mua);
}

/// <summary>
/// verify SingleInfiniteCylinderTissueInput deserializes correctly when using FileIO
/// </summary>
Expand Down Expand Up @@ -102,6 +104,7 @@ public void Validate_deserialized_class_is_correct_when_using_FileIO()

Assert.AreEqual(iCloned.Regions[1].RegionOP.Mua, i.Regions[1].RegionOP.Mua);
}

/// <summary>
/// verify CreateTissue generates ITissue
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private static ValidationResult ValidateGeometry(IList<LayerTissueRegion> layers
{
// check that layer definition is valid
var tempResult = MultiLayerTissueInputValidation.ValidateLayers(layers);
if (!tempResult.IsValid){ return tempResult; }
if (!tempResult.IsValid) return tempResult;

if (infiniteCylinder.Radius == 0.0)
{
Expand All @@ -45,7 +45,7 @@ private static ValidationResult ValidateGeometry(IList<LayerTissueRegion> layers
"SingleInfiniteCylinderTissueInput: infinite cylinder has radius equal to 0",
"SingleInfiniteCylinderTissueInput: make sure infinite cylinder radius is > 0");
}
if (!tempResult.IsValid) { return tempResult; }
if (!tempResult.IsValid) return tempResult;

// test for air layers and eliminate from list
var tissueLayers = layers.Where(layer => !layer.IsAir());
Expand All @@ -59,7 +59,7 @@ private static ValidationResult ValidateGeometry(IList<LayerTissueRegion> layers
"SingleInfiniteCylinderTissueInput: tissue layer is assumed to be at least a single layer with air layer above and below",
"SingleInfiniteCylinderTissueInput: redefine tissue definition to contain at least a single layer of tissue");
}
if (!tempResult.IsValid) { return tempResult; }
if (!tempResult.IsValid) return tempResult;

// check that cylinder is contained within a tissue layer
var cylinderRadius = infiniteCylinder.Radius;
Expand All @@ -78,7 +78,7 @@ private static ValidationResult ValidateGeometry(IList<LayerTissueRegion> layers
"Resize radii and or Center so that infinite cylinders entirely within tissue layer");
}

if (!tempResult.IsValid) { return tempResult; }
if (!tempResult.IsValid) return tempResult;

return new ValidationResult(
true,
Expand Down

0 comments on commit 6f8a824

Please sign in to comment.