Commit Graph

56 Commits

Author SHA1 Message Date
Kamil
0b440285e8
Gaussian_elemination - change to remove warning (#10221)
* Replacing the generator with numpy vector operations from lu_decomposition.

* Revert "Replacing the generator with numpy vector operations from lu_decomposition."

This reverts commit ad217c6616.

* Removes the warning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation
2023-10-10 10:24:51 -04:00
Tianyi Zheng
fbad85d3ec
Delete empty junk file (#9062)
* updating DIRECTORY.md

* updating DIRECTORY.md

* Delete empty junk file

* updating DIRECTORY.md

* Fix ruff errors

* Fix more ruff errors

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-09-17 00:12:31 +02:00
Kamil
4246da387f
jacobi_iteration_method.py the use of vector operations, which reduces the calculation time by dozens of times (#8938)
* Replaced loops in jacobi_iteration_method function with vector operations. That gives a reduction in the time for calculating the algorithm.

* Replaced loops in jacobi_iteration_method function with vector operations. That gives a reduction in the time for calculating the algorithm.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Delete main.py

* Update jacobi_iteration_method.py

Changed a line that was too long.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update jacobi_iteration_method.py

Changed the type of the returned list as required.

* Update jacobi_iteration_method.py

Replaced init_val with new_val.

* Update jacobi_iteration_method.py

Fixed bug: init_val: list[int]  to  list[float].
Since the numbers are fractional: init_val = [0.5, -0.5, -0.5].

* Update jacobi_iteration_method.py

Changed comments, made variable names more understandable.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update jacobi_iteration_method.py

left the old algorithm commented out, as it clearly shows what is being done.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update jacobi_iteration_method.py

Edits upon request.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-09-11 13:05:32 +02:00
Saransh Chopra
5a5ca06944
Update actions/checkout with fetch-depth: 0 (#9046)
* Update `actions/checkout` with `fetch-depth: 0`

* Update directory_writer.yml

* Create junk.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update directory_writer.yml

* Update directory_writer.yml

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-09-09 19:58:43 +02:00
pre-commit-ci[bot]
421ace81ed
[pre-commit.ci] pre-commit autoupdate (#9013)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.285 → v0.0.286](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.285...v0.0.286)
- [github.com/tox-dev/pyproject-fmt: 0.13.1 → 1.1.0](https://github.com/tox-dev/pyproject-fmt/compare/0.13.1...1.1.0)

* updating DIRECTORY.md

* Fis ruff rules PIE808,PLR1714

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-08-29 15:18:10 +02:00
Dom
1984d97171
Refactorings (#8987)
* use np.dot

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* further improvements using array slicing

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-08-20 16:43:09 -07:00
Caeden Perelli-Harris
44b1bcc7c7
Fix failing tests from ruff/newton_raphson (ignore S307 "possibly insecure function") (#8862)
* chore: Fix failing tests (ignore S307 "possibly insecure function")

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: Move noqa back to right line

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-07-11 11:51:21 +02:00
Christian Clauss
4b79d771cd
Add more ruff rules (#8767)
* Add more ruff rules

* Add more ruff rules

* pre-commit: Update ruff v0.0.269 -> v0.0.270

* Apply suggestions from code review

* Fix doctest

* Fix doctest (ignore whitespace)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-05-26 09:34:17 +02:00
Tianyi Zheng
5ce63b5966
Fix mypy errors in lu_decomposition.py (attempt 2) (#8100)
* updating DIRECTORY.md

* Fix mypy errors in lu_decomposition.py

* Replace for-loops with comprehensions

* Add explanation of LU decomposition and extra doctests

Add an explanation of LU decomposition with conditions for when an LU
decomposition exists

Add extra doctests to handle each of the possible conditions for when a
decomposition exists/doesn't exist

* updating DIRECTORY.md

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-04-01 07:11:24 +02:00
Christian Clauss
c96241b5a5
Replace bandit, flake8, isort, and pyupgrade with ruff (#8178)
* Replace bandit, flake8, isort, and pyupgrade with ruff

* Comment on ruff rules

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-03-15 13:58:25 +01:00
Christian Clauss
c909da9b08
pre-commit: Upgrade psf/black for stable style 2023 (#8110)
* pre-commit: Upgrade psf/black for stable style 2023

Updating https://github.com/psf/black ... updating 22.12.0 -> 23.1.0 for their `2023 stable style`.
* https://github.com/psf/black/blob/main/CHANGES.md#2310

> This is the first [psf/black] release of 2023, and following our stability policy, it comes with a number of improvements to our stable style…

Also, add https://github.com/tox-dev/pyproject-fmt and https://github.com/abravalheri/validate-pyproject to pre-commit.

I only modified `.pre-commit-config.yaml` and all other files were modified by pre-commit.ci and psf/black.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-02-01 18:44:54 +05:30
Caeden Perelli-Harris
9bba42eca8
refactor: Indent ... for visual purposes (#7744) 2022-10-27 19:42:30 +02:00
Caeden
4d0c830d2c
Add flake8 pluin flake8 bugbear to pre-commit (#7132)
* ci(pre-commit): Add ``flake8-builtins`` additional dependency to ``pre-commit`` (#7104)

* refactor: Fix ``flake8-builtins`` (#7104)

* fix(lru_cache): Fix naming conventions in docstrings (#7104)

* ci(pre-commit): Order additional dependencies alphabetically (#7104)

* fix(lfu_cache): Correct function name in docstring (#7104)

* Update strings/snake_case_to_camel_pascal_case.py

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

* Update data_structures/stacks/next_greater_element.py

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

* Update digital_image_processing/index_calculation.py

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

* Update graphs/prim.py

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

* Update hashes/djb2.py

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

* refactor: Rename `_builtin` to `builtin_` ( #7104)

* fix: Rename all instances (#7104)

* refactor: Update variable names (#7104)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* ci: Create ``tox.ini`` and ignore ``A003`` (#7123)

* revert: Remove function name changes (#7104)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Rename tox.ini to .flake8

* Update data_structures/heap/heap.py

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>

* refactor: Rename `next_` to `next_item` (#7104)

* ci(pre-commit): Add `flake8` plugin `flake8-bugbear` (#7127)

* refactor: Follow `flake8-bugbear` plugin (#7127)

* fix: Correct `knapsack` code (#7127)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-13 18:03:06 +02:00
Caeden
d5a9f649b8
Add flake8-builtins to pre-commit and fix errors (#7105)
Ignore `A003`

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-13 19:53:59 +05:30
Caeden
07e991d553
Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062)
* ci(pre-commit): Add pep8-naming to `pre-commit` hooks (#7038)

* refactor: Fix naming conventions (#7038)

* Update arithmetic_analysis/lu_decomposition.py

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

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* refactor(lu_decomposition): Replace `NDArray` with `ArrayLike` (#7038)

* chore: Fix naming conventions in doctests (#7038)

* fix: Temporarily disable project euler problem 104 (#7069)

* chore: Fix naming conventions in doctests (#7038)

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-13 00:54:20 +02:00
Saksham1970
f42b2b8dff
Newton raphson complex (#6545)
* Newton raphson better implementation

* flake8 test passed

* Update arithmetic_analysis/newton_raphson_new.py

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

* added multiline suggestions

Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-02 19:51:04 +02:00
Christian Clauss
b75a7c77f8
pre-commit autoupdate: pyupgrade v2.34.0 -> v2.37.0 (#6245)
* pre-commit autoupdate: pyupgrade v2.34.0 -> v2.37.0

* pre-commit run --all-files
2022-07-11 10:19:52 +02:00
John Law
9135a1f411
Fix doctests and builds in various files (#6233)
* Fix doctest in hamming distance

* add line break

* try to fix quantum_riper_adder

* fix floating point build
2022-07-06 10:00:05 +02:00
Leoriem-code
533eea5afa
fix mypy annotations for arithmetic_analysis (#6040)
* fixed mypy annotations for arithmetic_analysis

* shortened numpy references
2022-05-12 11:35:56 +08:00
Harshit Agarwal
1f1daaf1c7
feat: add strings/ngram algorithm (#6074)
* feat: added ngram algorithm
* fix(test): use `math.isclose` to match floating point numbers approximately

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-04-04 09:06:32 +05:30
Christian Clauss
885580b3a1
pyupgrade --py310-plus and run mypy in precommit, not build (#5996)
* pyupgrade --py310-plus and run mypy in precommit, not build

* pyupgrade --py310-plus web_programming/fetch_well_rx_price.py

* pyupgrade --py310-plus web_programming/fetch_well_rx_price.py

* Fix arithmetic_analysis/in_static_equilibrium.py

* Fix arithmetic_analysis/in_static_equilibrium.py
2022-02-13 11:01:58 +01:00
Christian Clauss
24d3cf8244
The black formatter is no longer beta (#5960)
* The black formatter is no longer beta

* pre-commit autoupdate

* pre-commit autoupdate

* Remove project_euler/problem_145 which is killing our CI tests

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-01-30 20:29:54 +01:00
Nivas Manduva
c3d1ff0ebd
Add Jacobi Iteration Method (#5113)
* Added Jacobi Iteration Method

Added this method in arithmetic_analysis folder. This method is used to solve system of linear equations.

* Added comments

* Added reference link

* Update jacobi_iteration_method.py

* Changes for codespell test

* Update jacobi_iteration_method.py

* Update jacobi_iteration_method.py

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* updating DIRECTORY.md

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update jacobi_iteration_method.py

* Update jacobi_iteration_method.py

* Update jacobi_iteration_method.py

* fix styles

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-11-09 22:40:57 +08:00
Leoriem-code
47dd31f4a1
Add README files 1/7 (#5754)
* Added 5 README files

* corrected arithmetic_analysis README

* Update audio_filters/README.md

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

* Update backtracking/README.md

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

* Update bit_manipulation/README.md

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

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-11-04 18:49:36 +08:00
Christian Clauss
cecf43d648
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-09-07 13:37:03 +02:00
arfy slowy
6732fa0131
[fixed] module 'numpy' is imported with both 'import' and 'import from' (#4544)
* [fixed] module 'numy' is imported with both 'import' and 'import from'

* remove commented
2021-07-26 14:52:52 +02:00
Suyash Shrivastava
407c979063
[Mypy fix] fix secant method (#4501)
* case switch using python

* review comments

* added type hints

* general code format

* [mypy] Fix type annotations for secant_method.py

* remove bad push
2021-07-21 08:01:55 +02:00
algobytewise
5229c74955
[mypy] Fix directory arithmetic_analysis (#4304)
* fix directory arithmetic_analysis

* Update build.yml

* temporary fix for psf/black bug

see https://github.com/psf/black/issues/2079

* Update in_static_equilibrium.py
2021-04-02 09:32:12 +02:00
Dhruv Manilawala
ad5108d6a4
Fix mypy errors for arithmetic analysis algorithms (#4053) 2020-12-23 10:52:43 +01:00
Dhruv
48357cea5b
Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
Dhruv
187e8ccc95
Small fix (#2498) 2020-09-27 15:05:09 +02:00
Christian Clauss
9200a2e543
from __future__ import annotations (#2464)
* from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-23 13:30:13 +02:00
Du Yuanchao
4d0a8f2355
Optimized recursive_bubble_sort (#2410)
* optimized recursive_bubble_sort

* Fixed doctest error due whitespace

* reduce loop times for optimization

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-10 10:31:26 +02:00
Sven
1495382367
Fixed bug with incorrect LU decomposition (#2261)
* Fixed Bug #2257

* =

Co-authored-by: Svn-Sp <svn-sp@email>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-01 22:11:39 +02:00
spamegg
473072bd4f
added type hints and doctests to arithmetic_analysis/newton_method.py (#2259)
* added type hints and doctests to arithmetic_analysis/newton_method.py

Continuing #2128
Also changed some variable names, made them more descriptive.

* Added type hints and doctests to arithmetic_analysis/newton_method.py

added a type alias for Callable[[float], float] and cleaned up the exception handling

* added type hints and doctests to arithmetic_analysis/newton_method.py

improved exception handling

* Update newton_method.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-01 15:17:46 +02:00
spamegg
9cda130c07
added type hints and doctests to arithmetic_analysis/intersection.py (#2242)
continuing #2128
2020-08-01 08:02:31 +02:00
spamegg
bd74f20bf2
added type hints and doctests to arithmetic_analysis/bisection.py (#2241)
* added type hints and doctests to arithmetic_analysis/bisection.py

continuing in line with #2128

* modified arithmetic_analysis/bisection.py

Put back print statement at the end, replaced algorithm's print statement with an exception.

* modified arithmetic_analysis/bisection.py

Removed unnecessary type import "Optional"

* modified arithmetic_analysis/bisection.py

Replaced generic Exception with ValueError.

* modified arithmetic_analysis/bisection.py

fixed doctests
2020-07-27 15:23:55 +02:00
Christian Clauss
5f4da5d616
isort --profile black . (#2181)
* updating DIRECTORY.md

* isort --profile black .

* Black after

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-06 09:44:19 +02:00
Christian Clauss
9316e7c014
Set the Python file maximum line length to 88 characters (#2122)
* flake8 --max-line-length=88

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-16 10:09:19 +02:00
Christian Clauss
1f8a21d727
Tighten up psf/black and flake8 (#2024)
* Tighten up psf/black and flake8

* Fix some tests

* Fix some E741

* Fix some E741

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-22 08:10:11 +02:00
Christian Clauss
bfcb95b297
Create codespell.yml (#1698)
* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
2020-01-18 13:24:33 +01:00
Christian Clauss
34c808b375 actions/checkout@v2 (#1643)
* actions/checkout@v2

https://github.com/actions/checkout/releases

* fixup! Format Python code with psf/black push
2019-12-26 19:50:12 +08:00
Rohit Joshi
f4779bc04a Bug Fixed in newton_raphson_method.py (#1634)
* Bug Fixed

* Fixed newton_raphson_method.py

* Fixed newton_raphson_method.py 2

* Fixed newton_raphson_method.py 3

* Fixed newton_raphson_method.py 4

* Fixed newton_raphson_method.py 5

* Fixed newton_raphson_method.py 6

* Update newton_raphson_method.py

* Update newton_raphson_method.py

* # noqa: F401, F403

* newton_raphson

* newton_raphson

* precision: int=10 ** -10

* return float(x)

* 3.1415926536808043

* Update newton_raphson_method.py

* 2.23606797749979

* Update newton_raphson_method.py

* Rename newton_raphson_method.py to newton_raphson.py
2019-12-15 08:27:07 +01:00
GeorgeChambi
9eb50cc223 Improved readability (#1615)
* improved readability

* further readability improvements

* removed csv file and added f
2019-12-07 06:39:59 +01:00
dimgrichr
f8a30b42ce Addition of Secant Method (#876)
* Add files via upload

* Update secant_method.py

* Remove unused import

* Remove unused import
2019-10-28 19:27:00 +01:00
Isaac Gomes de Oliveira
03e9a75d69 Add gaussian_elimination.py for solving linear systems (#1448) 2019-10-25 05:56:56 +02:00
Anmol Jain
54830644a2 Create newton_forward_interpolation.py (#333)
* Create newton_forward_interpolation.py

This code is for calculating newton forward difference interpolation for fixed difference.

* Add doctests and reformat with black
2019-10-22 10:01:14 +02:00
William Zhang
9eac17a408 psf/black code formatting (#1277) 2019-10-05 10:14:13 +05:00
Shubham garg
03aba96c0a added defination (#1244) 2019-10-03 21:31:11 +02:00
Christian Clauss
89acf5d017 print() is a function just like every other function (#1101)
* print() is a function just like every other function
2019-08-06 12:14:23 +02:00