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 |
|---|---|---|---|---|---|---|
"""Persistence utilities for JAX/equinox models."""
from pathlib import Path
from typing import Any, cast
import dill
import equinox as eqx
import jax
__all__ = ["load", "recast_to_template", "save"]
def save(path: Path | str, model: eqx.Module) -> None:
"""Pickle an equinox model to disk via dill.
Parame... | Computational-Biology-Aachen/MxlPy | src/mxlpy/jax/io.py | .py | bc1b997edfaacaa7 | 7.62 | 16 |
"""Named, DataFrame-based simulation results for JAX models."""
from __future__ import annotations
from dataclasses import dataclass
from functools import cached_property, partial
from typing import TYPE_CHECKING
import jax
import numpy as np
import pandas as pd
if TYPE_CHECKING:
from mxlpy.jax.models import Fl... | Computational-Biology-Aachen/MxlPy | src/mxlpy/jax/simulation.py | .py | 373fed6985de1876 | 7.62 | 16 |
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from reconcile.utils.glitchtip import GlitchtipClient
def test_organsiation_create(
glitchtip_client: GlitchtipClient,
test_org: str,
delete_test_org_before_start: None,
) -> None:
"""Create a new organization."""
org = glitcht... | app-sre/glitchtip | acceptance/test_organizations.py | .py | e4f71887ee7a5989 | 7.92 | 6 |
from typing import TYPE_CHECKING
import pytest
from reconcile.utils.glitchtip.models import (
ProjectAlert,
ProjectAlertRecipient,
RecipientType,
)
if TYPE_CHECKING:
from reconcile.utils.glitchtip import GlitchtipClient
@pytest.fixture
def test_alert(
glitchtip_client: GlitchtipClient,
test_... | app-sre/glitchtip | acceptance/test_project_alerts.py | .py | 7defd726d77846bd | 7.92 | 6 |
import os
import sys
from dataclasses import dataclass
from pathlib import Path
import django
from django.contrib.auth import get_user_model
from django.contrib.auth.hashers import make_password
# add the parent directory to the path so we can import the glitchtip module(s)
sys.path.append(str(Path(__file__).resolve(... | app-sre/glitchtip | appsre/create-api-users.py | .py | 3931b400024c3803 | 7.42 | 6 |
"""Regression test pinning the real JSON shape GlitchTip sends for a generic webhook alert recipient.
Not part of the upstream glitchtip-backend source: this file is COPY'd into
the built image inside the Docker `test` stage (see ../Dockerfile) and run
via `make test`, which Konflux already builds on every PR
(.tekton... | app-sre/glitchtip | django-tests/test_webhook_payload_contract.py | .py | 0eefed45c149639c | 7.92 | 6 |
import unittest
from unittest.mock import MagicMock, patch
import tempfile
import os
from tickr.fetch_candles import initialize_exchange, CandleFetcher
import datetime
import json
class TestFetchCandles(unittest.TestCase):
@patch('tickr.fetch_candles.ccxt')
def test_initialize_exchange_success(self, mock_ccxt... | syncsoftco/tickr | tests/test_fetch_candles.py | .py | 77f6d78625f75a75 | 7.06 | 12 |
"""
test_tickr_client.py
Unit tests for the TickrClient class in tickr/tickr_client.py.
License: MIT
"""
import unittest
from unittest.mock import patch, MagicMock
import base64
import pandas as pd
import datetime
import json
from tickr.tickr_client import TickrClient, main
from absl.testing import absltest
from abs... | syncsoftco/tickr | tests/test_tickr_client.py | .py | 91981904c14c44ca | 7.06 | 12 |
"""
fetch_candles.py
This script fetches the latest cryptocurrency candle data using the CCXT library and updates
the local data files in the repository. It is intended to be run manually or via a scheduled GitHub Actions workflow.
License: MIT
"""
from absl import app, flags
import ccxt
import os
import datetime
im... | syncsoftco/tickr | tickr/fetch_candles.py | .py | 7385280eaef77fd1 | 7.56 | 12 |
"""
tickr_client.py
A high-level API client for accessing cryptocurrency candle data stored in a GitHub repository.
The TickrClient class provides an easy interface to fetch the most recent candles or specify a date range.
This script can also be run as a standalone program to fetch and display candle data
using comm... | syncsoftco/tickr | tickr/tickr_client.py | .py | b6c5108cb16595ef | 7.56 | 12 |
"""Input archive/document discovery and extraction."""
import os
import re
import shutil
import tempfile
import unicodedata
import zipfile
from pathlib import Path
from .constants import IMAGE_EXTENSIONS
from .sorting import sort_key_improved
_temp_extraction_dirs = []
def extract_images_from_zip(zip_path, extract_... | esmail-mkh/PhotoSlicer | engine/archive_io.py | .py | 224f48bbb450a912 | 7.6 | 15 |
"""Image decoding, dimension inspection, resizing, and stitching."""
import os
from concurrent.futures import ThreadPoolExecutor
from PIL import Image, ImageFile
from .constants import WEBP_MAX_DIMENSION
ImageFile.LOAD_TRUNCATED_IMAGES = True
Image.MAX_IMAGE_PIXELS = None
try:
from pillow_heif import register_... | esmail-mkh/PhotoSlicer | engine/image_io.py | .py | 32cae58435d5483a | 7.6 | 15 |
"""Top-level image processing pipeline orchestration."""
import os
import shutil
import zipfile
from concurrent.futures import ThreadPoolExecutor, as_completed
from PIL import Image
import img2pdf
from .image_io import (
any_image_exceeds_webp_limit,
get_concat_v_optimized,
open_image_robust,
)
from .psd... | esmail-mkh/PhotoSlicer | engine/pipeline.py | .py | 2248b81b6997d7dd | 7.6 | 15 |
"""Photoshop-compatible layered PSD export."""
import os
from PIL import Image
import numpy as np
from .watermark import (
_default_watermark_placements,
_prepare_watermark_for_canvas,
compute_watermark_placements,
)
def _save_multilayer_psd(path: str, base_image: Image.Image, placements: list) -> bool:... | esmail-mkh/PhotoSlicer | engine/psd_export.py | .py | 46f3d8c06b44f9ef | 7.6 | 15 |
"""Filename ordering and image-directory discovery."""
import os
import re
import unicodedata
from pathlib import Path
def sort_key_improved(filepath):
"""Return a deterministic natural-sort key for paths and filenames.
Numeric runs are compared by value wherever they occur in the stem. This
deliberately... | esmail-mkh/PhotoSlicer | engine/sorting.py | .py | 910dca94c0cc451e | 7.6 | 15 |
#!/usr/bin/env python
"""
Update docstrings in stub files.
Copyright 2024 Vlad Emelianov
"""
import argparse
import datetime
import logging
from dataclasses import dataclass
from pathlib import Path
AUTHOR_NAME = "Vlad Emelianov"
YEAR = datetime.datetime.now().year
LOGGER_NAME = "docstrings"
def print_path(path: P... | youtype/types-boto3 | scripts/update_dosctrings.py | .py | c12237ec986f6208 | 7.42 | 6 |
import re
def extract_tvg_ids(m3u_path):
"""
Extrai todos os `tvg-id` de um arquivo .m3u.
"""
with open(m3u_path, 'r', encoding='utf-8') as m3u_file:
m3u_content = m3u_file.read()
# Usando regex para capturar os tvg-id no formato tvg-id="..."
tvg_ids = re.findall(r'tvg-id="([^"]+)"', m3... | thomraider12/canaistvpt | EPG/scripts/validar-ids-m3u.py | .py | d19294c9be58a787 | 7.5 | 9 |
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2025-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import logging
import sys
from typing import TYPE_CHECKING
from syncmaster.worker.ivy2 import get_excluded_packages, get_packages
if TYPE_CHECKING:
from pyspark.sql imp... | MTSWebServices/syncmaster | docker/download_ivy2_packages.py | .py | 36958c6741131984 | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
import asyncio
from logging.config import fileConfig
from pathlib import Path
from alembic import context
from alembic.script import ScriptDirectory
from celery.backends.database.session import ResultModelBase
from pydantic import Fi... | MTSWebServices/syncmaster | syncmaster/db/migrations/env.py | .py | 51c8a5052a0afef2 | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Create user table
Revision ID: 0001
Revises:
Create Date: 2023-11-23 11:35:18.193060
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "0001"
down_revision = None
branch_label... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2023-11-23_0001_create_user_table.py | .py | 964d9b3ed0474397 | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Create group table
Revision ID: 0002
Revises: 0001
Create Date: 2023-11-23 11:36:00.000000
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
re... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2023-11-23_0002_create_group_table.py | .py | 1fef3dc1518103cd | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Create queue table
Revision ID: 0003
Revises: 0002
Create Date: 2023-11-23 11:37:00.000000
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
re... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2023-11-23_0003_create_queue_table.py | .py | cda6862306ddac9e | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Create connection table
Revision ID: 0004
Revises: 0003
Create Date: 2023-11-23 11:38:00.000000
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembi... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2023-11-23_0004_create_connection_table.py | .py | 2c0c341c3718ff67 | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Create user_group table
Revision ID: 0005
Revises: 0004
Create Date: 2023-11-23 11:39:00.000000
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "0005"
down_revision = "0004"... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2023-11-23_0005_create_user_group_table.py | .py | 484c760a01888729 | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Create auth_data table
Revision ID: 0006
Revises: 0005
Create Date: 2023-11-23 11:40:00.000000
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "0006"
down_revision = "0005"
... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2023-11-23_0006_create_auth_data_table.py | .py | 4da348536ad9ccaf | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Create transfer table
Revision ID: 0007
Revises: 0006
Create Date: 2023-11-23 11:41:00.000000
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2023-11-23_0007_create_transfer_table.py | .py | e74de70a9c3d1a57 | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Create run table
Revision ID: 0008
Revises: 0007
Create Date: 2023-11-23 11:42:00.000000
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "0008"
down_revision = "0007"
branch... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2023-11-23_0008_create_run_table.py | .py | 7949c730fdf2e126 | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Create celery_taskmeta and celery_tasksetmeta tables
Revision ID: 0009
Revises: 0008
Create Date: 2023-11-23 11:43:00.000000
"""
import sqlalchemy as sa
from alembic import op
revision = "0009"
down_revision = "0008"
branch_labe... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2023-11-23_0009_create_celery_tables.py | .py | 06ecf55f0ac75388 | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Add pg_trgm extension to apply fuzzy search
Revision ID: 0010
Revises: 0009
Create Date: 2024-10-07 06:59:12.667067
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "0010"
down_revision = "0009"
br... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2024-10-07_0010_add_pg_trgm_extension.py | .py | 4c870555c4e3117c | 7.56 | 12 |
# SPDX-FileCopyrightText: 2023-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Create apscheduler table
Revision ID: 0011
Revises: 0010
Create Date: 2024-11-01 08:37:47.078657
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "0011"
down_revision = "001... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2024-11-01_0011_create_apscheduler_table.py | .py | d689ce30d46a1be5 | 7.56 | 12 |
# SPDX-FileCopyrightText: 2025-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
"""Add celery_*_date_done indexex
Revision ID: 0013
Revises: 0012
Create Date: 2026-04-02 11:06:44.293882
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "0013"
down_revision = "0012"
branch_labels =... | MTSWebServices/syncmaster | syncmaster/db/migrations/versions/2026-04-02_0013_add_celery_date_done_indexes.py | .py | ff8e007cefe8fd3f | 7.56 | 12 |
# SPDX-FileCopyrightText: 2025-present MTS PJSC
# SPDX-License-Identifier: Apache-2.0
from collections.abc import Sequence
from enum import IntFlag
from string import punctuation
from sqlalchemy import ColumnElement, func
from sqlalchemy.orm import InstrumentedAttribute
# left some punctuation to match file paths, UR... | MTSWebServices/syncmaster | syncmaster/db/repositories/search.py | .py | 482158a30032c854 | 7.56 | 12 |
#!/usr/bin/env python3
"""Convert a FLOW geometry HDF5 file to SPINE geometry YAML.
Example usage:
python3 bin/geo/parse_flow_geometry.py --source geometry.hdf5 \
--output geometry.yaml --opdet-thickness 1.0 --tag cr3
"""
from __future__ import annotations
import argparse
import re
from typing import Any... | DeepLearnPhysics/spine | bin/geo/parse_flow_geometry.py | .py | 8d384f9bda971eea | 7.5 | 9 |
#!/usr/bin/env python3
"""Mark all bad LArCV ROOT files before merging them with hadd."""
from __future__ import annotations
import argparse
from collections.abc import Sequence
import numpy as np
from larcv import larcv # pylint: disable=W0611
from ROOT import TFile # pylint: disable=E0611
from tqdm import tqdm
f... | DeepLearnPhysics/spine | bin/larcv/larcv_check_valid.py | .py | bf19bda67aaf161e | 7.5 | 9 |
#!/usr/bin/env python3
"""Counts the number of events in a LArCV dataset."""
from __future__ import annotations
import argparse
from collections.abc import Sequence
from larcv import larcv # pylint: disable=W0611
from ROOT import TFile # pylint: disable=E0611
from tqdm import tqdm
from utils import get_tree, get_t... | DeepLearnPhysics/spine | bin/larcv/larcv_count_entries.py | .py | 925bba762d16af38 | 7.5 | 9 |
#!/usr/bin/env python3
"""Finds duplicated files."""
from __future__ import annotations
import argparse
from collections.abc import Sequence
import numpy as np
from larcv import larcv # pylint: disable=W0611
from ROOT import TFile # pylint: disable=E0611
from tqdm import tqdm
from utils import get_branch_key, get_... | DeepLearnPhysics/spine | bin/larcv/larcv_find_duplicates.py | .py | a8fe94d1d8796dd4 | 7.5 | 9 |
#!/usr/bin/env python3
"""Builds a list of file which make a data run."""
from __future__ import annotations
import argparse
from collections.abc import Sequence
from larcv import larcv # pylint: disable=W0611
from ROOT import TFile # pylint: disable=E0611
from tqdm import tqdm
from utils import get_branch_key, ge... | DeepLearnPhysics/spine | bin/larcv/larcv_find_run.py | .py | cc748ead927cc2d9 | 7.5 | 9 |
#!/usr/bin/env python3
"""Inject run numbers into every event and product in LArCV ROOT files."""
from __future__ import annotations
import argparse
import os
import tempfile
from collections.abc import Sequence
from typing import Any
from larcv import larcv # pylint: disable=W0611
from tqdm import tqdm
from utils ... | DeepLearnPhysics/spine | bin/larcv/larcv_inject_run_number.py | .py | b8db07fea9821007 | 7.5 | 9 |
#!/usr/bin/env python3
"""Counts the number of events in a LArCV dataset."""
from __future__ import annotations
import argparse
from collections.abc import Sequence
from pathlib import Path
from larcv import larcv # pylint: disable=W0611
from ROOT import TFile # pylint: disable=E0611
from tqdm import tqdm
from uti... | DeepLearnPhysics/spine | bin/larcv/larcv_tree_sizes.py | .py | f70da6cb90680f06 | 7.5 | 9 |
#!/usr/bin/env python3
"""Validate SPINE outputs against the list of source input files.
The script checks that each expected output file exists and then verifies that
the output is complete.
For modern HDF5 outputs, completeness is determined primarily from explicit
writer metadata:
- ``info.attrs["complete"]`` whe... | DeepLearnPhysics/spine | bin/output/output_check_valid.py | .py | 705ca0fe711705db | 7.5 | 9 |
#!/usr/bin/env python3
"""Create a compact output directly from a V2 SPINE HDF5 file."""
from __future__ import annotations
import argparse
from collections.abc import Sequence
from typing import Any
import yaml
from spine.io.transform import DEFAULT_LITE_KEYS, litify_hdf5
def load_keys(config_path: str) -> list[... | DeepLearnPhysics/spine | bin/output/output_litify.py | .py | e7b295519b0614e1 | 7.5 | 9 |
"""Sphinx directive for readable, source-driven dataclass API pages."""
from __future__ import annotations
import inspect
import math
import pydoc
from collections import OrderedDict
from dataclasses import MISSING, Field, fields, is_dataclass
from types import NoneType, UnionType
from typing import Any, get_args, ge... | DeepLearnPhysics/spine | docs/source/_ext/spine_dataclass.py | .py | a3b79cd16916c2c1 | 7.5 | 9 |
"""MCS angular resolution calibration module.
This module uses high energy muon tracks to evaluate the base angular resolution
of the tracks as a basis to correct the scattering angle spread in the MCS-based
KE estimation used in SPINE.
"""
from collections.abc import Mapping, Sequence
from functools import partial
f... | DeepLearnPhysics/spine | src/spine/ana/calib/mcs.py | .py | 557fe24ed92d9b2f | 7.5 | 9 |
"""Diagnostic analysis tools for graph clustering edge lengths.
This script evaluates the expected length between fragments/particles that
belong to the same group (particle or interaction groups) in order to optimize
the edge length.
"""
from __future__ import annotations
from collections.abc import Mapping, Sequen... | DeepLearnPhysics/spine | src/spine/ana/diag/graph.py | .py | 0915ae2df92981bf | 7.5 | 9 |
"""Diagnostic analysis of reconstructed space-point completeness."""
from __future__ import annotations
from collections.abc import Mapping, Sequence
from typing import Any
import numpy as np
from scipy.spatial import cKDTree
from spine.ana.base import AnaBase
__all__ = ["PointCompletenessAna"]
class PointComple... | DeepLearnPhysics/spine | src/spine/ana/diag/point.py | .py | 4de78ebb585b431c | 7.5 | 9 |
"""Module to evaluate diagnostic metrics on showers."""
from __future__ import annotations
from collections.abc import Mapping, Sequence
from typing import Any
import numpy as np
from spine.ana.base import AnaBase
from spine.cluster.direction import cluster_dedx, cluster_dedx_dir
from spine.constants import SHOWR_S... | DeepLearnPhysics/spine | src/spine/ana/diag/shower.py | .py | ee3f565730d436dc | 7.5 | 9 |
"""Module to evaluate diagnostic metrics on tracks."""
from __future__ import annotations
from collections.abc import Mapping, Sequence
from typing import Any
import numpy as np
from numpy.typing import NDArray
from spine.ana.base import AnaBase
from spine.constants import MUON_PID, TRACK_SHP
from spine.math.distan... | DeepLearnPhysics/spine | src/spine/ana/diag/track.py | .py | 3962d3781a815a5a | 7.5 | 9 |
"""Manages the operation of analysis scripts."""
from __future__ import annotations
from collections import OrderedDict
from collections.abc import Mapping
from typing import Any
from spine.config.factory import parse_module_config
from spine.utils.manager import ModuleManager
from spine.utils.stopwatch import Stopw... | DeepLearnPhysics/spine | src/spine/ana/manager.py | .py | 4047ae3adce1c456 | 7.5 | 9 |
"""Analysis script used to evaluate the clustering accuracy."""
from __future__ import annotations
from collections.abc import Callable, Mapping, Sequence
from typing import Any
import numpy as np
from numpy.typing import NDArray
import spine.math.metrics
from spine.ana.base import AnaBase
from spine.constants impo... | DeepLearnPhysics/spine | src/spine/ana/metric/cluster.py | .py | 00eff29e3e049f90 | 7.5 | 9 |
"""Analysis script used to evaluate optical flash matching."""
from __future__ import annotations
from collections.abc import Mapping, Sequence
from typing import Any
from spine.ana.base import AnaBase
from spine.data.out import RecoInteraction, TruthInteraction
__all__ = ["FlashMatchingAna"]
class FlashMatchingA... | DeepLearnPhysics/spine | src/spine/ana/metric/optical.py | .py | ec8c4a2af934d4d4 | 7.5 | 9 |
"""Analysis script used to evaluate the point proposal accuracy."""
from __future__ import annotations
from collections.abc import Mapping
from typing import Any
import numpy as np
from scipy.spatial.distance import cdist
from spine.ana.base import AnaBase
from spine.constants import LOWES_SHP
__all__ = ["PointPro... | DeepLearnPhysics/spine | src/spine/ana/metric/point.py | .py | 28e9c6b54a6968ad | 7.5 | 9 |
"""Analysis script used to evaluate the semantic segmentation accuracy."""
from __future__ import annotations
from collections.abc import Mapping
from typing import Any
import numpy as np
from scipy.special import softmax
from spine.ana.base import AnaBase
from spine.constants import GHOST_SHP, LOWES_SHP
__all__ =... | DeepLearnPhysics/spine | src/spine/ana/metric/segment.py | .py | ea21c358785fff07 | 7.5 | 9 |
"""Analysis script used to store the reconstruction output to CSV files."""
from __future__ import annotations
from collections.abc import Mapping, Sequence
from typing import Any
import numpy as np
from spine.ana.base import AnaBase
from spine.data.out import (
RecoFragment,
RecoInteraction,
RecoPartic... | DeepLearnPhysics/spine | src/spine/ana/script/save.py | .py | 861232464033a902 | 7.5 | 9 |
"""Analysis module template.
Use this template as a basis to build your own analysis script. An analysis
script takes the output of the reconstruction and the post-processors and
performs basic selection cuts and stores the output to a CSV file.
"""
from __future__ import annotations
from collections.abc import Mapp... | DeepLearnPhysics/spine | src/spine/ana/template.py | .py | e44b7ae07cb2c36e | 7.5 | 9 |
"""Command line tools for inspecting resolved SPINE configurations."""
import argparse
import difflib
import sys
from typing import TextIO
import yaml
from spine.config import load_config_file
from spine.config.loader import DownloadTag
def represent_download(dumper: yaml.SafeDumper, value: DownloadTag) -> yaml.No... | DeepLearnPhysics/spine | src/spine/bin/config.py | .py | ab14bdf88fb457b6 | 7.5 | 9 |
"""Constants used in calibration modules."""
from __future__ import annotations
from typing import Protocol, TypeAlias, cast
import numpy as np
from numpy.typing import NDArray
from .database import CalibrationDatabase
CalibValue: TypeAlias = float | list[float] | tuple[float, ...] | NDArray[np.floating]
CalibData... | DeepLearnPhysics/spine | src/spine/calib/constant.py | .py | 78d48bae41c9d869 | 7.5 | 9 |
"""SQLite calibration database parsing."""
from __future__ import annotations
import sqlite3 as sql
from pathlib import Path
from typing import Any, TypeAlias, cast
import numpy as np
import pandas as pd
from numpy.typing import NDArray
FloatArray: TypeAlias = NDArray[np.floating]
IntArray: TypeAlias = NDArray[np.i... | DeepLearnPhysics/spine | src/spine/calib/database.py | .py | 4f77c6565700bf52 | 7.5 | 9 |
"""Applies field non-uniformity corrections."""
from __future__ import annotations
from collections.abc import Sequence
from pathlib import Path
from typing import TYPE_CHECKING, TypeAlias, cast
import numpy as np
from numpy.typing import NDArray
from spine.geo import GeoManager, Geometry
from spine.utils.condition... | DeepLearnPhysics/spine | src/spine/calib/field.py | .py | 3e2b7c05096e139b | 7.5 | 9 |
"""Functions used in calibration modules."""
from __future__ import annotations
import numexpr as ne
import numpy as np
from numpy.typing import NDArray
class CalibrationFunction:
"""Handles calibration functions evaluated on charge arrays."""
def __init__(self, expression: str, variable: str = "x") -> Non... | DeepLearnPhysics/spine | src/spine/calib/function.py | .py | 5c6c036c1ac6bb97 | 7.5 | 9 |
"""Applies conversion form ADC to number ionization electrons."""
from __future__ import annotations
from typing import TypeAlias
import numpy as np
from numpy.typing import NDArray
from .constant import CalibrationConstant
__all__ = ["GainCalibrator"]
CalibValue: TypeAlias = float | list[float] | tuple[float, ..... | DeepLearnPhysics/spine | src/spine/calib/gain.py | .py | 41bcb4f246b2bbde | 7.5 | 9 |
"""Apply electron lifetime corrections."""
from __future__ import annotations
from typing import TypeAlias
import numpy as np
from numpy.typing import NDArray
from spine.geo.base import Geometry
from .constant import CalibrationConstant
__all__ = ["LifetimeCalibrator"]
CalibValue: TypeAlias = float | list[float]... | DeepLearnPhysics/spine | src/spine/calib/lifetime.py | .py | f09219b0cfdd479c | 7.5 | 9 |
"""Add the OPERA DSWX S1 water-classification layer from OPERA.ipynb to datasets.tsv."""
import time
import ee
import pandas as pd
from geemap.ee_tile_layers import _get_tile_url_format, _validate_palette
from auto_update import ensure_uid_column, initialize_earth_engine, make_uid
DATASETS_PATH = "datasets.tsv"
DA... | opengeos/ee-tile-layers | add_opera_dswx.py | .py | d36a9b8129a24e9b | 7.48 | 8 |
import json
import os
import time
import ee
import pandas as pd
from geemap.ee_tile_layers import _get_tile_url_format, _validate_palette
def _get_service_account_credentials():
"""Create Earth Engine credentials from the EE_SERVICE_ACCOUNT environment variable.
Returns:
A tuple containing service a... | opengeos/ee-tile-layers | auto_update.py | .py | 62d32b2dc737276d | 7.48 | 8 |
"""
FHIRcraft Global Configuration
"""
import dataclasses
import os
from contextlib import contextmanager
from contextvars import ContextVar
from dataclasses import dataclass, field
from typing import Sequence, FrozenSet, Generator, Literal
from fhircraft.fhir.terminology import TerminologyService
__all__ = [
"F... | luisfabib/fhircraft | fhircraft/config.py | .py | 52f23cebea7a74cc | 7.52 | 10 |
from abc import ABC, abstractmethod
from fhircraft.fhir.mapper.engine.scope import MappingScope
from typing import Any
import re
from fhircraft.fhir.path import FHIRPath, parse_fhirpath
class FHIRMappingEngineComponent(ABC):
"""Base class for components of the FHIR Mapper Engine."""
fhirpath_engine = None
... | luisfabib/fhircraft | fhircraft/fhir/mapper/engine/abstract.py | .py | daf170f956a6fc31 | 7.52 | 10 |
from typing import TYPE_CHECKING, List, Optional, Sequence
from fhircraft.fhir.mapper.engine.abstract import FHIRMappingEngineComponent
from fhircraft.exceptions import (
MapperDigestionError,
MapperGroupProcessingError,
MapperScopeError,
)
import logging
from fhircraft.fhir.path.engine.core import FHIRPat... | luisfabib/fhircraft | fhircraft/fhir/mapper/engine/group.py | .py | 0976a74324e4e890 | 7.52 | 10 |
from typing import TYPE_CHECKING, List
from fhircraft.fhir.mapper.engine.abstract import FHIRMappingEngineComponent
from fhircraft.exceptions import (
MapperRuleProcessingError,
MapperExecutionError,
MapperSourceProcessingError,
MapperDigestionError,
)
from fhircraft.fhir.mapper.engine import transforms... | luisfabib/fhircraft | fhircraft/fhir/mapper/engine/rule.py | .py | 201a5faf4eba5d87 | 7.52 | 10 |
from typing import TYPE_CHECKING, Optional
from fhircraft.fhir.mapper.engine.abstract import FHIRMappingEngineComponent
from fhircraft.exceptions import (
MapperDigestionError,
MapperException,
MapperExecutionError,
MapperSourceProcessingError,
)
from fhircraft.fhir.path import engine as fhirpath
import... | luisfabib/fhircraft | fhircraft/fhir/mapper/engine/source.py | .py | 401c19146e8c762d | 7.52 | 10 |
from typing import TYPE_CHECKING, Optional
from fhircraft.fhir.mapper.engine.abstract import FHIRMappingEngineComponent
from fhircraft.exceptions import (
MapperDigestionError,
MapperException,
MapperExecutionError,
MapperTargetProcessingError,
)
from fhircraft.fhir.mapper.engine import transforms as tf... | luisfabib/fhircraft | fhircraft/fhir/mapper/engine/target.py | .py | 2bb7666d3c91f02c | 7.52 | 10 |
"""
FHIRPath supports a general-purpose aggregate function to enable the calculation of aggregates such as sum, min, and max to be expressed
"""
__all__ = [
"Aggregate",
]
from typing import Any
from fhircraft.fhir.path.engine.core import (
FHIRPath,
FHIRPathCollection,
FHIRPathCollectionItem,
FHI... | luisfabib/fhircraft | fhircraft/fhir/path/engine/aggregates.py | .py | 5e01ecc22edbaab3 | 7.52 | 10 |
"""The tree navigation module contains the object representations of the tree-navigation category FHIRPath functions."""
__all__ = [
"Children",
"Descendants",
]
from pydantic import BaseModel
from fhircraft.fhir.path.engine.core import (
Element,
FHIRPathCollection,
FHIRPathFunction,
)
from fhir... | luisfabib/fhircraft | fhircraft/fhir/path/engine/navigation.py | .py | 67adfecd16ea78ea | 7.52 | 10 |
"""
FHIRPath utility functions for parsing, evaluating, and handling FHIRPath
expressions and collections.
"""
import re
import threading
from typing import Any, Dict, Union, TYPE_CHECKING
from fhircraft.fhir.path.engine.core import FHIRPathCollectionItem, FHIRPath, Literal
from fhircraft.utils import ensure_list
fro... | luisfabib/fhircraft | fhircraft/fhir/path/utils.py | .py | 16835c48891607f7 | 7.52 | 10 |
"""
Parent-context tracking mixin for FHIRBaseModel.
Provides the _parent / _index attributes and the lazy properties that
walk up the parent chain to locate containing resources.
"""
from typing import Any, Union
class FHIRContextMixin:
"""
Mixin that provides hierarchical parent-context tracking.
Eve... | luisfabib/fhircraft | fhircraft/fhir/resources/base/mixins/context.py | .py | 4306dc137364c69f | 7.52 | 10 |
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "black",
# "PyYAML",
# "typing-extensions>=4.5.0",
# ]
# ///
# Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this... | ansys/pyansys-units | scripts/generate_variable_descriptor.py | .py | dbaa4a4c7cfc6090 | 7.42 | 6 |
# Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limita... | ansys/pyansys-units | src/ansys/units/_constants.py | .py | a417619351882135 | 7.42 | 6 |
# Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limita... | ansys/pyansys-units | src/ansys/units/_unit_parsing.py | .py | daca8ea4fde47b49 | 7.42 | 6 |
# Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limita... | ansys/pyansys-units | src/ansys/units/dimensions.py | .py | e870fd19dcde91fd | 7.42 | 6 |
# Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limit... | ansys/pyansys-units | src/ansys/units/quantity_dimensions.py | .py | 50318976174446ee | 7.42 | 6 |
# Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limita... | ansys/pyansys-units | src/ansys/units/unit_registry.py | .py | 3299399cd1a87ec3 | 7.42 | 6 |
# pyright: reportUnannotatedClassAttribute=false
# Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Soft... | ansys/pyansys-units | src/ansys/units/variable_descriptor/variable_descriptor.py | .py | 87301d51d5d28d65 | 7.42 | 6 |
# Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limita... | ansys/pyansys-units | tests/test_aliases.py | .py | e0cad6d7dd0297ae | 7.92 | 6 |
# Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limita... | ansys/pyansys-units | tests/test_pandas_extension.py | .py | 6360a683ff9104c2 | 7.92 | 6 |
import rasterio
import numpy as np
import logging
import json
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def get_tif_stats(
tif: str,
stats_dict: dict = {},
stat_prefix: str = "",
mask=False,
verbose: bool = False,
) -> dict:
"""
Calculate basic statistic... | GeoscienceAustralia/sar-pipeline | sar_pipeline/analysis/compare_cog.py | .py | eea197ff07d71fc2 | 7.45 | 7 |
from pathlib import Path
import pandas as pd
import json
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def check_exact_files(folder_1: Path, folder_2: Path) -> bool:
"""
Check if two folders contain exactly the same files (recursively).
Parameters
-----... | GeoscienceAustralia/sar-pipeline | sar_pipeline/analysis/compare_folder.py | .py | 9df7792d4dc5e3e0 | 7.45 | 7 |
import json
import os
import xml.etree.ElementTree as ET
import os
def load_json_if_path(obj):
"""If obj is a string path to a file, load it as JSON, else return it unchanged."""
if isinstance(obj, str) and os.path.isfile(obj):
with open(obj, "r") as f:
return json.load(f)
return obj
... | GeoscienceAustralia/sar-pipeline | sar_pipeline/analysis/compare_metadata.py | .py | e005b3f7344a35f6 | 7.45 | 7 |
import h5py
from pathlib import Path
import numpy as np
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class H5Manager:
def __init__(self, file_path: str | Path, mode: str = "r"):
"""Initialize the manager with a specified HDF5 file.
Parameters
... | GeoscienceAustralia/sar-pipeline | sar_pipeline/pipelines/isce3_rtc/metadata/h5.py | .py | 6609b8432de91716 | 7.45 | 7 |
from pathlib import Path
from datetime import datetime, timezone
import json
import pandas as pd
from sar_pipeline.pipelines.isce3_rtc.metadata.h5 import H5Manager
import xml.etree.ElementTree as ET
import copy
import pyproj
import shapely
from typing import Literal
CURRENT_DIR = Path(__file__).parent.resolve()
XML_TE... | GeoscienceAustralia/sar-pipeline | sar_pipeline/pipelines/isce3_rtc/metadata/xml.py | .py | 3a67e6635748b94c | 7.45 | 7 |
import os
from ruamel.yaml import YAML
from pathlib import Path
import logging
import typing
from typing import Literal
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
BaseConfigType = Literal["S1_RTC_IW.yaml", "S1_RTC_STATIC_IW.yaml"]
VALID_BASE_CONFIGS = typing.get_args(BaseConfigType)
... | GeoscienceAustralia/sar-pipeline | sar_pipeline/pipelines/isce3_rtc/utils/config_manager.py | .py | 36b4f0cd10c3ec48 | 7.45 | 7 |
import click
import logging
from pathlib import Path
from pyroSAR import identify
from pyroSAR.gamma import geocode
from pyroSAR.gamma.dem import dem_import
import shutil
import sys
import tarfile
import zipfile
from sar_pipeline.preparation.etad import apply_etad_correction
from sar_pipeline.utils.gamma import set_ga... | GeoscienceAustralia/sar-pipeline | sar_pipeline/pipelines/pyrosar_gamma/processing/pyroSAR/pyrosar_geocode.py | .py | 37a5e67987b7efce | 7.45 | 7 |
from datetime import datetime, timedelta
import logging
from pathlib import Path
import requests
from typing import Any
import zipfile
from s1etad_tools.cli.slc_correct import s1etad_slc_correct_main
from sar_pipeline.utils.sentinel1 import get_dates_from_scene_id
logger = logging.getLogger(__name__)
def parse_eta... | GeoscienceAustralia/sar-pipeline | sar_pipeline/preparation/etad.py | .py | 1b4cd9fbdd1a2b4b | 7.45 | 7 |
from datetime import datetime
from pathlib import Path
import re
from typing import TypedDict, Optional, Union
import logging
import os
from sar_pipeline.utils.sentinel1 import (
get_dates_from_scene_id,
extract_metadata_from_s1_id,
)
from sar_pipeline.preparation.downloads.orbits import (
query_orbit_from... | GeoscienceAustralia/sar-pipeline | sar_pipeline/preparation/nci/orbits.py | .py | 417ab982ef9f13f5 | 7.45 | 7 |
import logging
import os
from pathlib import Path
from typing import Union, Optional
from sar_pipeline.utils.sentinel1 import (
get_product_type_from_scene_id,
get_dates_from_scene_id,
)
from sar_pipeline.preparation.downloads.scenes import (
query_scene_from_aus_cop_hub,
NonSingleSceneResultError,
... | GeoscienceAustralia/sar-pipeline | sar_pipeline/preparation/nci/scenes.py | .py | 32402ff674aa3b45 | 7.45 | 7 |
import os
import boto3
import logging
from botocore import UNSIGNED
from botocore.config import Config
from botocore.exceptions import ClientError
import logging
import mimetypes
from pathlib import Path
from datetime import datetime, timezone, timedelta
from subprocess import run
from dotenv import load_dotenv
loggin... | GeoscienceAustralia/sar-pipeline | sar_pipeline/utils/aws.py | .py | 9bdea400005bcd83 | 7.45 | 7 |
# checksum script based on
# https://github.com/opendatacube/eo-datasets/blob/eodatasets3-1.9.3/eodatasets3/verify.py
import binascii
import hashlib
import logging
import os
import typing
from pathlib import Path
from shutil import which
from urllib.parse import urlparse
import boto3
_LOG = logging.getLogger(__name_... | GeoscienceAustralia/sar-pipeline | sar_pipeline/utils/checksum.py | .py | 418571c694d99a3d | 7.45 | 7 |
from dotenv import load_dotenv
import os
import logging
from pathlib import Path
from typing import Union
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)
logger = logging.getLogger(__name__)
class MissingEnvironmentVariableError(Exception):
"""Exce... | GeoscienceAustralia/sar-pipeline | sar_pipeline/utils/environment_variables.py | .py | 30d83d7041698352 | 7.45 | 7 |
import time
import logging
from functools import wraps
from datetime import datetime
import re
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def log_timing(func):
"""
Decorator that logs the execution time of a function.
Parameters
----------
func : callable
... | GeoscienceAustralia/sar-pipeline | sar_pipeline/utils/general.py | .py | f114886ce3f88eb2 | 7.45 | 7 |
from osgeo import gdal
from pathlib import Path
import typing
GdalWarpResampleAlgType = typing.Literal[
"near",
"bilinear",
"cubic",
"cubicspline",
"lanczos",
"average",
"rms",
"mode",
"min",
"max",
"med",
"q1",
"q3",
"sum",
]
GDAL_WARP_RESAMPLE_ALGORITHMS: tuple... | GeoscienceAustralia/sar-pipeline | sar_pipeline/utils/post_processing.py | .py | 20726ccc3f5bc45d | 7.45 | 7 |
import pyproj
from pyproj import Transformer
from shapely import wkt
from shapely.geometry import mapping, box, Polygon, shape, MultiPolygon
from shapely import segmentize
from shapely.ops import unary_union, orient
import geopandas as gpd
import numpy as np
import rasterio
from rasterio.features import shapes
import j... | GeoscienceAustralia/sar-pipeline | sar_pipeline/utils/spatial.py | .py | f5eb289072c3288b | 7.45 | 7 |
from datetime import datetime
import pystac_client
from odc.stac import configure_s3_access
from shapely.geometry import Polygon, MultiPolygon
from pystac import Link, Item
from pystac.stac_io import DefaultStacIO
from typing import Union, Any
from urllib.parse import urlparse
import boto3
import tqdm
import tempfile
i... | GeoscienceAustralia/sar-pipeline | sar_pipeline/utils/stac.py | .py | 738cf7da77b179cc | 7.45 | 7 |
"""Benchmark job for Flyte Volumes.
Measures the metrics surfaced in the Volumes user guide so they can be
reproduced (and re-measured) per environment — object store, region, and
instance type all affect the results, so there is no single "right" number.
What it measures
----------------
1. **Mount time vs. number o... | unionai/unionai-docs | benchmarks/volume_benchmark.py | .py | feeb2c63ad600779 | 7.42 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.