DataFrameTypeDetector now works with nil#107
Conversation
Also added relevant tests
| { #category : #testing } | ||
| DataFrameTypeDetector >> canAllBeDateAndTime: aDataSeries [ | ||
| [ aDataSeries do: #asDateAndTime ] | ||
| [ aDataSeries do: [ :ele | ele isNil ifFalse: [ ele asDateAndTime ]] ] |
There was a problem hiding this comment.
Here and in the following, I'd use ele ifNotNil: rather than ele isNil ifFalse: .
|
|
||
| ^ aDataSeries | ||
| detect: [ :each | [ (regex matches: each) not ] on: Error do: [ ^ false ] ] | ||
| detect: [ :each | [ each isNil ifTrue: [ false ] ifFalse: [ (regex matches: each) not ]] on: Error do: [ ^ false ] ] |
There was a problem hiding this comment.
Simlarly: each ifNil: [ false ] ifNotNil: [...]
| DataFrameTypeDetector >> canAnyBeFloat: aDataSeries [ | ||
| ^ aDataSeries | ||
| detect: [ :each | each asNumber isFloat ] | ||
| detect: [ :each | each isNil ifTrue: [ false ] ifFalse: [ (each asNumber isFloat) ] ] |
There was a problem hiding this comment.
Simpler: each isNotNil and: [ each asNumber isFloat ].
| ^ aDataSeries collect: [ :each | each = 'true' ] | ||
| ^ aDataSeries collect: [ :each | | ||
| each isNil | ||
| ifFalse: [ each = 'true' ] ] |
There was a problem hiding this comment.
Once again: ifNotNil: is clearer than isNil ifFalse:.
There was a problem hiding this comment.
However, seeing all the following cases I wonder if it would be better to have a method #collectNonNils and use that instead of nil-testing in each particular use case.
There was a problem hiding this comment.
I'll add collectNonNils since it makes more sense. PR 102 has removeNils already so we can do dataSeries deepCopy removeNils, but one with collect would be better.
Also added relevant tests.
Fixes #66.