Skip to content
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

Skip dimension check on geometric error #1435

Merged
merged 4 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/OSPSuite.Infrastructure.Import/Core/DataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ private void validateErrorAgainstMeasurement(IReadOnlyList<ColumnInfo> columnInf
{
var measurementColumn = set.Data.FirstOrDefault(x => x.Key.ColumnInfo.Name == column.Name);
var errorColumn = set.Data.FirstOrDefault(x => x.Key.ColumnInfo.Name == relatedColumn.Name);

if (errorColumn.Key == null)
if (errorColumn.Key == null || errorColumn.Key.ErrorDeviation == Constants.STD_DEV_GEOMETRIC)
continue;

if (errorColumn.Value != null && measurementColumn.Value.Count != errorColumn.Value.Count)
Expand Down Expand Up @@ -208,13 +207,14 @@ private void validateUnitsSupportedAndSameDimension(IReadOnlyList<ColumnInfo> co
{
var column = set.Data.FirstOrDefault(x => x.Key.ColumnInfo.Name == columnInfo.Name);

if (column.Key == null)
if (column.Key == null || column.Key.ErrorDeviation == Constants.STD_DEV_GEOMETRIC)
continue;

//if unit comes from a column
if (column.Key.Column.Dimension == null)
{
var firstNonEmptyUnit = column.Value.FirstOrDefault(x => !string.IsNullOrEmpty(x.Unit));

var dimensionOfFirstUnit = columnInfo.SupportedDimensions.FirstOrDefault(x => x.FindUnit(firstNonEmptyUnit.Unit, ignoreCase: true) != null);

for (var i = 0; i < column.Value.Count(); i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using OSPSuite.Core.Domain;
using OSPSuite.Core.Domain.Data;
using OSPSuite.Core.Domain.Services;
using OSPSuite.Core.Domain.UnitSystem;
using OSPSuite.Infrastructure.Import.Extensions;

namespace OSPSuite.Infrastructure.Import.Core.Mappers
Expand Down Expand Up @@ -68,7 +69,7 @@ public DataSetToDataRepositoryMappingResult ConvertImportDataSet(ImportedDataSet
private bool convertParsedDataColumnAndReturnWarningFlag(DataRepository dataRepository, KeyValuePair<ExtendedColumn, IList<SimulationPoint>> columnAndData, string fileName)
{
DataColumn dataColumn;
var unit = columnAndData.Value.FirstOrDefault(x => !string.IsNullOrEmpty(x.Unit)).Unit;
var unit = columnAndData.Value.FirstOrDefault(x => !string.IsNullOrEmpty(x.Unit))?.Unit ?? Constants.Dimension.DIMENSIONLESS;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dimensionless is a dimension not a unit
I meant to use NO_DIMENSION to match the code that you had before
NO_DIMENSION.DefaultUnit or sthg kike this

var warningFlag = false;
var dimension = columnAndData.Key.Column.Dimension ?? columnAndData.Key.ColumnInfo.SupportedDimensions.FirstOrDefault(x => x.FindUnit(unit, ignoreCase: true) != null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class concern_for_DataSetToDataRepositoryMapperSpecs : ContextSp
protected Dictionary<ExtendedColumn, IList<SimulationPoint>> _parsedDataSetInconsistentLLOQ;
protected Dictionary<ExtendedColumn, IList<SimulationPoint>> _parsedDataSetUnitFromColumn;
protected DataSetToDataRepositoryMappingResult _result;

protected override void Context()
{
_dataSourceLLOQ = A.Fake<IDataSource>();
Expand Down