Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
b922ba6941 | |||
80b3280a83 | |||
356d8285e5 | |||
82ba1f0f45 | |||
4700cded06 | |||
501efc7365 | |||
aea6e29ec9 | |||
c3f91dc1e0 |
19
1_hw/LICENSE
Normal file
19
1_hw/LICENSE
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2018 The Python Packaging Authority
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
33
1_hw/README.md
Normal file
33
1_hw/README.md
Normal file
@ -0,0 +1,33 @@
|
||||
# Test package
|
||||
|
||||
## Sequence of commands for creating a virtual environment:
|
||||
```
|
||||
>> mkdir YOUR_PACKAGE_NAME
|
||||
>> cd YOUR_PACKAGE_NAME
|
||||
>> touch __init__.py
|
||||
>> cd ..
|
||||
>> touch pyproject.toml
|
||||
>> open pyproject.toml
|
||||
...
|
||||
>> touch LICENSE
|
||||
>> open LICENSE
|
||||
...
|
||||
>> touch README.md
|
||||
>> open README.md
|
||||
...
|
||||
>> python3 -m build
|
||||
```
|
||||
|
||||
## Creating documentation using sphinx:
|
||||
```
|
||||
>> mkdir docs
|
||||
>> cd docs
|
||||
>> sphinx-quickstart
|
||||
>> ...
|
||||
>> touch views.py
|
||||
>> open views.py
|
||||
>> ...
|
||||
>> cd source
|
||||
>> open index.rst
|
||||
>> ...
|
||||
```
|
1
1_hw/controls_Ermakov/__init__.py
Normal file
1
1_hw/controls_Ermakov/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
"""It's docstring!"""
|
BIN
1_hw/dist/controls_ermakov-0.0.1-py3-none-any.whl
vendored
Normal file
BIN
1_hw/dist/controls_ermakov-0.0.1-py3-none-any.whl
vendored
Normal file
Binary file not shown.
BIN
1_hw/dist/controls_ermakov-0.0.1.tar.gz
vendored
Normal file
BIN
1_hw/dist/controls_ermakov-0.0.1.tar.gz
vendored
Normal file
Binary file not shown.
20
1_hw/docs/Makefile
Normal file
20
1_hw/docs/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = source
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
28
1_hw/docs/conf.py
Normal file
28
1_hw/docs/conf.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# For the full list of built-in configuration values, see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
||||
|
||||
project = 'controls_Ermakov'
|
||||
copyright = '2023, Ermakov Alexey'
|
||||
author = 'Ermakov Alexey'
|
||||
release = '0.0.1'
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||
|
||||
extensions = []
|
||||
|
||||
templates_path = ['_templates']
|
||||
exclude_patterns = []
|
||||
|
||||
language = 'python3'
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
||||
|
||||
html_theme = 'alabaster'
|
||||
html_static_path = ['_static']
|
29
1_hw/docs/index.rst
Normal file
29
1_hw/docs/index.rst
Normal file
@ -0,0 +1,29 @@
|
||||
.. controls_Ermakov documentation master file, created by
|
||||
sphinx-quickstart on Fri Sep 29 17:02:16 2023.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to controls_Ermakov's documentation!
|
||||
============================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
||||
Documentation myproject
|
||||
======================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: example of automatic-generative docs views
|
||||
|
||||
./views.rst
|
35
1_hw/docs/make.bat
Normal file
35
1_hw/docs/make.bat
Normal file
@ -0,0 +1,35 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.https://www.sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
6
1_hw/docs/views.rst
Normal file
6
1_hw/docs/views.rst
Normal file
@ -0,0 +1,6 @@
|
||||
Views
|
||||
=====
|
||||
|
||||
.. automodule:: test_app.views
|
||||
:members:
|
||||
:undoc-members:
|
22
1_hw/pyproject.toml
Normal file
22
1_hw/pyproject.toml
Normal file
@ -0,0 +1,22 @@
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.poetry]
|
||||
name = "controls_Ermakov"
|
||||
version = "0.0.1"
|
||||
description = "Homework project"
|
||||
authors = ["Ermakov Alexey <[ermakov.ad@phystech.edu]>"]
|
||||
license = "MIT"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
pytest = "^4.6"
|
||||
Pylint = "^2.0"
|
||||
MyPy = "^1.2"
|
||||
|
||||
[tool.poetry.extras]
|
||||
docs = ["sphinx"]
|
||||
extensions = ["sphinx.ext.autodoc"]
|
BIN
2_hw/results.xlsx
Normal file
BIN
2_hw/results.xlsx
Normal file
Binary file not shown.
24
2_hw/with_numpy.py
Normal file
24
2_hw/with_numpy.py
Normal file
@ -0,0 +1,24 @@
|
||||
import time
|
||||
import numpy as np
|
||||
|
||||
def mandelbrot(pmin = -2.5, pmax = 1.5, qmin = -2, qmax = 2,
|
||||
ppoints = 200, qpoints = 200, max_iterations = 300, infinity_border= 100):
|
||||
|
||||
image = np.zeros((ppoints, qpoints))
|
||||
|
||||
for ip, p in enumerate(np.linspace(pmin, pmax, ppoints)):
|
||||
for iq, q in enumerate(np.linspace(qmin, qmax, qpoints)):
|
||||
c = p + 1j * q
|
||||
z = 0
|
||||
for k in range(max_iterations):
|
||||
z = z ** 2 + c
|
||||
if abs(z) > infinity_border:
|
||||
|
||||
image[ip, iq] = 1
|
||||
break
|
||||
return image
|
||||
|
||||
tic = time.perf_counter_ns()
|
||||
image = mandelbrot()
|
||||
toc = time.perf_counter_ns()
|
||||
print((toc - tic)/1_000_000_000, "s")
|
30
2_hw/with_typing_hints.py
Normal file
30
2_hw/with_typing_hints.py
Normal file
@ -0,0 +1,30 @@
|
||||
from __future__ import annotations
|
||||
import time
|
||||
|
||||
def linspace(start, stop, n):
|
||||
if n == 1:
|
||||
yield stop
|
||||
return
|
||||
h = (stop - start) / (n - 1)
|
||||
for i in range(n):
|
||||
yield start + h * i
|
||||
|
||||
def mandelbrot(pmin: float = -2.5, pmax: float = 1.5, qmin: float = -2, qmax: float = 2,
|
||||
ppoints: int = 200, qpoints: int = 200, max_iterations: int = 300, infinity_border: float = 100) -> list[list[int]]:
|
||||
|
||||
image: list[list[int]] = [[0 for i in range(qpoints)] for j in range(ppoints)]
|
||||
for ip, p in enumerate(linspace(pmin, pmax, ppoints)):
|
||||
for iq, q in enumerate(linspace(qmin, qmax, qpoints)):
|
||||
c: complex = p + 1j * q
|
||||
z: complex = 0
|
||||
for k in range(max_iterations):
|
||||
z = z ** 2 + c
|
||||
if abs(z) > infinity_border:
|
||||
image[ip][iq] = 1
|
||||
break
|
||||
return image
|
||||
|
||||
tic = time.perf_counter_ns()
|
||||
image = mandelbrot()
|
||||
toc = time.perf_counter_ns()
|
||||
print((toc - tic)/1_000_000_000, "s")
|
28
2_hw/without_typing_hints.py
Normal file
28
2_hw/without_typing_hints.py
Normal file
@ -0,0 +1,28 @@
|
||||
import time
|
||||
|
||||
def linspace(start, stop, n):
|
||||
if n == 1:
|
||||
yield stop
|
||||
return
|
||||
h = (stop - start) / (n - 1)
|
||||
for i in range(n):
|
||||
yield start + h * i
|
||||
|
||||
def mandelbrot(pmin = -2.5, pmax= 1.5, qmin = -2, qmax= 2,
|
||||
ppoints = 200, qpoints = 200, max_iterations = 300, infinity_border = 100):
|
||||
image = [[0 for i in range(qpoints)] for j in range(ppoints)]
|
||||
for ip, p in enumerate(linspace(pmin, pmax, ppoints)):
|
||||
for iq, q in enumerate(linspace(qmin, qmax, qpoints)):
|
||||
c = p + 1j * q
|
||||
z = 0
|
||||
for k in range(max_iterations):
|
||||
z = z ** 2 + c
|
||||
if abs(z) > infinity_border:
|
||||
image[ip][iq] = 1
|
||||
break
|
||||
return image
|
||||
|
||||
tic = time.perf_counter_ns()
|
||||
image = mandelbrot()
|
||||
toc = time.perf_counter_ns()
|
||||
print((toc - tic)/1_000_000_000, "s")
|
Loading…
Reference in New Issue
Block a user