Skip to content

UP my solution #111

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,16 @@ jobs:
name: Check code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.11
- name: Install dependencies
run: |
pip install flake8 pydocstyle
- name: Lint with flake8
python -m pip install --upgrade pip
pip install ruff
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --max-complexity=10 --max-line-length=80 --statistics
- name: Check doc style with pydocstyle
run: pydocstyle
ruff check --output-format=github .

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- Create a branch called `my_user_name` using `git checkout -b my_user_name`
- Make the changes to complete the assignment. You have to modify the files that contain `questions` in their name. Do not modify the files that start with `test_`.
- Check locally that your solution meet the test by running `pytest` from the root of the repo. You may need to install `pytest` using `pip` or `conda`.
- Check the code formating for your solution using `flake8`. You may need to install `flake8` using `pip` or `conda`.
- Check the code formating for your solution using `ruff`. You may need to install `ruff` using `pip` or `conda`.
- Open the pull request on GitHub:
- Create a commit with `git add -u` and `git commit -m "UP my solution"`
- Push your branch on your fork: `git push -u origin my_user_name`
Expand Down
20 changes: 17 additions & 3 deletions numpy_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
This will be enforced with `flake8`. You can check that there is no flake8
errors by calling `flake8` at the root of the repo.
"""

import numpy as np


Expand All @@ -39,9 +40,11 @@ def max_index(X):
"""
i = 0
j = 0

if not isinstance(X, np.ndarray) or X.ndim != 2:
raise ValueError()
# TODO

max_val = np.max(X)
i, j = np.where(X == max_val)
return i, j


Expand All @@ -64,4 +67,15 @@ def wallis_product(n_terms):
"""
# XXX : The n_terms is an int that corresponds to the number of
# terms in the product. For example 10000.
return 0.
if n_terms == 0:
return 2

product = 1
for i in range(1, n_terms + 1):
product *= (4 * i**2) / (4 * i**2 - 1)





return 2 * product
Loading