Skip to content

Commit

Permalink
precommit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cnheider committed Feb 6, 2021
1 parent 6e07627 commit 2670cbd
Show file tree
Hide file tree
Showing 154 changed files with 877 additions and 261 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ on: push
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [ 3.7, 3.8 ]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@master
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements/requirements_dev.txt
pip install -r requirements/requirements_docs.txt
- uses: cnheider/postdoc@master

20 changes: 19 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
fail_fast: true
#exclude: '^exclude'
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.7
language_version: python3.7
- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest
language: system
pass_filenames: false
always_run: true
- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest
language: system
pass_filenames: false
always_run: true
16 changes: 12 additions & 4 deletions benchmarks/torch_benchmarks/generator_vs_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def test_d3():
def test_d4():
from torchvision.transforms import transforms
import numpy
from draugr.generators.recycling import batched_recycle
from draugr import inner_map

a_transform = transforms.Compose(
Expand Down Expand Up @@ -195,6 +194,9 @@ def test_d4():
).to(device)

class RandomDataset(Dataset):
"""
"""

def __init__(self):
self.d = numpy.random.sample(data_shape)

Expand Down Expand Up @@ -239,7 +241,6 @@ def __getitem__(self, item):
def test_d5():
from torchvision.transforms import transforms
import numpy
from draugr.generators.recycling import batched_recycle
from draugr import inner_map

