text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
import time
from typing import Union, List, Tuple
from .abstract import cwipc_abstract_filter
from ..util import cwipc_pointcloud_wrapper
from ..registration.util import cwipc_randomize_floor
class RandomizeFloorFilter(cwipc_abstract_filter):
"""
randomize_floor - Find all points that are considered to represe... | cwi-dis/cwipc_util | python/cwipc/filters/randomize_floor.py | .py | 523927cbcab1dd38 | 7.24 | 2 |
import time
from typing import Union, List
from .abstract import cwipc_abstract_filter
from ..util import cwipc_pointcloud_wrapper, cwipc_from_points
class TransformFilter(cwipc_abstract_filter):
"""
transform - Adjust coordinate system of the point clouds.
Arguments:
x: offset to add to X ... | cwi-dis/cwipc_util | python/cwipc/filters/transform.py | .py | bed1078733416f9c | 7.24 | 2 |
import time
from typing import Union, List
from .abstract import cwipc_abstract_filter
from ..util import cwipc_pointcloud_wrapper
from ..registration.util import transformation_frompython, cwipc_transform
class Transform44Filter(cwipc_abstract_filter):
"""
transform - Adjust coordinate system of the point clo... | cwi-dis/cwipc_util | python/cwipc/filters/transform44.py | .py | 462b8cb6533565b8 | 7.24 | 2 |
"""
Defines the base class for Qt-based frontend windows.
Using Qt with Python presents an issue in which Python exceptions are swallowed.
The workaround to the problem is to use a custom exception handler as follows:
1. Back up the reference to the default system exception hook
2. Set a custom exception hook ... | cwi-dis/cwipc_util | python/cwipc/io/qt/mainwindow.py | .py | 4afc879348172885 | 7.24 | 2 |
"""
A Qt OpenGLWidget which displays point clouds and allows for user exploration.
"""
import time
import traceback
from dataclasses import dataclass
from PySide6.QtCore import Qt, QPointF, QTimer
from PySide6.QtGui import QSurfaceFormat, QKeyEvent, QMouseEvent, QWheelEvent
from PySide6.QtOpenGLWidgets import QOpenGLW... | cwi-dis/cwipc_util | python/cwipc/io/qt/pointcloudwidget/pointcloudwidget.py | .py | 7183f7dd2f3c7ece | 7.24 | 2 |
"""
The vector class.
"""
from __future__ import annotations
import numpy as np
from dataclasses import astuple, dataclass
from typing import Iterator
@dataclass(frozen=True)
class Vector:
x: float = 0.0
y: float = 0.0
z: float = 0.0
@staticmethod
def normalize(v: Vector) -> Vector:
"""... | cwi-dis/cwipc_util | python/cwipc/io/qt/utility/vector.py | .py | 8e05d36a3d582faf | 7.24 | 2 |
import queue
import time
Empty = queue.Empty
Full = queue.Full
class PeekQueue[T](queue.Queue[T]):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def dont_get(self, block : bool=True, timeout : float=None):
'''Does everything Queue.get does except removing and returni... | cwi-dis/cwipc_util | python/cwipc/net/peek_queue.py | .py | 4cffcdaf3b76ec85 | 7.24 | 2 |
"""In-Memory File System — path-based design (LeetCode #588).
Build a filesystem in memory addressed by absolute paths like
``/a/b/file``. The structure is a **trie of path components**: each node
is a directory (a dict of named children) or a file (a string of
content). Resolving a path means walking the trie one com... | rustatian/Algos_Python | Algorithms/probe1/build_fs/src/build_fs/build_fs.py | .py | b040516eb3e92d6e | 7 | 0 |
"""Tests for evil_hangman_reveal (Tier 1).
Every test fixes (candidates, guess, revealed) and asserts the returned
(new_candidates, new_revealed). The adversary's policy is:
1. Partition candidates by their reveal-pattern under `guess`.
2. Pick the group maximising (group_size, count_of_underscores).
—... | rustatian/Algos_Python | Algorithms/probe1/evil_hangman/tests/test_evil_hangman.py | .py | 1ce5fd8db780abc9 | 7.5 | 0 |
from __future__ import annotations
import importlib.machinery
import importlib.util
import os
import pathlib
import shutil
import socket
import subprocess
import sys
import time
import types
from collections.abc import Generator
import pytest
REPO_ROOT = pathlib.Path(__file__).parent.parent.resolve()
BOOTSTRAP_PY = ... | diegoferigo/dotfiles | tests/conftest.py | .py | e85787a6efacebd2 | 7.85 | 4 |
import os
import secrets
from collections.abc import Callable
from contextvars import ContextVar
import jinja2
from flask import current_app, make_response, render_template, request
from flask_wtf.csrf import CSRFError
from gds_metrics import GDSMetrics
from notifications_utils import request_helper
from notifications... | alphagov/document-download-frontend | app/__init__.py | .py | 39b9ba1793780347 | 7.3 | 3 |
from flask import request
from flask.ctx import has_request_context
from notifications_python_client.notifications import NotificationsAPIClient
class OnwardsRequestNotificationsAPIClient(NotificationsAPIClient):
def generate_headers(self, api_token):
headers = super().generate_headers(api_token)
... | alphagov/document-download-frontend | app/notify_client/service_api_client.py | .py | e50a6a951646bb56 | 7.3 | 3 |
"""
Array-of-vectors utilities — element-wise cross, dot and normalisation operations on (N, 3) numpy arrays.
"""
# operations with an array of 3D vectors, v[n_vectors,3]
import numpy
def vector_cross(u ,v):
# w = u X v
# u = array (npoints,vector_index)
w = numpy.zeros_like(u)
w[: ,0] = u[: ,1] * v[... | oasys-kit/wofryimpl | wofryimpl/beamline/optical_elements/util/arrayofvectors.py | .py | 4f7e5b4783e708e5 | 7.15 | 1 |
"""
S4OpticalSurface — abstract base class for optical surface shapes used in wofryimpl mirror elements.
"""
# abstract class defining the interfaces of the optical surfaces to be implemented in the children classes
# it also defines common utilities
import numpy
import os
import h5py
import time
class S4OpticalSurf... | oasys-kit/wofryimpl | wofryimpl/beamline/optical_elements/util/s4_optical_surface.py | .py | 472da42c75fdabfe | 7.15 | 1 |
"""
Fresnel1D — 1-D near-field Fresnel propagator using FFT-based convolution with the transfer function.
"""
import numpy
from srxraylib.util.data_structures import ScaledArray
from wofry.propagator.wavefront1D.generic_wavefront import GenericWavefront1D
from wofry.propagator.propagator import Propagator1D
class Fre... | oasys-kit/wofryimpl | wofryimpl/propagator/propagators1D/fresnel.py | .py | c25d08060e1dc602 | 7.15 | 1 |
"""
FresnelZoomScalingTheorem1D — 1-D zoomed Fresnel propagator based on the scaling theorem (magnification-preserving FFT).
"""
import numpy
from wofry.propagator.wavefront1D.generic_wavefront import GenericWavefront1D
from wofry.propagator.propagator import Propagator1D
class FresnelZoomScaling1D(Propagator1D):
... | oasys-kit/wofryimpl | wofryimpl/propagator/propagators1D/fresnel_zoom_scaling_theorem.py | .py | 8899e4b864f041d1 | 7.15 | 1 |
import datetime as dt
from typing import Annotated
import typer
from github import Github, UnknownObjectException
from github.Label import Label
from github.Repository import Repository
app = typer.Typer(help="A CLI tool to automate Hacktoberfest labeling")
@app.command()
def main(
github_token: Annotated[
... | browniebroke/hacktoberfest-labeler-action | src/hacktoberfest_labeler/cli.py | .py | 9db14c8f72a7c539 | 7.24 | 2 |
"""Pytest configuration and fixtures."""
from types import SimpleNamespace
import pytest
from pytest_mock import MockerFixture
@pytest.fixture
def mock_repo(mocker: MockerFixture):
"""Create a mock Repository instance."""
repo = mocker.MagicMock()
repo.get_topics.return_value = []
return repo
@pyt... | browniebroke/hacktoberfest-labeler-action | tests/conftest.py | .py | 66d9c8f2ab98106d | 7.74 | 2 |
from unittest import TestCase
import pandas
from reports.html_engine import HtmlEngine
from reports import Report, Section, Table, LineChart, DataSeries, ChartGroup, CandlestickChart
class TestReports(TestCase):
"""
Test reports package
"""
def test_reports(self):
"""
Test writing a ... | gshklover/reports | test/test_reports.py | .py | 318a76893120e2b3 | 7.65 | 1 |
from docarray import Document, DocumentArray
from jina import Executor, requests, Flow
from sentence_transformers import SentenceTransformer
import torch
class SentenceEncoder(Executor):
"""A simple sentence encoder that can be run on a CPU or a GPU
:param device: The pytorch device that the model is on, e.... | ajaykuma/ELK | AI-Integration/Flows_n_Executors/Flows_ex/SentenceEncoder/executor.py | .py | 5a8fa6c60aae1450 | 7.24 | 2 |
"""The facial keypoints dataset.
Ported from the 2019 ``data_load.py``. Two defects fixed:
* ``image.shape[2]`` assumed a 3-dimensional array and raised ``IndexError`` on any
grayscale source image.
* Reading was done with ``matplotlib.image.imread``, whose return dtype depends on the
file format (float32 in [0, ... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/data/dataset.py | .py | bfeb87743537e0a7 | 7 | 0 |
"""Fetching the dataset.
The original project hid this in a notebook cell as three shell commands writing to an
absolute ``/data`` path. It is a real step with real failure modes — a truncated download
looks exactly like a successful one until training produces nonsense — so it verifies what
it fetched.
"""
from __fu... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/data/download.py | .py | aff92e84c4717784 | 7 | 0 |
"""Train/validation splitting.
The original project had no validation split at all: the test set was used to decide when
to stop and which model to keep, which quietly contaminates every number it produced.
Splitting needs care here. The images are frames from the YouTube Faces Database, so the
same person appears ma... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/data/split.py | .py | 3c1cf7452e9dcd26 | 7 | 0 |
"""Face detector resolution.
The original repository vendored four Haar cascade XML files into
``detector_architectures/``. Three of them ship with OpenCV itself — two were
byte-identical to the installed copies — and only ``haarcascade_frontalface_default.xml``
was ever used. Resolving them from ``cv2.data`` keeps 3 ... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/detectors.py | .py | c960732488d96e5a | 7 | 0 |
"""Loading local environment overrides.
Secrets live in a gitignored ``.env`` at the project root, never in the repository and
never on a command line where they would land in shell history. This is imported by
``fkp/__init__.py`` so a token in ``.env`` works from the CLI, a notebook or a bare script
without each of t... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/env.py | .py | 6793ce8602109510 | 7 | 0 |
"""Keypoint error metrics.
The original project reported a single MSE in normalised units. That number cannot be
compared against anything — not against a different input resolution, not against another
implementation, not against published results — because its scale depends on the
normalisation constants in use.
No... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/eval/metrics.py | .py | 1e99af392f5fb028 | 7 | 0 |
"""Publishing checkpoints to the Hugging Face Hub.
Rented GPUs are ephemeral. A spot instance that gets reclaimed at epoch 140 takes the
whole run with it unless the weights are already somewhere else, so uploads happen
*during* training rather than only at the end.
Two file formats, deliberately:
* ``model.safetens... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/hub.py | .py | 313d36cd6f1f2eee | 7 | 0 |
"""Model registry.
Every architecture is reachable by name so configs stay declarative and the results table
can be keyed on something stable.
"""
from __future__ import annotations
from collections.abc import Callable
from torch import nn
from fkp.models.baseline_cnn import BaselineCNN
from fkp.models.deep_cnn im... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/models/__init__.py | .py | 5748171edd61812b | 7 | 0 |
"""The 2019 five-convolution baseline.
Ported from ``models.py`` unchanged in behaviour — this is the "before" measurement, and
rewriting it would make the comparison meaningless.
One fix: the original used ``nn.Dropout(p=0.2, inplace=True)`` on a ReLU output inside the
autograd graph. Inplace dropout is mathematical... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/models/baseline_cnn.py | .py | a3b61ca7c810d9e2 | 7 | 0 |
"""The 2019 ten-convolution variant.
Ported from ``models_deep.py`` unchanged in behaviour. Paired conv blocks with leaky-ReLU
and batch norm, pooling after every second convolution.
"""
from __future__ import annotations
import torch
import torch.nn.functional as F
from torch import nn
N_KEYPOINTS = 68
class Dee... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/models/deep_cnn.py | .py | f3eb193c02995559 | 7 | 0 |
"""Weight initialisation.
The 2019 code applied Xavier initialisation from inside ``train_net``, so calling the
training function twice silently reinitialised a trained model. It is an explicit,
opt-in step here.
Xavier is kept as an option because it is what the 2019 baseline used, and reproducing
that run needs it.... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/models/init.py | .py | dfc5b416283f3c33 | 7 | 0 |
"""Project path discovery, so the CLI works from any subdirectory."""
from __future__ import annotations
from pathlib import Path
def project_root(start: Path | None = None) -> Path:
"""Walk up from ``start`` until a directory containing ``pyproject.toml`` is found."""
current = (start or Path.cwd()).resolv... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/paths.py | .py | babefede731e6182 | 7 | 0 |
"""Training configuration.
Every run is described by one validated object, and that object is stored inside the
checkpoint. The original project could not say what produced a given set of weights — the
released file was named ``..._100epochs.pt`` while the notebook that wrote it trains for
25 — and this is the fix for... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/train/config.py | .py | 486422dfca7c79d9 | 7 | 0 |
"""Keypoint visualisation."""
from __future__ import annotations
from typing import Any
import matplotlib.pyplot as plt
import numpy as np
import torch
from matplotlib.axes import Axes
from matplotlib.figure import Figure
def _to_numpy(x: Any) -> np.ndarray:
if isinstance(x, torch.Tensor):
return x.det... | FrancescoMrn/cnn_facial_keypoint_detection | src/fkp/viz/plots.py | .py | f2794f327bc242e4 | 7 | 0 |
"""Checkpoint round-trip tests.
The original project's released weights could not be traced to a configuration: the file
was named ``..._100epochs.pt`` while the notebook that wrote it trains for 25, and it was
never committed. These tests pin the provenance that replaces that guesswork, and guard
the strict-loading p... | FrancescoMrn/cnn_facial_keypoint_detection | tests/test_checkpoint.py | .py | 437838e3279ee06a | 7.5 | 0 |
"""Detector resolution tests.
These replace the four Haar cascade XML files the project used to vendor. Two of them
were byte-identical to the copies OpenCV installs, and only the frontal-face one was ever
used, so the repository carried 3 MB of duplicated model weights.
"""
from __future__ import annotations
import... | FrancescoMrn/cnn_facial_keypoint_detection | tests/test_detectors.py | .py | 16eb9d3077ba89d9 | 7.5 | 0 |
"""Dataset download tests.
Nothing here touches the network — the 323 MB archive is not a test fixture. What is
worth testing is the status reporting and the verification that guards against a
truncated download, which is the failure mode that otherwise looks like success.
"""
from __future__ import annotations
from... | FrancescoMrn/cnn_facial_keypoint_detection | tests/test_download.py | .py | 6f2366c4efc0fcdb | 7.5 | 0 |
"""Early-stopping and run-reporting tests.
The training loop is meant to be launched on a rented GPU and watched through a streamed
log, so two things matter beyond correctness: it must stop on its own when it stops
improving, and it must leave its results on disk even if the box disappears mid-run.
"""
from __future... | FrancescoMrn/cnn_facial_keypoint_detection | tests/test_early_stopping.py | .py | 86e9f8174c3514f8 | 7.5 | 0 |
"""Hub publishing tests.
Nothing here touches the network. What is worth pinning is the token handling — a leaked
token is the expensive mistake — the safetensors round trip, and the guarantee that a
failed upload cannot kill a training run on a rented box.
"""
from __future__ import annotations
import json
from pat... | FrancescoMrn/cnn_facial_keypoint_detection | tests/test_hub.py | .py | b6176b0a4ee03491 | 7.5 | 0 |
"""Metric tests.
NME replaces the bare MSE the original project reported, which was expressed in whatever
units the normalisation happened to produce and so could not be compared to anything.
"""
from __future__ import annotations
import numpy as np
import pytest
import torch
from fkp.eval import LANDMARK_REGIONS, ... | FrancescoMrn/cnn_facial_keypoint_detection | tests/test_metrics.py | .py | eff63abffeda0021 | 7.5 | 0 |
"""Shape, registry and initialisation tests for the ported 2019 architectures."""
from __future__ import annotations
import pytest
import torch
from fkp.models import available_models, build_model, count_parameters, init_weights
@pytest.mark.parametrize("name", available_models())
def test_forward_shape(name: str)... | FrancescoMrn/cnn_facial_keypoint_detection | tests/test_models.py | .py | f6a943f963fd242f | 7.5 | 0 |
"""Transform tests — mostly regression tests for the 2019 defects."""
from __future__ import annotations
import numpy as np
import pytest
import torch
from fkp.data import (
CenterCrop,
LegacyKeypointNormalize,
Normalize,
RandomCrop,
Rescale,
ToTensor,
denormalize_keypoints,
)
def _samp... | FrancescoMrn/cnn_facial_keypoint_detection | tests/test_transforms.py | .py | dffe893deec9d45b | 7.5 | 0 |
from bifrostlib import common
from bifrostlib.datahandling import Sample
from bifrostlib.datahandling import SampleComponentReference
from bifrostlib.datahandling import SampleComponent
from bifrostlib.datahandling import Category
from typing import Dict
import os
import json
import re
def cat_region_data(property, s... | ssi-dk/bifrost_cge_resfinder | bifrost_cge_resfinder/datadump.py | .py | cc39746a34b755f9 | 7 | 0 |
import logging
import os
import sys
from logging.config import fileConfig
from alembic import context
from alembic.script import ScriptDirectory
from sqlalchemy import engine_from_config
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(os.path.join(BASE_DIR, "src"))
from core im... | DmitryBurnaev/podcast-service | alembic/env.py | .py | 0c88f157d97888e6 | 7.3 | 3 |
"""initial migration
Revision ID: 0001
Revises:
Create Date: 2020-07-15 23:07:36.957705
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0001"
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Al... | DmitryBurnaev/podcast-service | alembic/versions/0001_init.py | .py | 75548ab53c4a7866 | 7.3 | 3 |
"""create user sessions
Revision ID: 0002
Revises: 0001
Create Date: 2020-07-19 13:35:10.998315
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0002"
down_revision = "0001"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto genera... | DmitryBurnaev/podcast-service | alembic/versions/0002_create_user_sessions.py | .py | eba985cfbbb6c29a | 7.3 | 3 |
"""auth_sessions
Revision ID: 0004
Revises: 0003
Create Date: 2021-06-16 08:23:20.721662
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0004"
down_revision = "0003"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by A... | DmitryBurnaev/podcast-service | alembic/versions/0004_auth_sessions.py | .py | 2f37f20e6dcd51a5 | 7.3 | 3 |
"""shemas_up_to_date
Revision ID: 0005
Revises: 0004
Create Date: 2021-07-15 23:35:29.506142
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0005"
down_revision = "0004"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated... | DmitryBurnaev/podcast-service | alembic/versions/0005_shemas_up_to_date.py | .py | 78aa59fde0733be0 | 7.3 | 3 |
"""episode_source
Revision ID: 0006
Revises: 0005
Create Date: 2021-10-17 18:51:29.927189
"""
import sqlalchemy as sa
from sqlalchemy.sql import table, column
from sqlalchemy import String
from alembic import op
# revision identifiers, used by Alembic.
revision = "0006"
down_revision = "0005"
branch_labels = None
d... | DmitryBurnaev/podcast-service | alembic/versions/0006_episode_source.py | .py | 7a9ac293474c21e5 | 7.3 | 3 |
"""Create cookie model
Revision ID: 0007
Revises: 0006
Create Date: 2022-01-21 18:23:24.246648
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0007"
down_revision = "0006"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generat... | DmitryBurnaev/podcast-service | alembic/versions/0007_create_cookie_model.py | .py | 32a07bbd779c7378 | 7.3 | 3 |
"""Create file model
Revision ID: 0009
Revises: 0008
Create Date: 2022-04-15 09:20:31.654464
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0009"
down_revision = "0008"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated... | DmitryBurnaev/podcast-service | alembic/versions/0009_create_file_model.py | .py | 428f71cc16def3f8 | 7.3 | 3 |
"""New model: user's IP
Revision ID: 0011
Revises: 0010
Create Date: 2022-05-17 19:12:44.258445
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0011"
down_revision = "0010"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto genera... | DmitryBurnaev/podcast-service | alembic/versions/0011_new_model_user_s_ip.py | .py | fe896ee3fb1e948e | 7.3 | 3 |
"""User IPs: added field registred_by
Revision ID: 0012
Revises: 0011
Create Date: 2022-05-22 16:16:43.905285
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0012"
down_revision = "0011"
branch_labels = None
depends_on = None
def upgrade():
# ### comman... | DmitryBurnaev/podcast-service | alembic/versions/0012_user_ips_added_field_registred_by.py | .py | 7eb4412e5bcd8e56 | 7.3 | 3 |
"""File: added public
Revision ID: 0013
Revises: 0012
Create Date: 2022-06-02 22:32:02.254358
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0013"
down_revision = "0012"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generate... | DmitryBurnaev/podcast-service | alembic/versions/0013_file_added_public.py | .py | ebd6cccc8cb8aafe | 7.3 | 3 |
"""Files: added meta field
Revision ID: 0015
Revises: 0014
Create Date: 2022-07-21 09:20:01.998052
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import JSONB
# revision identifiers, used by Alembic.
revision = "0015"
down_revision = "0014"
branch_labels = None
depends_on = N... | DmitryBurnaev/podcast-service | alembic/versions/0015_files_added_meta_field.py | .py | f5c5ce7340adc4cd | 7.3 | 3 |
"""Episodes: new status CANCELING
Revision ID: 0018
Revises: 0017
Create Date: 2023-08-05 19:53:57.970306
"""
from alembic import op
from sqlalchemy import text
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "0018"
down_revision = "0017"
branch_labels = None
depends_o... | DmitryBurnaev/podcast-service | alembic/versions/0018_episodes_new_status_canceling.py | .py | 1634707b40a6cb01 | 7.3 | 3 |
"""Auth: user access token
Revision ID: 0021
Revises: 0020
Create Date: 2024-04-22 21:42:27.123364
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0021"
down_revision = "0020"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto gen... | DmitryBurnaev/podcast-service | alembic/versions/0021_auth_user_access_token.py | .py | 1c3d5ba7360b24a7 | 7.3 | 3 |
"""Episode: chapters
Revision ID: 0022
Revises: 0021
Create Date: 2024-08-01 16:06:04.591151
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "0022"
down_revision = "0021"
branch_labels = None
depends_on = None
def up... | DmitryBurnaev/podcast-service | alembic/versions/0022_episode_chapters.py | .py | 1298ad87f7962ac6 | 7.3 | 3 |
import tomllib
from pathlib import Path
import subprocess
from git import Repo, GitCommandError, Head
DEFAULT_BRANCH = "master"
ROOT_DIR = Path(__file__).parent.parent
REPO_DIR = ROOT_DIR / "."
PIPFILE_PATH = REPO_DIR / "Pipfile"
PIPFILE_LOC_PATH = REPO_DIR / "Pipfile.lock"
def update_packages(packages: dict[str, s... | DmitryBurnaev/podcast-service | etc/bump.py | .py | 1c5314d48f533484 | 7.3 | 3 |
from typing import Type, cast
import sqlalchemy as sa
from sqlalchemy import Column, Engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from core import settings
from common.typing import StringEnumT
# pylint: disable=too-many-ancestors,abstract-metho... | DmitryBurnaev/podcast-service | src/common/db_utils.py | .py | 920f9869e74053a4 | 7.3 | 3 |
import os
import logging
import mimetypes
from pathlib import Path
from typing import Callable, Optional
import boto3
import botocore
from starlette.concurrency import run_in_threadpool
from core import settings
from common.redis import RedisClient
logger = logging.getLogger(__name__)
class StorageS3:
"""Simpl... | DmitryBurnaev/podcast-service | src/common/storage.py | .py | de793e43e3e9cc41 | 7.3 | 3 |
import datetime
import hashlib
import uuid
import asyncio
import logging
import logging.config
from pathlib import Path
from typing import Coroutine, Any
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import httpx
import aiosmtplib
from starlette import status
from starlette.respon... | DmitryBurnaev/podcast-service | src/common/utils.py | .py | 8deae3c5b805d19c | 7.3 | 3 |
"""Cache of timing results."""
import collections
import datetime
import typing as t
from .timing import Timing
from .group import TimingGroup
class TimingCache:
"""Global cache for timing results."""
hierarchical: t.Dict[str, dict] = collections.OrderedDict()
"""Hierarchy of TimingGroup objects struct... | mbdevpl/timing | timing/cache.py | .py | a9eb1e3810b9af25 | 7.39 | 5 |
"""Handling of group of timings."""
import contextlib
import datetime
import functools
import types
import typing as t
import numpy as np
from .config import TimingConfig
from .timing import Timing
class TimingGroup(dict):
"""Group of timings."""
def __init__(self, name: str):
super().__init__()
... | mbdevpl/timing | timing/group.py | .py | ae58d114b6235f55 | 7.39 | 5 |
"""Core module of the timing package."""
import enum
import time
import typing as t
@enum.unique
class TimingState(enum.IntEnum):
"""State of a timing."""
NOT_STARTED = 0
RUNNING = 1
FINISHED = 2
class Timing:
"""Timing of performance-critical parts of application.
Uses time.perf_counter(... | mbdevpl/timing | timing/timing.py | .py | 15073ac0e9382be5 | 7.39 | 5 |
"""Utility and supporting functions for timing module."""
import collections
import logging
import statistics
import typing as t
from .config import TimingConfig
from .timing import Timing
from .group import TimingGroup
from .cache import TimingCache
if __debug__:
_LOG = logging.getLogger(__name__)
def get_tim... | mbdevpl/timing | timing/utils.py | .py | dcf85c576cf62e6c | 7.39 | 5 |
"""
Convenience functions that are inefficient, but are maybe a bit easier to work with?
"""
from collections import namedtuple
import numpy as np
from .CoordinateSystems import *
__all__ = [
"cartesian_to_zmatrix",
"zmatrix_to_cartesian"
]
zm_type = namedtuple("zms", ["coords", "ordering", "origins", "axes... | McCoyGroup/McUtils | McUtils/Coordinerds/Conveniences.py | .py | a00dc051b39c282d | 7 | 0 |
from .CoordinateSystemConverter import CoordinateSystemConverter
from .CommonCoordinateSystems import CartesianCoordinates3D, SphericalCoordinates
from ...Numputils import vec_dots, vec_angles
import numpy as np
# this import gets bound at load time, so unfortunately PyCharm can't know just yet
# what properties its cl... | McCoyGroup/McUtils | McUtils/Coordinerds/CoordinateSystems/CartesianToSpherical.py | .py | 2ae67bd72a3132dc | 7 | 0 |
"""
Little utils that both CoordinateSet and CoordinateSystem needed
"""
import numpy as np
__all__ = [
"is_multiconfig",
"mc_safe_apply"
]
def is_multiconfig(coords, coord_shape=None):
if coord_shape is None:
coord_shape = (None, None)
return len(coords.shape) > len(coord_shape)
def mc_safe... | McCoyGroup/McUtils | McUtils/Coordinerds/CoordinateSystems/CoordinateUtils.py | .py | 0e43a76186d33c80 | 7 | 0 |
from .CoordinateSystemConverter import CoordinateSystemConverter
from .CommonCoordinateSystems import CartesianCoordinates3D, SphericalCoordinates
from ...Numputils import *
import numpy as np
class SphericalToCartesianConverter(CoordinateSystemConverter):
"""
A converter class for going from ZMatrix coordinat... | McCoyGroup/McUtils | McUtils/Coordinerds/CoordinateSystems/SphericalToCartesian.py | .py | 6c50370f2e6bdfde | 7 | 0 |
import abc
import numpy as np
from .. import Devutils as dev
from .. import Numputils as nput
from .Internals import canonicalize_internal
__all__ = [
"prune_internal_coordinates"
]
class InternalCoordinatePruner:
def pruning_iterator(self, coords, *args, **kwargs):
"""
**LLM Docstring**
... | McCoyGroup/McUtils | McUtils/Coordinerds/Pruning.py | .py | ec7a72ceb2145dc2 | 7 | 0 |
"""
Provides a class for handling a compiled set of atomic data
"""
import os
from .. import Devutils as dev
from .CommonData import DataHandler
__all__ = [ "AtomData", "AtomDataHandler" ]
__reload_hook__ = [".CommonData"]
class AtomDataHandler(DataHandler):
"""
A DataHandler that's built for use with the ato... | McCoyGroup/McUtils | McUtils/Data/AtomData.py | .py | bd3de9abe3c53318 | 7 | 0 |
"""
Defines a common data handler
"""
from .. import Devutils as dev
import os, sys
__all__ = [ "DataHandler", "DataError", "DataRecord" ]
default_data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)))
default_data_package = "TheRealMcCoy"
default_data_key = "data"
default_data_source_key = "source"
cla... | McCoyGroup/McUtils | McUtils/Data/CommonData.py | .py | 5dd6d05ce8a1598d | 7 | 0 |
from .CommonData import DataHandler, DataRecord
__all__ = [ "PotentialData" ]
__reload_hook__ = [".CommonData"]
class PotentialDataHandler(DataHandler):
def __init__(self):
super().__init__("PotentialData", record_type=PotentialDataRecord)
def __getitem__(self, item):
"""
:param item:
... | McCoyGroup/McUtils | McUtils/Data/PotentialData.py | .py | 0606c5b06b904b6a | 7 | 0 |
"""
Provides a QuantityArray class to manage data & units simultaneously
"""
import numpy as np, io
__all__ = [
"QuantityArray"
]
class QuantityArrayException(Exception):
...
class QuantityArray:
"""
A little helper for working with NumPy arrays with units.
It's mostly just a safety mechanism for im... | McCoyGroup/McUtils | McUtils/Data/QuantityArray.py | .py | 0acbeb33a9da6da2 | 7 | 0 |
from django import http
from django.conf import settings
from django.contrib.auth import get_user_model, login, logout,models
from django.utils import timezone
from django.utils.deprecation import MiddlewareMixin
from django.utils.html import strip_tags
from markupsafe import escape
from dbca_utils.utils import env
E... | dbca-wa/dbca-utils | src/dbca_utils/middleware.py | .py | ee898c51aadaa49b | 7 | 0 |
from django.conf import settings
from django.db import models
from django.utils import timezone
class ActiveMixinManager(models.Manager):
"""Manager class for ActiveMixin."""
def current(self):
return self.filter(effective_to=None)
def deleted(self):
return self.filter(effective_to__isnu... | dbca-wa/dbca-utils | src/dbca_utils/models.py | .py | db59a72e096500d5 | 7 | 0 |
from dataclasses import dataclass
from scipy.stats import beta # type: ignore[import-untyped]
from probs.continuous.rv import ContinuousRV
@dataclass(eq=False)
class Beta(ContinuousRV):
"""
The beta distribution is a family of continuous probability distributions
defined on the interval [0, 1] paramete... | TylerYep/probs | probs/continuous/beta.py | .py | 01e3d4bbb4e540da | 7.15 | 1 |
from dataclasses import dataclass
from scipy.stats import gamma # type: ignore[import-untyped]
from probs.continuous.rv import ContinuousRV
@dataclass(eq=False)
class Gamma(ContinuousRV):
"""
The gamma distribution is a two-parameter family of continuous probability
distributions. The exponential distr... | TylerYep/probs | probs/continuous/gamma.py | .py | 2e8f71bb7f6ee67e | 7.15 | 1 |
from dataclasses import dataclass
from scipy.stats import invgamma # type: ignore[import-untyped]
from probs.continuous.rv import ContinuousRV
@dataclass(eq=False)
class InverseGamma(ContinuousRV):
"""
The inverse gamma distribution is a two-parameter family of continuous
probability distributions on t... | TylerYep/probs | probs/continuous/inv_gamma.py | .py | 6da0847f1a2400d3 | 7.15 | 1 |
from dataclasses import dataclass
from scipy.stats import betabinom # type: ignore[import-untyped]
from probs.discrete.rv import DiscreteRV
@dataclass(eq=False)
class BetaBinomial(DiscreteRV):
"""
The beta-binomial distribution is a family of discrete probability
distributions on a finite support of no... | TylerYep/probs | probs/discrete/beta_binomial.py | .py | 9e14603a53a08dfc | 7.15 | 1 |
import math
from dataclasses import dataclass
from probs.counting import nCr
from probs.discrete.rv import DiscreteRV
@dataclass(eq=False)
class Binomial(DiscreteRV):
"""
The binomial distribution with parameters n and p is the discrete
probability distribution of the number of successes in a sequence of... | TylerYep/probs | probs/discrete/binomial.py | .py | 2ed5da1822201b0f | 7.15 | 1 |
import math
from dataclasses import dataclass
from probs.discrete.rv import DiscreteRV
@dataclass(eq=False)
class Poisson(DiscreteRV):
"""
The Poisson distribution is a discrete probability distribution that
expresses the probability of a given number of events occurring in a fixed
interval of time o... | TylerYep/probs | probs/discrete/poisson.py | .py | 906260af37527320 | 7.15 | 1 |
from __future__ import annotations
import operator
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, TypeVar, cast
from probs.floats import ApproxFloat
from probs.rv import Event, RandomVariable
if TYPE_CHECKING:
from collections.abc import Callable
T = TypeVar("T")
@dataclass(eq... | TylerYep/probs | probs/discrete/rv.py | .py | ab02feb3a95779c1 | 7.15 | 1 |
#!/usr/bin/env python3
"""
wifiPass — list saved Wi-Fi profiles and their stored passwords (Windows).
Uses the built-in ``netsh wlan`` command to enumerate Wi-Fi profiles configured
on the machine and reveal the clear-text "Key Content" (the saved password) for
each one.
Requirements
------------
* Windows OS (relies... | shivamtripathi599/wifiPass | wifiPassWin.py | .py | 491a4c1539574bde | 7 | 0 |
#!/usr/bin/env python
# coding: utf-8
from keras.applications import MobileNet
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten, GlobalAveragePooling2D
from keras.layers import Conv2D, MaxPooling2D, ZeroPadding2D
from keras.layers.normalization import BatchNormalization... | shivamtripathi599/mlops_task3_share | Rebuild.py | .py | 3dd1f4addb1e3c11 | 7 | 0 |
#
# The Python Imaging Library
# $Id$
#
# bitmap distribution font (bdf) file parser
#
# history:
# 1996-05-16 fl created (as bdf2pil)
# 1997-08-25 fl converted to FontFile driver
# 2001-05-25 fl removed bogus __init__ call
# 2002-11-20 fl robustification (from Kevin Cazabon, Dmitry Vasiliev)
# 2003-04-22 fl ... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/BdfFontFile.py | .py | 3e19597c846611f9 | 7 | 0 |
#
# The Python Imaging Library.
# $Id$
#
# a class to read from a container file
#
# History:
# 1995-06-18 fl Created
# 1995-09-07 fl Added readline(), readlines()
#
# Copyright (c) 1997-2001 by Secret Labs AB
# Copyright (c) 1995 by Fredrik Lundh
#
# See the README file for information on usage and redistribut... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/ContainerIO.py | .py | c2406a2f618301be | 7 | 0 |
#
# The Python Imaging Library
# $Id$
#
# base class for raster font file parsers
#
# history:
# 1997-06-05 fl created
# 1997-08-19 fl restrict image width
#
# Copyright (c) 1997-1998 by Secret Labs AB
# Copyright (c) 1997-1998 by Fredrik Lundh
#
# See the README file for information on usage and redistribution.
#
... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/FontFile.py | .py | 4adeccc4ee50fa86 | 7 | 0 |
"""
A Pillow loader for .ftc and .ftu files (FTEX)
Jerome Leclanche <jerome@leclan.ch>
The contents of this file are hereby released in the public domain (CC0)
Full text of the CC0 license:
https://creativecommons.org/publicdomain/zero/1.0/
Independence War 2: Edge Of Chaos - Texture File Format - 16 October 2001
... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/FtexImagePlugin.py | .py | bf623962475f340d | 7 | 0 |
#
# The Python Imaging Library.
# $Id$
#
# GD file handling
#
# History:
# 1996-04-12 fl Created
#
# Copyright (c) 1997 by Secret Labs AB.
# Copyright (c) 1996 by Fredrik Lundh.
#
# See the README file for information on usage and redistribution.
#
"""
.. note::
This format cannot be automatically recognized, s... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/GdImageFile.py | .py | 2cfe14c6fdd8da2b | 7 | 0 |
#
# Python Imaging Library
# $Id$
#
# stuff to read (and render) GIMP gradient files
#
# History:
# 97-08-23 fl Created
#
# Copyright (c) Secret Labs AB 1997.
# Copyright (c) Fredrik Lundh 1997.
#
# See the README file for information on usage and redistribution.
#
"""
Stuff to translate curve segments to pa... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/GimpGradientFile.py | .py | 67fe1351831d3f25 | 7 | 0 |
#
# Python Imaging Library
# $Id$
#
# stuff to read GIMP palette files
#
# History:
# 1997-08-23 fl Created
# 2004-09-07 fl Support GIMP 2.0 palette files.
#
# Copyright (c) Secret Labs AB 1997-2004. All rights reserved.
# Copyright (c) Fredrik Lundh 1997-2004.
#
# See the README file for information on usage ... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/GimpPaletteFile.py | .py | 60712129386c1159 | 7 | 0 |
#
# The Python Imaging Library.
# $Id$
#
# macOS icns file decoder, based on icns.py by Bob Ippolito.
#
# history:
# 2004-10-09 fl Turned into a PIL plugin; removed 2.3 dependencies.
# 2020-04-04 Allow saving on all operating systems.
#
# Copyright (c) 2004 by Bob Ippolito.
# Copyright (c) 2004 by Secret Labs.
#... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/IcnsImagePlugin.py | .py | aaf8be38fd20f024 | 7 | 0 |
#
# The Python Imaging Library
# $Id$
#
# map CSS3-style colour description strings to RGB
#
# History:
# 2002-10-24 fl Added support for CSS-style color strings
# 2002-12-15 fl Added RGBA support
# 2004-03-27 fl Fixed remaining int() problems for Python 1.5.2
# 2004-07-19 fl Fixed gray/grey spelling issues
# 2... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/ImageColor.py | .py | 20603d0b6ba67840 | 7 | 0 |
#
# The Python Imaging Library.
# $Id$
#
# image enhancement classes
#
# For a background, see "Image Processing By Interpolation and
# Extrapolation", Paul Haeberli and Douglas Voorhies. Available
# at http://www.graficaobscura.com/interp/index.html
#
# History:
# 1996-03-23 fl Created
# 2009-06-16 fl Fixed mean ca... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/ImageEnhance.py | .py | e04961cff972cb12 | 7 | 0 |
#
# The Python Imaging Library.
# $Id$
#
# standard filters
#
# History:
# 1995-11-27 fl Created
# 2002-06-08 fl Added rank and mode filters
# 2003-09-15 fl Fixed rank calculation in rank filter; added expand call
#
# Copyright (c) 1997-2003 by Secret Labs AB.
# Copyright (c) 1995-2002 by Fredrik Lundh.
#
# See t... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/ImageFilter.py | .py | 3224e8c18f6689c8 | 7 | 0 |
#
# The Python Imaging Library
# $Id$
#
# a simple math add-on for the Python Imaging Library
#
# History:
# 1999-02-15 fl Original PIL Plus release
# 2005-05-05 fl Simplified and cleaned up for PIL 1.1.6
# 2005-09-12 fl Fixed int() and float() for Python 2.4.1
#
# Copyright (c) 1999-2005 by Secret Labs AB
# Copy... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/ImageMath.py | .py | 5dab0cb208da0fda | 7 | 0 |
#
# The Python Imaging Library.
# $Id$
#
# standard mode descriptors
#
# History:
# 2006-03-20 fl Added
#
# Copyright (c) 2006 by Secret Labs AB.
# Copyright (c) 2006 by Fredrik Lundh.
#
# See the README file for information on usage and redistribution.
#
from __future__ import annotations
import sys
from functools ... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/ImageMode.py | .py | e723b1383019ee31 | 7 | 0 |
# A binary morphology add-on for the Python Imaging Library
#
# History:
# 2014-06-04 Initial version.
#
# Copyright (c) 2014 Dov Grobgeld <dov.grobgeld@gmail.com>
from __future__ import annotations
import re
from . import Image, _imagingmorph
LUT_SIZE = 1 << 9
# fmt: off
ROTATION_MATRIX = [
6, 3, 0,
7, 4... | shivamtripathi599/college_project | .venv/lib/python3.9/site-packages/PIL/ImageMorph.py | .py | 4e8c179e4d50db05 | 7 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.