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
"""Bounded row-wise mean, median, and standard-deviation reductions.""" from collections.abc import Iterator import numpy as np _ROW_BATCH_ELEMENTS = 262_144 def row_slices(n_rows: int, n_columns: int) -> Iterator[tuple[int, int]]: """Yield row slices whose matrices stay near the shared element budget.""" ...
Cameron-Lyons/ier
src/ier/_row_statistics.py
.py
d613bc41b33300e6
7.48
8
"""Small statistical primitives used internally by IER. The implementations here intentionally cover only the narrow operations the package needs. Keeping them local avoids making a large general-purpose statistics library a runtime dependency. """ from __future__ import annotations import math from statistics impo...
Cameron-Lyons/ier
src/ier/_statistics.py
.py
1996c70f49ee6329
7.48
8
"""Shared input validation utilities for careless detection functions.""" from collections.abc import Iterator, Mapping, Sequence from typing import Any, Protocol, TypeAlias import numpy as np from numpy.typing import ArrayLike class SupportsArray(Protocol): """Protocol for objects convertible to numpy arrays (...
Cameron-Lyons/ier
src/ier/_validation.py
.py
aa3cd41aa9de68d1
7.48
8
"""This module contains the evenodd function for calculating even-odd consistency scores.""" import numpy as np from ier._correlation import row_correlations from ier._validation import MatrixLike, validate_matrix_input def calculate_correlations(even_cols: np.ndarray, odd_cols: np.ndarray) -> np.ndarray: """ ...
Cameron-Lyons/ier
src/ier/evenodd.py
.py
647b369e57a6094d
7.48
8
""" Guttman errors for person-fit analysis in detecting careless responding. Guttman errors count the number of response reversals relative to item difficulty ordering. High error counts suggest inconsistent or careless responding. """ import warnings import numpy as np from ier._row_statistics import row_slices fr...
Cameron-Lyons/ier
src/ier/guttman.py
.py
ee525c2756f5a153
7.48
8
"""The main module for the app logic""" import sys import webbrowser from PyQt6 import QtCore, QtWidgets from _version import __version__ from encoding_mappings import ( ALL_EXT_ENCODINGS, CYRILLIC_ENCODINGS, HK, HK_EXT, ROMAN_BASIC_ENCODINGS, Encodings, ) from service import convert from upd...
kosperun/SansConverter
src/sans_converter.py
.py
87178b0e06ab5235
7.42
6
from encoding_mappings import ( ASPIRATED_CYRILLIC_LETTERS, ASPIRATED_CYRILLIC_LETTERS_VOICED, ASPIRATED_CYRILLIC_LETTERS_VOICELESS, ASPIRATED_ROMAN_LETTERS, IAST_INPUT_ALIASES, RUSSIAN_ENCODINGS, Encodings, ) UKR_ENCODINGS = (Encodings.UKR_G.value, Encodings.UKR_H.value) def convert( ...
kosperun/SansConverter
src/service.py
.py
36031efe7808fcec
7.42
6
"""Checks GitHub Releases for a newer version of SansConverter.""" import json import platform import urllib.error import urllib.request from dataclasses import dataclass from typing import Optional GITHUB_API_URL = "https://api.github.com/repos/kosperun/SansConverter/releases/latest" REQUEST_TIMEOUT_SECONDS = 5 # M...
kosperun/SansConverter
src/update_checker.py
.py
aebd1c173b73b519
7.42
6
""" 'About' dialog window generated by QtDesigner""" from PyQt6 import QtCore, QtGui, QtWidgets from _version import __version__ class UiAboutDialog(QtWidgets.QDialog): """Creates an 'About' dialog window""" def __init__(self, parent): super().__init__(parent) # parent dialog will be SansCo...
kosperun/SansConverter
src/windows/about.py
.py
a3f3b382ebc5d472
7.42
6
"""Help dialog window generated by QtDesigner""" from PyQt6 import QtCore, QtGui, QtWidgets class UiHelpDialog(QtWidgets.QDialog): """Help window GUI""" def __init__(self, parent): super().__init__(parent) # parent dialog will be SansConverter self.parent_dialog = parent self...
kosperun/SansConverter
src/windows/help.py
.py
9f5dc3906ff5666c
7.42
6
"""Select Encodings dialog window""" from PyQt6.QtCore import QCoreApplication, Qt from PyQt6.QtWidgets import ( QDialog, QDialogButtonBox, QLabel, QListWidget, QListWidgetItem, QVBoxLayout, ) from windows.select_encodings_warning import WarningDialog class UiSelectEncodingsDialog(QDialog): ...
kosperun/SansConverter
src/windows/select_encodings.py
.py
a4a7af1becb844cf
7.42
6
# sourced from https://github.com/mitgobla/python-discord-rpc/ # -- forked from https://github.com/suclearnub/python-discord-rpc/ # References: # * https://github.com/devsnek/discord-rpc/tree/master/src/transports/IPC.js # * https://github.com/devsnek/discord-rpc/tree/master/example/main.js # * https://github.com/disc...
irbyjm/trakt-discord-presence
libs/rpc.py
.py
335287bcd367aac0
7.42
6
"""Module to manage AiiDAlab configuration.""" from __future__ import annotations from os import getenv from pathlib import Path from typing import Any import click import toml CONFIG_PATH = Path.home() / "aiidalab.toml" _CONFIG = toml.loads(CONFIG_PATH.read_text()) if CONFIG_PATH.is_file() else {} _DEVELOP_MODE = ...
aiidalab/aiidalab
aiidalab/config.py
.py
ed4838ad54911ba2
7.63
17
"""App environment specification The specification is used to describe a reproducible environment for a specific app, similar to the Reproducible Environment Specification (REES) [1] [1] https://repo2docker.readthedocs.io/en/latest/specification.html The following configuration files are recognized with the order of...
aiidalab/aiidalab
aiidalab/environment.py
.py
e76b176016e11e2a
7.63
17
"""Utility module for git-managed AiiDAlab apps.""" # This future import turns on postponed evaluation of annotations, per PEP 563. # https://peps.python.org/pep-0563/ # This is needed for two reasons: # 1. Using the new Union syntax (type1 | type2) with Python < 3.10 # 2. Instead of using the Self type when returning...
aiidalab/aiidalab
aiidalab/git_util.py
.py
fcba4718af98ca02
7.63
17
"""Generate API endpoints.""" import json from collections.abc import Generator from pathlib import Path from .apps_index import validate_apps_index_and_apps from .core import AppRegistrySchemas def build_api_v1(api_path: Path, apps_index: dict, apps_data: dict) -> Generator[Path]: """Build tree for API endpoin...
aiidalab/aiidalab
aiidalab/registry/api.py
.py
396e2727ae145713
7.63
17
"""Generate the apps index including all aggregated metadata.""" from __future__ import annotations import logging from collections import OrderedDict from copy import deepcopy from dataclasses import asdict from typing import Any import jsonschema from ..utils import _ParseAppCallable, sort_semantic from . import ...
aiidalab/aiidalab
aiidalab/registry/apps_index.py
.py
c16cf11e027fca0e
7.63
17
"""Core data classes for the app registry.""" import json from dataclasses import dataclass, fields from pathlib import Path import jsonschema import pkg_resources from .util import load_json @dataclass class AppRegistrySchemas: """The app registry JSON-schema objects.""" app: dict apps: dict apps...
aiidalab/aiidalab
aiidalab/registry/core.py
.py
f152f627b31964e3
7.63
17
from __future__ import annotations import logging import os import re from collections.abc import Generator from dataclasses import dataclass, replace from urllib.parse import urlsplit, urlunsplit from dulwich.refs import Ref from ..environment import Environment from ..fetch import fetch_from_url from ..git_util im...
aiidalab/aiidalab
aiidalab/registry/releases.py
.py
15c69aef92304cd0
7.63
17
"""Utility functions for the application registry.""" import json import string from pathlib import Path from urllib.parse import urlparse def get_html_app_fname(app_name: str) -> str: valid_characters = set(string.ascii_letters + string.digits + "_-") simple_string = "".join(c for c in app_name if c in val...
aiidalab/aiidalab
aiidalab/registry/util.py
.py
27c237a307daf61a
7.63
17
"""Generate the app registry website.""" from __future__ import annotations import logging import os import os.path import shutil from collections.abc import Generator from itertools import chain from pathlib import Path import pkg_resources from ..utils import parse_app_repo from . import api, yaml from .apps_inde...
aiidalab/aiidalab
aiidalab/registry/web.py
.py
b2052f6309ad752a
7.63
17
from __future__ import annotations from pathlib import Path from typing import Any from urllib.parse import urlsplit import cachecontrol import jsonref # type: ignore[import-untyped] import requests from ruamel.yaml import YAML REQUESTS = cachecontrol.CacheControl(requests.Session()) class JsonYamlLoader(jsonref....
aiidalab/aiidalab
aiidalab/registry/yaml.py
.py
78ddf94a9985a462
7.63
17
# pylint: disable=invalid-name # -*- coding: utf-8 -*- """Sphinx configuration for aiidalab.""" import os import subprocess import sys import time import aiidalab # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extens...
aiidalab/aiidalab
docs/source/conf.py
.py
1f7600570901292a
7.63
17
import sys import threading from pathlib import Path import pytest from ruamel.yaml import YAML @pytest.fixture(scope="session") def static_path(): return Path(__file__).parent.absolute() / "static" @pytest.fixture(scope="session") def apps_path(static_path): return static_path / "apps.yaml" @pytest.fixt...
aiidalab/aiidalab
tests/conftest.py
.py
be3cfde2d15da149
8.13
17
import threading from dataclasses import dataclass from pathlib import Path from time import sleep import pytest import traitlets from aiidalab.app import AiidaLabApp, AiidaLabAppWatch def test_init_refresh(generate_app): app = generate_app() # App is being refreshed already in the `generate_app` fixture ...
aiidalab/aiidalab
tests/test_appclass.py
.py
00e4d091bec40aa1
8.13
17
"""Test the dataclass _AiidaLabApp. We mock the app requirements and the medatada by a simple yaml file.""" import sys from pathlib import Path import pytest from packaging.requirements import Requirement from aiidalab.app import AppRemoteUpdateStatus, AppVersion, _AiidaLabApp @pytest.fixture def python_bin(): ...
aiidalab/aiidalab
tests/test_appdataclass.py
.py
e561f75f9fa36bb8
7.13
17
from pathlib import Path import pytest # To learn more about testing Click applications see # http://click.pocoo.org/5/testing/ from click.testing import CliRunner import aiidalab.__main__ as cli from aiidalab import __version__ def test_version_displays_library_version(): """ Run `aiidalab --version` and ...
aiidalab/aiidalab
tests/test_cli.py
.py
d7965f6868e30f1c
7.13
17
"""Test fixtures defined in conftest.py""" import pytest def test_forbidden_functions(): """Ensure that we fail if we try to run `pip install` and other functions that might influence global environment. """ from aiidalab.utils import ( load_app_registry_entry, load_app_registry_index...
aiidalab/aiidalab
tests/test_conftest.py
.py
6a3ff0d22645a409
7.13
17
import os import pytest from aiidalab.fetch import GitRepo, fetch_from_url pytestmark = pytest.mark.registry def test_get_all_tagged_releases(): """Test that all tagged releases are returned.""" from aiidalab.registry.releases import _get_release_commits, _split_release_line url = "git+https://github....
aiidalab/aiidalab
tests/test_registry.py
.py
d6a8019742d8291b
7.13
17
import collections from typing import List, Tuple import numba as nb import numpy as np import spectrum_utils.spectrum as sus SpectrumTuple = collections.namedtuple( "SpectrumTuple", ["precursor_mz", "precursor_charge", "mz", "intensity"] ) def cosine( spectrum1: sus.MsmsSpectrum, spectrum2: sus.MsmsSp...
mwang87/MetabolomicsSpectrumResolver
metabolomics_spectrum_resolver/similarity.py
.py
9123fb2313761337
8.02
10
import io import sys from typing import Any, Tuple import celery import celery_once import joblib import redis import spectrum_utils.spectrum as sus from metabolomics_spectrum_resolver import drawing, parsing from metabolomics_spectrum_resolver import tasks_analytics memory = joblib.Memory("tmp/joblibcache", verbose...
mwang87/MetabolomicsSpectrumResolver
metabolomics_spectrum_resolver/tasks.py
.py
51299a802caa9bd7
7.02
10
import copy import csv import io import json import urllib.parse from typing import Any, Dict, List, Optional, Tuple, Union import flask import numpy as np import qrcode from spectrum_utils import spectrum as sus from metabolomics_spectrum_resolver import similarity, tasks from metabolomics_spectrum_resolver.rate_lim...
mwang87/MetabolomicsSpectrumResolver
metabolomics_spectrum_resolver/views.py
.py
0a48ebd8e699c8f8
7.02
10
"""Authenticated Received Chain (ARC) sealing and verification (RFC 8617) ARC lets a sequence of intermediaries (mailing lists, forwarders, gateways) record the email authentication results they observed, so that a later receiver can trust those results even when SPF/DKIM/DMARC break in transit. Each hop adds an *ARC ...
seanthegeek/mailsuite
mailsuite/arc.py
.py
012879ebc6fcc0cf
7.57
13
"""Abstract base class for mailbox connections""" from __future__ import annotations from abc import ABC from collections.abc import Callable from typing import Any class FolderExistsError(RuntimeError): """Raised when a folder/label operation targets a name that is already taken — e.g. :meth:`MailboxConnec...
seanthegeek/mailsuite
mailsuite/mailbox/base.py
.py
cbf41be0eb59dd3d
7.57
13
"""Gmail mailbox backend""" from __future__ import annotations import base64 import logging from collections.abc import Callable from functools import lru_cache from pathlib import Path from time import sleep from typing import Any from mailsuite.mailbox.base import ( FolderNotFoundError, MailboxConnection, ...
seanthegeek/mailsuite
mailsuite/mailbox/gmail.py
.py
5a6475f6cf8236d6
7.57
13
"""IMAP mailbox backend""" from __future__ import annotations import logging from collections.abc import Callable from time import sleep from typing import Any, cast from imapclient.exceptions import IMAPClientError from mailsuite.imap import IMAPClient from mailsuite.mailbox.base import MailboxConnection logger =...
seanthegeek/mailsuite
mailsuite/mailbox/imap.py
.py
94c57bd0d13e2079
7.57
13
"""Maildir mailbox backend""" from __future__ import annotations import logging import mailbox import os from collections.abc import Callable from time import sleep from typing import Any from mailsuite.mailbox.base import MailboxConnection logger = logging.getLogger(__name__) class MaildirConnection(MailboxConne...
seanthegeek/mailsuite
mailsuite/mailbox/maildir.py
.py
f68ab8c187862fc7
7.57
13
"""Shared pytest fixtures.""" from __future__ import annotations import pytest from mailsuite.dkim import generate_dkim_keypair @pytest.fixture(scope="session") def dkim_keypair() -> tuple[str, str]: """A 2048-bit RSA DKIM keypair shared across tests for speed.""" return generate_dkim_keypair(key_size=2048...
seanthegeek/mailsuite
tests/conftest.py
.py
c3397e1428e5fb98
8.07
13
"""Tests for mailsuite.arc.""" from __future__ import annotations import pytest from mailsuite.arc import ARCError, seal_email, verify_arc_chain from mailsuite.dkim import generate_dkim_keypair, generate_dkim_txt_record def _dns_func_for(pub: str): """A fake DNS resolver returning a DKIM TXT record for ``pub``...
seanthegeek/mailsuite
tests/test_arc.py
.py
31b383029f68f7be
7.07
13
"""Docker-based integration tests for the IMAP IDLE watch loop. These exercise ``mailsuite.imap.IMAPClient``'s IDLE watch against a real IMAP server (GreenMail) running in Docker — the behaviour that the mocked unit tests can't cover: live IDLE notifications and reconnect-during-IDLE. They are **opt-in**: skipped unl...
seanthegeek/mailsuite
tests/test_imap_idle_integration.py
.py
a98d6a6fd93a26d8
8.07
13
"""Tests for mailsuite.mailbox.gmail.GmailConnection. The Gmail SDK is fully mocked. We construct connections via __new__ and inject a fake service builder so we don't need real OAuth or network I/O. """ from __future__ import annotations import base64 from unittest.mock import MagicMock import pytest # Skip every...
seanthegeek/mailsuite
tests/test_mailbox_gmail.py
.py
9301dd9dbea563e6
8.07
13
"""Tests for mailsuite.mailbox.imap.IMAPConnection.""" from __future__ import annotations from unittest.mock import MagicMock import pytest from imapclient.exceptions import IMAPClientError from mailsuite.mailbox import FolderExistsError from mailsuite.mailbox.imap import IMAPConnection def _bare_connection() -> ...
seanthegeek/mailsuite
tests/test_mailbox_imap.py
.py
ce49de9871d6e80b
8.07
13
"""Tests for mailsuite.mailbox.maildir.""" from __future__ import annotations import mailbox import os import pytest from mailsuite.mailbox import ( FolderExistsError, FolderNotFoundError, MailboxConnection, MaildirConnection, ) @pytest.fixture def maildir_path(tmp_path): md = tmp_path / "Mail...
seanthegeek/mailsuite
tests/test_mailbox_maildir.py
.py
7e7dffd2a92e6c23
7.07
13
"""Tests for mailsuite.utils.""" from __future__ import annotations import base64 import logging import pytest from mailsuite.utils import ( create_email, decode_base64, from_trusted_domain, get_filename_safe_string, is_outlook_msg, parse_authentication_results, parse_dkim_signature, ...
seanthegeek/mailsuite
tests/test_utils.py
.py
29700ef2d5bbecea
8.07
13
# -*- coding: utf-8 -*- """ This module is a simple common base for text file IO. @outhor: Kijin Nam, knam@water.ca.gov """ class BaseIO(object): """Common IO routines to handle text inputs""" def __init__(self, logger=None): """Constructor""" self._logger = logger self._lc = 0 @...
CADWRDeltaModeling/schimpy
schimpy/base_io.py
.py
09dbcf11602303cb
7.52
10
#!/usr/bin/env python #! -*- coding: utf-8 -*- """Calculate skewness of elements form gr3 file""" import schimpy.schism_mesh import schimpy.sms2gr3 import click import os import numpy as np angle_e = np.array((np.pi / 3.0, np.pi * 2.0 / 3.0)) def calculate_skewness(mesh, normalize=True, mask_tri=False): """Calc...
CADWRDeltaModeling/schimpy
schimpy/check_mesh_skewness.py
.py
75e11d1dd9629d76
7.52
10
#!/usr/bin/env python import math import click import schimpy.schism_yaml as schism_yaml try: from osgeo import gdal from osgeo.gdalconst import * gdal.TermProgress = gdal.TermProgress_nocb except ImportError: import gdal from gdalconst import * import subprocess import numpy as np import sys imp...
CADWRDeltaModeling/schimpy
schimpy/clip_dems.py
.py
88097e3951494210
7.52
10
#!/usr/bin/env python # -*- coding: utf-8 -*- """Command line tool to merge possibly overlapping flux.dat files from hotstart runs""" import click import numpy as np def combine_flux(infiles, outfile, prefer_last=False): """Merge possibly overlapping flux.dat files from hostart runs""" filedata = [] for f...
CADWRDeltaModeling/schimpy
schimpy/combine_flux.py
.py
4ca26d1a89a1b7ba
7.52
10
#!/usr/bin/env python # -*- coding: utf-8 -*- """Command line tool to convert SCHISM line strings in YAML to Shapefile and vice versa """ from schimpy.schism_linestring import read_linestrings, write_linestrings from schimpy.prepare_schism import get_structures_from_yaml from schimpy.schism_setup import check_and_sugge...
CADWRDeltaModeling/schimpy
schimpy/convert_linestrings.py
.py
f9572f5cb1b4f8c2
7.52
10
#!/usr/bin/env python # -*- coding: utf-8 -*- """Mesh converter""" from schimpy.schism_mesh import read_mesh, write_mesh import click @click.command( help="Convert a mesh from one format to another. The format is decided by the extensions automatically." ) @click.option( "--input", required=True, typ...
CADWRDeltaModeling/schimpy
schimpy/convert_mesh.py
.py
41548032bfdb02d2
7.52
10
#!/usr/bin/env python # -*- coding: utf-8 -*- """Command line tool to convert SCHISM points (source and sink) in YAML to Shapefile""" import click import geopandas as gpd import pandas as pd import warnings import warnings from shapely.geometry import Point from schimpy.schism_sources_sinks import yaml2df import yaml ...
CADWRDeltaModeling/schimpy
schimpy/convert_points.py
.py
6c23d4fe34825cfb
7.52
10
#!/usr/bin/env python # -*- coding: utf-8 -*- """Command line tool to convert SCHISM polygons in YAML to Shapefile and vice versa """ from schimpy.schism_polygon import read_polygons, write_polygons import click @click.command(help="Convert SCHISM polygons between YAML and Shapefile formats.") @click.option( "--i...
CADWRDeltaModeling/schimpy
schimpy/convert_polygons.py
.py
b43d5e6f40157334
7.52
10
#!/usr/bin/env python # -*- coding: utf-8 -*- import click import numpy as np from osgeo import gdal from schimpy.schism_polygon import read_polygons, Point from scipy.ndimage import gaussian_filter as gfilt def read_density_tiff(fpath_densitiy_tiff): """Read geotiff values for density It is assumed that th...
CADWRDeltaModeling/schimpy
schimpy/convert_sav_class_to_number.py
.py
515b9ca2f4d78887
7.52
10
#!/usr/bin/env python # -*- coding: utf-8 -*- """Create a mesh file with the number of vertical levels as nodal value""" from schimpy.schism_mesh import read_mesh, write_mesh import numpy as np import click def create_mesh_n_levels(hgrid, vgrid, output): """ Create a mesh file with the number of vertical level...
CADWRDeltaModeling/schimpy
schimpy/create_mesh_n_levels.py
.py
358c57e3d8d18770
7.52
10
#!/usr/bin/env python import click import os import pandas as pd import schimpy.station as station from schimpy.yaml_util import yaml_from_file import glob import numpy as np from datetime import datetime import warnings def read_staout_lite(fname, station_infile): """Read a SCHISM staout_* file into a pandas Dat...
CADWRDeltaModeling/schimpy
schimpy/create_station_output.py
.py
fe4e1bc6c1577e00
7.52
10
#!/usr/bin/env python # -*- coding: utf-8 -*- # runfile('D:/Delta/BayDeltaSCHISM/Scripts/create_vgrid_lsc2.py', # wdir='D:/temp/gridopt/%s' % (scene), # args="--hgrid=%s.gr3 --minmaxregion=../minmaxlayer.shp --dxwgt=1.0 --curvewgt=8. --archive_nlayer=out --nlayer_gr3=%s_nlayer.gr3 --eta=1.0" %(scene,sce...
CADWRDeltaModeling/schimpy
schimpy/create_vgrid_lsc2.py
.py
e3f973761650f697
7.52
10
"""Functions to cut certain parts in the mesh by cutting lines.""" ## Author: Kijin Nam, knam@water.ca.gov from schimpy.schism_mesh import read_mesh, write_mesh import numpy as np import os import click def read_lines(fpath): """Read coordinates of cutting line segments from a plain text file. The expecte...
CADWRDeltaModeling/schimpy
schimpy/cut_mesh.py
.py
1ae6a0b64fbe0a1d
7.52
10
"""Embed finer gridded data in coarser, using curvature flow smoothing to reconcile Main function is called embed_fine """ import numpy as np import matplotlib.pyplot as plt import scipy.ndimage as cv from nodepy import * import sys import os.path from schimpy.contour_smooth import * try: from osgeo import gdal...
CADWRDeltaModeling/schimpy
schimpy/embed_raster.py
.py
e6387ba32995715d
7.52
10
# -*- coding: utf-8 -*- import os import yaml import json import numpy as np import pandas as pd import logging import geopandas as gpd from shapely.geometry import Point, Polygon, LineString, mapping, MultiPolygon from pyproj import Proj, CRS def shapely_to_geopandas(features, crs=None, shp_fn=None): """Convert...
CADWRDeltaModeling/schimpy
schimpy/geo_tools.py
.py
0d05ed9390b39bb8
7.52
10
# -*- coding: utf-8 -*- """ Package to read a mesh in GR3 format. """ from schimpy.schism_mesh import BoundaryType import schimpy.schism_mesh import schimpy.base_io import numpy as np import os class Gr3IO(schimpy.base_io.BaseIO): """A class that manages I/O of GR3 files""" def __init__(self, logger=None): ...
CADWRDeltaModeling/schimpy
schimpy/gr3.py
.py
85c9454decde0a59
7.52
10
# -*- coding: utf-8 -*- """invdisttree.py: inverse-distance-weighted interpolation using KDTree""" import numpy as np from scipy.spatial import cKDTree as KDTree class Invdisttree: """Inverse-distance-weighted interpolation using KDTree Examples -------- tree = interp_2d.Invdisttree(obs_xy) # initia...
CADWRDeltaModeling/schimpy
schimpy/interp_2d.py
.py
5c6fea1b756358a8
7.52
10
#!/usr/bin/env python # -*- coding: utf-8 -*- import click import pandas as pd from vtools import hours def test_date_label_correct(fname_th): """Make sure that the date column in the file doens't have comment marker and raise error if it does""" label_correct = False with open(fname_th, "r") as testread...
CADWRDeltaModeling/schimpy
schimpy/interpolate_structure.py
.py
f95b847b8ce706ff
7.52
10
from __future__ import annotations import logging import os import sys from dataclasses import dataclass from datetime import datetime from pathlib import Path from typing import Optional, Tuple @dataclass(frozen=True) class LoggingConfig: package_name: str level: int = logging.INFO # Handlers conso...
CADWRDeltaModeling/schimpy
schimpy/logging_config.py
.py
505d2439edfe5503
7.52
10
#!/usr/bin/env python import sys import click from osgeo import ogr def read_keyfile(keyfile): """Reads a file pairing labels and values""" keys = {} with open(keyfile, "r") as kf: for line in kf: if line and len(line) > 2: key, val = line.strip().split() ...
CADWRDeltaModeling/schimpy
schimpy/material_poly.py
.py
199a5fa33231d673
7.52
10
def parse(file_content): """ Here's a simple implementation of a parser for the Fortran namelist format If there's a line starting with !, the parser will store it as the full_line_comment and attach it to the next key-value pair it encounters. If there's an inline comment starting with !, it will be st...
CADWRDeltaModeling/schimpy
schimpy/nml.py
.py
c88ea8fac95324f0
7.52
10
# Priority dictionary using binary heaps # David Eppstein, UC Irvine, 8 Mar 2002 class priorityDictionary(dict): def __init__(self): """Initialize priorityDictionary by creating binary heap of pairs (value,key). Note that changing or removing a dict entry will not remove the old pa...
CADWRDeltaModeling/schimpy
schimpy/priority_queue.py
.py
0939957055594c5f
7.52
10
from pydantic import SecretStr from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): model_config = SettingsConfigDict( env_prefix="OMICIDX_API_", env_file=".env", env_file_encoding="utf-8", extra="ignore", ) database_url: str = "post...
seandavi/omicidx
packages/omicidx-api/src/omicidx/api/config.py
.py
afd7f0c67f9184bd
7.56
12
import base64 import binascii import json from dataclasses import dataclass from fastapi import HTTPException @dataclass class CursorPage: """Decoded cursor with the keyset value for WHERE clause.""" after: str | int def encode_cursor(value: str | int) -> str: """Encode a keyset value into an opaque b...
seandavi/omicidx
packages/omicidx-api/src/omicidx/api/pagination.py
.py
8d8e40186f01bb42
7.56
12
from typing import Any, Generic, TypeVar from urllib.parse import urlencode from pydantic import BaseModel T = TypeVar("T") class CursorInfo(BaseModel): next: str | None = None prev: str | None = None class Meta(BaseModel): count: int cursor: CursorInfo | None = None class Links(BaseModel): ...
seandavi/omicidx
packages/omicidx-api/src/omicidx/api/schemas/envelope.py
.py
5152000227790afe
7.56
12
"""Tests for rate limiting via slowapi.""" from unittest.mock import patch from fastapi.testclient import TestClient def _make_app(rate_limit: str = "5/minute"): """Create a fresh app with the given rate limit for testing.""" with patch("omicidx.api.config.Settings.model_post_init", lambda *a, **kw: None): ...
seandavi/omicidx
packages/omicidx-api/tests/test_ratelimit.py
.py
521af0518db6eabb
8.06
12
import hashlib from dataclasses import dataclass from datetime import datetime from upath import UPath @dataclass class AssetMetadata: """Richer metadata for lineage and cataloging""" asset_key: str storage_path: str upstream_assets: list[str] # Data profile row_count: int | None = None ...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/biosample/asset_metadata.py
.py
d6cdede31f9e2036
7.56
12
""" Simplified biosample/bioproject extraction without Prefect dependencies. """ import gzip import shutil import tempfile import threading import time from datetime import datetime from pathlib import Path import click import httpx import orjson import tenacity from omicidx.etl.log import get_logger from omicidx.par...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/biosample/extract.py
.py
6b75f045eb250c21
7.56
12
"""config settings for omicidx_etl""" from dotenv import load_dotenv from pydantic_settings import BaseSettings, SettingsConfigDict from upath import UPath load_dotenv() # Load environment variables from .env file class Settings(BaseSettings): """settings for omicidx_etl""" model_config = SettingsConfigDi...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/config.py
.py
c85ad45f5430e6f7
7.56
12
import contextlib import tempfile from pathlib import Path import duckdb from .config import settings def _q(value: str) -> str: """Escape a string for safe use in a SQL single-quoted literal.""" return value.replace("'", "''") def duckdb_setup_sql(temp_directory: str | None = None): """ Generate ...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/db.py
.py
ee23bb285f0138ab
7.56
12
import shutil import tempfile from collections.abc import Iterable from datetime import date, datetime, timedelta import anyio import click import httpx import pyarrow as pa import pyarrow.parquet as pq import tenacity from omicidx.etl.log import get_logger from upath import UPath from .schema import get_biosample_sc...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/ebi_biosample/extract.py
.py
6e912ea4a31f3c7e
7.56
12
import tarfile import tempfile import zipfile from pathlib import Path import click import httpx from omicidx.etl.db import duckdb_connection from omicidx.etl.log import get_logger from upath import UPath logger = get_logger(__name__) ICITE_COLLECTION_ID = 4586573 def get_icite_collection_articles() -> list[dict[s...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/icite.py
.py
d692fe889406611b
7.56
12
""" Centralized logging configuration for omicidx-gh-etl. Provides structured JSON logging in CI environments and human-friendly colorized logging for local development. Usage: from omicidx.etl.log import configure_logging, get_logger, log_duration # Configure once at application startup configure_loggin...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/log.py
.py
0782142ae3e8dfed
7.56
12
import gzip import pathlib import shutil import tempfile import zipfile from datetime import datetime import click import httpx import polars as pl from omicidx.etl.log import get_logger from upath import UPath logger = get_logger(__name__) # Configuration constants DEFAULT_OUTPUT_DIR = UPath("/tmp/omicidx/nih_repor...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/nih_reporter.py
.py
a0d0ce6454696bb2
7.56
12
import datetime import re import shutil import tempfile from urllib.request import urlretrieve import click import pubmed_parser as pp import pyarrow as pa import pyarrow.parquet as pq from omicidx.etl.log import get_logger from upath import UPath logger = get_logger(__name__) # Module-level constants PUBMED_BASE =...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/pubmed.py
.py
2d5878b5f494f16b
7.56
12
""" SRA catalog management. This module provides the SRACatalog class for managing the processing and cleanup of SRA mirror entries. """ import contextlib import json import re from datetime import datetime from upath import UPath from ..log import LogProgress, get_logger, log_operation from .mirror import SRAMirro...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/sra/catalog.py
.py
b964a0d5acca51b5
7.56
12
""" CLI commands for SRA module. Provides commands to sync SRA mirror entries and manage the catalog. """ from datetime import date import click from omicidx.etl.log import get_logger from .catalog import SRACatalog from .mirror import SRAMirrorEntry, get_sra_mirror_entries @click.group() def sra(): """SRA (S...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/sra/cli.py
.py
65ae6b24b7137269
7.56
12
""" SRA mirror entry management. This module provides classes and functions for working with NCBI SRA mirror files, including parsing mirror URLs and determining which files to process. """ import datetime import re from loguru import logger from upath import UPath class SRAMirrorEntry: """ Represents an e...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/sra/mirror.py
.py
6a1755580b4d4992
7.56
12
""" Parquet processing for SRA mirror entries. This module provides functions to download, parse, and write SRA mirror entries as parquet files in bounded-memory chunks. """ from __future__ import annotations import gzip import shutil import tempfile from collections.abc import Callable, Iterable from xml.etree.Elem...
seandavi/omicidx
packages/omicidx-etl/src/omicidx/etl/sra/mirror_parquet.py
.py
e4dfde5172cd3059
7.56
12
# SPDX-License-Identifier: MIT # (c) 2020 The TJHSST Director 4.0 Development Team & Contributors from django.urls import reverse from ...test.director_test import DirectorTestCase class AuthTest(DirectorTestCase): def test_accept_guidelines(self): # Log in as a user that has not accepted guidelines ...
tjcsl/director4
manager/director/apps/auth/tests.py
.py
1d97d05c3b118228
7.02
10
# SPDX-License-Identifier: MIT # (c) 2019 The TJHSST Director 4.0 Development Team & Contributors import os import re import time import urllib.parse import xml.etree.ElementTree from typing import Any, Dict, Generator, List, Optional, Set, Tuple import bleach import markdown import markdown.extensions.toc from bleac...
tjcsl/director4
manager/director/apps/docs/utils.py
.py
86fb4dedb048abc0
7.52
10
from django.urls import reverse from ...test.director_test import DirectorTestCase class ShellServerTestCase(DirectorTestCase): def test_authenticate_view(self): self.login(username="awilliam", accept_guidelines=True) # I'm not waiting 15 seconds for this test to complete with self.setti...
tjcsl/director4
manager/director/apps/shell_server/tests.py
.py
f259bc2c6f143eb8
7.02
10
"""__init__.py - package definition module for DHParser/parsers Copyright 2024 by Eckhart Arnold (arnold@badw.de) Bavarian Academy of Sciences an Humanities (badw.de) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You m...
jecki/DHParser
DHParser/parsers/__init__.py
.py
a2446c7ac4672368
7.45
7
#!/usr/bin/env python3 """dhparser_rename.py - rename a dhparser project properly UNMAINTAINED!!! Copyright 2019 by Eckhart Arnold (arnold@badw.de) Bavarian Academy of Sciences an Humanities (badw.de) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except i...
jecki/DHParser
DHParser/scripts/dhparser_rename.py
.py
e36a5ea34caca3e3
7.45
7
# validate.py - validation of node-trees according to a # grammar-like schema (inspired by Relax NG) # # Copyright 2022 by Eckhart Arnold (arnold@badw.de) # Bavarian Academy of Sciences an Humanities (badw.de) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may n...
jecki/DHParser
DHParser/validate.py
.py
87389b33926cfb65
7.45
7
from __future__ import annotations import logging import platform from collections import defaultdict from collections.abc import Callable from ssl import SSLContext from typing import Any from pydantic import BaseModel from pydantic_xml import BaseXmlModel from ._errors import APIError, ErrorStatus, build_error_map...
librestfly/restfly
restfly/_base.py
.py
62621621ca5b2db9
7.62
16
""" Error handling classes and data-classes. """ import logging from collections import defaultdict from dataclasses import dataclass, replace from httpx import Response from pydantic import BaseModel class RetryError(Exception): """ RetryError is thrown when too many retries have been made to the endpoint ...
librestfly/restfly
restfly/_errors.py
.py
f305b188d8c048fd
7.62
16
from __future__ import annotations from typing import TYPE_CHECKING, Any, get_origin, get_type_hints, overload from httpx import Response from pydantic import BaseModel, TypeAdapter from pydantic_xml import BaseXmlModel from .types import Model, XMLModel if TYPE_CHECKING: from ._async import AsyncAPIClient ...
librestfly/restfly
restfly/_utils.py
.py
5c928b3e0c5841c5
7.62
16
# Copyright 2018 Comcast Cable Communications Management, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
vinyldns/vinyldns-python
func_tests/test_client.py
.py
427d19209a050eb7
7.06
12
# Copyright 2018 Comcast Cable Communications Management, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
vinyldns/vinyldns-python
func_tests/utils.py
.py
a717083fa1161f7d
8.06
12
# Copyright 2018 Comcast Cable Communications Management, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
vinyldns/vinyldns-python
func_tests/vinyldns_context.py
.py
802545ff33f60292
8.06
12
# Copyright 2018 Comcast Cable Communications Management, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
vinyldns/vinyldns-python
scripts/search_records_by_name.py
.py
5ae6ac2935a826a8
7.56
12
# Copyright 2018 Comcast Cable Communications Management, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
vinyldns/vinyldns-python
scripts/update_record_owner.py
.py
b98f47359db81eee
7.56
12
# Copyright 2018 Comcast Cable Communications Management, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
vinyldns/vinyldns-python
scripts/verify_reverse_zones.py
.py
156a0ba9de05239b
7.56
12
# Copyright 2018 Comcast Cable Communications Management, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
vinyldns/vinyldns-python
scripts/zone_dump.py
.py
fcfc3d183440378d
7.56
12
# Copyright 2018 Comcast Cable Communications Management, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
vinyldns/vinyldns-python
src/vinyldns/boto_request_signer.py
.py
6f15be9a180dfb70
7.56
12