a_transform = transforms.Compose(
Expand All @@ -263,6 +264,9 @@ def test_d5():
batch_shape = torch.Size([batch_size, channels_in, 224, 224])

class RandomDataset(Dataset):
"""
"""

def __init__(self):
self.d = numpy.random.sample(data_shape)

Expand Down Expand Up @@ -305,7 +309,6 @@ def __getitem__(self, item):
def test_d6():
from torchvision.transforms import transforms
import numpy
from draugr.generators.recycling import batched_recycle
from draugr import inner_map

a_transform = transforms.Compose(
Expand All @@ -329,6 +332,9 @@ def test_d6():
batch_shape = torch.Size([batch_size, channels_in, 224, 224])

class RandomDataset(Dataset):
"""
"""

def __init__(self):
self.d = numpy.random.sample(data_shape)

Expand Down Expand Up @@ -371,7 +377,6 @@ def __getitem__(self, item):

def test_d7():
import numpy
from draugr.generators.recycling import batched_recycle

channels_in = 3

Expand All @@ -384,6 +389,9 @@ def test_d7():
dtype = torch.float

class RandomDataset(Dataset):
"""
"""

def __init__(self):
self.d = numpy.random.sample(data_shape)

Expand Down
4 changes: 4 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,16 @@


def patched_make_field(self, types, domain, items, **kw) -> nodes.field:
"""
"""
# `kw` catches `env=None` needed for newer sphinx while maintaining
# backwards compatibility when passed along further down!

## type: (List, unicode, Tuple) -> nodes.field

def handle_item(fieldarg, content):
"""
"""
par = nodes.paragraph()
par += addnodes.literal_strong("", fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
Expand Down
2 changes: 2 additions & 0 deletions draugr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def dist_is_editable(dist: Any) -> bool:


def get_version(append_time: Any = DEVELOP) -> str:
"""
"""
version = __version__
if not version:
version = os.getenv("VERSION", "0.0.0")
Expand Down
4 changes: 2 additions & 2 deletions draugr/drawers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
__doc__ = r"""
"""

import pathlib
from pathlib import Path

with open(pathlib.Path(__file__).parent / "README.md", "r") as this_init_file:
with open(Path(__file__).parent / "README.md", "r") as this_init_file:
__doc__ += this_init_file.read()

from .mpl_drawers import *
2 changes: 2 additions & 0 deletions draugr/drawers/drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
class Drawer(object):
@abstractmethod
def draw(self, *args, **kwargs):
"""
"""
raise NotImplementedError

def __enter__(self):
Expand Down
8 changes: 3 additions & 5 deletions draugr/drawers/mpl_drawers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
__doc__ = r"""
"""

import pathlib
from pathlib import Path

with open(pathlib.Path(__file__).parent / "README.md", "r") as this_init_file:
with open(Path(__file__).parent / "README.md", "r") as this_init_file:
__doc__ += this_init_file.read()

try:
Expand All @@ -17,7 +17,5 @@
from draugr.drawers.mpl_drawers.series_scroll_plot import *
from draugr.drawers.mpl_drawers.spectral import *
except ImportError as ix:
print(
f"Make sure requirements is installed for {pathlib.Path(__file__).parent.name}"
)
print(f"Make sure requirements is installed for {Path(__file__).parent.name}")
raise ix
23 changes: 21 additions & 2 deletions draugr/drawers/mpl_drawers/discrete_scroll_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ def discrete_scroll_plot(
reverse: bool = True,
overwrite: bool = False,
):
"""
"""
d = vector_provider.__next__()
num_actions = len(d)
if not window_length:
Expand All @@ -169,6 +171,8 @@ def discrete_scroll_plot(
array[-1] = d

def update_fig(n):
"""
"""
data = vector_provider.__next__()
array = im.get_array()

Expand Down Expand Up @@ -239,10 +243,14 @@ def update_fig(n):
if __name__ == "__main__":

def siajdisajd():
"""
"""
import queue
import threading

def ma():
"""
"""
data = queue.Queue(100)

class QueueGen:
Expand All @@ -256,25 +264,35 @@ def __call__(self, *args, **kwargs):
return self.__next__()

def add(self, a):
"""
"""
return data.put(a)

def get(self):
"""
"""
return data.get()

def get_sample(num_actions=3):
"""
"""
a = numpy.zeros(num_actions)
a[numpy.random.randint(0, num_actions)] = 1.0
return a

class MyDataFetchClass(threading.Thread):
"""
"""

def __init__(self, data):

threading.Thread.__init__(self)

self._data = data

def run(self):

"""
"""
while True:
self._data.add(get_sample())

Expand All @@ -290,7 +308,8 @@ def run(self):
print("Plot Closed")

def asda():

"""
"""
s = DiscreteScrollPlot(3, default_delta=None)
for _ in range(100):
s.draw(numpy.random.rand(3))
Expand Down
4 changes: 4 additions & 0 deletions draugr/drawers/mpl_drawers/image_stream_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def _draw(self, data: Sequence):

@staticmethod
def close(event):
"""
"""
if event.key == "q":
pyplot.close(event.canvas.figure)
raise StopIteration
Expand All @@ -57,6 +59,8 @@ def close(event):
if __name__ == "__main__":

def asdasf():
"""
"""
import cv2
from draugr.opencv_utilities import frame_generator
from draugr.tqdm_utilities import progress_bar
Expand Down
8 changes: 4 additions & 4 deletions draugr/drawers/mpl_drawers/mpldrawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def __post_init__(self,*, figure_size: Tuple[int, int] = None):
"""

def draw(self, data: Any, delta: float = None):
"""
"""
if not self.fig:
raise NotImplementedError(
"Figure was not instantiated check specialisation of MplDrawer"
Expand Down Expand Up @@ -120,8 +122,7 @@ def _draw(self, data: Any) -> None:
:param data:
:type data:
:param delta:
:type delta:"""
"""
raise NotImplementedError


Expand All @@ -135,6 +136,5 @@ def _draw(self, data: Sequence) -> None:
:param data:
:type data:
:param delta:
:type delta:"""
"""
pass
2 changes: 2 additions & 0 deletions draugr/drawers/mpl_drawers/series_scroll_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ def _draw(self, data: Union[Sequence, int, float, complex]):
if __name__ == "__main__":

def asidjas():
"""
"""
from math import cos, sin

def multi_series():
Expand Down
2 changes: 2 additions & 0 deletions draugr/drawers/mpl_drawers/spectral/fast_fourier_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def _draw(self, signal_sample: float, delta: float = 1 / 120) -> None:
if __name__ == "__main__":

def a():
"""
"""
duration_sec = 4
mul = 1000
sampling_Hz = 44
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ def _draw(self, signal_sample: float, delta: float = 1 / 120) -> None:
if __name__ == "__main__":

def a():
"""
"""
duration_sec = 4
mul = 1000
sampling_Hz = 44.1
Expand Down
5 changes: 3 additions & 2 deletions draugr/drawers/opencv_drawers/opencv_image_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from typing import Sequence

import cv2

from draugr.drawers.drawer import Drawer
from warg import passes_kws_to


class OpencvImageStream(Drawer):
Expand Down Expand Up @@ -40,7 +40,8 @@ def draw(self, data: Sequence):
if __name__ == "__main__":

def asdasf():

"""
"""
from draugr.opencv_utilities import frame_generator, AsyncVideoStream
from draugr.tqdm_utilities import progress_bar

Expand Down
4 changes: 2 additions & 2 deletions draugr/entry_points/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Created on 9/5/19
"""

import pathlib
from pathlib import Path

with open(pathlib.Path(__file__).parent / "README.md", "r") as this_init_file:
with open(Path(__file__).parent / "README.md", "r") as this_init_file:
__doc__ += this_init_file.read()
2 changes: 2 additions & 0 deletions draugr/entry_points/cpu_usage_entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@


def main():
"""
"""
# from draugr import TerminalPlotWriter
from draugr.drawers import SeriesScrollPlot
import psutil
Expand Down
2 changes: 2 additions & 0 deletions draugr/entry_points/toggle_darkmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@


def main():
"""
"""
with GtkThemePreferences() as a:
a.prefer_dark_mode = not a.prefer_dark_mode

Expand Down
Loading

0 comments on commit 2670cbd

Please sign in to comment.