Skip to content

Commit

Permalink
Merge pull request #3 from int-brain-lab/develop
Browse files Browse the repository at this point in the history
core.DataFrameTableModel: fixed issue with sorting
  • Loading branch information
bimac authored Nov 28, 2024
2 parents 678114c + 277ea87 commit f4d0a7d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [0.3.1] - 2024-10-08

### Fixed

- core.DataFrameTableModel: fixed issue with sorting

## [0.3.0] - 2024-10-08

### Added
Expand Down Expand Up @@ -55,6 +61,7 @@ _First release._
- core.ColoredDataFrameTableModel: An extension of DataFrameTableModel providing color-mapped numerical data.
- widgets.StatefulButton: A QPushButton that maintains an active/inactive state.

[0.3.1]: https://github.com/int-brain-lab/iblqt/releases/tag/v0.3.1
[0.3.0]: https://github.com/int-brain-lab/iblqt/releases/tag/v0.3.0
[0.2.0]: https://github.com/int-brain-lab/iblqt/releases/tag/v0.2.0
[0.1.2]: https://github.com/int-brain-lab/iblqt/releases/tag/v0.1.2
Expand Down
2 changes: 1 addition & 1 deletion iblqt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""A collection of extensions to the Qt framework."""

__version__ = '0.3.0'
__version__ = '0.3.1'
4 changes: 3 additions & 1 deletion iblqt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ def sort(self, column: int, order: Qt.SortOrder = Qt.SortOrder.AscendingOrder):
return
columnName = self._dataFrame.columns[column]
self.layoutAboutToBeChanged.emit()
self._dataFrame.sort_values(by=columnName, ascending=not order, inplace=True)
self._dataFrame.sort_values(
by=columnName, ascending=order == Qt.SortOrder.AscendingOrder, inplace=True
)
self.layoutChanged.emit()


Expand Down
10 changes: 5 additions & 5 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

def test_dataframe_model(qtbot):
# instantiation / setting of dataframe
df1 = pd.DataFrame({'X': [0, 1, 2], 'Y': ['A', 'B', 'C']})
df = pd.DataFrame({'X': [0, 1, 2], 'Y': ['A', 'B', 'C']})
model = core.ColoredDataFrameTableModel()
assert model.dataFrame.empty
model = core.ColoredDataFrameTableModel(dataFrame=df1)
assert model.dataFrame is not df1
assert model.dataFrame.equals(df1)
model = core.ColoredDataFrameTableModel(dataFrame=df)
assert model.dataFrame is not df
assert model.dataFrame.equals(df)
with qtbot.waitSignal(model.modelReset, timeout=100):
model.dataFrame = df1
model.dataFrame = df

# header data
assert model.headerData(-1, Qt.Orientation.Horizontal) is None
Expand Down

0 comments on commit f4d0a7d

Please sign in to comment.