Skip to content

Added New Tests in Signum #10724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Oct 20, 2023
Merged

Added New Tests in Signum #10724

merged 23 commits into from
Oct 20, 2023

Conversation

imSanko
Copy link
Contributor

@imSanko imSanko commented Oct 20, 2023

Describe your change:

Added new tests in Signum

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword.

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 20, 2023
@cclauss
Copy link
Member

cclauss commented Oct 20, 2023

Please do NOT remove tests. The original developer might have had very good reasons for creating those particular tests.

Also, please run python3 -m doctest -v maths/signum.py on your own computer so you know if your proposed changes are going to pass the build test

=================================== FAILURES ===================================
________________________ [doctest] maths.signum.signum _________________________
007 
008      Applies signum function on the number
009 
010     Custom test cases:
011     >>> signum(-20)
Expected:
    -2
Got:
    -1

Finally, please try to add tests that show how the algorithm fails with difficult or garbage input.

     >>> signum(-21)
     >>> signum(1_000_000_000)
     >>> signum(12.345)
     >>> signum("a")
     >>> signum([])

@cclauss cclauss self-assigned this Oct 20, 2023
Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

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

Please bring back the old tests and add more.

@algorithms-keeper algorithms-keeper bot added the awaiting changes A maintainer has requested changes to this PR label Oct 20, 2023
@algorithms-keeper algorithms-keeper bot added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Oct 20, 2023
@imSanko imSanko requested a review from cclauss October 20, 2023 08:09
@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 20, 2023
@imSanko
Copy link
Contributor Author

imSanko commented Oct 20, 2023

Please bring back the old tests and add more.

Does it meet the requirements or can you tell me I'll add more tests?

Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

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

a few more

@algorithms-keeper algorithms-keeper bot added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Oct 20, 2023
@algorithms-keeper algorithms-keeper bot removed the awaiting changes A maintainer has requested changes to this PR label Oct 20, 2023
@cclauss cclauss added the awaiting changes A maintainer has requested changes to this PR label Oct 20, 2023
@algorithms-keeper algorithms-keeper bot removed the awaiting changes A maintainer has requested changes to this PR label Oct 20, 2023
@imSanko imSanko requested a review from cclauss October 20, 2023 08:48
Co-authored-by: Christian Clauss <cclauss@me.com>
@imSanko imSanko requested a review from cclauss October 20, 2023 08:49
@cclauss
Copy link
Member

cclauss commented Oct 20, 2023

 021     >>> signum([])
UNEXPECTED EXCEPTION: TypeError("'<' not supported between instances of 'list' and 'int'")
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/doctest.py", line 1357, in __run
    exec(compile(example.source, filename, "single",
  File "<doctest maths.signum.signum[4]>", line 1, in <module>
  File "/home/runner/work/Python/Python/maths/signum.py", line 28, in signum
    if num < 0:
       ^^^^^^^
TypeError: '<' not supported between instances of 'list' and 'int'
/home/runner/work/Python/Python/maths/signum.py:21: UnexpectedException

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 20, 2023
@imSanko
Copy link
Contributor Author

imSanko commented Oct 20, 2023

 021     >>> signum([])
UNEXPECTED EXCEPTION: TypeError("'<' not supported between instances of 'list' and 'int'")
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/doctest.py", line 1357, in __run
    exec(compile(example.source, filename, "single",
  File "<doctest maths.signum.signum[4]>", line 1, in <module>
  File "/home/runner/work/Python/Python/maths/signum.py", line 28, in signum
    if num < 0:
       ^^^^^^^
TypeError: '<' not supported between instances of 'list' and 'int'
/home/runner/work/Python/Python/maths/signum.py:21: UnexpectedException

Test cases have passed
7 tests in signum.signum
7 tests in 3 items.
7 passed and 0 failed.
Test passed.

Co-authored-by: Christian Clauss <cclauss@me.com>
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 20, 2023
@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 20, 2023
@imSanko imSanko requested a review from cclauss October 20, 2023 10:49
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 20, 2023
@cclauss cclauss merged commit 5799376 into TheAlgorithms:master Oct 20, 2023
@cclauss cclauss added the hacktoberfest-accepted Accepted to be counted towards Hacktoberfest label Oct 20, 2023
@imSanko
Copy link
Contributor Author

imSanko commented Oct 20, 2023

@cclauss Thanks a lot for mentoring me

@cclauss
Copy link
Member

cclauss commented Oct 20, 2023

The trick is NOT to change the code to fix the test but to change ONLY the test to describe how the code ACTUALLY works.

sedatguzelsemme pushed a commit to sedatguzelsemme/Python that referenced this pull request Sep 15, 2024
* Added new tests!

* [ADD]: Inproved Tests

* fixed

* Removed spaces

* Changed the file name

* Added Changes

* changed the code and kept the test cases

* changed the code and kept the test cases

* missed the line

* removed spaces

* Update power_using_recursion.py

* Added new tests in Signum

* Few things added

* Removed few stuff and added few changes

* Fixed few things

* Reverted the function

* Update maths/signum.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Added few things

* Update maths/signum.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Added the type hint back

* Update signum.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
@isidroas isidroas mentioned this pull request Jan 25, 2025
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Accepted to be counted towards Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants