-
Notifications
You must be signed in to change notification settings - Fork 7
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 #1949 data importer parsing unit should be case insensitive #1952
Fixes #1949 data importer parsing unit should be case insensitive #1952
Conversation
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.
I ran resharper in a bunch of files. This should be done more often
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.
@georgeDaskalakis Please review
@@ -76,7 +75,7 @@ private void setDimensionsForMappings(ColumnInfoCache columnInfos) | |||
else | |||
{ | |||
var supportedDimensions = concreteColumnInfo.SupportedDimensions; | |||
var dimensionForUnit = supportedDimensions.FirstOrDefault(x => x.HasUnit(mappedColumn.Unit.SelectedUnit)); | |||
var dimensionForUnit = supportedDimensions.FirstOrDefault(x => x.SupportsUnit(mappedColumn.Unit.SelectedUnit, ignoreCase: true)); |
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.
this is the one change that did not impact my failing test but should be done I believe?
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.
agreed
@@ -159,7 +158,12 @@ public UnitDescription ExtractUnitDescriptions(string description, IReadOnlyList | |||
|
|||
protected string ValidateUnit(string unit, IReadOnlyList<IDimension> supportedDimensions) | |||
{ | |||
return supportedDimensions.Any(x => x.HasUnit(unit)) ? unit : UnitDescription.InvalidUnit; | |||
var dimensionForUnit = supportedDimensions.FirstOrDefault(x => x.SupportsUnit(unit, ignoreCase: true)); |
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.
this was the one change that was required
protected override void Context() | ||
{ | ||
_fakedTimeDimension = A.Fake<IDimension>(); | ||
_fakedConcentrationDimensionMolar = A.Fake<IDimension>(); | ||
_fakedConcentrationDimensionMolar = A.Fake<IDimension>(); |
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.
Why are we faking all the dimensions here? shouldn't we use real dimension instead?
tests/OSPSuite.Presentation.Tests/Importer/Core/DataFormat/DataFormat_MetaData_CSpecs.cs
Show resolved
Hide resolved
@msevestre I am removing the remaining .HasUnit and am thinking a bit about how to restructure the functions. Should I commit directly to the PR? |
@georgeDaskalakis I don't think we need to refactor RIGHT Now. But this needs refactoring for sure |
@@ -76,7 +75,7 @@ private void setDimensionsForMappings(ColumnInfoCache columnInfos) | |||
else | |||
{ | |||
var supportedDimensions = concreteColumnInfo.SupportedDimensions; | |||
var dimensionForUnit = supportedDimensions.FirstOrDefault(x => x.HasUnit(mappedColumn.Unit.SelectedUnit)); | |||
var dimensionForUnit = supportedDimensions.FirstOrDefault(x => x.SupportsUnit(mappedColumn.Unit.SelectedUnit, ignoreCase: true)); |
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.
agreed
tests/OSPSuite.Presentation.Tests/Importer/Core/DataFormat/DataFormat_MetaData_CSpecs.cs
Show resolved
Hide resolved
* 1886 importer unit for fraction not recognized (#1892) * changing the check * correction to get the first non empty unit * cleaning up * Fixes #1925 (#1926) @Yuri05 Merging. NEed to test in the app * Fixes #1925 (#1927) * 2566 fixed (#1932) * nunit adapter updated (#1938) * Fixes #1379 (#1948) * Fixes #1946 mobi cannot handler observed data sets with only 1 point (#1947) * Fixes #1949 data importer parsing unit should be case insensitive (#1952) * Fixes #1949 data importer parsing unit should be case insensitive * Run resharper * Remove fake to use real dimensions * Remove fake to use real dimensions * refactoring and removing further .HasUnit() calls --------- Co-authored-by: georgeDaskalakis <37107428+georgeDaskalakis@users.noreply.github.com> * preventing exception (#1957) * templates changed (#1962) --------- Co-authored-by: georgeDaskalakis <37107428+georgeDaskalakis@users.noreply.github.com> Co-authored-by: Michael Sevestre <michael@design2code.ca>
@georgeDaskalakis The function hasUnit should not be used as it checked for actual value by keys. The code should always use SupportUnits In my opinion
I found a section that still uses hasUnit. The code is too complicated for me to review or change at this stage so I will ask you to do the modifications if required.

I really think the code in those functions (
validateUnitsSupportedAndSameDimension
orvalidateErrorAgainstMeasurement
etc) is very complicated. We should extract some of the logic regarding error mapping, finding units etc...we repeat almost the same code throughout the Datasource file and this makes modification much harder than they should