Skip to content

feat: check that methods of table can handle an empty table#314

Merged
zzril merged 83 commits intomainfrom
123-check-that-methods-of-table-can-handle-an-empty-table
Jun 6, 2023
Merged

feat: check that methods of table can handle an empty table#314
zzril merged 83 commits intomainfrom
123-check-that-methods-of-table-can-handle-an-empty-table

Conversation

@patrikguempel
Copy link
Contributor

Closes #123.

Summary of Changes

Every test for _table.py now ensures that empty tables can be handled. In some cases, the Table class has been adjusted, e.g. eq method.

Co-authored-by: jxnior01 129027012+jxnior01@users.noreply.github.com

patrikguempel and others added 30 commits May 12, 2023 14:09
…can-handle-an-empty-table' into 123-check-that-methods-of-table-can-handle-an-empty-table
…_file, from_excel_file, from_jsonfile

empty dataframe can be read.
added tests.
…can-handle-an-empty-table' into 123-check-that-methods-of-table-can-handle-an-empty-table
… test_keep_only_columns.py, test_number_of_columns.py, test_number_of_rows.py
…_duplicate_rows.py and test_remove_rows_with_outliers.py
….py, test_shuffle_rows.py, test_slice_rows.py, test_sort_columns.py
…can-handle-an-empty-table' into 123-check-that-methods-of-table-can-handle-an-empty-table
changed table#split so that empty tables can be "splitted"
…can-handle-an-empty-table' into 123-check-that-methods-of-table-can-handle-an-empty-table
…can-handle-an-empty-table' into 123-check-that-methods-of-table-can-handle-an-empty-table
…can-handle-an-empty-table' into 123-check-that-methods-of-table-can-handle-an-empty-table
…ck-that-methods-of-table-can-handle-an-empty-table

# Conflicts:
#	tests/safeds/data/tabular/containers/_table/test_from_csv_file.py
#	tests/safeds/data/tabular/containers/_table/test_from_json_file.py
#	tests/safeds/data/tabular/containers/_table/test_remove_rows_with_outliers.py
#	tests/safeds/data/tabular/containers/_table/test_sort_columns.py
#	tests/safeds/data/tabular/containers/_table/test_summary.py
#	tests/safeds/data/tabular/containers/_table/test_to_csv_file.py
#	tests/safeds/data/tabular/containers/_table/test_to_excel_file.py
…can-handle-an-empty-table' into 123-check-that-methods-of-table-can-handle-an-empty-table
daniaHu
daniaHu previously approved these changes Jun 5, 2023
Copy link
Contributor

@zzril zzril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test for Table.__repr__()

The __repr__ method of Table has no testcases at all.


Meaningless testcase in test_from_dict.py:

def test_should_create_table_from_dict(data: dict[str, list[Any]], expected: Table) -> None:
    assert Table.from_dict(data).schema == expected.schema
    assert Table.from_dict(data) == expected

This is the test case:

        (
            {},
            Table.from_dict({}),
        ),

So, the assertion really just compares Table.from_dict({}) with Table.from_dict({}).
Should change the expected table to Table() as in the other testcases for empty tables.

…can-handle-an-empty-table' into 123-check-that-methods-of-table-can-handle-an-empty-table
@patrikguempel patrikguempel dismissed stale reviews from daniaHu and Marsmaennchen221 via f9d7c46 June 6, 2023 13:27
@patrikguempel
Copy link
Contributor Author

Missing test for Table.__repr__()

The __repr__ method of Table has no testcases at all.

Meaningless testcase in test_from_dict.py:

def test_should_create_table_from_dict(data: dict[str, list[Any]], expected: Table) -> None:
    assert Table.from_dict(data).schema == expected.schema
    assert Table.from_dict(data) == expected

This is the test case:

        (
            {},
            Table.from_dict({}),
        ),

So, the assertion really just compares Table.from_dict({}) with Table.from_dict({}). Should change the expected table to Table() as in the other testcases for empty tables.

