-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #2484 bug when exporting pop simulation #2503
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using PKSim.Core.Chart; | ||
using OSPSuite.Utility.Extensions; | ||
using PKSim.Core.Chart; | ||
|
||
namespace PKSim.Core.Mappers | ||
{ | ||
|
@@ -33,16 +33,18 @@ protected override IEnumerable<DataRow> AddSpecificChartValues(DataRow row, Curv | |
for (var i = 0; i < curveData.XValues.Count; i++) | ||
{ | ||
var newRow = row.Table.NewRow(); | ||
var yValue = curveData.YValues[i]; | ||
newRow.ItemArray = row.ItemArray; | ||
newRow[_xValue] = curveData.XValues[i].ToString(curveData.XAxis); | ||
newRow[_lowerWhisker] = ValueForDataTableFor(curveData.YAxis, curveData.YValues[i].LowerWhisker); | ||
newRow[_lowerBox] = ValueForDataTableFor(curveData.YAxis, curveData.YValues[i].LowerBox); | ||
newRow[_median] = ValueForDataTableFor(curveData.YAxis, curveData.YValues[i].Median); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was the error everywhere. Using the dimension of the Y axis instead of the YDimensiion defined at the curve level (was not easy to find!) |
||
newRow[_upperBox] = ValueForDataTableFor(curveData.YAxis, curveData.YValues[i].UpperBox); | ||
newRow[_upperWhisker] = ValueForDataTableFor(curveData.YAxis, curveData.YValues[i].UpperWhisker); | ||
newRow[_lowerWhisker] = yValueForDataTableFor(curveData, yValue.LowerWhisker); | ||
newRow[_lowerBox] = yValueForDataTableFor(curveData, yValue.LowerBox); | ||
newRow[_median] = yValueForDataTableFor(curveData, yValue.Median); | ||
newRow[_upperBox] = yValueForDataTableFor(curveData, yValue.UpperBox); | ||
newRow[_upperWhisker] = yValueForDataTableFor(curveData, yValue.UpperWhisker); | ||
newRow[_variable] = curveData.YAxis.Caption; | ||
newRows.Add(newRow); | ||
} | ||
|
||
return newRows; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,13 @@ | |
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Linq; | ||
using OSPSuite.Core.Domain; | ||
using OSPSuite.Core.Domain.UnitSystem; | ||
using OSPSuite.Utility; | ||
using OSPSuite.Utility.Data; | ||
using OSPSuite.Utility.Extensions; | ||
using PKSim.Core.Chart; | ||
using OSPSuite.Core.Domain; | ||
using OSPSuite.Core.Extensions; | ||
using PKSim.Core.Extensions; | ||
|
||
namespace PKSim.Core.Mappers | ||
{ | ||
|
@@ -73,6 +74,7 @@ private DataTable getRawTableDataBasedOn(ChartData<TXValue, TYValue> chartData, | |
AddPanesToTable(dataTable, pane, exportForPivot); | ||
AddObservedDataToTable(dataTable, pane, exportForPivot); | ||
} | ||
|
||
dataTable.EndLoadData(); | ||
|
||
return dataTable; | ||
|
@@ -149,21 +151,22 @@ private CurveData<TXValue, TYValue> firstCurveDefinedIn(ChartData<TXValue, TYVal | |
} | ||
|
||
protected abstract void AddSpecificChartColumns(DataTable dataTable, CurveData<TXValue, TYValue> curveData, bool exportForPivot); | ||
|
||
protected abstract IEnumerable<DataRow> AddSpecificChartValues(DataRow row, CurveData<TXValue, TYValue> curveData, bool exportForPivot); | ||
|
||
protected virtual IReadOnlyList<string> GetDataFields(CurveData<TXValue, TYValue> curveData) | ||
{ | ||
return new List<string>(); | ||
} | ||
protected virtual IReadOnlyList<string> GetDataFields(CurveData<TXValue, TYValue> curveData) => new List<string>(); | ||
|
||
protected virtual IReadOnlyList<string> GetRowFields(CurveData<TXValue, TYValue> curveData) | ||
{ | ||
return new List<string>(); | ||
} | ||
protected virtual IReadOnlyList<string> GetRowFields(CurveData<TXValue, TYValue> curveData) => new List<string>(); | ||
|
||
//For x values, we can use the dimension of the x axis right away as it is always the same for all curves | ||
protected object xValueForDataTableFor<TX, TY>(CurveData<TX, TY> curveData, double value) where TX : IXValue where TY : IYValue => ValueForDataTableFor(curveData.XAxis, curveData.XAxis.Dimension, value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created two helper methods so that I don't have to duplicate the logic |
||
|
||
//For y values, we need to use the dimension specified for each curve as it may be a merged dimension | ||
protected object yValueForDataTableFor<TX, TY>(CurveData<TX, TY> curveData, double value) where TX : IXValue where TY : IYValue => ValueForDataTableFor(curveData.YAxis, curveData.YDimension, value); | ||
|
||
protected object ValueForDataTableFor(IWithDisplayUnit withDisplayUnit, double value) | ||
protected object ValueForDataTableFor(IWithDisplayUnit objectWithTargetUnit, IDimension valueDimension, double value) | ||
{ | ||
return double.IsNaN(value) ? DBNull.Value : (object) withDisplayUnit.ConvertToDisplayUnit(value); | ||
return double.IsNaN(value) ? DBNull.Value : (object) objectWithTargetUnit.DisplayValue(value, valueDimension); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using OSPSuite.Utility.Extensions; | ||
using PKSim.Assets; | ||
using PKSim.Core.Chart; | ||
using OSPSuite.Utility.Extensions; | ||
|
||
namespace PKSim.Core.Mappers | ||
{ | ||
|
@@ -42,16 +42,20 @@ protected override IEnumerable<DataRow> AddSpecificChartValues(DataRow row, Curv | |
for (var i = 0; i < curveData.XValues.Count; i++) | ||
{ | ||
var newRow = row.Table.NewRow(); | ||
var xValue = curveData.XValues[i]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sometimes it's good to avoid a bit of code dup by introducing a variable lol...oh my |
||
var yValue = curveData.YValues[i]; | ||
|
||
newRow.ItemArray = row.ItemArray; | ||
newRow[_xMinimumColumn] = ValueForDataTableFor(curveData.XAxis, curveData.XValues[i].Minimum); | ||
newRow[_xValueColumn] = ValueForDataTableFor(curveData.XAxis, curveData.XValues[i].X); | ||
newRow[_xMaximumColumn] = ValueForDataTableFor(curveData.XAxis, curveData.XValues[i].Maximum); | ||
newRow[_xNumberOfIndividualsColumn] = curveData.XValues[i].NumberOfItems; | ||
newRow[_yLowerPercentileColumn] = ValueForDataTableFor(curveData.YAxis, curveData.YValues[i].LowerPercentile); | ||
newRow[_yValueColumn] = ValueForDataTableFor(curveData.YAxis, curveData.YValues[i].Median); | ||
newRow[_yUpperPercentileColumn] = ValueForDataTableFor(curveData.YAxis, curveData.YValues[i].UpperPercentile); | ||
newRow[_xMinimumColumn] = xValueForDataTableFor(curveData, xValue.Minimum); | ||
newRow[_xValueColumn] = xValueForDataTableFor(curveData, xValue.X); | ||
newRow[_xMaximumColumn] = xValueForDataTableFor(curveData, xValue.Maximum); | ||
newRow[_xNumberOfIndividualsColumn] = xValue.NumberOfItems; | ||
newRow[_yLowerPercentileColumn] = yValueForDataTableFor(curveData, yValue.LowerPercentile); | ||
newRow[_yValueColumn] = yValueForDataTableFor(curveData, yValue.Median); | ||
newRow[_yUpperPercentileColumn] = yValueForDataTableFor(curveData, yValue.UpperPercentile); | ||
newRows.Add(newRow); | ||
} | ||
|
||
return newRows; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just formatting in this file