Commit Graph

2361 Commits

Author SHA1 Message Date
Erwin Junge
aaaa175b66
[mypy] annotate computer_vision (#5571) 2021-10-23 23:26:21 +02:00
Martmists
00a67010e8
Simple audio filters (#5230)
* Add IIR Filter and Butterworth design functions

Signed-off-by: Martmists <martmists@gmail.com>

* naming conventions and missing type hints

Signed-off-by: Martmists <martmists@gmail.com>

* Link wikipedia in IIRFilter

Signed-off-by: Martmists <martmists@gmail.com>

* Add doctests and None return types

Signed-off-by: Martmists <martmists@gmail.com>

* More doctests

Signed-off-by: Martmists <martmists@gmail.com>

* Requested changes

Signed-off-by: Martmists <martmists@gmail.com>

* run pre-commit

Signed-off-by: Martmists <martmists@gmail.com>

* Make mypy stop complaining about ints vs floats

Signed-off-by: Martmists <martmists@gmail.com>

* Use slower listcomp to make it more readable

Signed-off-by: Martmists <martmists@gmail.com>

* Make doctests happy

Signed-off-by: Martmists <martmists@gmail.com>

* Remove scipy

Signed-off-by: Martmists <martmists@gmail.com>

* Test coefficients from bw filters

Signed-off-by: Martmists <martmists@gmail.com>

* Protocol test

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

* Make requested change

Signed-off-by: Martmists <martmists@gmail.com>

* Types

Signed-off-by: Martmists <martmists@gmail.com>

* Apply suggestions from code review

* Apply suggestions from code review

* Update butterworth_filter.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-23 23:19:25 +02:00
Christian Clauss
bd9464e4ac
mandelbrot.py: Commenting out long running tests (#5558)
* mandelbrot.py: Commenting out long running tests

* updating DIRECTORY.md

* Comment out 9 sec doctests

* Update bidirectional_breadth_first_search.py

* Comment out slow tests

* Comment out slow (9.15 sec) pytests...

* # Comment out slow (4.20s call) doctests

* Comment out slow (3.45s) doctests

* Update miller_rabin.py

* Update miller_rabin.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-23 18:15:30 +02:00
Studiex
218d8921db
Implementation of SHA-256 using Python (#5532)
* Add files via upload

* Update sha256.py

* Update sha256.py

* Update sha256.py

* Update sha256.py

* Update sha256.py

* Update sha256.py

* Update sha256.py

* Update sha256.py

* @staticmethod def preprocessing(data: bytes) -> bytes:

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-23 15:20:52 +02:00
Limbad Yash
80a885c975
Update pop function (#5544)
* 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>
2021-10-23 15:18:09 +02:00
Mitheel
b72a66b713
Fixed grammatical errors in CONTRIBUTING.md (#5555) 2021-10-23 14:54:41 +02:00
Jaydeep Das
b64fd56776
Added feature to web_programming/nasa_data.py : Can download the APOD image to a specified location on disk. (#5551)
* Added a feature to download images.

* Minor changes

* Update nasa_data.py

* :

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-23 14:38:25 +02:00
Jaydeep Das
27f2465135
Added new file: nasa_data.py (#5543)
* 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>
2021-10-23 12:56:26 +02:00
Atishaye Jain
c50f0c56aa
add check_cycle.py (#5475)
* 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>
2021-10-23 12:29:42 +02:00
Dylan Buchi
20e09c3ec2
[mypy] Add type annotations for linked queue in data structures (#5533)
* [mypy] Add/fix type annotations for linked queue in data_structures

* add return type annotation to __iter__

* Add more readable syntax
2021-10-23 11:56:58 +02:00
Edward Nuno
11ec2fd3fb
[mypy] Fix type annotations for trie.py (#5022)
* 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>
2021-10-23 01:21:41 +08:00
Murilo Gonçalves
07141e4bcc
Add doctests to prime_check function (#5503)
* added doctests to prime_check function

* fix doctests function name
2021-10-23 01:14:27 +08:00
Rohan R Bharadwaj
2ddd81df21
Remove wrongly placed double qoutes (#5530)
* Update baconian_cipher.py

* Update join.py

* Updated type hint
2021-10-23 01:14:08 +08:00
Toki345
0ca1279997
Fixed grammar on Anagram Description (#5512)
Made the description more formal, also fixed a few grammatical issues.
2021-10-22 16:07:57 +02:00
Sherman Hui
629848e372
[mypy] Fix type annotations in data_structures/binary_tree (#5518)
* 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>
2021-10-22 16:07:05 +02:00
QuartzAl
d82cf5292f
split into usable functions and added docstrings for base32 cipher (#5466)
* split into usable functions and added docstrings

* Simplified code

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

* Simplified code

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-22 13:14:35 +02:00
poloso
061614880d
[mypy] fix type annotations for graphs/a_star.py #4052 (#5224)
* [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>
2021-10-22 18:07:28 +08:00
Erwin Junge
d924a8051b
[mypy] Add missing type annotation (#5491) 2021-10-22 17:45:30 +08:00
Erwin Junge
08254eb2e4
[mypy] Fix type annotations for boolean_algebra/quine_mc_cluskey.py (#5489)
* 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`
2021-10-22 17:45:19 +08:00
Erwin Junge
83a63d9c22
[mypy] Add missing type annotation in conways_game_of_life.py (#5490) 2021-10-22 12:14:45 +08:00
Jenny Vo
57a7e5738b
Add implementation of Coulomb's Law (#4897) 2021-10-22 11:52:39 +08:00
Sherman Hui
b373c991f6
[mypy] fix: fix mypy error in trie.py(#5516) 2021-10-22 11:40:17 +08:00
Sherman Hui
9153db2d27
[mypy] fix: fix mypy error in singly_linked_list.py (#5517)
The list comprehension shortcut was implicitly expecting a return
value causing a mypy error since `insert_tail` doesn't return a value
2021-10-22 11:39:18 +08:00
poloso
fdf095f69f
[mypy] check polygon and corrections (#5419)
* 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>
2021-10-21 21:13:42 +08:00
John Law
c0acfd46cb
Fix factorial issues (#5496)
* updating DIRECTORY.md

* pass integer to `math.factorial` in `project_euler/problem_015`

* remove duplicated factorial function

* updating DIRECTORY.md

* Update maths/factorial_iterative.py

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

* Update factorial_iterative.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-21 15:06:32 +08:00
Benjamín García Roqués
2e955aea46
Replace double_ended_queue.py (#5429)
* Add deque_from_scratch.py

* added deque_from_scratch.py

* add extend, extendleft and make comparison

* updated operations list

* fix doctest on Deque.__iter__

* pre-commit fix

* time complexity comments, change type hints

* pre-commit fix

* added more doctests
2021-10-21 11:38:04 +08:00
Hithru De Alwis
672a0c8816
Fixed Typo (#5477)
Change how many "=" sign to how many "=" signs
2021-10-20 15:34:31 +02:00
Manan Rathi
50485f7c8e
Fix typos in Sorts and Bit_manipulation (#4949)
* 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>
2021-10-20 16:42:32 +08:00
P U N I T H
83cf5786cd
Add wildcard pattern matching using dynamic programming (#5334)
* 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>
2021-10-20 16:30:58 +08:00
Immiel
2e2e1b656c
singly_linked_list: Added additional documentation, type hints and test cases (#4988)
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.
2021-10-20 16:08:39 +08:00
Snimerjot Singh
c886a66d34
Added check_strong_password.py (#4950)
* Added check_strong_password.py

* Corrected Comment

* Updated

* Updated check_strong_password.py

* Ran Pre-Commit
2021-10-20 07:35:41 +02:00
Alvin Philips
d32d0158a3
Fixed typo (#5439)
Changed it's (it is) to its
2021-10-19 21:39:15 +02:00
Rohan R Bharadwaj
21cf3cc260
Typo (#5443) 2021-10-19 21:36:01 +02:00
Christian Clauss
f7804334f1
length_conversion.py: Deal with uppercase and abbreviations (#5433)
* length_conversion.py: Deal with uppercase and abbreviations

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-19 11:11:49 +02:00
Vinicius Cordeiro
4880931c24
Add Polybius cipher (#5409)
* Add polybius cipher

* Fix polybius.py build issues and add test
2021-10-19 08:37:51 +02:00
Christian Clauss
aa0ace4df7
Remove exception detail from doctest (#5430)
* 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>
2021-10-19 08:05:20 +02:00
Sabari Ganesh
66c96aa037
Added length unit conversions (#5373)
* 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>
2021-10-19 07:26:03 +02:00
Jainendra Mandavi
d28463c75d
Create count_1s_brian_kernighan_method (#5385)
Ref - http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan
2021-10-18 18:53:10 +02:00
iradonov
4af5215042
added Schur complement to linear algebra (#4793)
* 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>
2021-10-18 18:46:47 +02:00
Rohan R Bharadwaj
fa88559cab
Create join.py (#5363)
* Create join.py

Because we have a split.py

* Update join.py

* Update join.py

* Update join.py

* Update join.py

* Update join.py

* Update strings/join.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update join.py

* Update join.py

* Update join.py

* Update join.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-18 21:35:35 +08:00
Jaydeep Das
0935ab0cb2
Added giphy.py to fetch gifs on a given topic (#5378)
* 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>
2021-10-18 09:16:42 +02:00
Atharva Deshpande
1e64bf4600
Re-organize math/series (#5044)
* 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>
2021-10-18 12:46:23 +08:00
Meysam
08d4d226d7
[mypy] Fix type annotations for graphs/boruvka (#4867)
* fix: type annotations for pypi 🏷️

Fixes #4052

* updating DIRECTORY.md

* apply suggestions from code review

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

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-17 18:26:12 +02:00
John Law
4bf2eedd3c
[mypy] fix mypy error in Project Euler Problem 092 solution 1 (#5357)
* fix mypy error

* updating DIRECTORY.md

* simplify code

* run black

* fix doc consistency

* Fix doc

* fix doc

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-17 08:07:45 +02:00
Srishtik Bhandarkar
7ef2e4d1d0
Add Project Euler Problem 092 (#5091)
* adde solution to problem 092

* added solution to problem 092

* fixed the pre-comit shebang issue
2021-10-17 01:08:41 +08:00
Christian Clauss
8dc7cdbc57
Add tests to morse_code.py (#5337)
* Add tests to morse_code.py

@dhruvmanila @poyea Your reviews, please.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-16 18:57:38 +02:00
Saurabh Suresh Powar
433b804f7d
Added morphological operations, fixes: #5197 (#5199)
* 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
2021-10-16 16:32:40 +02:00
Appledora
37385883aa
Improved readability of web_programming/get_imdbtop.py and added documentations with doctests (#4855)
* improved readability of the existing method by reformatting, adding documentations with doctests.

* improved readability of the existing method by reformatting, adding documentations with doctests.

* fixed typo in test

* added doctest to parse dictionary method

* added doctest to parse dictionary method

* Changed return type, removed print() from method and implemented doctests as suggested

* Fixed doctest error, removed print() from method, created new script as suggested

* Update get_imdbtop.py

* Fix typo discovered by codespell

* return ()

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-16 03:32:33 +02:00
Appledora
152261765a
Show images from google query (#4853)
* Added new script to open the google image tab with a search query.

* Added new script to open the google image tab with a search query.

* Added new script to open the google image tab with a search query with doctests.

* Fixed doctest error, removed print() from method, changed return type

* Update web_programming/show_image_tab_from_google_query.py

using iterators instead of lists

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

* Update web_programming/show_image_tab_from_google_query.py

Improve readability by removing one-time used variable

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

* Update web_programming/show_image_tab_from_google_query.py

Decreasing complication through standard practices.

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

* Update web_programming/show_image_tab_from_google_query.py

Exception Handling

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

* changed complete method to download images from google search query

* Update download_images_from_google_query.py

* Delete show_image_tab_from_google_query.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-16 02:02:44 +02:00
Murilo Gonçalves
4cf1aaeb96
Updated mypy.ini, removed ok folders that were excluded (#5331) 2021-10-15 23:57:41 +02:00