Fixed the respective test case. The repr test cases are probably stuff for a new issue.

@patrikguempel patrikguempel requested a review from zzril June 6, 2023 13:31
@zzril
Copy link
Contributor

zzril commented Jun 6, 2023

Fixed the respective test case. The repr test cases are probably stuff for a new issue.

Makes sense, opend one (#349).

Rest looks good to me, will approve.

@zzril zzril merged commit 686c2e7 into main Jun 6, 2023
@zzril zzril deleted the 123-check-that-methods-of-table-can-handle-an-empty-table branch June 6, 2023 16:17
lars-reimann pushed a commit that referenced this pull request Jun 30, 2023
## [0.14.0](v0.13.0...v0.14.0) (2023-06-30)

### Features

* 290 properties for width-height of image ([#359](#359)) ([d9ebdc1](d9ebdc1)), closes [#290](#290)
* Add `find_edges` method to `Image` class ([#383](#383)) ([d14b6ce](d14b6ce)), closes [#288](#288)
* Add `StandardScaler` transformer ([#316](#316)) ([57b0572](57b0572)), closes [#142](#142)
* Add docstrings to the getter methods for hyperparameters in Regression and Classification models ([#371](#371)) ([9073f04](9073f04)), closes [#313](#313)
* Added `Table.group_by` to group a table by a given key ([#343](#343)) ([afb98be](afb98be)), closes [#160](#160)
* Added and improved errors and warnings in the table transformers ([#372](#372)) ([544e307](544e307)), closes [#152](#152)
* added crop() method in image and tests ([#365](#365)) ([eba8163](eba8163))
* added invert_colors method ([#367](#367)) ([1e4d110](1e4d110))
* adjust brightness and contrast of image ([#368](#368)) ([1752feb](1752feb)), closes [#289](#289) [#291](#291)
* blur Image method ([#363](#363)) ([c642176](c642176))
* check that methods of table can handle an empty table ([#314](#314)) ([686c2e7](686c2e7)), closes [#123](#123)
* convert image to grayscale ([#366](#366)) ([1312fe7](1312fe7)), closes [#287](#287)
* enhance `replace_column` to accept a list of new columns ([#312](#312)) ([d50c5b5](d50c5b5)), closes [#301](#301)
* Explicitly throw `UnknownColumnNameError` in `TaggedTable._from_table` ([#334](#334)) ([498999f](498999f)), closes [#333](#333)
* flip images / eq method for image ([#360](#360)) ([54f4ae1](54f4ae1)), closes [#280](#280)
* improve `table.summary`. Catch `ValueError` thrown by `column.stability` ([#390](#390)) ([dbbe0e3](dbbe0e3)), closes [#320](#320)
* improve error handling of `column.stability` when given a column that contains only None ([#388](#388)) ([1da2499](1da2499)), closes [#319](#319)
* Improve Error Handling of classifiers and regressors ([#355](#355)) ([66f5f64](66f5f64)), closes [#153](#153)
* Resize image ([#354](#354)) ([3a971ca](3a971ca)), closes [#283](#283)
* rotate_left and rotate_right added to Image ([#361](#361)) ([c877530](c877530)), closes [#281](#281)
* set kernel of support vector machine ([#350](#350)) ([1326f40](1326f40)), closes [#172](#172)
* sharpen image ([#364](#364)) ([3444700](3444700)), closes [#286](#286)

### Bug Fixes

* Keeping no columns with Table.keep_only_columns results in an empty Table with a row count above 0 ([#386](#386)) ([15dab06](15dab06)), closes [#318](#318)
* remove default value of `positive_class` parameter of classifier metrics ([#382](#382)) ([58fc09e](58fc09e))
* remove default value of `radius` parameter of `blur` ([#378](#378)) ([7f07f29](7f07f29))
@lars-reimann
Copy link
Member

🎉 This PR is included in version 0.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Included in a release

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Check that methods of Table can handle an empty table

7 participants