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 |
|---|---|---|---|---|---|---|
"""
This file is part of MSS.
:copyright: Copyright 2021-2026 by the MSS team, see AUTHORS.
:license: APACHE-2.0, see LICENSE for details.
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 t... | Open-MSS/MSS | docs/gallery/plot_examples/HS_template.py | .py | a0123d46a9be4a96 | 7.95 | 80 |
"""
This file is part of MSS.
:copyright: Copyright 2021-2026 by the MSS team, see AUTHORS.
:license: APACHE-2.0, see LICENSE for details.
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 t... | Open-MSS/MSS | docs/gallery/plot_examples/VS_template.py | .py | 0a75b9eb5a4910b4 | 7.95 | 80 |
# -*- coding: utf-8 -*-
"""
mslib.mscolab.app
~~~~~~~~~~~~~~~~~
app module of mscolab
This file is part of MSS.
:copyright: Copyright 2016-2026 by the MSS team, see AUTHORS.
:license: APACHE-2.0, see LICENSE for details.
Licensed under the Apache License, Version 2.0 (the "License");
... | Open-MSS/MSS | mslib/mscolab/app/__init__.py | .py | ab040d871826923e | 7.95 | 80 |
# -*- coding: utf-8 -*-
"""
mslib.mscolab.auth
~~~~~~~~~~~~~~~~~~
handles login/token/SAML logic
This file is part of MSS.
:copyright: Copyright 2023 Reimar Bauer
:copyright: Copyright 2023-2026 by the MSS team, see AUTHORS.
:license: APACHE-2.0, see LICENSE for details.
Licensed un... | Open-MSS/MSS | mslib/mscolab/auth.py | .py | 405721528c275eb6 | 7.95 | 80 |
# -*- coding: utf-8 -*-
"""
mslib.mscolab.blueprints.user
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
User Blueprint for server for mscolab module
This file is part of MSS.
:copyright: Copyright 2019 Shivashis Padhi
:copyright: Copyright 2019-2026 by the MSS team, see AUTHORS.
:license: APACHE-2.0, se... | Open-MSS/MSS | mslib/mscolab/blueprints/user/__init__.py | .py | a41536e643088a05 | 7.95 | 80 |
# -*- coding: utf-8 -*-
"""
mslib.mscolab.chat_manager
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code to handle socket connections in mscolab
This file is part of MSS.
:copyright: Copyright 2019 Shivashis Padhi
:copyright: Copyright 2019-2026 by the MSS team, see AUTHORS.
:license: APACHE-2.0, see L... | Open-MSS/MSS | mslib/mscolab/chat_manager.py | .py | cced1b390a90ca47 | 7.95 | 80 |
# -*- coding: utf-8 -*-
"""
mslib.mscolab.events
~~~~~~~~~~~~~~~~~~~~
This module defines all socket event names used in the mscolab module.
This file is part of MSS.
:copyright: Copyright 2019 Shivashis Padhi
:copyright: Copyright 2019-2026 by the MSS team, see AUTHORS.
:license: APACHE-... | Open-MSS/MSS | mslib/mscolab/events.py | .py | f9c51ab8ba631962 | 7.95 | 80 |
"""
The MIT License (MIT)
Copyright (c) 2016 SUNSCRAPERS
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 limitation the rights
to use, copy, modify, merge, ... | Open-MSS/MSS | mslib/mscolab/migrations/env.py | .py | c73f31fdb0021c58 | 7.95 | 80 |
"""To version 10.0.0
Revision ID: 922e4d9c94e2
Revises: c171019fe3ee
Create Date: 2024-07-24 15:28:42.009581
"""
from alembic import op
import sqlalchemy as sa
import mslib.mscolab.custom_migration_types as cu
# revision identifiers, used by Alembic.
revision = '922e4d9c94e2'
down_revision = 'c171019fe3ee'
branch_l... | Open-MSS/MSS | mslib/mscolab/migrations/versions/922e4d9c94e2_to_version_10_0_0.py | .py | 9f0415918116cf91 | 7.95 | 80 |
"""To version 8.3.5 - Initial migration
Revision ID: 92eaba86a92e
Revises:
Create Date: 2024-07-08 15:47:24.916851
"""
from alembic import op
import sqlalchemy as sa
import mslib.mscolab.custom_migration_types as cu
# revision identifiers, used by Alembic.
revision = '92eaba86a92e'
down_revision = None
branch_label... | Open-MSS/MSS | mslib/mscolab/migrations/versions/92eaba86a92e_to_version_8_3_5_initial_migration.py | .py | 39e3049bb006cba4 | 7.95 | 80 |
"""To version 9.0.0
Revision ID: c171019fe3ee
Revises: 92eaba86a92e
Create Date: 2024-07-08 15:49:08.277483
"""
from alembic import op
import sqlalchemy as sa
import mslib.mscolab.custom_migration_types as cu
# revision identifiers, used by Alembic.
revision = 'c171019fe3ee'
down_revision = '92eaba86a92e'
branch_la... | Open-MSS/MSS | mslib/mscolab/migrations/versions/c171019fe3ee_to_version_9_0_0.py | .py | dab2037b7e95bb29 | 7.95 | 80 |
# -*- coding: utf-8 -*-
"""
mslib.mscolab.server
~~~~~~~~~~~~~~~~~~~~
Server for mscolab module
This file is part of MSS.
:copyright: Copyright 2019 Shivashis Padhi
:copyright: Copyright 2019-2026 by the MSS team, see AUTHORS.
:license: APACHE-2.0, see LICENSE for details.
Licensed ... | Open-MSS/MSS | mslib/mscolab/server.py | .py | deb0b5871ece87f7 | 7.95 | 80 |
# -*- coding: utf-8 -*-
"""
mslib.msui.aircraft
~~~~~~~~~~~~~~~~~~~
This module provides aircraft definitions
This file is part of MSS.
:copyright: Copyright 2016-2017 Joern Ungermann
:copyright: Copyright 2016-2026 by the MSS team, see AUTHORS.
:license: APACHE-2.0, see LICENSE for deta... | Open-MSS/MSS | mslib/msui/aircraft.py | .py | 15c2988d5036bd13 | 7.95 | 80 |
# -*- coding: utf-8 -*-
"""
mslib.msui.icons
~~~~~~~~~~~~~~~~
This module provides functions to process ECMWF forecast data.
This file is part of MSS.
:copyright: Copyright 2016-2026 by the MSS team, see AUTHORS.
:license: APACHE-2.0, see LICENSE for details.
Licensed under the Apache L... | Open-MSS/MSS | mslib/msui/icons/__init__.py | .py | 89fa78b1ee48b7f6 | 7.95 | 80 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""
Class that handles communications between Spyder kernel and frontend.
Comms transmit data in a list of buffers, and in a json-able dictionnary.
Here, we only sup... | spyder-ide/spyder-kernels | spyder_kernels/comms/commbase.py | .py | a9ee87856f3ea7d0 | 7.82 | 42 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""
Comms decorators.
"""
def comm_handler(fun):
"""Decorator to mark comm handler methods."""
fun._is_comm_handler = True
return fun
def register_com... | spyder-ide/spyder-kernels | spyder_kernels/comms/decorators.py | .py | a01793701d2099b7 | 7.82 | 42 |
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""
In addition to the remote_call mechanism implemented in CommBase:
- Implements _wait_reply, so blocking calls can be made.
"""
import asyncio
import sys
import ... | spyder-ide/spyder-kernels | spyder_kernels/comms/frontendcomm.py | .py | 061da80959530702 | 7.82 | 42 |
#
# Copyright (c) 2009- Spyder Kernels Contributors
#
# Licensed under the terms of the MIT License
# (see spyder_kernels/__init__.py for details)
import linecache
import os.path
import types
import sys
def new_main_mod(filename, modname):
"""
Reimplemented from IPython/core/interactiveshell.py to avoid cach... | spyder-ide/spyder-kernels | spyder_kernels/customize/namespace_manager.py | .py | 512242aee2a1a4f4 | 7.82 | 42 |
# Copyright (c) 2009- Spyder Kernels Contributors
#
# Licensed under the terms of the MIT License
# (see spyder_kernels/__init__.py for details)
"""User module reloader."""
import os
import sys
from spyder_kernels.customize.utils import path_is_library
class UserModuleReloader:
"""
User Module Reloader (UM... | spyder-ide/spyder-kernels | spyder_kernels/customize/umr.py | .py | f1d427ce5671ae0d | 7.82 | 42 |
# Copyright (c) 2009- Spyder Kernels Contributors
#
# Licensed under the terms of the MIT License
# (see spyder_kernels/__init__.py for details)
"""Utility functions."""
import ast
import builtins
import os
import re
import sys
import sysconfig
def create_pathlist():
"""
Create list of Python library paths ... | spyder-ide/spyder-kernels | spyder_kernels/customize/utils.py | .py | f4d47b4538ec6c01 | 7.82 | 42 |
import numpy as np
from scipy.linalg.lapack import dgtsv
__all__ = ['tdma', 'cyclic_tdma']
def tdma(lower_diagonal, main_diagonal, upper_diagonal, right_hand_side):
"""The thomas algorithm (tdma) solution for tri-diagonal matrix inversion
Parameters
----------
lower_diagonal: np.ndarray
The ... | FrictionTribologyEnigma/slippy | slippy/contact/_lubrication_utils.py | .py | a6c8d43aec14ce5b | 7.85 | 48 |
import numpy as np
from functools import partial
from typing import Callable, Optional
from slippy.core import _AdhesionModelABC
__all__ = ['MDAdhesionPotential', 'AdhesionModelFromFunction']
# central difference weights, replaces scipy.misc.derivative (removed in scipy 1.12)
_CD_WEIGHTS = {3: (-0.5, 0.0, 0.5),
... | FrictionTribologyEnigma/slippy | slippy/contact/adhesion_models.py | .py | 18dcf897be15e358 | 7.85 | 48 |
import warnings
import numpy as np
import slippy
from slippy.core import _SubModelABC
__all__ = ['WearElasticPerfectlyPlastic']
class WearElasticPerfectlyPlastic(_SubModelABC):
r"""
Remove overlap between surfaces left after contact with a maximum load
Parameters
----------
name: str
T... | FrictionTribologyEnigma/slippy | slippy/contact/sub_models/epp_wear.py | .py | 790203af00416fac | 7.85 | 48 |
from slippy.core import _SubModelABC
__all__ = ['FrictionCoulombSimple']
class FrictionCoulombSimple(_SubModelABC):
def __init__(self, name: str, coefficient):
""" Simple coulomb friction, limiting friction is normal force multiplied by a coefficient for each point
Parameters
----------... | FrictionTribologyEnigma/slippy | slippy/contact/sub_models/friction_coulomb_model.py | .py | 2ed58145151a97e4 | 7.85 | 48 |
from ._TransientSubModelABC import _TransientSubModelABC # noqa: E402
__all__ = ['UpdateShiftRollingSurface']
class UpdateShiftRollingSurface(_TransientSubModelABC):
"""
Shifts a RollingSurface at a set speed
"""
def __init__(self, name: str, surface_to_roll: int, speed_x: float = 0.0, speed_y: flo... | FrictionTribologyEnigma/slippy | slippy/contact/sub_models/shift_surface.py | .py | 5137372f413666d9 | 7.85 | 48 |
import numpy as np
import numpy.testing as npt
from slippy.contact._lubrication_utils import tdma, cyclic_tdma
def test_cyclic_matches_base():
# test that for non cyclic it gives the same result as the base tdma
size = 4
a = -1 * np.ones(size)
b = 4 * np.ones(size)
c = -1 * np.ones(size)
d = n... | FrictionTribologyEnigma/slippy | slippy/contact/tests/test_cyclic_tdma.py | .py | ffd7f9a391e44bc6 | 7.35 | 48 |
import numpy as np
import numpy.testing as npt
import pytest
import slippy
import slippy.contact as c
import slippy.surface as s
pytest.importorskip('cupy')
slippy.CUDA = True
steel = c.Elastic('Steel', {'E': 200e9, 'v': 0.3})
aluminum = c.Elastic('Aluminum', {'E': 70e9, 'v': 0.33})
def test_hertz_agreement_pk_sta... | FrictionTribologyEnigma/slippy | slippy/contact/tests/test_elastic_bem_cuda.py | .py | 768b861e40955e8d | 7.35 | 48 |
import numpy as np
import numpy.testing as npt
import pytest
import scipy.integrate as integrate
from slippy.contact.hertz import _sanitise_radii, hertz_full
def test_sanitise_radii():
npt.assert_allclose(_sanitise_radii(1), [1.0, 1.0])
npt.assert_allclose(_sanitise_radii((1,)), [1.0, 1.0])
npt.assert_... | FrictionTribologyEnigma/slippy | slippy/contact/tests/test_hertz_full.py | .py | dd261790e1c74378 | 7.35 | 48 |
//go:build go || all
// +build go all
package examples
import (
"os"
"path/filepath"
"testing"
"github.com/pulumi/providertest/pulumitest"
"github.com/pulumi/providertest/pulumitest/opttest"
"github.com/stretchr/testify/require"
)
func TestGoExampleLifecycle(t *testing.T) {
cwd, err := os.Getwd()
require.No... | pulumi/pulumi-provider-boilerplate | examples/go_test.go | .go | c69481e2f8afd08f | 7.46 | 84 |
//go:build yaml || all
// +build yaml all
package examples
import (
"testing"
"github.com/pulumi/providertest"
"github.com/pulumi/providertest/pulumitest"
"github.com/pulumi/providertest/pulumitest/assertpreview"
"github.com/pulumi/providertest/pulumitest/opttest"
)
func TestYAMLExampleLifecycle(t *testing.T) ... | pulumi/pulumi-provider-boilerplate | examples/yaml_test.go | .go | c5da057a3e95adb1 | 7.46 | 84 |
// Copyright 2025, Pulumi Corporation.
//
// 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 applicable law or agre... | pulumi/pulumi-provider-boilerplate | provider/random_resource_test.go | .go | b4213d8b27d5c421 | 7.46 | 84 |
#!/usr/bin/env python3
"""RAMSES RF - CLI Payload and Packet Inspector.
This module provides utilities to dissect arbitrary hex payloads and RAMSES
packets into multi-representation word blocks (1, 2, 4, 6, and 8 bytes) with
endianness, signed/unsigned decimal, binary, ASCII, IEEE-754 float conversions,
and schema-dri... | ramses-rf/ramses_rf | src/ramses_cli/inspect.py | .py | 0a89afb9ebeb8681 | 8.46 | 82 |
#!/usr/bin/env python3
"""RAMSES RF - a RAMSES-II protocol decoder & analyser.
`ramses_rf` takes care of the device (upper) layer.
Works with (amongst others):
- evohome (up to 12 zones)
- sundial (up to 2 zones)
- chronotherm (CM60xNG can do 4 zones)
- hometronics (16? zones)
- vision pro
"""
from __future__ import... | ramses-rf/ramses_rf | src/ramses_rf/__init__.py | .py | 4fb15ff03fcfa3a0 | 7.96 | 82 |
"""RAMSES RF - Intent-to-DTO Translation Helpers."""
from datetime import datetime as dt
from typing import Any
from ramses_rf.address import Address
from ramses_rf.const import ZON_MODE_MAP
from ramses_tx import exceptions as exc
from ramses_tx.const import FA
def resolve_addrs(
source: Address | str, destinat... | ramses-rf/ramses_rf | src/ramses_rf/commands/builders/helpers.py | .py | 41c8e2b36c12efe5 | 7.96 | 82 |
"""RAMSES RF - Core outbound command intent definitions."""
from dataclasses import dataclass, field, replace
from typing import Any
from uuid import UUID, uuid4
from ramses_rf.address import Address
from ramses_rf.enums import Action
@dataclass(frozen=True, slots=True)
class Command:
"""An immutable applicatio... | ramses-rf/ramses_rf | src/ramses_rf/commands/core.py | .py | 609b0b0c86a62454 | 7.96 | 82 |
"""RAMSES RF - Outbound Command Dispatcher."""
from ramses_rf.commands.builders import build_dto
from ramses_rf.commands.core import Command
from ramses_rf.interfaces import GatewayInterface
from ramses_rf.messages import Message
from ramses_tx import Priority
from ramses_tx.const import DEFAULT_WAIT_FOR_REPLY
from ra... | ramses-rf/ramses_rf | src/ramses_rf/commands/dispatcher.py | .py | 4a1468373852d859 | 7.96 | 82 |
#!/usr/bin/env python3
"""RAMSES RF - Transport layer configuration."""
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from typing import Any, Final, Literal, Never, TypeVar
import probatio as vol
from ramses_tx.config import EngineConfig
from ramse... | ramses-rf/ramses_rf | src/ramses_rf/config.py | .py | c1391d5d39c93e2b | 7.96 | 82 |
#!/usr/bin/env python3
"""RAMSES RF - Heating devices (e.g. CTL, OTB, BDR, TRV)."""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from ramses_rf import exceptions as exc
from ramses_rf.const import DEV_TYPE_MAP, DevType
from ramses_rf.models import DeviceTraits
from .dev_filter ... | ramses-rf/ramses_rf | src/ramses_rf/devices/__init__.py | .py | 03666c4986b18992 | 7.96 | 82 |
"""RAMSES RF - Device Filtering."""
from __future__ import annotations
from collections.abc import Callable
from ramses_rf.exceptions import DeviceNotFoundError
from ramses_rf.typing import DeviceIdT
from ramses_tx.address import HGI_DEV_ADDR
from ramses_tx.schemas import SZ_BLOCK_LIST, SZ_SCHEMA
class DeviceFilte... | ramses-rf/ramses_rf | src/ramses_rf/devices/dev_filter.py | .py | 293bcb38bed5dfce | 7.96 | 82 |
"""RAMSES RF - Heating Controller Devices."""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any, Final
from ramses_rf.const import SZ_HEAT_DEMAND, SZ_RELAY_DEMAND, DevType
from ramses_rf.entity import Entity
from ramses_rf.enums import PumpRelayState
from ramses_rf.helpers impor... | ramses-rf/ramses_rf | src/ramses_rf/devices/heat_controllers.py | .py | 9d33ebdd683c5a5c | 7.96 | 82 |
"""RAMSES RF - Heating Sensor Devices."""
from __future__ import annotations
import dataclasses
import logging
from datetime import timedelta as td
from typing import Any, Final
from ramses_rf.const import HEARTBEAT_TIMEOUT_DHW, SZ_TEMPERATURE, DevType
from ramses_rf.enums import Action, ZoneRole
from ramses_rf.mess... | ramses-rf/ramses_rf | src/ramses_rf/devices/heat_sensors.py | .py | c6a5de9ca415efe7 | 7.96 | 82 |
"""RAMSES RF - Heating Thermostat & Setpoint Devices."""
from __future__ import annotations
from datetime import timedelta as td
from typing import TYPE_CHECKING, Any, Final
from ramses_rf.const import (
HEARTBEAT_TIMEOUT_TRV,
SZ_HEAT_DEMAND,
SZ_SETPOINT,
SZ_WINDOW_OPEN,
DevType,
)
from ramses_rf... | ramses-rf/ramses_rf | src/ramses_rf/devices/heat_thermostats.py | .py | 528fa6d0810360d8 | 7.96 | 82 |
"""RAMSES RF - Helper functions for devices."""
from __future__ import annotations
import logging
from typing import Any, Protocol
from ramses_rf.address import Address
from ramses_rf.commands.core import Command as Intent
from ramses_rf.enums import Action
from ramses_rf.exceptions import DeviceNotFaked
from ramses... | ramses-rf/ramses_rf | src/ramses_rf/devices/helpers.py | .py | 68d958ad2cbb9539 | 7.96 | 82 |
"""RAMSES RF - OpenTherm Bridge Device."""
from __future__ import annotations
import logging
from datetime import timedelta as td
from typing import Any, Final
from ramses_rf.const import (
HEARTBEAT_TIMEOUT_OTB,
SZ_BOILER_OUTPUT_TEMP,
SZ_BOILER_RETURN_TEMP,
SZ_BOILER_SETPOINT,
SZ_BURNER_FAILED_S... | ramses-rf/ramses_rf | src/ramses_rf/devices/opentherm_bridge.py | .py | 60dd00b2363f9000 | 7.96 | 82 |
#!/usr/bin/env python3
"""RAMSES RF - Decode/process a message (payload into JSON)."""
from __future__ import annotations
# TODO:
# - fix dispatching - what devices (some are Addr) are sent packets, esp. 1FC9s
import logging
from datetime import timedelta as td
from typing import TYPE_CHECKING, Final
from . import e... | ramses-rf/ramses_rf | src/ramses_rf/dispatcher.py | .py | e5bdb5c205d939e7 | 7.96 | 82 |
#!/usr/bin/env python3
"""RAMSES RF - Base class for all RAMSES-II objects: devices and constructs."""
from __future__ import annotations
import asyncio
import logging
from inspect import getmembers, isclass
from sys import modules
from typing import TYPE_CHECKING, Any
from ramses_tx import Priority, QosParams
from... | ramses-rf/ramses_rf | src/ramses_rf/entity.py | .py | 9f63ded5ddba6d09 | 7.96 | 82 |
"""RAMSES RF - Cross-domain enumerations for the L7 event pipeline."""
from enum import EnumCheck, StrEnum, verify
# slugs for device/zone entity klasses, used by 0005/000C
@verify(EnumCheck.UNIQUE)
class DevRole(StrEnum):
"""Slugs for device/zone entity classes, used by commands 0005/000C."""
ACT = "ACT" ... | ramses-rf/ramses_rf | src/ramses_rf/enums.py | .py | dc2e41bfb7a41d97 | 7.96 | 82 |
#!/usr/bin/env python3
"""RAMSES RF - Helper functions."""
from __future__ import annotations
import asyncio
from collections.abc import Awaitable, Callable
from copy import deepcopy
from inspect import iscoroutinefunction
from typing import Any, TypeAlias
_SchemaT: TypeAlias = dict[str, Any]
def is_subset(inner: ... | ramses-rf/ramses_rf | src/ramses_rf/helpers.py | .py | 136da43112472cf9 | 7.96 | 82 |
r"""History objects for representing demography :math:`\eta(t)` and MuSH
:math:`\boldsymbol\mu(t)`.
A base class :class:`mushi.histories.History` is defined, from which
:class:`mushi.eta` and :class:`mushi.mu` are derived and exposed
at package level.
"""
from typing import List
import numpy as np
import matplotlib ... | harrispopgen/mushi | mushi/histories.py | .py | 1cd08fd8aa4b43f1 | 7.72 | 27 |
r"""Optimization algorithms.
An abstract base class :class:`mushi.optimization.Optimizer` is defined, from
which concrete optimization classes are derived (perhaps with intermediate
abstraction).
"""
import abc
import numpy as np
from typing import Callable, Tuple
import prox_tv as ptv
from scipy.linalg import choles... | harrispopgen/mushi | mushi/optimization.py | .py | febbfa5dfa2420f4 | 7.72 | 27 |
r"""Utility functions."""
import numpy as onp
import jax.numpy as np
from typing import List
def C(n: int) -> np.ndarray:
r"""The combinatorial matrix :math:`\mathbf C` defined in the paper's
appendix.
Args:
n: the number of sampled haplotypes :math:`n`
Returns:
:math:`(n-1)\times(n... | harrispopgen/mushi | mushi/utils.py | .py | 31f5fbeff1bc60d9 | 7.72 | 27 |
#! /usr/bin/env python
import unittest
import numpy as np
import mushi
from mushi import utils
class TestMushi(unittest.TestCase):
def test_constant_history(self):
u"""test expected SFS under constant demography and mutation rate
against the analytic formula from Fu (1995)
"""
n =... | harrispopgen/mushi | tests/test_mushi.py | .py | 44e66b8f00487288 | 8.22 | 27 |
from __future__ import annotations
import typing
class CLVMStorage(typing.Protocol):
# It's not clear if it is possible to express the exclusivity without maybe
# restructuring all the classes, such as having a separate instance for each
# of the atom and pair cases and hinting a union of a protocol of e... | Chia-Network/clvm | clvm/CLVMObject.py | .py | 99262b8d20d56a2c | 7.98 | 89 |
from __future__ import annotations
import io
import typing
import typing_extensions
from .as_python import as_python
from .CLVMObject import CLVMObject, CLVMStorage
from .EvalError import EvalError
from .casts import (
int_from_bytes,
int_to_bytes,
)
from .serialize import sexp_to_stream, MAX_SAFE_BYTES
... | Chia-Network/clvm | clvm/SExp.py | .py | 1adf7a86d7dcbfac | 7.98 | 89 |
def int_from_bytes(blob: bytes) -> int:
size = len(blob)
if size == 0:
return 0
return int.from_bytes(blob, "big", signed=True)
def int_to_bytes(v: int) -> bytes:
byte_count = (v.bit_length() + 8) >> 3
if v == 0:
return b""
r = v.to_bytes(byte_count, "big", signed=True)
# m... | Chia-Network/clvm | clvm/casts.py | .py | 62eb3919d5047fee | 7.98 | 89 |
from typing import Callable, Dict, Generic, Optional, Tuple, TypeVar
import hashlib
from .CLVMObject import CLVMStorage
T = TypeVar("T")
class ObjectCache(Generic[T]):
"""
`ObjectCache` provides a way to calculate and cache values for each node
in a clvm object tree. It can be used to calculate the sha... | Chia-Network/clvm | clvm/object_cache.py | .py | 7cde13342e4cb30a | 7.98 | 89 |
from __future__ import annotations
from typing import Dict, Iterator, Optional, Protocol, Tuple, Type, TypeVar, overload
from . import core_ops, more_ops
from .SExp import SExp
from .EvalError import EvalError
from .casts import int_to_bytes
from .op_utils import operators_for_module
from .costs import (
ARITH... | Chia-Network/clvm | clvm/operators.py | .py | d4a7cac801af696f | 7.98 | 89 |
import io
import os
import shlex
import sys
import unittest
from typing import Callable, Iterable, List, Optional, Tuple
import importlib_metadata
# If the REPAIR environment variable is set, any tests failing due to
# wrong output will be corrected. Be sure to do a "git diff" to validate that
# you're getting chang... | Chia-Network/clvm | tests/cmds_test.py | .py | 3532dcec3e9d0db5 | 7.48 | 89 |
import unittest
from typing import Dict
from clvm.operators import OperatorProtocol, OperatorDict
class OperatorDictTest(unittest.TestCase):
def test_operatordict_constructor(self) -> None:
"""Constructing should fail if quote or apply are not specified,
either by object property or by keyword a... | Chia-Network/clvm | tests/operatordict_test.py | .py | 631205d5e7fb0603 | 8.48 | 89 |
import unittest
from typing import Tuple
from clvm.operators import (
OPERATOR_LOOKUP,
KEYWORD_TO_ATOM,
default_unknown_op,
OperatorDict,
)
from clvm.EvalError import EvalError
from clvm.SExp import SExp
from clvm.costs import CONCAT_BASE_COST
class OperatorsTest(unittest.TestCase):
def setUp(sel... | Chia-Network/clvm | tests/operators_test.py | .py | c84a1745d4b93b48 | 7.48 | 89 |
import gzip
import io
import unittest
from typing import Optional
import pytest
from clvm import to_sexp_f
from clvm.SExp import CastableType, SExp
from clvm.serialize import (
MAX_SAFE_BYTES,
_atom_from_stream,
sexp_from_stream,
sexp_buffer_from_stream,
atom_to_byte_iterator,
sexp_to_stream,
... | Chia-Network/clvm | tests/serialize_test.py | .py | db2c7e36f7711bef | 8.48 | 89 |
import unittest
from dataclasses import dataclass
from typing import ClassVar, Optional, TYPE_CHECKING, Tuple, cast
from clvm.SExp import SExp, looks_like_clvm_object, convert_atom_to_bytes
from clvm.CLVMObject import CLVMObject, CLVMStorage
def validate_sexp(sexp: SExp) -> None:
validate_stack = [sexp]
whil... | Chia-Network/clvm | tests/to_sexp_test.py | .py | e9296843e54fb22e | 7.48 | 89 |
from homeassistant.components.binary_sensor import (
BinarySensorEntity,
BinarySensorEntityDescription,
BinarySensorDeviceClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_ON
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.e... | avbor/HomeAssistantConfig | custom_components/auto_backup/binary_sensor.py | .py | 39111a31ada5c6c7 | 7.97 | 85 |
"""Config flow for Auto Backup integration."""
import logging
from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.core import callback, HomeAssistant
from homeassistant.helpers.hassio import is_hassio
from .helpers import is_backup
from .const import DOMAIN, DEF... | avbor/HomeAssistantConfig | custom_components/auto_backup/config_flow.py | .py | 7c74f10114b1480c | 7.97 | 85 |
import asyncio
import logging
import shutil
from dataclasses import asdict
from http import HTTPStatus
from os import getenv
from typing import Dict, List, Optional
import aiofiles
import aiohttp
from aiohttp.hdrs import AUTHORIZATION
from homeassistant.components.backup.manager import BackupManager
try:
from home... | avbor/HomeAssistantConfig | custom_components/auto_backup/handlers.py | .py | ae562b035918a318 | 7.97 | 85 |
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
from homeassistant.components.backup.const import DOMAIN as DOMAIN_BACKUP
from homeassistant.loader import bind_hass
from .const impo... | avbor/HomeAssistantConfig | custom_components/auto_backup/helpers.py | .py | 41908da11ce4fb3f | 7.97 | 85 |
import logging
from datetime import datetime, timedelta, timezone
from fnmatch import fnmatchcase
from os.path import join, isfile
from typing import List, Dict, Tuple, Optional
from homeassistant.components.backup.manager import DATA_MANAGER
try:
from homeassistant.components.hassio.const import ( # HA 2026.5+
... | avbor/HomeAssistantConfig | custom_components/auto_backup/manager.py | .py | 120758a02549bdec | 7.97 | 85 |
"""Bodymiscale entity module."""
from homeassistant.const import CONF_NAME
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.helpers.typing import UNDEFINED
from .const import DOMAIN, VERSION
from .metric... | avbor/HomeAssistantConfig | custom_components/bodymiscale/entity.py | .py | 6853721c4c6f01b6 | 7.97 | 85 |
"""Body score module."""
from collections import namedtuple
from collections.abc import Mapping
from datetime import datetime
from typing import Any
from homeassistant.helpers.typing import StateType
from ..const import (
CONF_GENDER,
CONF_HEIGHT,
CONF_IMPEDANCE_MODE,
CONF_SCALE,
IMPEDANCE_MODE_D... | avbor/HomeAssistantConfig | custom_components/bodymiscale/metrics/body_score.py | .py | 4762258848c25fc9 | 7.97 | 85 |
"""Body scale module."""
from functools import cached_property
from typing import ClassVar
from ..models import Gender
class Scale:
"""Scale implementation."""
# Fat% table: [very low, low, normal, high] by age range / gender
_FAT_SCALES: ClassVar[list[tuple[int, int, list[float], list[float]]]] = [
... | avbor/HomeAssistantConfig | custom_components/bodymiscale/metrics/scale.py | .py | d069116f505a9359 | 7.97 | 85 |
"""Metrics module — weight-based calculations (no impedance required).
Three distinct modes:
XIAOMI :
BMR : exact Zepp Life formula.
Visceral : exact Zepp Life formula.
SCIENCE :
BMR : Schofield equation (official WHO standard).
Visceral : Zepp Life formula (no validated WHO alternative... | avbor/HomeAssistantConfig | custom_components/bodymiscale/metrics/weight.py | .py | 4108ee86790b86ee | 7.97 | 85 |
"""Models module."""
from enum import StrEnum
from .const import (
ATTR_AGE,
ATTR_BCM,
ATTR_BMI,
ATTR_BMR,
ATTR_BODY,
ATTR_BODY_SCORE,
ATTR_BONES,
ATTR_ECW_TBW_RATIO,
ATTR_EXTRACELLULAR_WATER,
ATTR_FAT,
ATTR_INTRACELLULAR_WATER,
ATTR_LAST_MEASUREMENT_TIME,
ATTR_LBM,... | avbor/HomeAssistantConfig | custom_components/bodymiscale/models.py | .py | c1ace8ee07388940 | 7.97 | 85 |
"""Util module."""
from collections.abc import Mapping
from datetime import datetime
from typing import Any
from .const import CONF_GENDER, CONF_HEIGHT
from .models import Gender
def check_value_constraints(value: float, minimum: float, maximum: float) -> float:
"""Set the value to a boundary if it overflows.""... | avbor/HomeAssistantConfig | custom_components/bodymiscale/util.py | .py | 3832a7427c47f8d4 | 7.97 | 85 |
"""Adds config flow for Frigate."""
from __future__ import annotations
import logging
from typing import Any
import voluptuous as vol
from voluptuous.validators import All, Range
from yarl import URL
from homeassistant import config_entries
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
from... | avbor/HomeAssistantConfig | custom_components/frigate/config_flow.py | .py | bee8058d9514ebea | 7.97 | 85 |
"""Diagnostics support for Frigate."""
from __future__ import annotations
from typing import Any
from homeassistant.components.diagnostics import async_redact_data
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from .const import ATTR_CLIENT, ATTR_CONFIG, CONF_PASS... | avbor/HomeAssistantConfig | custom_components/frigate/diagnostics.py | .py | 8f5be9ea737baf5b | 7.97 | 85 |
"""Support for Frigate images."""
from __future__ import annotations
import datetime
import logging
from typing import Any
from titlecase import titlecase
from homeassistant.components.image import ImageEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_URL
from homeass... | avbor/HomeAssistantConfig | custom_components/frigate/image.py | .py | 04dbd31d0dba83ee | 7.97 | 85 |
"""LLM API for Frigate integration."""
from __future__ import annotations
import logging
from typing import Any
import voluptuous as vol
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, llm
from homeassistant.util.json import JsonObjectType
from .api import Fr... | avbor/HomeAssistantConfig | custom_components/frigate/llm_functions.py | .py | cb27797732fd879e | 7.97 | 85 |
"""Select platform for frigate."""
from __future__ import annotations
import logging
from typing import Any
from homeassistant.components.mqtt import async_publish
from homeassistant.components.select import SelectEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_URL
fr... | avbor/HomeAssistantConfig | custom_components/frigate/select.py | .py | 6d75026c254e6083 | 7.97 | 85 |
"""Sensor platform for frigate."""
from __future__ import annotations
import logging
from typing import Any
from titlecase import titlecase
from homeassistant.components.mqtt import async_publish
from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homea... | avbor/HomeAssistantConfig | custom_components/frigate/switch.py | .py | d6cab947e6b4b009 | 7.97 | 85 |
"""Update platform for frigate."""
from __future__ import annotations
import logging
from homeassistant.components.update import UpdateEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_URL
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity im... | avbor/HomeAssistantConfig | custom_components/frigate/update.py | .py | ae48ef90514122a3 | 7.97 | 85 |
"""Frigate MQTT to WebSocket proxy."""
from __future__ import annotations
from abc import ABC
import logging
from homeassistant.components import websocket_api
from homeassistant.components.mqtt.models import ReceiveMessage
from homeassistant.components.mqtt.subscription import (
EntitySubscription,
async_pr... | avbor/HomeAssistantConfig | custom_components/frigate/ws_proxy.py | .py | 855f8763191def28 | 7.97 | 85 |
import json
import logging
import hashlib
from urllib.request import Request
import urllib
import cfnresponse
import boto3
LOGGER = logging.getLogger()
LOGGER.setLevel(logging.INFO)
API_CALL_SOURCE_HEADER_VALUE = "cfn-iam-permissions"
CHUNK_SIZE = 150 # Maximum number of IAM permissions per customer managed policy
BA... | DataDog/cloudformation-template | aws_attach_integration_permissions/attach_integration_permissions.py | .py | 179c74efcb55bfab | 7.84 | 47 |
#!/usr/bin/env python3
import json
import sys
import unittest
from unittest.mock import patch, Mock, MagicMock, call
from urllib.error import HTTPError
from urllib.parse import urlparse, parse_qsl
from io import BytesIO
if "boto3" not in sys.modules:
sys.modules["boto3"] = MagicMock()
if "cfnresponse" not in sys.... | DataDog/cloudformation-template | aws_organizations/attach_integration_permissions_test.py | .py | bcfb934825504fc5 | 7.34 | 47 |
#!/usr/bin/env python3
import json
import sys
import unittest
from types import SimpleNamespace
from unittest.mock import patch, Mock, MagicMock
from urllib.error import HTTPError
# boto3 is available in Lambda runtime but not necessarily in CI.
# Insert a mock module so the lazy import inside ensure_security_audit_p... | DataDog/cloudformation-template | aws_quickstart/datadog_agentless_api_call_test.py | .py | 2abb5e73a33b8d61 | 7.34 | 47 |
# This script checks changed GRIB2_CodeFlag_.*_CodeTable_en.csv files.
# It validates changed CodeFlag values as either:
# - numeric values (<192 or 255 with MeaningParameterDescription_en='Missing')
# - numeric ranges (e.g. 192-254)
import re
import sys
import csv
import subprocess
def get_changed_files():
""... | wmo-im/GRIB2 | .github/scripts/check_code_flag_ranges.py | .py | 80871cb45b7a8cc9 | 7.78 | 35 |
import gzip
import json
import os
import secrets
import shutil
from datetime import datetime
from pathlib import Path
from unicodedata import normalize
import pandas as pd
from slugify import slugify
def check_has_enough_disk_space():
"""
Check if the machine has enough disk space to continue.
"""
# ... | ResearchHub/researchhub-backend | scripts/backfill_openalex.py | .py | e537e0b9f7bb0cec | 7.84 | 47 |
from ai_peer_review.models import ProposalReview, RFPSummary
from ai_peer_review.services.report_access import (
is_editor_or_moderator,
user_can_view_proposal_review,
user_can_view_rfp_summary,
)
from utils.permissions import AuthorizationBasedPermission
class AIPeerReviewPermission(AuthorizationBasedPer... | ResearchHub/researchhub-backend | src/ai_peer_review/permissions.py | .py | fbf4ebcfb2fed5a8 | 7.84 | 47 |
import contextlib
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from django.utils import timezone
from ai_peer_review.constants import (
AUTO_KI_DAILY_CAP_PER_REVIEW_DEFAULT,
... | ResearchHub/researchhub-backend | src/ai_peer_review/services/auto_run_guards.py | .py | 443c2064e87421d9 | 7.84 | 47 |
import json
import re
from ai_peer_review.constants import CATEGORY_ITEMS, CATEGORY_KEYS, CRITICAL_FAIL_ITEMS
from ai_peer_review.models import OverallRating
def parse_json_response(text: str) -> dict:
text = text.strip()
try:
return json.loads(text)
except json.JSONDecodeError:
pass
... | ResearchHub/researchhub-backend | src/ai_peer_review/services/proposal_review_scoring.py | .py | 400fb0c3b171b6a1 | 7.84 | 47 |
from unittest.mock import patch
from django.test import SimpleTestCase
from ai_peer_review.tasks import process_proposal_review_task, process_rfp_summary_task
class AIPeerReviewTaskTests(SimpleTestCase):
# Patch names on ``tasks`` — that module binds ``run_*`` at import time, so
# patching ``services.*.run_... | ResearchHub/researchhub-backend | src/ai_peer_review/tests/test_tasks.py | .py | ff4cb7f84dd1cbe4 | 7.34 | 47 |
#!/usr/bin/env python
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2013, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must ... | NASA-AMMOS/AIT-Core | ait/core/bin/ait_seq_send.py | .py | 378bcdab2603255f | 7.87 | 54 |
#!/usr/bin/env python
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2013, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must ... | NASA-AMMOS/AIT-Core | ait/core/bin/ait_yaml_validate.py | .py | 62d642e5cc0f642b | 7.87 | 54 |
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2017, by the California Institute of Technology. ALL
# RIGHTS RESERVED. United States Government Sponsorship
# acknowledged. Any commercial use must be negotiated with th... | NASA-AMMOS/AIT-Core | ait/core/ccsds.py | .py | 3e86fecbbdb62dc4 | 7.87 | 54 |
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2013, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the... | NASA-AMMOS/AIT-Core | ait/core/cfg.py | .py | 555bc06616d5baaa | 7.87 | 54 |
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2013, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the... | NASA-AMMOS/AIT-Core | ait/core/cmd.py | .py | aa4790b595ed72cc | 7.87 | 54 |
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2013, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the... | NASA-AMMOS/AIT-Core | ait/core/coord.py | .py | 2e6a652964b2258b | 7.87 | 54 |
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2013, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the... | NASA-AMMOS/AIT-Core | ait/core/dmc.py | .py | a54ec429088b407c | 7.87 | 54 |
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2015, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the... | NASA-AMMOS/AIT-Core | ait/core/evr.py | .py | 93a0c0abe0007cf4 | 7.87 | 54 |
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2013, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the... | NASA-AMMOS/AIT-Core | ait/core/gds.py | .py | 964b52179b68e9ce | 7.87 | 54 |
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2017, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the... | NASA-AMMOS/AIT-Core | ait/core/json.py | .py | dd2385d744ceca16 | 7.87 | 54 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.