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 |
|---|---|---|---|---|---|---|
"""Connection manager Oppo UDP-20x integration."""
import asyncio
import logging
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_PORT
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_send... | simbaja/ha_oppoudp | custom_components/oppo_udp/manager.py | .py | d1781971f9345206 | 7.57 | 13 |
"""Remote control support for Oppo UDP-20x players."""
import asyncio
import logging
from homeassistant.components.remote import (
ATTR_DELAY_SECS,
ATTR_NUM_REPEATS,
DEFAULT_DELAY_SECS,
RemoteEntity,
)
from homeassistant.const import CONF_HOST
from homeassistant.core import callback
from oppoudpsdk im... | simbaja/ha_oppoudp | custom_components/oppo_udp/remote.py | .py | 2e4d641b0879e360 | 7.57 | 13 |
import torch
from torch.utils.data import Dataset
import h5py
import json
import os
class CaptionDataset(Dataset):
"""
A PyTorch Dataset class to be used in a PyTorch DataLoader to create batches.
"""
def __init__(self, data_folder, data_name, split, transform=None):
"""
:param data_f... | aryankargwal/capbot2.0 | model/datasets.py | .py | 98a5d25859e23c46 | 7.65 | 19 |
#!/usr/bin/env python3
"""
usage:
python3 -m pip install nordpool
python3 ellevio_hourly_costs.py
tested only with winter time exports and windows lineendings with a blank line at the end
"""
from datetime import date
from math import isinf
import csv
from nordpool import elspot
CET_CEST_00_TO_01 = 0
... | sander-visser/py-playground | ellevio_hourly_costs.py | .py | 66ce8c6239963078 | 7.6 | 15 |
# -*- coding: utf-8 -*-
"""Waze route calculator"""
import logging
import requests
import re
class WRCError(Exception):
def __init__(self, message):
self.message = message
def __str__(self):
return self.message
class WazeRouteCalculator(object):
"""Calculate actual route time and dista... | t0mer/Wazy | app/WazeRouteCalculator.py | .py | a0539f1f72e77ff9 | 7.65 | 19 |
"""Capture calibration reference values from Bruker's native ``timsdata`` library.
The output (``tests/data/calibration_golden.json``) pins the index/mz,
scan/mobility, scan/voltage and CCS conversions so they can be regression-tested
without the native library.
Bruker's library is no longer vendored here, so this ne... | tacular-omics/tdfpy | scripts/generate_calibration_golden.py | .py | a6400d9a55465b91 | 7.45 | 7 |
"""Bruker timsTOF calibration models.
Pure functions over the ``MzCalibration`` and ``TimsCalibration`` rows of
``analysis.tdf``. No file or database access happens here, which keeps the models
unit-testable in isolation from any ``.d`` folder.
These reproduce Bruker's native ``tims_index_to_mz``, ``tims_mz_to_index`... | tacular-omics/tdfpy | src/tdfpy/calibration.py | .py | 5384dcf1e4b985b1 | 7.45 | 7 |
"""Noise filtering for raw timsTOF peaks.
A noise filter inspects raw peaks in their native integer-index form
``(scan_indices, mz_indices, intensities)`` and returns a boolean keep
mask. Multiple filters can be chained in user-specified order — see
:func:`tdfpy.pipeline.apply_noise` for the runner.
Public surface:
... | tacular-omics/tdfpy | src/tdfpy/noise/__init__.py | .py | f5310be704fa6e88 | 7.45 | 7 |
"""Statistical intensity-threshold noise filters.
Each subclass of :class:`IntensityThreshold` exposes the knobs of its
estimator as dataclass fields so users can tune them with full type
support. The string shorthand ``"mad"`` / ``"percentile"`` / etc. (handled
in :mod:`tdfpy.noise`) maps to these classes with their ... | tacular-omics/tdfpy | src/tdfpy/noise/intensity.py | .py | 60b8944622cc23a8 | 7.45 | 7 |
"""Region exclusions in (m/z, 1/K0) space.
A region is a known area of the (m/z, 1/K0) plane that the user wants to
drop wholesale — typically based on physical/chemical knowledge of the
acquisition rather than from estimating noise. The canonical example is
the singly-charged / polymer contamination band in timsTOF M... | tacular-omics/tdfpy | src/tdfpy/regions.py | .py | d5e12156c1da34eb | 7.45 | 7 |
"""
Utility for slicing a Bruker timsTOF .d folder to a subset of frames.
Produces a smaller, valid .d folder containing only the specified frame range,
with a rebuilt binary file and filtered SQLite metadata.
"""
import logging
import shutil
import sqlite3
import struct
from contextlib import closing
from pathlib im... | tacular-omics/tdfpy | src/tdfpy/slicer.py | .py | 95230293465717d7 | 7.45 | 7 |
"""Regression tests pinning the calibration conversions to reference values.
The reference values in ``tests/data/calibration_golden.json`` were captured from
Bruker's native ``timsdata`` library (see
``scripts/generate_calibration_golden.py``). They exist so the conversions stay
correct after the native library is go... | tacular-omics/tdfpy | tests/test_calibration_golden.py | .py | c2feceb0afcc73e3 | 7.95 | 7 |
import numpy as np
import pytest
from tdfpy.centroiding import _sum_by_tof_index, batch_iterator, calculate_nmass
PROTON = 1.007276466812
class TestCalculateNmass:
def test_charge_1(self):
mz = 500.0
charge = 1
expected = mz * 1 - 1 * PROTON
assert calculate_nmass(mz, charge) == ... | tacular-omics/tdfpy | tests/test_centroiding_utils.py | .py | d7afc54b6e40a0ed | 7.95 | 7 |
import pathlib
import numpy as np
import pytest
from tdfpy import DDA, get_acquisition_type
D_PATH = "tests/data/example_dda.d"
SKIP_NO_DATA = pytest.mark.skipif(
not pathlib.Path(D_PATH).exists(), reason="Test data not available"
)
def test_get_acquisition_type():
"""Test that get_acquisition_type correct... | tacular-omics/tdfpy | tests/test_dda.py | .py | 6dd9a70345bc89fd | 7.95 | 7 |
import pathlib
import pytest
from tdfpy import DIA, DiaWindow, DiaWindowGroup, DIAMs1Frame, get_acquisition_type
D_PATH = "tests/data/example_dia.d"
SKIP_NO_DATA = pytest.mark.skipif(
not pathlib.Path(D_PATH).exists(), reason="Test data not available"
)
def test_get_acquisition_type_dia():
"""Test that get... | tacular-omics/tdfpy | tests/test_dia.py | .py | 6549e86475c385d3 | 7.95 | 7 |
"""Bound how far tdfpy's peak picking may drift from Bruker's.
``Precursor.peaks`` and ``PasefFrameMsmsInfo.peaks`` used to call Bruker's
proprietary peak picker. tdfpy now sums the mobility dimension away and
centroids by greedy m/z merging, which is close but deliberately not identical:
Bruker's algorithm is closed ... | tacular-omics/tdfpy | tests/test_peaks_divergence.py | .py | 332d7c3edd8d2f07 | 7.95 | 7 |
import pathlib
import numpy as np
import pytest
from tdfpy import PRM, PrmTarget, PrmTransition, get_acquisition_type
D_PATH = "tests/data/example_prm.d"
SKIP_NO_DATA = pytest.mark.skipif(
not pathlib.Path(D_PATH).exists(), reason="Test data not available"
)
def test_get_acquisition_type_prm():
"""Test tha... | tacular-omics/tdfpy | tests/test_prm.py | .py | fdb10e532d6970b9 | 7.95 | 7 |
from pathlib import Path
import json
import numpy as np
from collections import Counter
def get_minmax(minmax_path: str, graph_type: str, instance: str, num_nodes: str,
ER_probability: str = None, swap_layers: str = None, degree: str = None):
"""Locate the min/max-cut JSON file for a given instanc... | usra-riacs/stochastic-benchmark | examples/IBM_QAOA/src/approx_ratio_calc.py | .py | 16a830bf78b6b6d1 | 7.45 | 7 |
# Functions for storing and plotting windows stickers plots
# new functions
import json
import pickle
import pandas as pd
import numpy as np
import os
import glob
try:
import maxcut_benchmark
from qedclib import metrics
except ImportError:
maxcut_benchmark = None
metrics = None
from scipy.special impor... | usra-riacs/stochastic-benchmark | examples/QEDC_to_WS_conversion/conversion.py | .py | bf9573e1401b1e24 | 7.45 | 7 |
#!/usr/bin/env python3
"""
Test runner script for stochastic-benchmark package.
This script provides convenient commands to run different types of tests.
"""
import argparse
import subprocess
import sys
import os
import glob
def run_command(cmd, description):
"""Run a command and handle errors."""
print(f"\n... | usra-riacs/stochastic-benchmark | run_tests.py | .py | 1d46bc7f710926e6 | 7.95 | 7 |
from collections import defaultdict
import copy
from dataclasses import dataclass, field
import logging
import df_utils
from itertools import product
from multiprocess import Process, Pool, Manager
import numpy as np
import os
import pandas as pd
from tqdm import tqdm
from typing import Callable, List, DefaultDict, Opt... | usra-riacs/stochastic-benchmark | src/bootstrap.py | .py | 7b193aaa2c50800d | 7.45 | 7 |
import glob
from multiprocess import Pool
import os
import logging
import pandas as pd
import names
import numpy as np
EPSILON = 1e-10
confidence_level = 68
s = 0.99
gap = 1.0
logger = logging.getLogger(__name__)
def applyParallel(dfGrouped, func):
"""
Apply pandas groupby operation using multiprocessing.
... | usra-riacs/stochastic-benchmark | src/df_utils.py | .py | 47a90ff480c50340 | 7.45 | 7 |
import os
class paths:
"""
Class to define paths to various files
"""
def __init__(self, home_dir):
self.cwd = home_dir
self.raw_data = os.path.join(self.cwd, "exp_raw")
self.checkpoints = os.path.join(self.cwd, "checkpoints")
self.plots = os.path.join(self.cwd, "plots... | usra-riacs/stochastic-benchmark | src/names.py | .py | cb9c55e2ed3ede90 | 7.45 | 7 |
from dataclasses import dataclass, field
from itertools import product
from tqdm import tqdm
import pandas as pd
from utils_ws import *
import stats
import names
@dataclass
class RandomSearchParameters:
"""
Defines parameters for Random search experiments
Attributes
----------
budgets : list[i... | usra-riacs/stochastic-benchmark | src/random_exploration.py | .py | 5a0974fc081ca63e | 7.45 | 7 |
from dataclasses import dataclass, field
from itertools import product
from tqdm import tqdm
import logging
import pandas as pd
import df_utils
import names
from utils_ws import *
import stats
logger = logging.getLogger(__name__)
tqdm.pandas()
@dataclass
class SequentialSearchParameters:
"""
Defines para... | usra-riacs/stochastic-benchmark | src/sequential_exploration.py | .py | 14cb994da89876bd | 7.45 | 7 |
import pytest
import pandas as pd
import numpy as np
import tempfile
import os, sys
from unittest.mock import patch
# Add src directory to path
TESTS_DIR = os.path.dirname(__file__)
SRC_PATH = os.path.abspath(os.path.join(TESTS_DIR, os.pardir, os.pardir, 'src'))
sys.path.insert(0, SRC_PATH)
# Import modules to test i... | usra-riacs/stochastic-benchmark | tests/integration/test_module_integration.py | .py | b191643aa1adff1d | 7.95 | 7 |
import pytest
import tempfile
import shutil
import os
from unittest.mock import patch, MagicMock
# Import the module to test
import sys
TESTS_DIR = os.path.dirname(__file__)
SRC_PATH = os.path.abspath(os.path.join(TESTS_DIR, os.pardir, 'src'))
sys.path.insert(0, SRC_PATH)
from names import paths, param2filename, file... | usra-riacs/stochastic-benchmark | tests/test_names.py | .py | cb8ffd0bbdc786fc | 7.95 | 7 |
"""
rss-fetcher deploy script using mc-deploy (in system-dev-ops repo,
installed in development venv thru "dev" optional-dependencies in
pyproject.toml)
replaces shell scripts: push.sh, instance.sh, config.sh, common.sh,
dburl.sh, clone-db.sh plus vars.py
"""
import os
import sys
from mc_deploy.base import CmdArgs, ... | mediacloud/rss-fetcher | dokku-scripts/deploy.py | .py | 87267e8e36dcab26 | 7.52 | 10 |
"""
Used by alembic only
"""
from logging.config import fileConfig
# PyPI
from alembic import context
from sqlalchemy import engine_from_config, pool
# local
from fetcher.config import conf, fix_database_url
from fetcher.database import models
# this is the Alembic Config object, which provides
# access to the valu... | mediacloud/rss-fetcher | fetcher/database/env.py | .py | 58677e1b79c37503 | 7.52 | 10 |
"""
Postgresql functions not (yet?) supplied by SQLAlchemy
"""
from typing import Any
import sqlalchemy.sql.functions as functions
# Phil October 2022
if hasattr(functions, 'greatest'):
greatest = getattr(functions, 'greatest')
else:
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql import... | mediacloud/rss-fetcher | fetcher/database/functions.py | .py | f065b2fdb6fdacbb | 7.52 | 10 |
"""create feeds table
Revision ID: bc56acb800bf
Revises:
Create Date: 2022-02-17 12:00:53.437355
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'bc56acb800bf'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
... | mediacloud/rss-fetcher | fetcher/database/versions/20220217_1629_create_feeds_table.py | .py | 59104192c86d2cac | 7.52 | 10 |
"""add stories table
Revision ID: 95a50840dc89
Revises: a91f46836029
Create Date: 2022-02-17 12:37:44.960582
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '95a50840dc89'
down_revision = 'a91f46836029'
branch_labels = None
depends_on = None
def upgrade():
... | mediacloud/rss-fetcher | fetcher/database/versions/20220217_2055_add_stories_table.py | .py | ac2a3e5270566b9d | 7.52 | 10 |
"""make story url unique
Revision ID: 35fe32618767
Revises: 95a50840dc89
Create Date: 2022-02-18 09:04:27.127883
"""
from alembic import op
# import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '35fe32618767'
down_revision = '95a50840dc89'
branch_labels = None
depends_on = None
def upgrade... | mediacloud/rss-fetcher | fetcher/database/versions/20220218_0905_make_story_url_unique.py | .py | d0b995e2fbbc7747 | 7.02 | 10 |
"""add feed last_fetch_failures
Revision ID: 8f9a42e8903c
Revises: 35fe32618767
Create Date: 2022-04-27 12:35:51.027664
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8f9a42e8903c'
down_revision = '35fe32618767'
branch_labels = None
depends_on = None
def up... | mediacloud/rss-fetcher | fetcher/database/versions/20220427_1237_add_feed_last_fetch_failures.py | .py | af1ff85b8c70592f | 7.02 | 10 |
"""add story media_id
Revision ID: 68cbc0802d68
Revises: c3809e49662f
Create Date: 2022-05-25 15:37:35.766908
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '68cbc0802d68'
down_revision = 'c3809e49662f'
branch_labels = None
depends_on = None
def upgrade():
... | mediacloud/rss-fetcher | fetcher/database/versions/20220525_1538_add_story_media_id.py | .py | e837420d10856b2e | 7.02 | 10 |
"""update-feeds
Revision ID: a83638d0280b
Revises: 8f9a42e8903c
Create Date: 2022-05-16 15:43:26.041869
"""
# revision identifiers, used by Alembic.
revision = 'a83638d0280b'
down_revision = '8f9a42e8903c'
branch_labels = None
depends_on = None
# Data generated with this command on the production database:
# psq... | mediacloud/rss-fetcher | fetcher/database/versions/20220526-1319_update_feeds.py | .py | 997a3aae1ead612a | 7.52 | 10 |
"""update feed mc data
Revision ID: 324d49ce6374
Revises: 68cbc0802d68
Create Date: 2022-05-26 11:39:35.536749
Turns out when we first imported things there was a bug that made the media cloud feed and media ids not import,
which is a problem because now we want to actually use those! This script goes back to the raw... | mediacloud/rss-fetcher | fetcher/database/versions/20220526_1437_update_feed_mc_data.py | .py | 0c898c5bccbd0941 | 7.52 | 10 |
"""add story normalized_url
Revision ID: c3809e49662f
Revises: a83638d0280b
Create Date: 2022-05-25 15:21:31.802512
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c3809e49662f'
down_revision = 'a83638d0280b'
branch_labels = None
depends_on = None
def upgrad... | mediacloud/rss-fetcher | fetcher/database/versions/20220526_1449_add_normalized_story_info.py | .py | 83ecbe1945f99b56 | 7.52 | 10 |
"""update feeds again
Revision ID: f7784f3c22e6
Revises: 324d49ce6374
Create Date: 2022-06-02 15:22:35.542978
"""
import logging
logger = logging.getLogger(__name__)
# revision identifiers, used by Alembic.
revision = 'f7784f3c22e6'
down_revision = '324d49ce6374'
branch_labels = None
depends_on = None
def upgrad... | mediacloud/rss-fetcher | fetcher/database/versions/20220602_1536_update_feeds_again.py | .py | 61baf4fddcc7e2db | 7.02 | 10 |
"""prepopulate feeds
Revision ID: a91f46836029
Revises: bc56acb800bf
Create Date: 2022-02-17 12:05:34.020034
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = 'a91f46836029'
down_revision = 'bc56acb800bf'
branch_labels = None
depends_on = None
# Data generated with this command on the ... | mediacloud/rss-fetcher | fetcher/database/versions/20220602_1538_prepopulate_feeds.py | .py | 350f3d5f67b7bee7 | 7.52 | 10 |
"""reset fetch failures
Revision ID: 0dffb2c71f4e
Revises: f7784f3c22e6
Create Date: 2022-07-06 10:52:59.762105
"""
from alembic import op
# import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0dffb2c71f4e'
down_revision = 'f7784f3c22e6'
branch_labels = None
depends_on = None
def upgrade(... | mediacloud/rss-fetcher | fetcher/database/versions/20220606_1054_reset_fetch_failures.py | .py | 907aedb08cf1a088 | 7.02 | 10 |
"""create fetch_events
Revision ID: aeea5e7ec71a
Revises: 0dffb2c71f4e
Create Date: 2022-07-14 14:44:02.347135
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.sql import func
# revision identifiers, used by Alembic.
revision = 'aeea5e7ec71a'
down_revision = '0dffb2c71f4e'
branch_labels = None
depe... | mediacloud/rss-fetcher | fetcher/database/versions/20220714_1503_create_fetch_events.py | .py | 3eff2efb083ce3fb | 7.52 | 10 |
"""drop unique title constriant
Revision ID: 0a99c2299af2
Revises: aeea5e7ec71a
Create Date: 2022-07-14 15:11:47.844632
"""
from alembic import op
# import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0a99c2299af2'
down_revision = 'aeea5e7ec71a'
branch_labels = None
depends_on = None
def ... | mediacloud/rss-fetcher | fetcher/database/versions/20220714_1514_drop_unique_title_constriant.py | .py | 981031363d239861 | 7.52 | 10 |
"""add story title index
Revision ID: 9bc05393d82c
Revises: 0a99c2299af2
Create Date: 2022-07-14 16:39:25.472880
"""
from alembic import op
# import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9bc05393d82c'
down_revision = '0a99c2299af2'
branch_labels = None
depends_on = None
def upgrade... | mediacloud/rss-fetcher | fetcher/database/versions/20220714_1640_add_story_title_index.py | .py | fc22bcec206e52f6 | 7.02 | 10 |
"""drop duplicate feeds ids
Revision ID: 313f51e4eefd
Revises: 9bc05393d82c
Create Date: 2022-08-03 20:39:22.905810
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '313f51e4eefd'
down_revision = '9bc05393d82c'
branch_labels = None
depends_on = None
def upgrad... | mediacloud/rss-fetcher | fetcher/database/versions/20220803_2039_drop_duplicate_feeds_ids.py | .py | 36c2b1bc19103b28 | 7.52 | 10 |
"""rename media_id to sources_id
Revision ID: 056d7ddcf6b5
Revises: 313f51e4eefd
Create Date: 2022-08-17 15:54:10.511960
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '056d7ddcf6b5'
down_revision = '313f51e4eefd'
branch_labels = None
depends_on = None
def u... | mediacloud/rss-fetcher | fetcher/database/versions/20220817_1554_rename_media_id_to_sources_id.py | .py | 7f9c2cfff07b4c3c | 7.52 | 10 |
"""add conditional fetch
Revision ID: ccbf360c92f8
Revises: 056d7ddcf6b5
Create Date: 2022-08-26 00:12:58.388887
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ccbf360c92f8'
down_revision = '056d7ddcf6b5'
branch_labels = None
depends_on = None
def upgrade()... | mediacloud/rss-fetcher | fetcher/database/versions/20220826_0012_add_conditional_fetch.py | .py | c686fc533c45cee9 | 7.52 | 10 |
"""add update_minutes
Revision ID: 24a9f51b9ceb
Revises: 184509e31258
Create Date: 2022-09-01 20:04:05.104722
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '24a9f51b9ceb'
down_revision = '184509e31258'
branch_labels = None
depends_on = None
def upgrade():
... | mediacloud/rss-fetcher | fetcher/database/versions/20220901_2004_add_update_minutes.py | .py | 3bb6f990b53f1b27 | 7.02 | 10 |
"""remove column timezones
Revision ID: ffc26b3bb9fc
Revises: 24a9f51b9ceb
Create Date: 2022-10-16 14:39:23.566599
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ffc26b3bb9fc'
down_revision = '24a9f51b9ceb'
branch_labels = None
depends_on = None
def _flip(tz... | mediacloud/rss-fetcher | fetcher/database/versions/20221016_1439_remove_column_timezones.py | .py | 2acf2d218345bd1b | 7.52 | 10 |
"""add feeds.http_304
Revision ID: 9d6e6264b580
Revises: ffc26b3bb9fc
Create Date: 2022-10-24 12:34:07.998799
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9d6e6264b580'
down_revision = 'ffc26b3bb9fc'
branch_labels = None
depends_on = None
def upgrade():
... | mediacloud/rss-fetcher | fetcher/database/versions/20221024_1234_add_feeds_http_304.py | .py | 24b8711563022b69 | 7.02 | 10 |
"""indices: add feeds_system_enabled, feeds_next_fetch_attempt, drop feeds_last_fetch_attempt
Revision ID: 5a54dacd62e3
Revises: 9d6e6264b580
Create Date: 2022-10-27 14:06:27.295729
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '5a54dacd62e3'
down_revision = '9d6e6264b580'
branch_la... | mediacloud/rss-fetcher | fetcher/database/versions/20221027_1406_indices.py | .py | 961a751128a30d8e | 7.52 | 10 |
"""add feeds.system_status
Revision ID: 6145c35f1ece
Revises: 5a54dacd62e3
Create Date: 2022-10-27 14:10:36.366706
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6145c35f1ece'
down_revision = '5a54dacd62e3'
branch_labels = None
depends_on = None
def upgrade... | mediacloud/rss-fetcher | fetcher/database/versions/20221027_1410_system_status.py | .py | 04ffd23c0f65a1ca | 7.02 | 10 |
"""convert last_fetch_failures to float
Revision ID: e549e03d2f7a
Revises: 6145c35f1ece
Create Date: 2022-11-06 12:06:44.185428
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e549e03d2f7a'
down_revision = '6145c35f1ece'
branch_labels = None
depends_on = None
... | mediacloud/rss-fetcher | fetcher/database/versions/20221106_1206_last_fetch_failures_float.py | .py | 9b98e6404e806fe5 | 7.02 | 10 |
"""add last_new_stories
Revision ID: 91fae5a8a02e
Revises: e549e03d2f7a
Create Date: 2022-12-04 02:27:23.386149
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '91fae5a8a02e'
down_revision = 'e549e03d2f7a'
branch_labels = None
depends_on = None
def upgrade():... | mediacloud/rss-fetcher | fetcher/database/versions/20221204_0227_add_last_new_stories.py | .py | 51d8218f84de6f7c | 7.02 | 10 |
"""add properties
Revision ID: b22da3d31ffb
Revises: 91fae5a8a02e
Create Date: 2022-12-12 17:25:59.320833
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'b22da3d31ffb'
down_revision = '91fae5a8a02e'
branch_labels = None
depends_on = None
def upgrade():
o... | mediacloud/rss-fetcher | fetcher/database/versions/20221212_1725_add_properties.py | .py | 3260573f8e5a0757 | 7.52 | 10 |
"""add feeds.rss_title
Revision ID: dfb30173c4cc
Revises: b22da3d31ffb
Create Date: 2022-12-19 20:28:44.959123
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'dfb30173c4cc'
down_revision = 'b22da3d31ffb'
branch_labels = None
depends_on = None
def upgrade():
... | mediacloud/rss-fetcher | fetcher/database/versions/20221219_2028_add_feeds_rss_title.py | .py | 3df288429cc18497 | 7.02 | 10 |
"""add poll_minutes
Revision ID: 5332cd0c7e48
Revises: dfb30173c4cc
Create Date: 2023-01-11 12:37:11.136323
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5332cd0c7e48'
down_revision = 'dfb30173c4cc'
branch_labels = None
depends_on = None
def upgrade():
... | mediacloud/rss-fetcher | fetcher/database/versions/20230111_1237_add_poll_minutes.py | .py | 286740c815f69740 | 7.02 | 10 |
"""add stories_sources_id
Revision ID: 73d7a4ca0e7b
Revises: 5332cd0c7e48
Create Date: 2024-08-15 23:13:18.484530
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '73d7a4ca0e7b'
down_revision = '5332cd0c7e48'
branch_labels = None
depends_on = None
def upgrade():
op.create_index('... | mediacloud/rss-fetcher | fetcher/database/versions/20240815_2313_add_stories_sources_id.py | .py | 2deb6456e355e5fe | 7.02 | 10 |
"""add story_ref table
Revision ID: a6b7fce60801
Revises: 73d7a4ca0e7b
Create Date: 2026-06-20 00:11:29.056092
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a6b7fce60801'
down_revision = '73d7a4ca0e7b'
branch_labels = None
depends_on = None
def upgrade():
... | mediacloud/rss-fetcher | fetcher/database/versions/20260620_0011_add_story_ref_table.py | .py | 26cf59a6ca9de689 | 7.52 | 10 |
"""
"direct drive" worker subprocess management
No queue so that scheduler can have absolute knowledge of what work is
being done, and immediately schedule replacement work (avoiding excessive
concurrent fetches from the same source).
And unlike multiprocessing process pool which "applies" a function to
a bounded lis... | mediacloud/rss-fetcher | fetcher/direct.py | .py | 7b53c9329894af30 | 7.52 | 10 |
"""
HeadHunter: finds work for Workers.
(A more P.C. term might be Recruiter)
Not sophisticated enough to be called a Scheduler!!
Terminology used is that of CPU instruction scheduling:
"issue": to start execution
"blocked" and "unsafe": cannot currently be issued
"scoreboard": machinery that tracks issued feeds
not ... | mediacloud/rss-fetcher | fetcher/headhunter.py | .py | 17ad3e3fb19d0ef8 | 7.52 | 10 |
"""
pid file interlock
Meant to exclude multiple instances of a script run from cron.
Does NOT delay waiting for lock holder to exit, as that would allow
a pileup of processes if the lock holder runs slowly or hangs.
Uses UNIX system calls to atomically create a "pid file"
(file contain process pid).
ASSUMPTION: all... | mediacloud/rss-fetcher | fetcher/pidfile.py | .py | 70f22db5a9b5e057 | 7.52 | 10 |
import logging
import os
from dataclasses import dataclass
from typing import Union, List, Optional, TYPE_CHECKING
from ancpbids import plugins
from ancpbids import utils
from .plugin import get_plugins, load_plugins_from_entrypoints, \
load_mixins_from_entrypoints, DatasetPlugin, WritingPlugin, ValidationPlugin,... | ANCPLabOldenburg/ancp-bids | ancpbids/__init__.py | .py | e9fd59f23e765389 | 7.56 | 12 |
from ancpbids.plugin import mixin
@mixin(target="ancpbids.pybids_compat:BIDSLayout", ranking=0)
class DataFrameMixin:
"""Adds a pandas export for files tracked by a layout."""
def to_df(self, metadata=False, **filters):
"""Return information for files tracked in Layout as a pandas DataFrame.
... | ANCPLabOldenburg/ancp-bids | ancpbids/mixins/mixin_dataframe.py | .py | f9bf59a6c1cf06db | 7.56 | 12 |
import importlib
import inspect
import pkgutil
import warnings
from importlib.metadata import entry_points
from typing import List, Optional, Union
# global plugins registry (list of plugin metadata/settings)
__PLUGINS__ = []
# applied mixin contributions (for idempotency / introspection)
__MIXINS__ = []
# Packaging ... | ANCPLabOldenburg/ancp-bids | ancpbids/plugin.py | .py | 09aac7790bbf4845 | 7.56 | 12 |
from typing import Optional
from ancpbids.plugin import FileHandlerPlugin, hook
def read_yaml(file_path: str, **kwargs):
import yaml
with open(file_path, 'r') as stream:
try:
return yaml.load(stream, Loader=yaml.FullLoader)
except:
return None
def read_json(file_path... | ANCPLabOldenburg/ancp-bids | ancpbids/plugins/plugin_files_handlers.py | .py | 5b03a1304154a9b1 | 7.56 | 12 |
import os.path
from functools import partial
from typing import List, Union, Dict
import ancpbids
from ancpbids import ValidationPlugin
from . import load_dataset
from .query import query, query_entities
from .utils import resolve_segments, convert_to_relative
class _BIDSLayoutBase:
"""Non-object base so externa... | ANCPLabOldenburg/ancp-bids | ancpbids/pybids_compat.py | .py | 43607710b0679873 | 7.56 | 12 |
import logging
import os
from typing import Optional, TYPE_CHECKING
if TYPE_CHECKING:
from ancpbids.schema import Schema
FILE_READERS = {}
FILE_WRITERS = {}
LOGGER = logging.getLogger(__file__)
def parse_bids_name(name: str):
"""Parses a given string (file name) according to the BIDS naming scheme.
Pa... | ANCPLabOldenburg/ancp-bids | ancpbids/utils.py | .py | 6ba7e6387b83f940 | 7.56 | 12 |
import os
import ancpbids
from ..base_test_case import RESOURCES_FOLDER
def test_arbitrary_dataset_entities():
"""Test that querying entities in a non-BIDS-compliant dataset returns empty or minimal results."""
dataset_path = os.path.join(RESOURCES_FOLDER, 'synthetic_arbitrary')
layout = ancpbids.BIDSLayou... | ANCPLabOldenburg/ancp-bids | tests/auto/test_arbitrary_dataset.py | .py | db14797e26352a13 | 8.06 | 12 |
from __future__ import annotations
from typing import TYPE_CHECKING
from pycep.models import BicepElement
if TYPE_CHECKING:
from lark import Token
def transform_string_token(value: Token) -> str | BicepElement:
"""Transforms string typed Token to a `str` or `BicepElement`.
Additionally, removes surrou... | gruebel/pycep | pycep/utils.py | .py | 9b8d1ff6d9cd18fa | 7.59 | 14 |
"""Configuration resolution shared by the facade and the resource sub-clients.
Why
``lib_shopware6_api_base`` 3.x changed ``Shopware6AdminAPIClientBase`` to take
a required :class:`ConfShopware6ApiBase` and dropped the old
``use_docker_test_container`` constructor flag (dockware setup now lives in the
... | bitranox/lib_shopware6_api | src/lib_shopware6_api/_conf_helper.py | .py | fd9570112228fac4 | 7.45 | 7 |
# STDLIB
import sys
# OWN
from lib_shopware6_api_base import ConfShopware6ApiBase, Shopware6AdminAPIClientBase
# PROJ
from ._conf_helper import resolve_config
from .sub_currency import Currency
from .sub_delivery_time import DeliveryTime
from .sub_media import Media
from .sub_product import Product
from .sub_tax impo... | bitranox/lib_shopware6_api | src/lib_shopware6_api/lib_shopware6_api.py | .py | a860c369930ac336 | 7.45 | 7 |
"""CLI for lib_shopware6_api."""
# STDLIB
import json
import os
import platform
import socket
import sys
from pathlib import Path
from typing import Any
# OWN
import lib_cli_exit_tools
# EXT
import rich_click as click
from lib_layered_config import is_sensitive
from lib_shopware6_api_base import (
ConfigurationE... | bitranox/lib_shopware6_api | src/lib_shopware6_api/lib_shopware6_api_cli.py | .py | 4a753f985e64347c | 7.45 | 7 |
"""Centralized ``lib_log_rich`` logging setup for the CLI entry point.
Why
Library modules emit records through the standard library
(``logging.getLogger(__name__)``) and must not configure logging themselves.
The application entry point (the CLI) owns logging setup; this module is the
single place tha... | bitranox/lib_shopware6_api | src/lib_shopware6_api/logging_setup.py | .py | ba5ad471810134e5 | 7.45 | 7 |
# STDLIB
from functools import cache
from typing import Any
# OWN
from lib_shopware6_api_base import ConfShopware6ApiBase, Shopware6AdminAPIClientBase
from lib_shopware6_api_base import lib_shopware6_api_base_criteria as dal
from ._conf_helper import resolve_config
# Currency{{{
class Currency:
def __init__(
... | bitranox/lib_shopware6_api | src/lib_shopware6_api/sub_currency.py | .py | 66025884a59f5f1a | 7.45 | 7 |
# STDLIB
from functools import cache
from typing import Any
# OWN
from lib_shopware6_api_base import ConfShopware6ApiBase, PayLoad, Shopware6AdminAPIClientBase
from lib_shopware6_api_base import lib_shopware6_api_base_criteria as dal
from ._conf_helper import resolve_config
# DeliveryTime{{{
class DeliveryTime:
... | bitranox/lib_shopware6_api | src/lib_shopware6_api/sub_delivery_time.py | .py | 873b713afb518b44 | 7.45 | 7 |
# STDLIB
from functools import cache
from typing import Any
# OWN
from lib_shopware6_api_base import ConfShopware6ApiBase, PayLoad, Shopware6AdminAPIClientBase
from ._conf_helper import resolve_config
# Unit{{{
class Unit:
def __init__(
self,
admin_client: Shopware6AdminAPIClientBase | None = No... | bitranox/lib_shopware6_api | src/lib_shopware6_api/sub_unit.py | .py | b5a99cb6d10ed34e | 7.45 | 7 |
"""Execute the module doctests as part of the normal test suite.
Doctests carry no pytest marker, so the marker-based unit/integration split
(``make test`` = ``-m "not integration"``, ``make testintegration`` = ``-m
integration``) cannot route them on its own. We therefore run them explicitly
through :func:`doctest.t... | bitranox/lib_shopware6_api | tests/test_doctests.py | .py | 863d64cd610182fe | 7.95 | 7 |
#
# ミサイル対決ゲーム「ACLM」
# ウィングマン氏作の「ACLM」を参考にしました.
# cf. 電波新聞社:「マイコン BASIC Magazine」, 1983年10月号, p.77.
#
# Sep 18, 2023 ver.1 (Pyxelによる実装)
#
# -*- coding: utf-8 -*-
import math
import pyxel
def init():
global st,w,h,x,y,r,a,b,pa,pb
# 0:開始 1:遊戯中 2:自機勝利 3:敵機勝利 4:引分 5:終了
st = 0
# 画面サイズ
... | jay-kumogata/RetroGames | pyxel/aclm/aclm.py | .py | 4a51b22ed40d6b53 | 7.63 | 17 |
#
# 花札デモ
# matt氏作の「Hanafuda Koi-Koi(Japanese card game)」を参考にしました.
# https://www.lexaloffle.com/bbs/?tid=2421
#
# Nov 26, 2023 ver.1 (first release)
#
# -*- coding: utf-8 -*-
import pyxel
class Hanafuda:
def __init__( self ):
# Pyxel初期化
pyxel.init( 128, 128, title="Hanafuda", fps=20)
... | jay-kumogata/RetroGames | pyxel/hanafuda/hanafuda.py | .py | 0c78fdf9a8a84353 | 7.63 | 17 |
#
# 麻雀デモ
# まぐち氏作の「mahjong! #アイロンビーズ #ドット絵 #麻雀 #mahjong」を参考にしました.
# https://x.com/maguchi_tweet/status/876398803732934657
#
# Feb 07, 2025 ver.1 (first release)
#
# -*- coding: utf-8 -*-
import pyxel
import random
class Mahjong:
def __init__( self ):
pyxel.init( 96, 96, title="Mahjong", fps=20)... | jay-kumogata/RetroGames | pyxel/mahjong/mahjong.py | .py | acf208fa00639378 | 7.63 | 17 |
# Nixie Tube Clock v0.1: Nixie Tube Clock in Pyxel/Python
# Copyright (c) 2022 Kumogata Computing Laboratory.
# All Rights Reserved.
import pyxel
class Nixie:
# Variables
f1 = 0
f2 = 1
f3 = 2
f4 = 3
# Constructor
def __init__( self ):
pyxel.init( 128, 64, titl... | jay-kumogata/RetroGames | pyxel/nixie/Nixie.py | .py | 930b7afb1049cfe5 | 7.63 | 17 |
#
# Pyxelを使ったPinballゲーム
# Isidor氏作の「PINBALL PONG」を参考にしました.
# https://www.lexaloffle.com/bbs/?tid=28488
#
# Apr 30, 2023 ver.1 (changed graphics library to pyxel)
# Oct 23, 2023 ver.2 (added flippers and renamed to Pinball)
# Nov 17, 2023 ver.3 (fixed gravitational acceleration and added flipper speed)
#
# -*- ... | jay-kumogata/RetroGames | pyxel/pinball/Pinball.py | .py | a2d2c4442657bae1 | 7.63 | 17 |
from __future__ import annotations
from typing import Optional, Tuple, TYPE_CHECKING
import color
import exceptions
if TYPE_CHECKING:
from engine import Engine
from entity import Actor, Entity, Item
class Action:
def __init__(self, entity: Actor) -> None:
super().__init__()
... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part10/actions.py | .py | 516562e29d9f31cc | 7.63 | 17 |
from __future__ import annotations
import random
from typing import List, Optional, Tuple, TYPE_CHECKING
import numpy as np # type: ignore
import tcod
from actions import Action, BumpAction, MeleeAction, MovementAction, WaitAction
if TYPE_CHECKING:
from entity import Actor
class BaseAI(Action):
... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part10/components/ai.py | .py | 53cfc75cb15fe8fd | 7.63 | 17 |
from __future__ import annotations
from typing import List, TYPE_CHECKING
from components.base_component import BaseComponent
if TYPE_CHECKING:
from entity import Actor, Item
class Inventory(BaseComponent):
parent: Actor
def __init__(self, capacity: int):
self.capacity = capacity... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part10/components/inventory.py | .py | 6269d8b631e2da17 | 7.63 | 17 |
from __future__ import annotations
import lzma
import pickle
from typing import TYPE_CHECKING
import pyxel
from tcod.map import compute_fov
import exceptions
from message_log import MessageLog
from render_functions import render_bar, render_names_at_mouse_location
if TYPE_CHECKING:
from entity imp... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part10/engine.py | .py | 7ce6e6222f68d72f | 7.63 | 17 |
from __future__ import annotations
import copy
import math
from typing import Optional, Tuple, Type, TypeVar, TYPE_CHECKING, Union
from render_order import RenderOrder
if TYPE_CHECKING:
from components.ai import BaseAI
from components.consumable import Consumable
from components.fighter im... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part10/entity.py | .py | 73db585dbbe58662 | 7.63 | 17 |
from __future__ import annotations
from typing import Iterable, Iterator, Optional, TYPE_CHECKING
import numpy as np # type: ignore
import pyxel
import color
from entity import Actor, Item
import tile_types
if TYPE_CHECKING:
from engine import Engine
from entity import Entity
class GameMap:... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part10/game_map.py | .py | 4cdeee419f57130e | 7.63 | 17 |
import traceback
import pyxel
import color
import exceptions
import input_handlers
import setup_game
def save_game(handler: input_handlers.BaseEventHandler, filename: str) -> None:
"""If the current event handler has an active Engine then save it."""
if isinstance(handler, input_handlers.EventHa... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part10/main.py | .py | 8a61b9710067e425 | 7.63 | 17 |
from typing import Iterable, List, Reversible, Tuple
import textwrap
import tcod
import pyxel
import color
class Message:
def __init__(self, text: str, fg: int):
self.plain_text = text
self.fg = fg
self.count = 1
@property
def full_text(self) -> str:
"""... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part10/message_log.py | .py | 2b9edcad04695d03 | 7.63 | 17 |
from __future__ import annotations
import random
from typing import Iterator, List, Tuple, TYPE_CHECKING
import tcod
import entity_factories
from game_map import GameMap
import tile_types
if TYPE_CHECKING:
from engine import Engine
class RectangularRoom:
def __init__(self, x: int, y: int... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part10/procgen.py | .py | 1ae92ec837920796 | 7.63 | 17 |
"""Handle the loading and initialization of game sessions."""
from __future__ import annotations
import copy
import lzma
import pickle
import traceback
from typing import Optional
import tcod
import pyxel
import color
from engine import Engine
import entity_factories
import input_handlers
from procge... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part10/setup_game.py | .py | 55058b2b56d41ab9 | 7.63 | 17 |
from __future__ import annotations
from typing import Optional, Tuple, TYPE_CHECKING
import color
import exceptions
if TYPE_CHECKING:
from engine import Engine
from entity import Actor, Entity, Item
class Action:
def __init__(self, entity: Actor) -> None:
super().__init__()
... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part11/actions.py | .py | 6eaabe32b3ef18dd | 7.63 | 17 |
from __future__ import annotations
import lzma
import pickle
from typing import TYPE_CHECKING
import pyxel
from tcod.map import compute_fov
import exceptions
from message_log import MessageLog
import render_functions
if TYPE_CHECKING:
from entity import Entity
from game_map import GameMap, Ga... | jay-kumogata/RetroGames | pyxel/pyxelrogue/part11/engine.py | .py | 11821e74bb4c112a | 7.63 | 17 |
from __future__ import annotations
from pathlib import Path
from typing import Dict, Optional, Tuple, Union
from examples.media_generation import common
from openapi.providers.media_generation import (
AvatarCloneRequest,
DigitalHumanRequest,
FileUploadRequest,
HiFlyConfig,
MediaClient,
MediaO... | luffy-genius/openapi | examples/media_generation/workflows/digital_human_from_scratch.py | .py | 5f705bf3055bd77d | 7.52 | 10 |
"""
Unit tests for the staging clone availability Lambda.
Run from this directory:
pytest test_app.py -v
"""
import os
import pytest
# app.py reads this at import time; stub it before importing.
os.environ.setdefault("PRM_TAG_VALUE", "pc:testproductcode")
os.environ.setdefault("AWS_DEFAULT_REGION", "us-east-1")
... | datamasque/DataMasque-AWS-RDS-masking-stepfunctions-blueprint | functions/check_db_availability/test_app.py | .py | b10e27a275160607 | 7.92 | 6 |
"""
Unit tests for the TLS-verification flag parsing in app.py.
Run from this directory:
pytest test_app.py -v
"""
import os
import pytest
# app.py reads these at import time; stub them before importing.
os.environ.setdefault("DATAMASQUE_BASE_URL", "http://localhost:8080/")
os.environ.setdefault(
"DATAMASQUE... | datamasque/DataMasque-AWS-RDS-masking-stepfunctions-blueprint | functions/check_masking_run/test_app.py | .py | 0313148c65cdb4a5 | 7.92 | 6 |
"""
Unit tests for the masked snapshot Lambda.
Run from this directory:
pytest test_app.py -v
"""
import os
import pytest
# app.py reads this at import time; stub it before importing.
os.environ.setdefault("PRM_TAG_VALUE", "pc:testproductcode")
os.environ.setdefault("AWS_DEFAULT_REGION", "us-east-1")
import app... | datamasque/DataMasque-AWS-RDS-masking-stepfunctions-blueprint | functions/create_masked_snapshot/test_app.py | .py | b822eb8f4bcb17e4 | 7.92 | 6 |
#!/usr/bin/env python3
import os
import sys
import time
from itertools import repeat
import numpy as np
import scipy.signal as SS
import torch
import wfdb
from easydict import EasyDict as ED
from model import (
ECG_SEQ_LAB_NET_CPSC2021,
ECG_UNET_CPSC2021,
RR_LSTM_CPSC2021,
_main_task_post_process,
... | DeepPSP/cpsc2021 | entry_2021.py | .py | feff35a9751f99e4 | 7.62 | 16 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.