Skip to content

Commit d2430f8

Browse files
authored
Sadhiin/setup issue and github action failed (#93)
* Hacktoberfest contribution. Added Faster way to revers a list in python with proper docstring explaination. * Hacktoberfest contribution. Update the docstring * Hacktoberfest contribution: Add function to reverse a linked list * Hacktoberfest Contribute fixed #92 for github action task and publish as pypi package * Update .gitignore file * updat the setup and github workflow file with requirements install * hadling the error for requests module * newly added regex removed from the workflow * Hacktoberfest contribution. Update the docstring
1 parent dbd94af commit d2430f8

File tree

8 files changed

+297
-32
lines changed

8 files changed

+297
-32
lines changed

.github/workflows/publish-to-test-pypi.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ jobs:
99
steps:
1010
- uses: actions/checkout@master
1111
- name: Set up Python 3.9
12-
uses: actions/setup-python@v1
12+
uses: actions/setup-python@v3
1313
with:
1414
python-version: "3.9"
15+
- name: Update pip
16+
run: python -m pip install --upgrade pip
17+
- name: Install dependencies
18+
run: |
19+
pip install -r requirements.txt
20+
pip install .
1521
- name: Install pypa/build
1622
run: >-
1723
python -m

.github/workflows/run_black_and_isort.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ jobs:
2020
python-version: ${{ matrix.python-version }}
2121
- name: Install dependencies
2222
run: |
23+
pip install --upgrade pip
24+
pip install -r requirements.txt
2325
pip install .
2426
pip install black isort
2527
- name: Run black and isort
2628
run: |
2729
python -m black easyPythonpi/*
2830
python -m isort easyPythonpi/*
29-
31+

.github/workflows/run_tests.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
14+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
1515
os: [ubuntu-latest, macos-latest]
1616
steps:
1717
- uses: actions/checkout@v3
@@ -21,6 +21,8 @@ jobs:
2121
python-version: ${{ matrix.python-version }}
2222
- name: Install dependencies
2323
run: |
24+
pip install --upgrade pip
25+
pip install -r requirements.txt
2426
pip install .
2527
pip install regex
2628
- name: Run tests

.gitignore

+164-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,168 @@
1-
# prevents all pycaches from being added
1+
# prevents all pycaches from being added
22
__pycache__
33
easyPythonpi/__pycache__
44
build
55
dist
6-
easyPythonpi.egg.info
6+
easyPythonpi.egg.info
7+
8+
__pycache__/
9+
*.py[cod]
10+
*$py.class
11+
12+
# C extensions
13+
*.so
14+
15+
# Distribution / packaging
16+
.Python
17+
build/
18+
develop-eggs/
19+
dist/
20+
downloads/
21+
eggs/
22+
.eggs/
23+
lib/
24+
lib64/
25+
parts/
26+
sdist/
27+
var/
28+
wheels/
29+
share/python-wheels/
30+
*.egg-info/
31+
.installed.cfg
32+
*.egg
33+
MANIFEST
34+
35+
# PyInstaller
36+
# Usually these files are written by a python script from a template
37+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
38+
*.manifest
39+
*.spec
40+
41+
# Installer logs
42+
pip-log.txt
43+
pip-delete-this-directory.txt
44+
45+
# Unit test / coverage reports
46+
htmlcov/
47+
.tox/
48+
.nox/
49+
.coverage
50+
.coverage.*
51+
.cache
52+
nosetests.xml
53+
coverage.xml
54+
*.cover
55+
*.py,cover
56+
.hypothesis/
57+
.pytest_cache/
58+
cover/
59+
60+
# Translations
61+
*.mo
62+
*.pot
63+
64+
# Django stuff:
65+
*.log
66+
local_settings.py
67+
db.sqlite3
68+
db.sqlite3-journal
69+
70+
# Flask stuff:
71+
instance/
72+
.webassets-cache
73+
74+
# Scrapy stuff:
75+
.scrapy
76+
77+
# Sphinx documentation
78+
docs/_build/
79+
80+
# PyBuilder
81+
.pybuilder/
82+
target/
83+
84+
# Jupyter Notebook
85+
.ipynb_checkpoints
86+
87+
# IPython
88+
profile_default/
89+
ipython_config.py
90+
91+
# pyenv
92+
# For a library or package, you might want to ignore these files since the code is
93+
# intended to run in multiple environments; otherwise, check them in:
94+
# .python-version
95+
96+
# pipenv
97+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
98+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
99+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
100+
# install all needed dependencies.
101+
#Pipfile.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
#.idea/

easyPythonpi/methods/array.py

+24
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,27 @@ def arrayrev(array:'list')->'list':
3434

3535
return reversed_array
3636

37+
38+
def fast_arrayrev(array: 'list') -> 'list':
39+
"""
40+
Reverses the elements of the input list.
41+
42+
Parameters:
43+
array (list): The list to be reversed.
44+
45+
Returns:
46+
list: A new list containing the elements of the input list in reverse order.
47+
48+
Steps:
49+
1. The function takes a single argument, `array`, which is expected to be a list.
50+
2. It uses Python's slicing feature to reverse the list:
51+
- The slice notation `array[::-1]` means:
52+
- Start[start::] from the end [:end:] of the list (indicated by the negative step)[start : end : -1].
53+
- Move backwards through the list.
54+
- The result is a new list that contains the elements of `array` in reverse order.
55+
3. The reversed list is stored in the variable `reversed_array`.
56+
4. Finally, the function returns `reversed_array`, which is the reversed version of the input list.
57+
source: https://www.geeksforgeeks.org/python-reversed-vs-1-which-one-is-faster/
58+
"""
59+
reversed_array = array[::-1]
60+
return reversed_array

easyPythonpi/methods/linkedlist.py

+35-20
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,56 @@
22
#-*- coding: utf-8 -*-
33

44

5-
#Linked list
6-
7-
def create_node(data:'int')->'list':
8-
class node:
9-
def __init__(self,data):
10-
self.data=data
11-
self.next=None
12-
13-
a=node(data)
5+
#Linked list
6+
7+
class Node:
8+
def __init__(self,data):
9+
self.data=data
10+
self.next=None
11+
12+
def create_node(data:'int')->'Node':
13+
a=Node(data)
1414
return a
1515

16+
1617
# to link a node with another node
17-
def node_link(a:'int',b:'int'):
18+
def node_link(a:'Node', b:'Node'):
1819
a.next=b
1920
b.next=None
2021
#a=node(data1)
21-
22-
23-
# to count number of nodes
24-
def count_node(head:'node')->'int':
22+
23+
24+
# to count number of nodes
25+
def count_node(head:'Node')->'int':
26+
count=0
2527
if head is None:
26-
return 0
28+
return count
2729
else:
2830
temp=head
29-
count=0
3031
while(temp!=None):
31-
count=count+1
32-
temp=temp.next
33-
return count
32+
count=count+1
33+
temp=temp.next
34+
return count
3435

3536
# to diplay a linked list whose header node is passed as an argument.
36-
def display_nodes(head:'node')->'int':
37+
def display_nodes(head:'Node')->None:
3738
t=head
3839
while t is not None:
3940
print(t.data,"->",end="")
4041
t=t.next
4142
print("NULL")
4243

44+
# re revrese a lined list
45+
def revrese_lined_list(head: 'Node')->'Node':
46+
prev = None
47+
# a -> b -> c -> d -> e -> f -> g -> h -> None
48+
current = head
49+
while current is not None:
50+
next = current.next # b -> c -> d -> so one...
51+
52+
current.next = prev # a -> None
53+
prev = current # b -> a -> None
54+
current = next # c -> d -> e -> f -> g -> h -> None
55+
head=prev # h -> g -> f -> e -> d -> c -> b -> a -> None
56+
57+
return head

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
numpy >= 1.19.5
2+
requests >= 2.25.1

0 commit comments

Comments
 (0)