public void TestSerializationWithRelatedColumnExplicitelyAfter() { var baseGrid = new BaseGrid("Bastian", DimensionTime) { Values = new float[] { 0F, 3600F, 7200F } }; var x1 = new DataColumn("Columbus", DimensionLength, baseGrid); var relColG = new DataColumn("RenateG", DimensionLess, baseGrid); relColG.DataInfo = new DataInfo(ColumnOrigins.ObservationAuxiliary, AuxiliaryType.GeometricStdDev, " ", new DateTime(2010, 10, 22), "Study1", "Dog", 2.4); x1.AddRelatedColumn(relColG); var relColA = new DataColumn("RenateA", DimensionLength, baseGrid); relColA.DataInfo = new DataInfo(ColumnOrigins.ObservationAuxiliary, AuxiliaryType.ArithmeticStdDev, "cm", new DateTime(2010, 10, 22), "Study1", "Dog", 2.4); x1.AddRelatedColumn(relColA); var dr1 = new DataRepository("id") { x1, relColG, relColA }; var dr2 = SerializeAndDeserialize(dr1); var x2 = dr2.AllButBaseGrid().First(x => x.IsNamed("Columbus")); AssertForSpecs.AreEqualMcDataColumn(x1, x2); }
private DataRepository dataForSelectedOntogeny(Unit xUnit, Unit yUnit) { var dataRepository = new DataRepository { Name = PKSimConstants.UI.OntogenyFor(_dto.SelectedOntogeny.DisplayName) }; var pma = new BaseGrid(PKSimConstants.UI.PostMenstrualAge, _dimensionRepository.AgeInYears) { DisplayUnit = xUnit }; var mean = new DataColumn(dataRepository.Name, _dimensionRepository.Fraction, pma) { DisplayUnit = yUnit }; var std = new DataColumn(PKSimConstants.UI.StandardDeviation, _dimensionRepository.Fraction, pma) { DisplayUnit = yUnit }; mean.DataInfo.AuxiliaryType = AuxiliaryType.GeometricMeanPop; std.AddRelatedColumn(mean); dataRepository.Add(mean); dataRepository.Add(std); var allOntogenies = _ontogenyRepository.AllValuesFor(_dto.SelectedOntogeny, _dto.SelectedContainer.Name).OrderBy(x => x.PostmenstrualAge).ToList(); pma.Values = values(allOntogenies, x => x.PostmenstrualAge); mean.Values = values(allOntogenies, x => x.OntogenyFactor); std.Values = values(allOntogenies, x => x.Deviation); return(dataRepository); }
protected override void Context() { base.Context(); var path = new List <string>(new[] { "aa", "bb" }); _baseGrid = new BaseGrid("Bastian", DimensionTime) { Values = new[] { 0F, 3600F, 7200F } }; _col1 = new DataColumn("Columbus", DimensionLength, _baseGrid) { QuantityInfo = new QuantityInfo("Quain", path, QuantityType.Parameter), DataInfo = new DataInfo(ColumnOrigins.Observation, AuxiliaryType.Undefined, "cm", new DateTime(2010, 10, 22), "Study1", "Dog", 2.4), Values = new[] { 1.0F, 2.1F, -3.4F } }; _relCol = new DataColumn("Renate", DimensionLength, _baseGrid); _relCol.DataInfo = new DataInfo(ColumnOrigins.ObservationAuxiliary, AuxiliaryType.ArithmeticStdDev, "cm", new DateTime(2010, 10, 22), "Study1", "Dog", 2.4); _col2 = new DataColumn("Columbine", DimensionLength, _baseGrid); _col2.AddRelatedColumn(_relCol); _col3 = new DataColumn("Colette", DimensionLength, _baseGrid); _col3.AddRelatedColumn(_relCol); }
public void TestSerializationWithRelatedColumnExplicitelyBefore() { var baseGrid = new BaseGrid("Bastian", DimensionTime) { Values = new float[] { 0F, 3600F, 7200F } }; var x1 = new DataColumn("Columbus", DimensionLength, baseGrid) { IsInternal = false }; var relCol = new DataColumn("Renate", DimensionLess, baseGrid) { DataInfo = new DataInfo(ColumnOrigins.ObservationAuxiliary, AuxiliaryType.GeometricStdDev, " ", new DateTime(2010, 10, 22), "Study1", "Dog", 2.4) }; x1.AddRelatedColumn(relCol); var dr1 = new DataRepository("id") { x1, relCol }; var dr2 = SerializeAndDeserialize(dr1); var x2 = dr2.AllButBaseGrid().First(x => x.IsNamed("Columbus")); AssertForSpecs.AreEqualMcDataColumn(x1, x2); x2.RelatedColumns.First().Dimension.ShouldNotBeNull(); }
protected override Task Context() { _quantityInfoMapper = A.Fake <QuantityInfoMapper>(); _dataInfoMapper = A.Fake <DataInfoMapper>(); _dimensionRepository = A.Fake <IDimensionRepository>(); sut = new DataColumnMapper(_dataInfoMapper, _quantityInfoMapper, _dimensionRepository); var observedData = DomainHelperForSpecs.ObservedData(); _dataColumn = observedData.ObservationColumns().First(); _baseGrid = observedData.BaseGrid; _relatedColumn = new DataColumn("related", DomainHelperForSpecs.NoDimension(), observedData.BaseGrid) { Values = new[] { 0f, 0f, 0f }, DataInfo = { Origin = ColumnOrigins.ObservationAuxiliary } }; _dataColumn.AddRelatedColumn(_relatedColumn); _quantityInfoSnapshot = new Snapshots.QuantityInfo(); _dataInfoSnapshot = new Snapshots.DataInfo(); A.CallTo(() => _quantityInfoMapper.MapToSnapshot(_dataColumn.QuantityInfo)).Returns(_quantityInfoSnapshot); A.CallTo(() => _dataInfoMapper.MapToSnapshot(_dataColumn.DataInfo)).Returns(_dataInfoSnapshot); A.CallTo(() => _dimensionRepository.DimensionByName(_dataColumn.Dimension.Name)).Returns(_dataColumn.Dimension); A.CallTo(() => _dimensionRepository.DimensionByName(_baseGrid.Dimension.Name)).Returns(_baseGrid.Dimension); return(Task.FromResult(true)); }
public DataColumn AddErrorColumn(DataColumn column, string name, string errorType) { if (!Enum.TryParse(errorType, out AuxiliaryType auxiliaryType)) { throw new OSPSuiteException(Error.InvalidAuxiliaryType); } DataColumn errorColumn; switch (auxiliaryType) { case AuxiliaryType.ArithmeticStdDev: errorColumn = new DataColumn(name, column.Dimension, column.BaseGrid) { DisplayUnit = column.DisplayUnit }; break; case AuxiliaryType.GeometricStdDev: errorColumn = new DataColumn(name, NO_DIMENSION, column.BaseGrid); break; default: throw new OSPSuiteException(Error.InvalidAuxiliaryType); } errorColumn.DataInfo.AuxiliaryType = auxiliaryType; errorColumn.DataInfo.Origin = ColumnOrigins.ObservationAuxiliary; column.AddRelatedColumn(errorColumn); //May be null if the method is called for an orphan column... Does not make sense column.Repository?.Add(errorColumn); return(errorColumn); }
protected override void Context() { base.Context(); _baseGrid1.Values = new List <float> { 1f, 2f, 3f }; _col1 = new DataColumn("col1", "col1", _length, _baseGrid1) { Values = new[] { 1f, 11f, 111f } }; _col2 = new DataColumn("col2", "col2", _length, _baseGrid1) { Values = new[] { 2f, 22f, 222f } }; _col3 = new DataColumn("col3", "col3", _length, _baseGrid1) { Values = new[] { 3f, 33f, 333f } }; _col3.DataInfo.AuxiliaryType = AuxiliaryType.ArithmeticStdDev; _col1.AddRelatedColumn(_col3); _valuesToAdd = new Cache <string, float>(); sut.Add(_col1); sut.Add(_col2); sut.Add(_col3); }
public DataRepository CreateFor(string confidenceIntervalName, double[] confidenceInterval, OutputMapping outputMapping, OptimizationRunResult runResult) { if (confidenceInterval == null) { return(new NullDataRepository()); } var fullOutputPath = outputMapping.FullOutputPath; var dataRepository = new DataRepository().WithName(fullOutputPath); var simulationResult = runResult.SimulationResultFor(fullOutputPath); var simulationBaseGrid = simulationResult.BaseGrid; var timeGrid = new BaseGrid(simulationBaseGrid.Name, simulationBaseGrid.Dimension) { Values = simulationBaseGrid.Values, DataInfo = simulationBaseGrid.DataInfo.Clone(), QuantityInfo = simulationBaseGrid.QuantityInfo.Clone(), }; var outputColumn = new DataColumn(simulationResult.Name, simulationResult.Dimension, timeGrid) { Values = simulationResult.Values, DataInfo = simulationResult.DataInfo.Clone(), QuantityInfo = simulationResult.QuantityInfo.Clone(), }; outputColumn.DataInfo.AuxiliaryType = outputMapping.Scaling == Scalings.Linear ? AuxiliaryType.ArithmeticMeanPop : AuxiliaryType.GeometricMeanPop; var interval = new DataColumn(confidenceIntervalName, simulationResult.Dimension, timeGrid) { DisplayUnit = simulationResult.DisplayUnit, Values = confidenceInterval.ToFloatArray(), QuantityInfo = simulationResult.QuantityInfo.Clone(), DataInfo = { Origin = ColumnOrigins.CalculationAuxiliary, MolWeight = outputColumn.DataInfo.MolWeight }, }; outputColumn.IsInternal = true; interval.AddRelatedColumn(outputColumn); dataRepository.Add(interval); return(dataRepository); }
private IEnumerable <DataColumn> createRepository3DataColumns(IContainer organism, IQuantity q1, BaseGrid baseGrid3) { List <DataColumn> columns = new List <DataColumn>(); var arterialBlood = organism.GetSingleChildByName <IContainer>("ArterialBlood"); var q2 = arterialBlood.GetSingleChildByName <IQuantity>("Q"); var dc1A = new DataColumn("Spec1", q1.Dimension, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.Observation, AuxiliaryType.Undefined, q1.Dimension.DefaultUnitName, "Patient A", 320) { LLOQ = 1000 }, QuantityInfo = Helper.CreateQuantityInfo(q1), Values = new[] { 1.5F, 0.8F, Single.PositiveInfinity } }; columns.Add(dc1A); var dc2AStdDevA = new DataColumn("Spec2DevA", q2.Dimension, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.ObservationAuxiliary, AuxiliaryType.ArithmeticStdDev, q2.Dimension.DefaultUnitName, "Patient A", 320), QuantityInfo = Helper.CreateQuantityInfo(q2), Values = new[] { 0.6F, 0.2F, 0.8F } }; var dc2A = new DataColumn("Spec2", q2.Dimension, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.Observation, AuxiliaryType.Undefined, q2.Dimension.DefaultUnitName, "Patient A", 320) { LLOQ = 1000 }, QuantityInfo = Helper.CreateQuantityInfo(q2), Values = new[] { 2.3F, 0.8F, 0.4F } }; dc2A.AddRelatedColumn(dc2AStdDevA); columns.Add(dc2A); var dc1B = new DataColumn("Spec1", q1.Dimension, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.Observation, AuxiliaryType.Undefined, q1.Dimension.DefaultUnitName, "Patient B", 320) { LLOQ = 1000 }, QuantityInfo = Helper.CreateQuantityInfo(q1), Values = new[] { 1.6F, 1.1F, 3.9F } }; columns.Add(dc1B); var dimless = _dimensionFactory.Dimension("Dimensionless"); var dc2BStdDevG = new DataColumn("Spec2DevG", dimless, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.ObservationAuxiliary, AuxiliaryType.GeometricStdDev, dimless.DefaultUnitName, "Patient B", 320), QuantityInfo = Helper.CreateQuantityInfo(q2), Values = new[] { 0.1F, 0.1F, 0.15F } }; var dc2B = new DataColumn("Spec2", q2.Dimension, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.Observation, AuxiliaryType.Undefined, q2.Dimension.DefaultUnitName, "Patient B", 320) { LLOQ = 1000 }, QuantityInfo = Helper.CreateQuantityInfo(q2), Values = new[] { 2.1F, 0.4F, 3.3F } }; dc2B.AddRelatedColumn(dc2BStdDevG); columns.Add(dc2B); var length = _dimensionFactory.Dimension("Length"); var dc3L1 = new DataColumn("Length1", length, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.Observation, AuxiliaryType.Undefined, length.DefaultUnitName, "Patient A", 320) { LLOQ = 1000 }, QuantityInfo = Helper.CreateQuantityInfo(q1), Values = new[] { 1.1F, 1.8F, 1.4F } }; columns.Add(dc3L1); var dc3L2 = new DataColumn("Length2", length, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.Observation, AuxiliaryType.Undefined, length.DefaultUnitName, "Patient A", 320) { LLOQ = 1000 }, QuantityInfo = Helper.CreateQuantityInfo(q1), Values = new[] { 2.1F, 2.8F, 2.4F } }; columns.Add(dc3L2); var dc0 = new DataColumn("ValuesWith0", length, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.Observation, AuxiliaryType.Undefined, length.DefaultUnitName, "Patient A", 320) { LLOQ = 1000 }, QuantityInfo = Helper.CreateQuantityInfo(q1), Values = new[] { 0F, 0F, 1F } }; columns.Add(dc0); var dcX1ArithMeanPop = new DataColumn("X1_ArithMeanPop", length, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.Calculation, AuxiliaryType.ArithmeticMeanPop, length.DefaultUnitName, "Patient A", 320), QuantityInfo = Helper.CreateQuantityInfo(q2), Values = new[] { 2.3F, 0.8F, 3.4F } }; columns.Add(dcX1ArithMeanPop); var dcX1ArithMeanStdDev = new DataColumn("X1_ArithMeanStdDev", length, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.Calculation, AuxiliaryType.Undefined, length.DefaultUnitName, "Patient A", 320), QuantityInfo = Helper.CreateQuantityInfo(q2), Values = new[] { 0.4F, 0.2F, 0.3F } }; dcX1ArithMeanStdDev.AddRelatedColumn(dcX1ArithMeanPop); columns.Add(dcX1ArithMeanStdDev); var dcX1GeomMeanPop = new DataColumn("X1_GeomMeanPop", length, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.Calculation, AuxiliaryType.GeometricMeanPop, length.DefaultUnitName, "Patient A", 320), QuantityInfo = Helper.CreateQuantityInfo(q2), Values = new[] { 2.3F, 0.8F, 3.4F } }; columns.Add(dcX1GeomMeanPop); var dcX1GeomMeanStdDev = new DataColumn("X1_GeomMeanStdDev", dimless, baseGrid3) { DataInfo = new DataInfo(ColumnOrigins.Calculation, AuxiliaryType.Undefined, dimless.DefaultUnitName, "Patient A", 320), QuantityInfo = Helper.CreateQuantityInfo(q2), Values = new[] { 0.4F, 0.2F, 0.3F } }; dcX1GeomMeanStdDev.AddRelatedColumn(dcX1GeomMeanPop); columns.Add(dcX1GeomMeanStdDev); return(columns); }