Skip to content

Conversation

@AtharvaKhare
Copy link
Contributor

DataSeries can remove nils using the method removeNils
DataFrame can remove nils from rows and columns using methods:

  • removeColumnsWithNilsAtRow:
  • removeColumnsWithNilsAtRowNamed:
  • removeRowsWithNilsAtColumn:
  • removeRowsWithNilsAtColumnNamed:
    Added relevant tests for these methods

@AtharvaKhare
Copy link
Contributor Author

Any idea why code coverage decreased? The code in question is already covered in a test

@olekscode
Copy link
Member

This seems like a bad implementation:

DataFrameInternal >> removeRowsWithNilsAtColumn: columnNumber
    "Removes all rows having a nil value at the column columnNumber"

     | newContents rowsToDrop k |
    "rowsToDrop has 1 at i if i-th row needs to be dropped, else 0"
    rowsToDrop := (self columnAt: columnNumber) collect: [ :ele |
        (ele isNil) ifTrue: [ 1 ] ifFalse: [ 0 ] ].
    newContents := Array2D
        rows: (self numberOfRows - (rowsToDrop select: [ :ele | ele = 1 ]) size)
        columns: (self numberOfColumns).

     1 to: self numberOfColumns do: [ :j |
        k := 0.
        1 to: self numberOfRows do: [ :i |
            (rowsToDrop at: i) = 1 
                ifTrue: [ k := k + 1 ]
                ifFalse: [
                newContents at: i - k at: j put:
                    (contents at: i at: j) ]]].

     contents := newContents.

First you collect 0 and 1 (instead of true and false), then you check if element is equal to 1 (instead of having the boolean element). And so on

@olekscode
Copy link
Member

I suggest that we create a method for removing rows that satisfy a certain condition (and the same for columns).
Then you call it with the condition that element at a certain column is nil

DataSeries can remove nils using the method `removeNils`
DataFrame can remove nils from rows and columns using methods:
- `removeColumnsWithNilsAtRow:`
- `removeColumnsWithNilsAtRowNamed:`
- `removeRowsWithNilsAtColumn:`
- `removeRowsWithNilsAtColumnNamed:`
Added relevant tests for these methods

DataFrame can also delete rows and columns satisfing a certain
condition, such as isNil (above one), using these methods:
- `removeRowsOfColumnElementsSatisfing: onColumn:`
- `removeRowsOfColumnElementsSatisfing: onColumnNamed:`
- `removeColumnsOfRowElementsSatisfing: onRow:`
- `removeColumnsOfRowElementsSatisfing: onRowNamed:`
Similar method is available for DataFrameInternal
@AtharvaKhare
Copy link
Contributor Author

@olekscode done! Any idea about coveralls? Tests are written :/

@olekscode olekscode merged commit c571730 into PolyMathOrg:master Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants