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 |
|---|---|---|---|---|---|---|
"""
Script of extracting and calculating community level drought tolerance from the source data (.pickle)
"""
import glob
import os
import pickle
import sys
import pandas as pd
# define a function of extracting data from files in .pickle
def get_pickled_data(key):
"""
Derive a list of data files to be extra... | DEMENT-Model/DEMENTpy | SPA/scripts/drought_trait.py | .py | ae1dec809ed91dc7 | 7.62 | 16 |
"""
Script of extracting and calculating community level enzynme investment from the source data (.pickle)
"""
import glob
import os
import pickle
import sys
import pandas as pd
# define a function of extracting data from files in .pickle
def get_pickled_data(key):
"""
Derive a list of data files to be extr... | DEMENT-Model/DEMENTpy | SPA/scripts/enzyme_trait.py | .py | 2916aa84943305ec | 7.62 | 16 |
# output.py module dealing with outputs of DEMENTpy.
# Bin Wang, January, 2020
import numpy as np
import pandas as pd
class Output:
"""
This class deals with outputs.
Accepts data derived from the initialization.py and grid.py modules, and have two methods:
output(): stores all time ... | DEMENT-Model/DEMENTpy | SPA/scripts/output.py | .py | a058c8b12a11a8ff | 7.62 | 16 |
# This module, enzyme.py, deals with exclusively only enzyme-related parameters, holding:
# ............Enzyme(): class
# ............Arrhenius(): function
# ............Allison(): function
# Bin Wang in Janunary, 2020
import numpy as np
import pandas as pd
from utility import LHS
class Enzyme:
"""
Thi... | DEMENT-Model/DEMENTpy | src/enzyme.py | .py | 48ccd08e692631c5 | 7.62 | 16 |
"""
This module, with only one function "initialized_data(), initializes data related to
substrate, monomer, enzyme, and microbe, as well as their distribution on the spatial grid,
preceding the actual decompostion-related computations.
"""
import numbers
# import xarray as xr
import warnings
from pathlib import Path... | DEMENT-Model/DEMENTpy | src/initialization.py | .py | ae4a3167e0c22de9 | 7.62 | 16 |
"""
This module, utility.py, contains three functions facilitating the calculation.
1) LHS(): perform 1-D latin hypercube sampling
2) expand(): put a community on the spatial grid
3 random_assignment(): randomly assign different members in a pool to an individual
3) export(): ... | DEMENT-Model/DEMENTpy | src/utility.py | .py | 736b6ca0c38156a0 | 7.62 | 16 |
"""Tests for the Grid class."""
import pandas as pd
import pytest
from grid import Grid
from initialization import initialize_data
@pytest.fixture
def grid():
"""Initialize a Grid object using the initialize_data function."""
input_dir = "grassland"
runtime = pd.read_csv(
input_dir + "/runtime.t... | DEMENT-Model/DEMENTpy | tests/unit/test_grid.py | .py | 9e6b2759ae5bc045 | 8.12 | 16 |
"""Tests to show how to use pytest."""
import numpy as np
import pytest
def test_basic():
"""Illustrates how to write a simple test."""
assert 1 + 1 == 2
def test_raises_exception():
"""Illustrates how to write a test that checks for an exception."""
with pytest.raises(ZeroDivisionError):
1... | DEMENT-Model/DEMENTpy | tests/unit/test_placeholder.py | .py | 74a8c7d2121d9ad6 | 8.12 | 16 |
"""Export data in the format expected by the Delphi API."""
# -*- coding: utf-8 -*-
import logging
from datetime import datetime
from os.path import getsize, join
from typing import Optional
import numpy as np
import pandas as pd
from epiweeks import Week
from .nancodes import Nans
def filter_contradicting_missing_... | cmu-delphi/covidcast-indicators | _delphi_utils_python/delphi_utils/export.py | .py | adf741dc1fec771b | 7.56 | 12 |
"""Unified not-a-number codes for CMU Delphi codebase."""
from enum import IntEnum
import pandas as pd
class Nans(IntEnum):
"""An enum of not-a-number codes for the indicators.
See the descriptions here: https://cmu-delphi.github.io/delphi-epidata/api/missing_codes.html
"""
NOT_MISSING = 0
NOT_... | cmu-delphi/covidcast-indicators | _delphi_utils_python/delphi_utils/nancodes.py | .py | 725cac13eda06b57 | 7.56 | 12 |
"""Slack notifier for use in Delphi indicators."""
from slack import WebClient
class SlackNotifier:
"""Notifies slack channels of messages."""
def __init__(self, slack_channel, slack_token):
"""Initialize with a slack channel and token."""
self.slack_channel = slack_channel
self.client... | cmu-delphi/covidcast-indicators | _delphi_utils_python/delphi_utils/slack_notifier.py | .py | b91037ed74826e8a | 7.56 | 12 |
"""Read parameter files containing configuration information."""
# -*- coding: utf-8 -*-
from json import load,dump
from shutil import copyfile, move
import os
import sys
def read_params():
"""Read a file named 'params.json' in the current working directory.
If the file does not exist, it copies the file 'par... | cmu-delphi/covidcast-indicators | _delphi_utils_python/delphi_utils/utils.py | .py | 5c791bef31b9c318 | 7.56 | 12 |
"""Validation output reports."""
import sys
from typing import List
from ..logger import get_structured_logger
from .errors import ValidationFailure
class ValidationReport:
"""Class for reporting the results of validation."""
# pylint: disable=R0902
def __init__(self, errors_to_suppress: List[ValidationFa... | cmu-delphi/covidcast-indicators | _delphi_utils_python/delphi_utils/validator/report.py | .py | bcff8b0aae22622c | 7.56 | 12 |
# -*- coding: utf-8 -*-
"""Functions to call when running the tool.
This module should contain a function called `run_module`, that is executed
when the module is run with `python -m delphi_utils.validator`.
"""
import argparse as ap
import covidcast
from .. import read_params, get_structured_logger
from .validate imp... | cmu-delphi/covidcast-indicators | _delphi_utils_python/delphi_utils/validator/run.py | .py | 597a878802653667 | 7.56 | 12 |
"""Utility functions for validation."""
from dataclasses import dataclass, field
from datetime import date, datetime, timedelta
from typing import List
import pandas as pd
# Recognized geo types.
GEO_REGEX_DICT = {
'county': r'^\d{5}$',
'hrr': r'^\d{1,3}$',
'hhs': r'^\d{1,2}$',
'msa': r'^\d{5}$',
'... | cmu-delphi/covidcast-indicators | _delphi_utils_python/delphi_utils/validator/utils.py | .py | 2643e9d55ae6511c | 7.56 | 12 |
"""
Weekday effects (code from Aaron Rumack).
Created: 2020-05-06
"""
import cvxpy as cp
import numpy as np
from cvxpy.error import SolverError
class Weekday:
"""Class to handle weekday effects."""
@staticmethod
def get_params(data, denominator_col, numerator_cols, date_col, scales, logger, solver_overr... | cmu-delphi/covidcast-indicators | _delphi_utils_python/delphi_utils/weekday.py | .py | 84657830ed8ca232 | 7.56 | 12 |
"""Tests for delphi_utils.signal."""
from unittest.mock import patch
import pandas as pd
import pytest
from delphi_utils.signal import add_prefix
# Constants for mocking out the call to `covidcast.metadata` within `public_signal()`.
PUBLIC_SIGNALS = ["sig1", "sig2", "sig3"]
PUBLIC_SIGNALS_FRAME = pd.DataFrame(data={"... | cmu-delphi/covidcast-indicators | _delphi_utils_python/tests/test_signal.py | .py | 898a3476b8ad20bb | 8.06 | 12 |
"""
Tests for the smoothing utility.
Authors: Dmitry Shemetov, Addison Hu, Maria Jahja
"""
from numpy.lib.polynomial import poly
import pytest
import numpy as np
import pandas as pd
from delphi_utils import Smoother
class TestSmoothers:
def test_bad_inputs(self):
with pytest.raises(ValueError):
... | cmu-delphi/covidcast-indicators | _delphi_utils_python/tests/test_smooth.py | .py | 0bb416431366bf3d | 7.06 | 12 |
"""Common utilities for testing functions."""
from typing import Any, Dict
import pandas as pd
def check_valid_dtype(dtype):
"""Check if a dtype is a valid Pandas type."""
try:
pd.api.types.pandas_dtype(dtype)
except TypeError as e:
raise ValueError(f"Invalid dtype {dtype}") from e
def s... | cmu-delphi/covidcast-indicators | _delphi_utils_python/tests/testing.py | .py | 0377ab5a9f2b2ce6 | 8.06 | 12 |
"""Classes for handling the analysis of a modeling run.
"""
from ihm.util import _text_choice_property
class Step:
"""A single step in an :class:`Analysis`.
Normally one of the more specific derived classes is used;
see :class:`FilterStep`, :class:`ClusterStep`, :class:`RescoreStep`,
:clas... | ihmwg/python-ihm | ihm/analysis.py | .py | 2f64eba6d966a3db | 7.64 | 18 |
"""Classes for handling modeling protocols.
"""
class Step:
"""A single step in a :class:`Protocol`.
:param assembly: The part of the system modeled in this step
:type assembly: :class:`~ihm.Assembly`
:param dataset_group: The collection of datasets used in this modeling
:type dataset... | ihmwg/python-ihm | ihm/protocol.py | .py | 2f7b58861f9c77d9 | 7.64 | 18 |
"""Classes for providing extra information about an :class:`ihm.Entity`"""
import urllib.request
import ihm
class Reference:
"""Base class for extra information about an :class:`ihm.Entity`.
This class is not used directly; instead, use a subclass such as
:class:`Sequence` or :class:`UniProtSequen... | ihmwg/python-ihm | ihm/reference.py | .py | ac498267cd830508 | 7.64 | 18 |
"""Classes for describing the source of an entity.
"""
class Source:
"""Base class to describe the source of an :class:`ihm.Entity`.
See :class:`Manipulated`, :class:`Natural` and :class:`Synthetic`.
"""
src_method = None
class Details:
"""Identifying information for an entity source.
... | ihmwg/python-ihm | ihm/source.py | .py | 666d2c4458813958 | 7.64 | 18 |
"""Classes to handle starting models."""
import enum
class SequenceIdentityDenominator(enum.IntEnum):
"""The denominator used while calculating the sequence identity.
One of these constants can be passed to :class:`SequenceIdentity`."""
#: Length of the shorter sequence
SHORTER_LENGTH = 1
#:... | ihmwg/python-ihm | ihm/startmodel.py | .py | 7a8cf386ee331abc | 7.64 | 18 |
import utils
import os
import unittest
TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
utils.set_search_paths(TOPDIR)
import ihm.citations
class Tests(unittest.TestCase):
def test_citations(self):
"""Test citations module"""
pmi = ihm.citations.pmi
self.assertEqua... | ihmwg/python-ihm | test/test_citations.py | .py | c583ea6fb91ac68a | 7.64 | 18 |
import utils
import os
import unittest
TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
utils.set_search_paths(TOPDIR)
import ihm.dataset
import ihm.location
import ihm.geometry
def _make_test_file(fname):
with open(fname, 'w') as fh:
fh.write('contents')
class Tests(unittest.Tes... | ihmwg/python-ihm | test/test_dataset.py | .py | 1b4b9b980701aca0 | 8.14 | 18 |
import utils
import os
import unittest
from io import StringIO
TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
utils.set_search_paths(TOPDIR)
import ihm.reader
import ihm.dumper
class Tests(unittest.TestCase):
def test_entity(self):
"""Test Entity read followed by write"""
... | ihmwg/python-ihm | test/test_edit.py | .py | 340b985bfac4a212 | 8.14 | 18 |
import pytest
from tests.util import (
get_spark_session,
assert_dataframe_equality,
assert_zero,
get_dataframes_from_names,
all_match
)
from tube.utils.general import get_node_id_name
from pyspark.sql.types import ArrayType, BooleanType
from pyspark.sql.functions import array_contains, udf
@pytest... | uc-cdis/tube | tests/dataframe_tests/test_dataframe_aggregation.py | .py | 2165295dbf20b6c8 | 8 | 9 |
import pytest
from tests.util import (
get_spark_session,
assert_dataframe_equality,
get_dataframes_from_names,
)
from tube.utils.general import get_node_id_name
@pytest.mark.schema_ibdgc
@pytest.mark.parametrize("translator", [("ibdgc", "file", "injection", [
"edge_qcworkflowperformedonrawsnpgeno... | uc-cdis/tube | tests/dataframe_tests/test_dataframe_injection.py | .py | b9f969ef93325dd3 | 8 | 9 |
import pytest
from opensearchpy import OpenSearch, client
import tube.settings as config
from tube.etl.indexers.interpreter import create_translators
from tests.integrated_tests.utils import items_in_file
from tests.integrated_tests.utils_db import SQLQuery
from tests.integrated_tests.utils_es import get_names, get_es... | uc-cdis/tube | tests/integrated_tests/test_es/test_es.py | .py | efd2f915ac7b1f1b | 8 | 9 |
import itertools
import json
import os
from operator import itemgetter
test_data_folder = "./tests/integrated_tests/test_data"
def items_in_file(filename):
in_json = ".".join([filename, "json"])
in_json_path = os.path.join(test_data_folder, in_json)
with open(in_json_path, "r") as f:
entries = j... | uc-cdis/tube | tests/integrated_tests/utils.py | .py | 3b1974bf1d250d08 | 8 | 9 |
from psycopg2.sql import SQL, Identifier, Literal
from tests.integrated_tests.utils import pairwise
from tube.utils.db import execute_sql_query_return_first_field
class SQLQuery:
def __init__(self):
self.select_clauses = {}
self.join_clauses = {}
def __getitem__(self, item):
tables, ... | uc-cdis/tube | tests/integrated_tests/utils_db.py | .py | 45dbb0cb915c36c9 | 8 | 9 |
def test_add_auth_resource_path_mapping():
"""
Regression test that checks that `add_auth_resource_path_mapping` always adds
the `auth_resource_path` and `project_id` properties, instead of only adding
`auth_resource_path` when the properties already include `project_id`.
"""
from tube.etl.plugi... | uc-cdis/tube | tests/standalone_tests/test_misc.py | .py | 658576674e64b9c7 | 7 | 9 |
import pytest
from unittest.mock import patch
from tests.util import mock_dictionary_url, initialize_mappings
from tube.etl.indexers.injection.parser import Parser as InjectionParser
import tube.settings as config
from tube.utils.dd import init_dictionary
@pytest.fixture(scope="function")
@patch("tube.etl.indexers.i... | uc-cdis/tube | tests/standalone_tests/test_parser.py | .py | 38f1d92047e2a887 | 7 | 9 |
import json
import os
#
# make it easy to change this for testing
# on linux XDG_DATA_HOME defaults to $HOME/.local/share,
# but may need to add to .bashrc on Mac
#
XDG_DATA_HOME = os.getenv("XDG_DATA_HOME", "/usr/share")
def default_search_folders(app_name):
"""
Return the list of folders to search for conf... | uc-cdis/tube | tube/config_helper.py | .py | 2c116aa672cb6e65 | 7.5 | 9 |
from tube.etl.indexers.base.lambdas import (
get_aggregation_func_by_name,
get_single_frame_zero_by_func,
get_single_frame_value,
)
import builtins
def get_frame_zero(reducers):
return tuple(
[
get_single_frame_zero_by_func(rd.fn, rd.prop.id)
for rd in reducers
... | uc-cdis/tube | tube/etl/indexers/aggregation/lambdas.py | .py | 4ef49ecf15f14bff | 7.5 | 9 |
from tube.etl.indexers.base.prop import PropFactory
class ParentChain:
"""
Special root is the abstract node give the access to the aggregation path of a special_prop in etlMapping
"""
def __init__(self, head, relation, fn):
self.head = head # first ParentNode in the chain of nodes (like a l... | uc-cdis/tube | tube/etl/indexers/aggregation/nodes/parent_node.py | .py | 11c622ad1f9c6320 | 7.5 | 9 |
from tube.etl.indexers.base.prop import PropFactory
class SpecialChain:
"""
Special root is the abstract node give the access to the aggregation path of a special_prop in etlMapping
"""
def __init__(self, doc_name, name, head, fn):
self.name = name # name of the prop create by this special f... | uc-cdis/tube | tube/etl/indexers/aggregation/nodes/special_node.py | .py | 9bf7014cac1b3475 | 8 | 9 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details.
"""
Based on https://github.com/pytorch/pytorch/blob/master/torch/utils/collect_env.py
This script outputs relevant system enviro... | pyronear/pyro-engine | .github/collect_env.py | .py | 6c994050622a945f | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
import logging
from collections import deque
from datetime import datetime, timezone
from typing import Any, Dict, List, Optional,... | pyronear/pyro-engine | pyro-predictor/pyro_predictor/predictor.py | .py | e4abd67c6a00e491 | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
import cv2
import numpy as np
from tqdm import tqdm
__all__ = ["DownloadProgressBar", "letterbox", "nms", "xywh2xyxy"]
def xyw... | pyronear/pyro-engine | pyro-predictor/pyro_predictor/utils.py | .py | 09b3c1b598c79957 | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
import logging
import pathlib
import platform
import shutil
import tarfile
from typing import Tuple
import ncnn
import numpy as n... | pyronear/pyro-engine | pyro-predictor/pyro_predictor/vision.py | .py | f3e3875d287e98b4 | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from __future__ import annotations
import logging
import time
from io import BytesIO
from typing import List, Optional, Tuple
f... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/api/routes_cameras.py | .py | ae7756cea963235e | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from __future__ import annotations
import logging
import threading
from fastapi import APIRouter, HTTPException, Request
from ... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/api/routes_patrol.py | .py | 212016cc94309f3c | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from __future__ import annotations
import logging
import subprocess
import threading
from fastapi import APIRouter, HTTPExcepti... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/api/routes_stream.py | .py | 5dccde2f677cf504 | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from __future__ import annotations
import logging
import operator
import pathlib
import time
from io import BytesIO
from typing ... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/camera/adapters/reolink.py | .py | d9a1cfc07e913593 | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from __future__ import annotations
import base64
import logging
import re
from io import BytesIO
from typing import Any, Dict, O... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/camera/adapters/rest.py | .py | 2b616fcc5e41bf83 | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from __future__ import annotations
import logging
import subprocess
import tempfile
from typing import Optional
import cv2
impor... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/camera/adapters/rtsp.py | .py | 87da4a31a671ef9d | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from __future__ import annotations
import logging
import re
from io import BytesIO
from typing import Optional, Tuple
from urlli... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/camera/adapters/url.py | .py | 88987c39b1b9bd22 | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
"""Cooperative cancellation of the autofocus search.
The autofocus search (adapter focus_finder) sweeps the focus motor for
minu... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/camera/focus_manager.py | .py | 93842cd46f52113b | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from __future__ import annotations
import logging
import threading
import time
from typing import Any, Dict
from pyro_camera_ap... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/camera/patrol.py | .py | de0aee150ff7dc2e | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
"""Resolve the local pose -> azimuth mapping from the platform API.
credentials.json no longer carries azimuths, only local pose... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/camera/pose_azimuths.py | .py | d90007b5e9261f9d | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from __future__ import annotations
import logging
import os
import re
import threading
from collections import defaultdict
from ... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/camera/registry.py | .py | 1da503872458b3ec | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
"""
PTZ stuck-camera detector.
Every CHECK_INTERVAL seconds, compute pairwise pHash distances across the
most recent per-pose im... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/camera/stuck_detector.py | .py | 8dbc0640f4382e54 | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from __future__ import annotations
import logging
from typing import List, Tuple
import numpy as np
from PIL import Image
logge... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/services/anonymizer.py | .py | b104c82aba84ac09 | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
import cv2
import numpy as np
from tqdm import tqdm
__all__ = ["DownloadProgressBar", "letterbox", "nms", "xywh2xyxy"]
def xyw... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/services/utils.py | .py | 087cbc9688514894 | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
import logging
import pathlib
import platform
import tarfile
from typing import Optional, Tuple
from urllib.request import urlretr... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/services/vision.py | .py | e2d512a9490718af | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from __future__ import annotations
import time
_last_command_time: float = time.time()
def update_command_time() -> None:
... | pyronear/pyro-engine | pyro_camera_api/pyro_camera_api/utils/time_utils.py | .py | b364bf44a1de0ccb | 7.65 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from pyro_camera_api.api.routes_control import click_to_move
from pyro_camera_api.camera.adapters.mock import MockCamera
from pyr... | pyronear/pyro-engine | pyro_camera_api/tests/test_click_to_move.py | .py | 37adb4215025f7aa | 8.15 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
import threading
from PIL import Image
from pyro_camera_api.camera import patrol
from pyro_camera_api.camera.adapters.mock impo... | pyronear/pyro-engine | pyro_camera_api/tests/test_patrol_stream.py | .py | 6b11221e43564928 | 7.15 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
from unittest.mock import MagicMock, patch
import pytest
from pyro_camera_api.camera.adapters.mock import MockCamera
from pyro_... | pyronear/pyro-engine | pyro_camera_api/tests/test_pose_azimuths.py | .py | ef846f35da85a86b | 7.15 | 19 |
# Copyright (C) 2022-2026, Pyronear.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
import logging
import sys
import time
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, Option... | pyronear/pyro-engine | pyroengine/core.py | .py | 21d4ed05d2876a47 | 7.65 | 19 |
#!/usr/bin/env python3
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
#
# report.py - Append the ABI verdict + the abi-compliance-checker report body
# to $GITHUB_STEP_SUMMARY so the result is visible at a glance on the PR.
#
# Reads state from the environmen... | awslabs/aws-crt-builder | .github/actions/check-abi/scripts/report.py | .py | 0821c1329b2f7f79 | 7.62 | 16 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
import os
from builder.core.action import Action
from builder.core.project import Project
class DownloadSource(Action):
""" Downloads the source for a given project """
def __init__(self, **kwargs):
... | awslabs/aws-crt-builder | builder/actions/git.py | .py | bbc11691ec7769d0 | 7.62 | 16 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
import os
from builder.core.action import Action
from builder.core.project import Import
class Mirror(Action):
""" Updates mirrored dependencies in S3/CloudFront """
def is_main(self):
return ... | awslabs/aws-crt-builder | builder/actions/mirror.py | .py | 61a49170ae5bd658 | 7.62 | 16 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
import sys
from builder.core.action import Action
from builder.core.scripts import Scripts
from builder.core.util import replace_variables, to_list
class Script(Action):
""" A build step that runs a series... | awslabs/aws-crt-builder | builder/actions/script.py | .py | 90a712c2949536e9 | 7.62 | 16 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
class Action(object):
""" A build step """
def is_main(self):
""" Returns True if this action needs no external tasks run to set it up """
return False
def run(self, env):
... | awslabs/aws-crt-builder | builder/core/action.py | .py | 6f4a19f9dba1fc07 | 7.12 | 16 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
from builder.core.vmod import VirtualModule
from builder.core.shell import Shell
from builder.core.env import Env
from builder.core.action import Action
from builder.core.scripts import Scripts
from builder.core... | awslabs/aws-crt-builder | builder/core/api.py | .py | b7f4b7b152f289be | 7.62 | 16 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
import os
import subprocess
import sys
from builder.actions.git import DownloadSource
from builder.core.project import Project
from builder.core.shell import Shell
class Env(object):
""" Encapsulates the ... | awslabs/aws-crt-builder | builder/core/env.py | .py | 2e4bee10c8046a3a | 7.62 | 16 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
from builder.core.data import ARCHS, HOSTS, PKG_TOOLS
import os
import re
import sys
from functools import lru_cache
def current_os():
if sys.platform == 'win32':
return 'windows'
elif sys.pl... | awslabs/aws-crt-builder | builder/core/host.py | .py | 52d98cb18c6d5354 | 7.62 | 16 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
import importlib
import importlib.util
import glob
import os
import sys
Action = None
Project = None
Import = None
def _import_dynamic_classes():
# Must late import project to avoid cyclic dependency
... | awslabs/aws-crt-builder | builder/core/scripts.py | .py | 1a2922b347bbfb36 | 7.62 | 16 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
import os
from builder.core.data import *
from builder.core.host import current_host, current_os, current_arch, normalize_arch
def _parse_version(version_str):
"""Parse a version string into a list of int... | awslabs/aws-crt-builder | builder/core/spec.py | .py | 0b91c09ce4fe90f8 | 8.12 | 16 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
import copy
from collections import namedtuple, UserList
from collections.abc import Iterable
from functools import reduce
import os
import stat
from string import Formatter
import subprocess
import sys
from ti... | awslabs/aws-crt-builder | builder/core/util.py | .py | 9310130443791f15 | 7.62 | 16 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
from builder.core.fetch import fetch_script, fetch_and_extract
from builder.core.host import current_os, current_arch
from builder.core.project import Import, Project
import builder.core.util as util
from build... | awslabs/aws-crt-builder | builder/imports/nodejs.py | .py | 2a384e118789dfc0 | 7.62 | 16 |
import builder.core.api # force API to load and expose the virtual module
from collections import namedtuple
import os
import unittest
import unittest.mock as mock
from builder.core.env import Env
from builder.core.project import Project
from builder.core.spec import BuildSpec
from builder.core.host import current_o... | awslabs/aws-crt-builder | tests/test_env.py | .py | 417bbaca67b852fd | 8.12 | 16 |
import os
import unittest
import unittest.mock as mock
from builder.core.project import Project
from builder.core.spec import BuildSpec
from builder.actions.script import Script
import builder.core.api # force API to load and expose the virtual module
here = os.path.dirname(os.path.abspath(__file__))
test_data_dir ... | awslabs/aws-crt-builder | tests/test_project.py | .py | 549a8755723de7c6 | 7.12 | 16 |
import unittest
import builder.core.util as utils
class TestUtils(unittest.TestCase):
def test_deep_get_dict(self):
"""test deep_get for dictionary types"""
d = {
'foo': {
'bar': {
'baz': 'quux'
}
}
}
sel... | awslabs/aws-crt-builder | tests/test_utils.py | .py | e6cd07f0f531ee60 | 8.12 | 16 |
"""Alembic runtime environment.
Resolves the database URL from the project's app_settings (same source the
application uses), imports the SQLAlchemy ``Base`` from the models module
so autogenerate can diff the live schema against the ORM definitions.
"""
from __future__ import annotations
from logging.config import f... | sstagg/Magellon | CoreService/alembic/env.py | .py | 160c1e4fbca40578 | 7.45 | 7 |
"""Baseline: create the full pre-alembic base schema.
Root of the migration chain. Before this existed, migration 0001
assumed a dump-restored database, so ``alembic upgrade head`` could
never build a working schema from an empty MySQL — new environments
depended on hand-loading ``database/magellon01db.sql``.
Execute... | sstagg/Magellon | CoreService/alembic/versions/0000_baseline_schema.py | .py | e1891a9d7d23fadc | 7.45 | 7 |
"""add subject_kind + subject_id to image_job_task (Phase 3)
Revision ID: 0004_add_task_subject_axis
Revises: 0003_add_task_provenance
Create Date: 2026-05-03
Phase 3 — subject axis. Pre-Phase-3 every task is image-keyed
(``image_id`` FK on ``image_job_task``). The CAN classifier doesn't fit
that mold — its subject i... | sstagg/Magellon | CoreService/alembic/versions/0004_add_task_subject_axis.py | .py | 63a8f9d2ec8795a8 | 7.45 | 7 |
"""create artifact table (Phase 4)
Revision ID: 0005_create_artifact
Revises: 0004_add_task_subject_axis
Create Date: 2026-05-03
Phase 4 — Artifact entity. First-class typed output of any task whose
result is consumed by a downstream task. Today's only producer is the
PARTICLE_EXTRACTION plugin (Phase 5) and the only... | sstagg/Magellon | CoreService/alembic/versions/0005_create_artifact.py | .py | 5607e40f1d3666e1 | 7.45 | 7 |
"""create pipeline_run + image_job.parent_run_id (Phase 8)
Revision ID: 0006_create_pipeline_run
Revises: 0005_create_artifact
Create Date: 2026-05-03
Phase 8 — PipelineRun rollup. The architectural addition that lets a
user-visible "I ran the picker → extractor → classifier on session
X" map onto the existing image_... | sstagg/Magellon | CoreService/alembic/versions/0006_create_pipeline_run.py | .py | 2de81f8b0d9c9fdb | 7.45 | 7 |
"""add artifact.source_artifact_id FK for class-average lineage (High #5)
Revision ID: 0007_add_artifact_source_fk
Revises: 0006_create_pipeline_run
Create Date: 2026-05-04
Reviewer-flagged High #5 fix. Pre-fix lineage between
``class_averages`` artifacts (TWO_D_CLASSIFICATION output) and the
``particle_stack`` they ... | sstagg/Magellon | CoreService/alembic/versions/0007_add_artifact_source_fk.py | .py | abf3bd715ff3dac1 | 7.45 | 7 |
"""PM1: extend plugin table; add plugin_state + plugin_category_default
Revision ID: 0008_plugin_persistence
Revises: 0007_add_artifact_source_fk
Create Date: 2026-05-04
PM1 of PLUGIN_MANAGER_PLAN.md (revised 2026-05-04). Adds the
persistence layer the in-memory PluginStateStore +
InstalledPluginsRegistry pretended t... | sstagg/Magellon | CoreService/alembic/versions/0008_plugin_persistence.py | .py | 50aa66d699c18684 | 7.45 | 7 |
"""Add dispatch-cache columns + covering index to artifact (PE2)
Revision ID: 0010_artifact_dispatch_cache
Revises: 0009_plugin_endpoint
Create Date: 2026-05-12
PE2 (PIPELINE_ERGONOMICS_PLAN.md §PE2) wants to deduplicate dispatch
when the same plugin at the same version is asked to run with the
same input artifact se... | sstagg/Magellon | CoreService/alembic/versions/0010_artifact_dispatch_cache.py | .py | becdc7c9cf856576 | 7.45 | 7 |
"""Broker inspection HTTP surface — backs the Pipeline Health page.
Three endpoints, narrow on purpose:
* ``GET /admin/broker/health`` — Magellon-domain projection of broker
state + plugin liveness. Open access (page renders during local dev
without a token).
* ``GET /admin/broker/queues/{name}/peek?co... | sstagg/Magellon | CoreService/controllers/admin_broker_controller.py | .py | ace43fba0035a88b | 7.45 | 7 |
"""Admin endpoint for the PE2 dispatch cache.
One verb: ``POST /admin/dispatch-cache/invalidate`` to soft-delete
cache rows matching a filter. Filters are optional but at least one
must be supplied — an unfiltered call is refused as a safety check
(see :func:`services.dispatch_cache.invalidate_cache`).
The cache itse... | sstagg/Magellon | CoreService/controllers/admin_dispatch_cache_controller.py | .py | 576a8bfd16624e13 | 7.45 | 7 |
from typing import List, Optional
from uuid import UUID
from fastapi import Depends, HTTPException, APIRouter
from sqlalchemy.orm import Session
from starlette import status
import logging
from database import get_db
from models.pydantic_models import CameraDto
from repositories.camera_repository import CameraReposit... | sstagg/Magellon | CoreService/controllers/camera_controller.py | .py | 6761b97e7482f05d | 7.45 | 7 |
"""Cancellation HTTP surface (P9).
Two operator levers, mirroring the two primitives in
:mod:`services.cancellation_service`:
- ``POST /cancellation/queues/purge`` — drain pending tasks from one
or more category queues. Pending = the broker still has them; the
plugin hasn't pulled them off yet. Returns ``{q... | sstagg/Magellon | CoreService/controllers/cancellation_controller.py | .py | ba7b37757d1f428f | 7.45 | 7 |
from typing import List, Optional
from uuid import UUID
from fastapi import Depends, HTTPException, APIRouter
from sqlalchemy.orm import Session
from starlette import status
import logging
from database import get_db
from models.pydantic_models import ImageMetaDataCategoryDto
from repositories.image_meta_data_categor... | sstagg/Magellon | CoreService/controllers/image_meta_data_category_controller.py | .py | 0e561f237f385105 | 7.45 | 7 |
from typing import List, Optional
from uuid import UUID
from fastapi import Depends, HTTPException, APIRouter
from sqlalchemy.orm import Session
from starlette import status
import logging
from core.exceptions import EntityNotFoundError
from database import get_db
from models.pydantic_models import ImageMetaDataDto
f... | sstagg/Magellon | CoreService/controllers/image_meta_data_controller.py | .py | 006c17031a287b91 | 7.45 | 7 |
import numpy as np
from scipy import fftpack
from scipy.ndimage import uniform_filter
def lowpass_filter(image, resolution, pixel_size):
"""
Apply a low-pass Gaussian filter to a cryo-EM image at a specified resolution.
Parameters:
- image: 2D numpy array, the input cryo-EM image.
- resolution: T... | sstagg/Magellon | CoreService/controllers/image_processing_tools.py | .py | 603165c54f6692ff | 7.45 | 7 |
import json
import os
import logging
from datetime import datetime
from decimal import Decimal
from uuid import UUID
from typing import List, Dict, Any
from fastapi import APIRouter, HTTPException, Depends
from sqlalchemy.orm import Session
from config import app_settings
from core.serialization import serialize_date... | sstagg/Magellon | CoreService/controllers/import_export_controller.py | .py | 3ca1f6c26a5d6349 | 7.45 | 7 |
import logging
from uuid import UUID
from typing import Optional
from fastapi import APIRouter, HTTPException, Depends
from sqlalchemy.orm import Session
from models.pydantic_models import ImportJobBase
from models.relion_pydantic_models import RelionStarFileGenerationResponse, RelionSessionValidationResponse, \
... | sstagg/Magellon | CoreService/controllers/relion_controller.py | .py | edc7d27221140adf | 7.45 | 7 |
"""
Shared CRUD scaffolding for the security controllers.
The sys_sec_* controllers historically copy-pasted the same plumbing into
every route: the get-by-id-or-404 check, the ``try/except`` envelope that
logs and converts any failure into a 500, and the "repository returned
False -> 500" success check. These helpers... | sstagg/Magellon | CoreService/controllers/security/_crud_helpers.py | .py | acc3491f4c6ef738 | 7.45 | 7 |
"""
Authentication Controller
Provides login, logout, token management, and system setup endpoints.
"""
from datetime import timedelta, datetime
from typing import Optional
from uuid import UUID
import os
from fastapi import APIRouter, Depends, HTTPException, status
from pydantic import BaseModel
from sqlalchemy.orm ... | sstagg/Magellon | CoreService/controllers/security/auth_controller.py | .py | ef584a5a1ac7f8d4 | 7.45 | 7 |
"""
Session Access Management Controller (Refined Approach)
Admin endpoints to grant/revoke session-specific permissions.
Uses Casbin as single source of truth.
Flow:
1. Admin grants session access → Writes to sys_sec_object_permission
2. Triggers Casbin sync → Updates Casbin policies
3. Endpoints use existing Casbin... | sstagg/Magellon | CoreService/controllers/security/session_access_controller.py | .py | edf91269bb3216d2 | 7.45 | 7 |
"""
Controller for User-Role Management API endpoints
"""
from typing import List, Optional
from uuid import UUID
from fastapi import APIRouter, Depends, HTTPException, Query
from sqlalchemy.orm import Session
from starlette import status
from controllers.security._crud_helpers import (
crud_guard,
ensure_suc... | sstagg/Magellon | CoreService/controllers/security/sys_sec_user_role_controller.py | .py | 0197f85c5ed8d85a | 7.45 | 7 |
"""Test the Moneybird Administrations."""
from django.test import TestCase
from website.accounting.moneybird import Administration
from website.accounting.moneybird.administration import _build_url as build_url
class MockAdministration(Administration):
"""Mock version of a MoneyBird administration."""
def ... | JobDoesburg/landolfio | landolfio/accounting/tests/test_administration.py | .py | 4739954ebe5d0904 | 7.98 | 8 |
"""Test the accounting models."""
import datetime
from django.test import TestCase
from accounting.moneybird import DocKind
from inventory.models import Asset, Collection
from .models import Document
class TestGetDocumentUrl(TestCase):
"""Test the document moneybird property url."""
# pylint: disable=pro... | JobDoesburg/landolfio | landolfio/accounting/tests/test_models.py | .py | 38be1983c667223f | 7.98 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.