[DS-2562] created test and changed canSortTogether, so it is not taking a grid as a parameter

[DS-2562] removed polars tests

[DS-2562] split polars and pandas into different files and made tables fixtures

[DS-2562] added checks that generated commands actually work in Python

[DS-2562] changed function name

[DS-2562] moved tests into proper directory

[DS-2562] specified return type in createAscSortKeys

[DS-2562] removed duplications

[DS-2562] renamed tests and test file, added blank lines

[DS-2562] fixed naming in tests

[DS-2562] fixed caption to getSortCommand method

[DS-2562] deleted unused imports

[DS-2562] fixed tests

[DS-2562] fixed test for checking that command is generated properly

[DS-2562] refactored code and added test for checking that command is generated properly

[DS-2562] fixed comments

[DS-2562] added proper disposing

[DS-2562] fixed formatting

[DS-2562] fixed naming

[DS-2562] removed redundant dependencies

[DS-2562] removed unintentional formatting changed

[DS-2562] deleted changes in canSortTogether, fixed SortingTest

[DS-2562] created test and changed canSortTogether, so it is not taking a grid as a parameter


Merge-request: IJ-MR-113863
Merged-by: Georgii Zorabov <georgii.zorabov@jetbrains.com>

GitOrigin-RevId: 297e5b2f880fe8ac577b8704d24365256305ff1d
This commit is contained in:
Georgii Zorabov
2023-09-12 10:38:21 +00:00
committed by intellij-monorepo-bot
parent f2fe086f5b
commit de2f2bac64
2 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
# Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.

View File

@@ -0,0 +1,49 @@
# Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
"""
Here we test whether the commands generated for sorting pandas objects in Python work correctly.
The tests for generating the commands are in DSSortingTest.kt
"""
import pandas as pd
import pytest
from _pydevd_bundle.pydevd_utils import eval_expression
@pytest.fixture
def unsorted_table():
df = pd.DataFrame([[1, 'A'], [1, 'B'],
[2, 'D'], [2, 'C'],
[1, 'D'], [1, 'C'],
[2, 'A'], [2, 'B']], columns=['column 0', 'column 1'])
return df
@pytest.fixture
def sorted_table():
df = pd.DataFrame([[1, 'A'], [1, 'B'],
[1, 'C'], [1, 'D'],
[2, 'A'], [2, 'B'],
[2, 'C'], [2, 'D']], index=[0, 1, 5, 4, 6, 7, 3, 2],
columns=['column 0', 'column 1'])
return df
def test_commands(unsorted_table, sorted_table):
df = pd.Series([1, 3, 2])
sorting_command = "df.sort_values(ascending=[True])"
series = eval_expression(sorting_command, {}, {"df": df})
new_series = pd.Series([1, 2, 3], index=[0, 2, 1])
assert series.equals(new_series)
df = unsorted_table
sorting_command = "df.sort_values(by=[df.columns[0], df.columns[1]], ascending=[True, True])"
table = eval_expression(sorting_command, {}, {"df": df})
new_table = sorted_table
assert table.equals(new_table)
df.set_index(['column 0', 'column 1'], inplace=True)
new_table.set_index(['column 0', 'column 1'], inplace=True)
sorting_command = "df.sort_index(level=[0,1], ascending=[True,True])"
table = eval_expression(sorting_command, {}, {"df": df})
assert table.equals(new_table)