Skip to content

Conversation

@patrickleonardy
Copy link
Contributor

Story title

Remove mandatory id column #135

Changes made

Altered the calculate_pig_table & generate_pig_tables method such that the column_id_name is no longer needed, it was not really needed for the calculations in the background anyway.
Added a test in order to check if it still gives back the same results than before.

How does the solution address the problem

This PR provides the column_id_name by default with None. In that way, the Data scientist can just forget about the column_ID and the code still is backwards compatible.

Linked issues

Resolves #135

class TestPigTablesGeneration:

@pytest.mark.parametrize("id_col_name", [None, "col_id"]) # test None as this is the default value in generate pig tabels
def test_col_id(self, id_col_name):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
def test_col_id(self, id_col_name):
def test_col_id(self, id_col_name: str | None):

This is only possible for python 3.10 and above. I am wondering should I use this or the older version by importing typing and using typing.Union[str, None] for backwards compatibility reasons ? Or how does that actually work ?

Copy link
Contributor

Choose a reason for hiding this comment

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

You could use Optional instead, which has the same functionality as Union, but is more readable.

Suggested change
def test_col_id(self, id_col_name):
def test_col_id(self, id_col_name: Optional[str]):

'avg_target': [0.0, 0.5, 1.0, 0.0, 0.6666666666666666, 0.0, 1.0, 0.0]
})

pd.testing.assert_frame_equal(out, expected) No newline at end of file
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
pd.testing.assert_frame_equal(out, expected)
pd.testing.assert_frame_equal(out, expected)

@sandervh14 sandervh14 removed their request for review December 23, 2022 17:25
@patrickleonardy patrickleonardy merged commit 8f770c7 into develop Jan 10, 2023
@patrickleonardy patrickleonardy deleted the #135-Remove-mandatory-id-column branch January 10, 2023 09:11
@patrickleonardy patrickleonardy restored the #135-Remove-mandatory-id-column branch January 13, 2023 12:42
@sandervh14 sandervh14 added this to the 2023-03 milestone Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove mandatory id column

3 participants