* Updated Pop function
Added underflow condition
* Update Pop Function
Added condition to check underflow of stack
* Update stack.py
* if not self.stack: raise StackUnderflowError
* Add doctests
* StackUnderflowError
* ..., not ....
* Update stack.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Added new file: nasa_data.py
* Modified as per review
* Minor change
* print(get_archive_data("apollo 2011")["collection"]["items"][0]["data"][0]["description"])
* Update nasa_data.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* add check_cycle.py
* Update graphs/check_cycle.py
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Update check_cycle.py
* Apply suggestions from code review
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Fix type annotations for trie.py
* Add strict type annotations to trie.py
Annotate return type for all functions and type for "nodes"
* updating DIRECTORY.md
* Format trie.py
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* fix: fix mypy errors
Update binary_search_tree `arr` argument to be typed as a list
within `find_kth_smallest` function
Update return type of `merge_two_binary_trees` as both inputs can
be None which means that a None type value can be returned from
this function
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* [mypy] fix type annotations for graphs/a_star.py #4052
* updating DIRECTORY.md
* Add from __future__ import anotations
* rename delta by DIRECTIONS
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Rename delta by DIRECTIONS in all code
* Enclose script in __main__ code block
* Refactor DIRECTIONS with comments for readibility
* Delete heuristic example comment
* Do not print, return all values
* Fix multilines
* fix black
* Update a_star.py
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Add missing type annotation
* Fix conversion bug
This failed when called with the documented example of `1.5` and was correctly
pointed out by `mypy --strict`
* Update annotations to Python 3.10 #4052
* Add floats doctest
* Copy list to avoid changing input unpredictably
* Refactor code to make it readable
* updating DIRECTORY.md
* Improve raised ValueErrors and add doctest
* Split doctest in multiples lines
* Change ValueError to Monogons and Digons are not poly
* Correct doctest refering number of sides
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Fix several typos
* Update bit_manipulation/README.md
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Update double_sort.py
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Added regular expression implimentation using dp
* replaced input() with example values
* Apply suggestions from code review
Co-authored-by: Christian Clauss <cclauss@me.com>
* changed returning value to bool and added test cases
* added doctest
Co-authored-by: John Law <johnlaw.po@gmail.com>
* added test cases
* Apply suggestions from code review
Co-authored-by: John Law <johnlaw.po@gmail.com>
* shifted to strings
* Changed filename
* Update function name to match_pattern
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Update function name to match_pattern
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
This is a followup to https://github.com/TheAlgorithms/Python/pull/4973#issuecomment-933117382
As per given suggestion, I've added type hints to certain methods that don't have them. I have also added documentation and example doctests as a usage example for (most of) those that don't have them.
I have also added another test case following the previous test case's format. I noticed that the existing test case from previous pull request might be redundant with the ones I've made, so I decided to create a specific situation where the linked list would have to keep different kinds of data types for each node, in `test_singly_linked_list_2` test function.
Some minor changes in strings has been done to keep things consistent with other parts of the document. If it is undesirable, please let me know.
* Remove exception detail from doctest
These details are configuration dependant so should be removed according to https://docs.python.org/3/library/doctest.html
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Added length unit conversions
Conversion of length units were added with respective tests being implemented and passed.
Available Units:- Metre,Kilometre,Feet,Inch,Centimeter,Yard,Foot,Mile,Millimeter
* Formatted File
File was formatted to go as per repo rules
* Reformatted file
* Reformatted code once again
* Added more test
Added test to evaluate whether the code handles wrong arguements passed
* Update length_conversions.py
* Update length_conversions.py
* Update length_conversions.py
* Update length_conversions.py
* Update length_conversions.py
* Update length_conversions.py
* Update length_conversions.py
* Fixed Minor errors in test
One of the test was failing and it was fixed
Co-authored-by: Christian Clauss <cclauss@me.com>
* added schur complement and tests to linear algebra
* updated according to checklist
* updated variable names and typing
* added two testcases for input validation
* fixed import order
Co-authored-by: Ivan Radonov <ivan.radonov@ad.mentormate.bg>
* Added giphy.py to fetch gifs on a given topic
* Modified code
[*]Added doctest
[*]Formatted with black
* Minor change
* Minor refactoring to avoid name clash
* Made necessary changes as per review
* Update web_programming/giphy.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Apply suggestions from code review
* Final cleanup
* Placate psf/black
Co-authored-by: Christian Clauss <cclauss@me.com>
* added harmonic mean
* Update maths/series/harmonic_mean.py
Updated the write-up of reference given in the code.
Co-authored-by: John Law <johnlaw.po@gmail.com>
* changes in arithmetic and geometric mean code
* mean and series added in a single file
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Added morphological operations, fixes: #5197
* Added dilation tests and type hints
* Added erosion tests and type hints
* fixes: TheAlgorithms#5197
* fixes: TheAlgorithms#5197
* Update erosion_operation.py
* made suggested changes in dilation
* made suggested changes in erosion
* made suggested changes in dilation
* removed extra spaces in the tests
* removed extra spaces in the tests