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 |
|---|---|---|---|---|---|---|
"""Factory functions for creating UQ test function instances.
This module provides utilities for generating callable factories that
instantiate UQTestFun objects from their specifications and metadata.
The factory pattern allows dynamic creation of test functions
with configurable dimensions, input configurations,
and... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/registry/factory.py | .py | f7a37394284332ee | 8.04 | 11 |
"""Parser for the 'evaluate' section of test function YAML specification files.
This module provides functionality to parse and validate the 'evaluate' field
from YAML specification files, constructing CallableSpec objects that identify
the evaluation functions for UQ test functions.
"""
from pathlib import Path
from... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/registry/parser/evaluate.py | .py | 8bf2dfb1a559dda5 | 7.04 | 11 |
"""Parser for the 'inputs' section in the YAML specifications.
This module provides functionality to parse and validate probabilistic input
specifications from YAML specification files. It processes marginal
distributions defined as lists, templates, or factory references,
and supports input redirection to external YA... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/registry/parser/inputs.py | .py | 2e1455c0876990e7 | 8.04 | 11 |
"""Parser for the parameters section in the YAML specifications.
This module provides functionality to parse and validate parameter sets
from YAML configuration files. It processes parameter specifications,
resolves factory references for dynamically created parameter values,
and handles generic parameter values inclu... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/registry/parser/parameters.py | .py | 5be4a60caed67519 | 7.04 | 11 |
from pathlib import Path
from typing import Callable, Dict
import yaml
from uqtestfuns.core.registry.entries import (
UQTestFunInfo,
UQTestFunSpec,
KeywordInfo,
)
from .evaluate import parse_evaluate
from .inputs import parse_inputs
from .parameters import parse_parameters
from .utils import safe_load
fro... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/registry/parser/spec_file.py | .py | 215fce554a7d7b2f | 8.04 | 11 |
"""Utility functions for parsing YAML specification files.
This module provides helper functions for loading, parsing, and resolving
values from YAML specification files used to define UQ test functions. It
includes utilities for:
- Safe loading of YAML files
- Resolving generic and numeric values with support for ma... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/registry/parser/utils.py | .py | bf44a14d725493b9 | 8.04 | 11 |
"""Validation utilities for YAML specification parsing.
This module provides validation functions for YAML specification files used
in the UQTestFuns registry system. It includes validators for marginal
distributions, callable string references, and general dictionary structure
validation with required keys.
"""
impo... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/registry/parser/validation.py | .py | 29d1c41f19d1920b | 8.04 | 11 |
"""Registry system for UQ test function metadata.
This module provides the Registry class which manages a collection of UQ
(Uncertainty Quantification) test function specifications. The registry loads
and stores metadata about test functions from YAML specification files,
providing a centralized catalog for function d... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/registry/registry.py | .py | f0adae2c2de718fd | 8.04 | 11 |
"""Resolution utilities for UQ test function specifications.
This module provides functions to resolve parsed specifications into
concrete runtime objects. It handles dynamic imports of callables,
construction of probabilistic input objects from various marginal
representations, and parameter object creation with supp... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/registry/resolver.py | .py | ed9843243655479e | 8.04 | 11 |
"""Specifications for callable objects in the registry.
This module contains dataclass specifications used for registering and
managing callable objects in the UQTestFuns registry system.
"""
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Union
@dataclass(frozen=True)
class Callable... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/registry/specs.py | .py | 65c06d33052f9c5b | 8.04 | 11 |
"""Module containing the concrete implementation of UQ test functions.
This module provides the UQTestFun class, which encapsulates an evaluation
function, a probabilistic input model, and optional parameters into a single
callable object for uncertainty quantification test functions.
"""
import numpy as np
from typ... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/uqtestfun.py | .py | facdd1a12cf1a003 | 8.04 | 11 |
"""
Utility module for all the UQ test functions.
"""
from .prob_input.marginal import Marginal
from .prob_input.probabilistic_input import ProbInput
def create_canonical_uniform_input(
input_dimension: int, min_value: float, max_value: float
) -> ProbInput:
"""Create a MultivariateInput in a canonical domai... | damar-wicaksono/uqtestfuns | src/uqtestfuns/core/utils.py | .py | cb358320b8c9cdff | 7.04 | 11 |
"""
Module providing high-level helper functions.
Notes
-----
- High-level functions typically contain many guardrails against invalidity
of the input arguments.
"""
from tabulate import tabulate as tbl # 'tabulate' is used as a parameter name
from .utils import get_available_classes, SUPPORTED_TAGS
from . import ... | damar-wicaksono/uqtestfuns | src/uqtestfuns/helpers.py | .py | 5a862fe5cdc8a880 | 8.04 | 11 |
"""
This module contains a collection of the default basis functions
for the meta.
"""
import numpy as np
__all__ = ["BASIS_BY_ID"]
def linear(xx: np.ndarray) -> np.ndarray:
"""Compute the linear function on a set of 1-dimensional points."""
return xx
def quadratic(xx: np.ndarray) -> np.ndarray:
"""Co... | damar-wicaksono/uqtestfuns | src/uqtestfuns/meta/basis_functions.py | .py | eb70784b415c3797 | 7.04 | 11 |
"""
This module contains the classes that implement specification
for a meta and the resulting test function.
"""
import numpy as np
import itertools
from dataclasses import dataclass, field, InitVar
from scipy.special import comb
from typing import Dict, Callable, Tuple, Optional, Union, List
from ..core import Marg... | damar-wicaksono/uqtestfuns | src/uqtestfuns/meta/metaspec.py | .py | e4875bbe47c1e78a | 8.04 | 11 |
"""
This module contains the implementation of the meta in UQTestFuns.
The implementation is based on the meta proposed in [1].
To further specify the meta, a set of default parameter values
according to [1] is also implemented.
References
----------
1. William Becker, “Metafunctions for benchmarking in sensitivity ... | damar-wicaksono/uqtestfuns | src/uqtestfuns/meta/uqmetatestfun.py | .py | 9413fe04d282b11e | 8.04 | 11 |
from pathlib import Path
from textwrap import dedent
from unittest.mock import mock_open
from hypernode.downloader.main import replace_images_with_local_variants
from tests.testcase import HypernodeTestCase
class TestReplaceImagesWithLocalVariants(HypernodeTestCase):
def setUp(self) -> None:
module = "hy... | ByteInternet/hypernode-docs-next | tests/downloader/main/test_replace_images_with_local_variants.py | .py | f466a7dc31335762 | 7.06 | 12 |
from __future__ import annotations
import asyncio
from asyncio.events import AbstractEventLoop
from collections.abc import Callable, Coroutine, Iterator
from functools import partial
from signal import SIGINT, SIGTERM, Signals
from sys import stderr
from typing import TYPE_CHECKING
from aiostream import stream
from a... | lmmx/range-streams | src/range_streams/async_utils.py | .py | e0281949a5d68c55 | 7.52 | 10 |
from __future__ import annotations
from struct import calcsize
from ranges import Range
__all__ = ["PngData"]
class SimpleDataClass:
"""
Provide a neat repr and common methods for the classes which become instance
attributes of :class:`PngData`.
(Note: Duplicate of the zip codec class of the same ... | lmmx/range-streams | src/range_streams/codecs/png/data.py | .py | 7c278028f260a2b7 | 7.52 | 10 |
from __future__ import annotations
__all__ = ["PaethPredictor"]
def reconstruct_idat(
idat_bytes: bytes,
channels: int,
height: int,
width: int,
) -> list[int]: # pragma: no cover
"""
Parse a list of (zlib-decompressed) bytes into a flat list of integers (the pixel
values), validating th... | lmmx/range-streams | src/range_streams/codecs/png/reconstruct.py | .py | b807e96404b28d0c | 7.52 | 10 |
from __future__ import annotations
import struct
import zlib
from ranges import Range
from ...stream import RangeStream
from .data import PngChunkInfo, PngData
from .reconstruct import reconstruct_idat
__all__ = ["PngStream"]
class PngStream(RangeStream):
"""
As for RangeStream, but if `scan_ihdr` is True... | lmmx/range-streams | src/range_streams/codecs/png/stream.py | .py | 017df86c8f8e447c | 7.52 | 10 |
from __future__ import annotations
from struct import calcsize
__all__ = ["TarData"]
class SimpleDataClass:
"""
Provide a neat repr and common methods for the classes which become instance
attributes of :class:`TarData`.
"""
def __repr__(self):
attrs = {
k: getattr(self, k)
... | lmmx/range-streams | src/range_streams/codecs/tar/data.py | .py | cbbb315e159ec4c9 | 7.52 | 10 |
from __future__ import annotations
from ranges import Range
from ...stream import RangeStream
from .data import TarData
__all__ = ["TarStream", "TarredFileInfo"]
class TarStream(RangeStream):
"""
As for :class:`~range_streams.stream.RangeStream`, but if ``scan_headers``
is ``True``, then immediately ca... | lmmx/range-streams | src/range_streams/codecs/tar/stream.py | .py | e594f6b01a7357b5 | 7.52 | 10 |
r"""When preparing a HTTP GET request, the HTTP `range request
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests>`_
header must be provided as a :class:`dict`, for example:
.. code-block:: python
{"range": "bytes=0-1"}
would request the two bytes at positions ``0`` and ``1`` (i.e. the inclusive
i... | lmmx/range-streams | src/range_streams/http_utils.py | .py | 1292dfa1d0db7cff | 7.52 | 10 |
from __future__ import annotations
from typing import TYPE_CHECKING
from .range_utils import range_termini
if TYPE_CHECKING: # pragma: no cover
from ranges import Range, RangeDict
__all__ = ["get_range_containing", "overlap_whence"]
# This could be written more clearly by using a range_utils helper function... | lmmx/range-streams | src/range_streams/overlaps.py | .py | 52e00505c0247f06 | 7.52 | 10 |
from __future__ import annotations
__all__ = [
"ALWAYS_SET_TOLD",
"most_recent_range",
"range_len",
"range_max",
"range_min",
"range_span",
"range_termini",
"ranges_in_reg_order",
"response_ranges_in_reg_order",
"validate_range",
]
from typing import TYPE_CHECKING
if TYPE_CHEC... | lmmx/range-streams | src/range_streams/range_utils.py | .py | 8083b21ef050a041 | 7.52 | 10 |
from __future__ import annotations
from collections.abc import AsyncIterator, Iterator
from typing import TYPE_CHECKING
MYPY = False # when using mypy will be overrided as True
if MYPY or not TYPE_CHECKING: # pragma: no cover
import httpx # avoid importing to Sphinx type checker
from ranges import Range
from... | lmmx/range-streams | src/range_streams/request.py | .py | 16e90316189f92c1 | 7.52 | 10 |
import asyncio
from signal import SIGINT
from pytest import mark, raises
from range_streams import _EXAMPLE_PNG_URL, _EXAMPLE_ZIP_URL, RangeStream
from range_streams.async_utils import AsyncFetcher
from range_streams.codecs import PngStream
from .data import EXAMPLE_SMALL_PNG_URL, EXAMPLE_URL
# https://tonybaloney.... | lmmx/range-streams | tests/async_test.py | .py | 8a7e2796e99c32c9 | 8.02 | 10 |
from pytest import fixture
from ranges import Range
from range_streams import RangeStream
from .data import EXAMPLE_FILE_LENGTH, EXAMPLE_URL
from .share import client
@fixture
def empty_range_stream():
"""
By default, not passing the `byte_range` param to `RangeStream` will give the
empty `Range(0,0)`. ... | lmmx/range-streams | tests/conftest.py | .py | e4fe22d7ad367b08 | 7.02 | 10 |
from pytest import mark, raises
from ranges import Range
from range_streams.overlaps import get_range_containing
from range_streams.range_utils import (
ranges_in_reg_order,
response_ranges_in_reg_order,
)
from .range_stream_core_test import (
make_range_stream,
)
from .share import client
@mark.paramet... | lmmx/range-streams | tests/overlaps_test.py | .py | f2dc0c08f401d183 | 8.02 | 10 |
from pytest import mark, raises
from ranges import Range
from range_streams import RangeStream
from range_streams.range_utils import ranges_in_reg_order
from .data import EXAMPLE_FILE_LENGTH
from .range_stream_core_test import (
make_range_stream,
)
from .share import client
def test_overlapping_ranges(empty_ra... | lmmx/range-streams | tests/range_stream_edge_case_test.py | .py | 19e2c334f650adf8 | 7.02 | 10 |
from pytest import fixture, mark, raises
from ranges import Range
from range_streams import RangeStream
from .data import EXAMPLE_URL
from .share import client
@fixture(scope="session")
def monostream():
"""
By default, not passing the ``byte_range`` param to
:class:`~range_streams.stream.RangeStream` w... | lmmx/range-streams | tests/range_stream_mono_test.py | .py | e5f18c803736b111 | 8.02 | 10 |
from io import SEEK_END, SEEK_SET
import httpx
from pytest import fixture, mark, raises
from ranges import Range
from range_streams.request import RangeRequest
from range_streams.response import RangeResponse
from range_streams.stream import RangeStream
from .data import EXAMPLE_FILE_LENGTH, EXAMPLE_URL
# from .req... | lmmx/range-streams | tests/response_test.py | .py | 793729aee9098eb9 | 7.02 | 10 |
from pprint import pprint
import defopt
from .codegen.gen import emit_deserialisers
from .codegen.populate import generate_schema_coverage
from .openapi.fetch import refresh_schema
from .openapi.scan import count_namespace, scan_namespace
def deserialise(schema_name: str) -> None:
"""Map each API schema to a co... | lmmx/tubeulator | src/tubeulator/cli.py | .py | 440e7f73b02bf6d6 | 7.45 | 7 |
import ast
import textwrap
from itertools import starmap
from typing import Literal
from ...openapi.scan import scan_namespace
from ...utils.paths import SchemaPath
from ...utils.schemas import load_endpoint_component_schemas
from ...utils.string_conv import to_pascal_case
from .jsonschema import python_type
from .res... | lmmx/tubeulator | src/tubeulator/codegen/gen/dto.py | .py | 7a441323b6d34b91 | 7.45 | 7 |
"""Functions for the unique resolution of schema identifiers."""
from ...utils.lcp_trie import Trie
from ...utils.paths import SchemaPath
__all__ = [
"find_backrefs",
"find_string_literals",
"find_array_literals",
"find_chased",
"find_arrays",
]
def find_backrefs(monoschema: dict) -> dict[str, S... | lmmx/tubeulator | src/tubeulator/codegen/gen/resolution.py | .py | 24942f1d087bcdfa | 7.45 | 7 |
"""TinyDB implementation for credential storage."""
import os
from functools import lru_cache
from pydantic import BaseModel, Field, ValidationError
from tinydb import TinyDB
from ..utils.logs import set_up_logging
from ..utils.paths import db_path
__all__ = ["check_creds"]
logger = set_up_logging(__name__)
clas... | lmmx/tubeulator | src/tubeulator/db/store_creds.py | .py | ceca681c1ab53ca1 | 7.45 | 7 |
from __future__ import annotations
import json
from datetime import datetime
from dataclasses import dataclass, field
from tubeulator.utils.string_conv import to_camel_case
from pydantic import AliasGenerator, BaseModel, ConfigDict, PrivateAttr
from ..utils.paths import DtoEnum
class Object(BaseModel):
"""
Aut... | lmmx/tubeulator | src/tubeulator/generated/AirQuality.py | .py | f8ad4b432907d152 | 7.45 | 7 |
from __future__ import annotations
import json
from datetime import datetime
from dataclasses import dataclass, field
from tubeulator.utils.string_conv import to_camel_case
from pydantic import AliasGenerator, BaseModel, ConfigDict, PrivateAttr
from ..utils.paths import DtoEnum
class LiftDisruption(BaseModel):
"""... | lmmx/tubeulator | src/tubeulator/generated/DisruptionsLiftsv2.py | .py | daec5d5af06b522c | 7.45 | 7 |
from __future__ import annotations
import json
from datetime import datetime
from dataclasses import dataclass, field
from tubeulator.utils.string_conv import to_camel_case
from pydantic import AliasGenerator, BaseModel, ConfigDict, PrivateAttr
from ..utils.paths import DtoEnum
class PredictionTiming(BaseModel):
"... | lmmx/tubeulator | src/tubeulator/generated/Vehicle.py | .py | bdfdae3e9fb2718e | 7.45 | 7 |
import hashlib
import os
class InvalidChecksumLine(Exception):
pass
class NoDifferException(Exception):
pass
class ChecksumMismatch(Exception):
pass
class ChecksumFile:
"""
Slurp a checksum file and be able to check and compare its contents to a
given root directory. Also: be able to wri... | ansible/ansible-sign | src/ansible_sign/checksum/base.py | .py | a2901729a37698d5 | 7.62 | 16 |
import os
from pathlib import PurePath
class ChecksumFileExistenceDiffer:
"""
When checking checksum files, it can be important to ensure not only that
the files listed have correct hashes, but that no files were added that
are not listed.
This is particularly important in situations where files ... | ansible/ansible-sign | src/ansible_sign/checksum/differ/base.py | .py | 83b74693a4601469 | 7.62 | 16 |
from distlib.manifest import Manifest
import errno
import os
from .base import ChecksumFileExistenceDiffer
class DistlibManifestChecksumFileExistenceDiffer(ChecksumFileExistenceDiffer):
"""
Read in a MANIFEST.in file and process it. Use the results for comparing
what is listed in the checksum file with w... | ansible/ansible-sign | src/ansible_sign/checksum/differ/distlib_manifest.py | .py | 76b95ff965357c67 | 7.62 | 16 |
"""
Fixtures for ansible-sign tests
"""
import fileinput
import gnupg
import libtmux
import os
from pathlib import Path
import pytest
import shutil
from ansible_sign.signing import GPGSigner
if gnupg.__version__ >= "1.0":
# https://stackoverflow.com/q/35028852/99834
pytest.exit(
"Unsupported gnupg l... | ansible/ansible-sign | tests/conftest.py | .py | 0d7624050463e1bf | 7.12 | 16 |
import os
import pytest
from ansible_sign.checksum import (
ChecksumFile,
InvalidChecksumLine,
ChecksumMismatch,
DistlibManifestChecksumFileExistenceDiffer,
)
__author__ = "Rick Elrod"
__copyright__ = "(c) 2022 Red Hat, Inc."
__license__ = "MIT"
FIXTURES_DIR = os.path.join(
os.path.dirname(os.pa... | ansible/ansible-sign | tests/test_checksum.py | .py | 38b945e64321be47 | 7.12 | 16 |
import os
import sys
import pytest
from ansible_sign.cli import main
__author__ = "Rick Elrod"
__copyright__ = "(c) 2022 Red Hat, Inc."
__license__ = "MIT"
IS_GITHUB_ACTION_MACOS = (
sys.platform == "darwin" and os.environ.get("CI", "false") == "true"
)
@pytest.mark.parametrize(
"args, exp_stdout_substr, ex... | ansible/ansible-sign | tests/test_cli.py | .py | 2a9ff4c2afa0dd78 | 7.12 | 16 |
import pytest
import sys
import time
__author__ = "Rick Elrod"
__copyright__ = "(c) 2022 Red Hat, Inc."
__license__ = "MIT"
# On MacOS the is a dialog popup asking for password, not a console prompt.
@pytest.mark.skipif(
sys.platform == "darwin", reason="Interactive test not working on MacOS"
)
def test_pinentry... | ansible/ansible-sign | tests/test_cli_pinentry.py | .py | 8d3bcf64d9323286 | 7.12 | 16 |
import os
from typing import Dict, List, Optional
import dagster as dg
# Imports
from . import resources
from .assets.archiving import build_archiving_asset
from .assets.assessment import build_assess_sequence_asset
from .assets.get_sequences import build_target_sequences_asset
from .assets.transcode_retry import bui... | bfidatadigipres/dpx_encoding | bfi_dagster_project/__init__.py | .py | 6e90f591f6cb4705 | 7.6 | 15 |
import datetime
import os
import shutil
import tarfile
import time
from pathlib import Path
from typing import Any, Dict, List, Optional
import dagster as dg
from . import utils
def build_archiving_asset(key_prefix: Optional[str] = None):
"""
New factory function that returns the asset with optional key pre... | bfidatadigipres/dpx_encoding | bfi_dagster_project/assets/archiving.py | .py | 4a957f188f5953b7 | 7.6 | 15 |
import os
from typing import List, Optional
import dagster as dg
def build_target_sequences_asset(key_prefix: Optional[str] = None):
"""Factory function that returns the asset with optional key prefix."""
# Build the asset key with optional prefix
asset_key = (
[f"{key_prefix}", "target_sequence... | bfidatadigipres/dpx_encoding | bfi_dagster_project/assets/get_sequences.py | .py | a85d2906aa34435b | 7.6 | 15 |
import cmd
import datetime
import os
import shutil
import subprocess
import time
from pathlib import Path
from typing import List, Optional
import dagster as dg
from . import utils
def build_transcode_retry_asset(key_prefix: Optional[str] = None):
"""
New factory function that returns the asset with key pre... | bfidatadigipres/dpx_encoding | bfi_dagster_project/assets/transcode_retry.py | .py | c0b5543227e8d838 | 7.6 | 15 |
import datetime
import os
import shutil
import subprocess
import time
from pathlib import Path
from typing import Any, Dict, List, Optional
import dagster as dg
from . import utils
def build_transcode_ffv1_asset(key_prefix: Optional[str] = None):
"""
New factory function that returns the asset with optional... | bfidatadigipres/dpx_encoding | bfi_dagster_project/assets/transcoding.py | .py | e23bbf30ff66a26f | 7.6 | 15 |
#!/usr/bin/env python3
"""
Script to manage transcode of downloaded MKV and DPX files
from Black Pearl, but for use by film ops teams (with an aim
to allow them an option that avoids using DPI downloader).
Joanna White
2023
"""
import logging
import os
import re
import shutil
import subprocess
from pathlib import Pa... | bfidatadigipres/dpx_encoding | cron_code/filmops_transcode_prores.py | .py | 92c6c1d220471a9b | 7.6 | 15 |
import os
import sqlite3
import sys
import pandas as pd
import plotly.graph_objects as go
import streamlit as st
def get_data(database):
"""
Fetch file size data from encoding_database
"""
conn = sqlite3.connect(database)
query = "SELECT seq_id, seq_size, derivative_size FROM encoding_status WHER... | bfidatadigipres/dpx_encoding | visuals/app.py | .py | 1721fc24d324cba9 | 7.6 | 15 |
#!/usr/bin/env python3
import sys
import rclpy
from rclpy.node import Node
from geometry_msgs.msg import Twist, TwistStamped
from std_msgs.msg import String, Header
import beamngpy as bngpy
from beamng_msgs.msg import VehicleControl, DroneControl, StateSensor
from beamng_msgs.srv import VehicleCommand, SetControlMode
... | BeamNG/beamng-ros2-integration | beamng_agent/beamng_agent/beamng_agent.py | .py | f310109edfdb47c9 | 7.65 | 19 |
#!/usr/bin/env python3
import sys
import time
import rclpy
from rclpy.node import Node
from beamng_msgs.msg import DroneControl
from beamng_msgs.srv import SetControlMode
import beamngpy as bngpy
from pathlib import Path
NODE_NAME = "beamng_drone_controller"
class DroneControllerNode(Node):
"""ROS2 node for con... | BeamNG/beamng-ros2-integration | beamng_agent/beamng_agent/drone_controller.py | .py | 213d6a4fd42177d4 | 7.65 | 19 |
"""
A minimal working example client which uses the StartScenario service of the BeamNGBridge node
to spawn the default scenario (``/config/scenarios/example_tech_ground.json``).
"""
import rclpy
from beamng_msgs.srv import StartScenario
from rclpy.node import Node
class ExampleClientAsync(Node):
def __init__(se... | BeamNG/beamng-ros2-integration | beamng_ros2/beamng_ros2/examples/example_client.py | .py | 1ef7cdb8daf4c2e7 | 7.65 | 19 |
from typing import List, Type
from beamng_ros2.utils import xyz_to_point, xyz_to_vec3, xyzw_to_quat
from beamngpy import BeamNGpy
from geometry_msgs.msg import Pose
from rclpy.time import Duration, Time
from std_msgs.msg import ColorRGBA
from visualization_msgs.msg import Marker, MarkerArray
from .base import BeamNGP... | BeamNG/beamng-ros2-integration | beamng_ros2/beamng_ros2/publishers/road_network.py | .py | 6390ab54fe6d9f6a | 7.65 | 19 |
#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from beamng_msgs.msg import DroneControl
import sys, select, os
if os.name == "nt":
import msvcrt
else:
import tty, termios
DRONE_MAX_ASCEND = 1.0
DRONE_MAX_DESCEND = 1.0
DRONE_MAX_PITCH = 1.0
DRONE_MAX_ROLL = 1.0
DRONE_MAX_YAW = 1.0
STEP_SIZE... | BeamNG/beamng-ros2-integration | beamng_teleop_keyboard/beamng_teleop_keyboard/drone_teleop.py | .py | 8eb71fa292b8ff4c | 7.65 | 19 |
#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from geometry_msgs.msg import Twist, TwistStamped
from std_msgs.msg import Float64MultiArray, Header
from beamng_msgs.msg import DroneControl
class DroneController(Node):
"""
ROS2 drone controller node that converts velocity commands to drone c... | BeamNG/beamng-ros2-integration | drone_controller/drone_controller/drone_controller.py | .py | 62392dd6733b6160 | 7.65 | 19 |
#!/usr/bin/env python3
"""
Simple PID controller implementation for drone attitude and position control.
"""
class PIDController:
"""
PID (Proportional-Integral-Derivative) controller for drone control.
"""
def __init__(self, kp=1.0, ki=0.0, kd=0.0, min_output=-1.0, max_output=1.0):
"""
... | BeamNG/beamng-ros2-integration | drone_controller/drone_controller/pid_controller.py | .py | 03d183be7e13a825 | 7.65 | 19 |
"""This module contains the main entrypoint functionality to the Causal Testing Framework."""
import argparse
import json
import logging
from enum import Enum
from importlib.metadata import entry_points
from typing import Optional, Sequence
from warnings import warn
import networkx as nx
import pandas as pd
from cau... | CITCOM-project/CausalTestingFramework | causal_testing/__main__.py | .py | 01dd7cf124f2d815 | 8.15 | 19 |
"""
This module implements the abstract Discovery class to infer causal DAGs from data.
"""
import random
import re
import warnings
from abc import ABC, abstractmethod
from itertools import permutations
import networkx as nx
import numpy as np
import pandas as pd
import rustworkx as rx
from causal_testing.causal_tes... | CITCOM-project/CausalTestingFramework | causal_testing/discovery/abstract_discovery.py | .py | adcc656bf22fee4f | 8.15 | 19 |
"""
This module implements a hill climbing algorithm to optimise causal DAGs based on the tests that pass/fail.
"""
import random
import numpy as np
import pandas as pd
from tqdm import tqdm
from causal_testing.discovery.abstract_discovery import Discovery
from causal_testing.specification.causal_dag import CausalDA... | CITCOM-project/CausalTestingFramework | causal_testing/discovery/hill_climber_discovery.py | .py | afe42b4f77f96354 | 8.15 | 19 |
"""
This module implements a multiobjective discovery algorithm in terms of test outcomes.
"""
import numpy as np
import pandas as pd
import pygad
from causal_testing.discovery.abstract_discovery import Discovery
from causal_testing.specification.causal_dag import CausalDAG
class NSGADiscovery(Discovery):
"""
... | CITCOM-project/CausalTestingFramework | causal_testing/discovery/nsga_discovery.py | .py | 87777c99d6431ead | 8.15 | 19 |
"""This module contains the Estimator abstract class"""
import logging
from abc import ABC, abstractmethod
from typing import Any
logger = logging.getLogger(__name__)
class Estimator(ABC):
# pylint: disable=too-many-instance-attributes
"""An estimator contains all of the information necessary to compute a c... | CITCOM-project/CausalTestingFramework | causal_testing/estimation/abstract_estimator.py | .py | de486c12d67e2e73 | 8.15 | 19 |
"""This module contains the RegressionEstimator, which is an abstract class for concrete regression estimators."""
import ast
import logging
from abc import abstractmethod
from typing import Any
import pandas as pd
from patsy import ModelDesc, build_design_matrices, dmatrices # pylint: disable = no-name-in-module
fr... | CITCOM-project/CausalTestingFramework | causal_testing/estimation/abstract_regression_estimator.py | .py | 8568a2b4a3cd6704 | 8.15 | 19 |
"""
This module contains the EffectEstimate dataclass.
"""
from dataclasses import dataclass
import pandas as pd
@dataclass
class EffectEstimate:
"""
A dataclass to hold the value and confidence intervals of a causal effect estimate
:ivar type: The type of estimate, e.g. ate, or risk_ratio
... | CITCOM-project/CausalTestingFramework | causal_testing/estimation/effect_estimate.py | .py | 6cbc3524643bb034 | 8.15 | 19 |
"""This module contains the ExperimentalEstimator class for directly interacting with the system under test."""
from abc import abstractmethod
from typing import Any
import pandas as pd
from causal_testing.estimation.abstract_estimator import Estimator
from causal_testing.estimation.effect_estimate import EffectEsti... | CITCOM-project/CausalTestingFramework | causal_testing/estimation/experimental_estimator.py | .py | 733a33d1bef80035 | 8.15 | 19 |
"""This module contains the InstrumentalVariableEstimator class, for estimating
continuous outcomes with unobservable confounding."""
import logging
from math import ceil
import pandas as pd
import statsmodels.api as sm
from causal_testing.estimation.abstract_estimator import Estimator
from causal_testing.estimation... | CITCOM-project/CausalTestingFramework | causal_testing/estimation/instrumental_variable_estimator.py | .py | 7e0571386b5f5bdd | 8.15 | 19 |
"""This module contains the IPCWEstimator class, for estimating the time to a particular event"""
import logging
from typing import Any
from uuid import uuid4
import numpy as np
import pandas as pd
import statsmodels.formula.api as smf
from lifelines import CoxPHFitter
from causal_testing.estimation.abstract_estimat... | CITCOM-project/CausalTestingFramework | causal_testing/estimation/ipcw_estimator.py | .py | 9ee2711f270e75bb | 8.15 | 19 |
"""This module contains the LogisticRegressionEstimator class for estimating categorical outcomes."""
import logging
import numpy as np
import pandas as pd
import statsmodels.api as sm
from causal_testing.estimation.abstract_regression_estimator import RegressionEstimator
from causal_testing.estimation.effect_estima... | CITCOM-project/CausalTestingFramework | causal_testing/estimation/logistic_regression_estimator.py | .py | 904d0f0324313fe1 | 8.15 | 19 |
"""This module contains the LogisticRegressionEstimator class for estimating categorical outcomes."""
import logging
import numpy as np
import pandas as pd
import statsmodels.api as sm
from causal_testing.estimation.abstract_regression_estimator import RegressionEstimator
from causal_testing.estimation.effect_estima... | CITCOM-project/CausalTestingFramework | causal_testing/estimation/multinomial_regression_estimator.py | .py | e083868fbbc1d701 | 8.15 | 19 |
# pylint: disable=too-few-public-methods
"""This module contains the CausalEffect abstract class, as well as the concrete extension classes:
ExactValue, Positive, Negative, SomeEffect, NoEffect"""
from abc import ABC, abstractmethod
import numpy as np
from causal_testing.estimation.effect_estimate import EffectEstim... | CITCOM-project/CausalTestingFramework | causal_testing/testing/causal_effect.py | .py | 3f42629816444511 | 7.15 | 19 |
"""This module contains the CausalTestCase class, a class that holds the information required for a causal test"""
import logging
import numpy as np
import pandas as pd
from causal_testing.estimation.abstract_estimator import Estimator
from causal_testing.testing.causal_effect import CausalEffect
from causal_testing... | CITCOM-project/CausalTestingFramework | causal_testing/testing/causal_test_case.py | .py | fa1089bb6e802490 | 8.15 | 19 |
"""This module contains the CausalTestResult class, which is a container for the results of a causal test."""
from dataclasses import dataclass
from enum import Enum
from causal_testing.estimation.effect_estimate import EffectEstimate
TestOutcome = Enum("TestOutcome", [("PASS", 2), ("FAIL", 0), ("INESTIMABLE", 1)])
... | CITCOM-project/CausalTestingFramework | causal_testing/testing/causal_test_result.py | .py | bc55f2b82d1fe84b | 8.15 | 19 |
"""
This module contains code to measure various aspects of causal test adequacy.
"""
import logging
from itertools import combinations
from causal_testing.specification.causal_dag import CausalDAG
from causal_testing.testing.causal_test_case import CausalTestCase
logger = logging.getLogger(__name__)
class DAGAdeq... | CITCOM-project/CausalTestingFramework | causal_testing/testing/dag_adequacy.py | .py | 4b48d0c95d3d8093 | 8.15 | 19 |
"""
This module contains code to measure various aspects of causal test adequacy.
"""
import logging
from pandas import Series
logger = logging.getLogger(__name__)
class DataAdequacy:
"""
Measures the adequacy of a given test according to the Fisher kurtosis of the bootstrapped result.
* Positive kurt... | CITCOM-project/CausalTestingFramework | causal_testing/testing/data_adequacy.py | .py | 98d5acbdc9ce5775 | 8.15 | 19 |
"""This module contains the Intervention class, which intervenes on an input configuration"""
class Intervention:
"""
An intervention is an object which manipulates the input configuration of the scenario-under-test. It must define
a method which takes the input configuration, does something to it, and re... | CITCOM-project/CausalTestingFramework | causal_testing/testing/intervention.py | .py | c10fc4e224963949 | 8.15 | 19 |
"""This module contains the CausalValidator class for performing Quantitive Bias Analysis techniques"""
import math
import numpy as np
from scipy.stats import t
from statsmodels.regression.linear_model import RegressionResultsWrapper
class CausalValidator:
"""A suite of validation tools to perform Quantitive Bi... | CITCOM-project/CausalTestingFramework | causal_testing/utils/validation.py | .py | 20725ed7ac6603f7 | 8.15 | 19 |
import os
import logging
from pathlib import Path
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from causal_testing.testing.causal_test_case import CausalTestCase
from causal_testing.testing.causal_effect import Positive
from causal_testing.estimation.linear_regression_estimator import LinearR... | CITCOM-project/CausalTestingFramework | examples/covasim_/doubling_beta/example_beta.py | .py | 8ab0775e4ffb4dd7 | 7.65 | 19 |
import os
import logging
import pandas as pd
from causal_testing.specification.causal_dag import CausalDAG
from causal_testing.testing.causal_test_case import CausalTestCase
from causal_testing.testing.causal_effect import Positive, Negative, NoEffect
from causal_testing.estimation.linear_regression_estimator import Li... | CITCOM-project/CausalTestingFramework | examples/covasim_/vaccinating_elderly/example_vaccine.py | .py | 44baba63fd1ac47f | 7.65 | 19 |
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from causal_testing.specification.causal_dag import CausalDAG
from causal_testing.testing.causal_test_case import CausalTestCase
from causal_testing.testing.causal_effect import Positive, Negative, NoEffect
from causal_testing.estimation.linear_regr... | CITCOM-project/CausalTestingFramework | examples/lr91/example_max_conductances.py | .py | 08ff12cb4f62a17d | 7.65 | 19 |
import unittest
from causal_testing.estimation.experimental_estimator import ExperimentalEstimator
class SystemUnderTest:
"""
Basic example of a system under test.
"""
def run(self, x):
return x * 2
class ConcreteExperimentalEstimator(ExperimentalEstimator):
"""
Concrete experiment... | CITCOM-project/CausalTestingFramework | tests/estimation_tests/test_experimental_estimator.py | .py | e39c31bc95eb1877 | 7.15 | 19 |
import unittest
import deap
import pandas as pd
from causal_testing.estimation.genetic_programming_regression_fitter import GP, mut_insert
def root(x):
return x**0.5
class TestGP(unittest.TestCase):
def test_init_invalid_fun_name(self):
"""
Test that GP raises ValueError if sympy conversio... | CITCOM-project/CausalTestingFramework | tests/estimation_tests/test_genetic_programming_regression_fitter.py | .py | 21a13215be5465fc | 8.15 | 19 |
import unittest
import numpy as np
import pandas as pd
from causal_testing.estimation.instrumental_variable_estimator import InstrumentalVariableEstimator
class TestInstrumentalVariableEstimator(unittest.TestCase):
"""
Test the instrumental variable estimator.
"""
@classmethod
def setUpClass(cl... | CITCOM-project/CausalTestingFramework | tests/estimation_tests/test_instrumental_variable_estimator.py | .py | d0294187086ef13e | 8.15 | 19 |
import unittest
import numpy as np
import pandas as pd
from causal_testing.estimation.genetic_programming_regression_fitter import reciprocal
from causal_testing.estimation.linear_regression_estimator import LinearRegressionEstimator
from causal_testing.utils.validation import CausalValidator
def load_nhefs_df():
... | CITCOM-project/CausalTestingFramework | tests/estimation_tests/test_linear_regression_estimator.py | .py | 59dec61d204cbc46 | 7.15 | 19 |
import unittest
import pandas as pd
from causal_testing.estimation.logistic_regression_estimator import LogisticRegressionEstimator
class TestLogisticRegressionEstimator(unittest.TestCase):
"""Test the logistic regression estimator against the scarf example from
https://investigate.ai/regression/logistic-re... | CITCOM-project/CausalTestingFramework | tests/estimation_tests/test_logistic_regression_estimator.py | .py | 4f1ba686fffb7da8 | 8.15 | 19 |
import os
import shutil
import tempfile
import unittest
import networkx as nx
from causal_testing.specification.causal_dag import CausalDAG, close_separator, list_all_min_sep
class TestCausalDAGIssue90(unittest.TestCase):
"""
Test the CausalDAG class for the resolution of Issue 90.
"""
def setUp(se... | CITCOM-project/CausalTestingFramework | tests/specification_tests/test_causal_dag.py | .py | db323ea63c8c05f3 | 7.15 | 19 |
"""This module modifies GitHub-style Markdown links in MkDocs pages."""
import re
from mkdocs.config.defaults import MkDocsConfig
from mkdocs.structure.files import Files
from mkdocs.structure.pages import Page
def on_page_markdown(
markdown: str, *, page: Page, config: MkDocsConfig, files: Files
) -> str | Non... | fedejaure/dev-setup | material/overrides/hooks/fix_markdown_links.py | .py | 4b57c85a9f7519b0 | 7.42 | 6 |
"""Tasks for maintaining the project.
Execute 'invoke --list' for guidance on using Invoke
"""
import platform
from pathlib import Path
from typing import Any, List, Optional
from invoke import call, task
from invoke.context import Context
from invoke.runners import Result
ROOT_DIR = Path(__file__).parent
DOCS_BUIL... | fedejaure/dev-setup | tasks.py | .py | baa4e2f458d6da0b | 7.42 | 6 |
import logging
# import typing as tp
import pytest
from pttools.logging import setup_logging
# if tp.TYPE_CHECKING:
# from _pytest.fixtures import SubRequest
logger = logging.getLogger(__name__)
def pytest_configure(config: pytest.Config):
setup_logging()
@pytest.fixture(scope="function", autouse=True)
... | CFT-HY/pttools | conftest.py | .py | 674576ce4a4bd7d0 | 8.02 | 10 |
"""
Plot multiple spectra
=====================
Plot the velocity and GW spectra of multiple bubbles
"""
import matplotlib.pyplot as plt
from examples import utils
from pttools.analysis import plot_spectra_multi
from pttools.bubble import Bubble
from pttools.models import BagModel, ConstCSModel
from pttools.omgw0 im... | CFT-HY/pttools | examples/basic/plot_spectra.py | .py | 56f6d780a0a0dd18 | 7.02 | 10 |
"""
GW spectra for ConstCSModel
===========================
Plot GW spectra for various ConstCSModels
These figures and this table are used in Mika's M.Sc. thesis.
"""
import io
import logging
import os.path
import time
import typing as tp
import matplotlib.pyplot as plt
import numpy as np
from examples import uti... | CFT-HY/pttools | examples/const_cs/const_cs_gw.py | .py | 9896f56dba8f5dd0 | 7.52 | 10 |
"""
Entropy (old reference)
=======================
Created on Fri Jul 2 18:20:37 2021
@author: hindmars
Requires input data as an npz file.
"""
import logging
import os.path
import matplotlib.pyplot as plt
import numpy as np
from examples.utils import FIG_DIR
from pttools.analysis.plot_entropy_grid import plot_... | CFT-HY/pttools | examples/entropy/plot_entropy_old.py | .py | eef4fa91d3f29796 | 7.52 | 10 |
r"""
Giese et al. testing 2
======================
Compare :giese_2021:`\ ` fluid profiles with PTtools
"""
import matplotlib.pyplot as plt
import numpy as np
from examples import utils
from pttools.analysis.utils import A4_PAPER_SIZE
from pttools.bubble import Bubble, Phase, lorentz, kappaNuMuModel, v_chapman_jougu... | CFT-HY/pttools | examples/gksvdv/gksvdv_testing2.py | .py | 9acbbbc564d06b6d | 7.02 | 10 |
r"""
Giese et al. testing 3
======================
Testing to find the properties of a single bubble with PTtools and :giese_2021:`\ ` solvers
"""
import matplotlib.pyplot as plt
from pttools.bubble import Bubble
from pttools.models import ConstCSModel
from pttools.bubble.gksvdv.gksvdv21 import kappaNuMuModel
from p... | CFT-HY/pttools | examples/gksvdv/gksvdv_testing3.py | .py | ffff36f91531c240 | 7.02 | 10 |
"""
Reverse
=======
Find thermodynamic parameters for a given peak of the gravitational wave spectrum.
This is very much work in progress and not yet functional.
"""
import numpy as np
from scipy.optimize import minimize, OptimizeResult
from pttools.bubble import Bubble
from pttools.models import BagModel, Model
fro... | CFT-HY/pttools | examples/reverse/reverse.py | .py | 8a1b619a3156007c | 7.52 | 10 |
"""
Approximate reverse
===================
Find thermodynamic parameters for a given peak of the gravitational wave spectrum.
This is very much work in progress and not yet functional.
"""
import typing as tp
import numpy as np
from scipy.optimize import minimize, OptimizeResult
from pttools.omgw0.approx import f0... | CFT-HY/pttools | examples/reverse/reverse_approx.py | .py | 88c3d6282d00e8bc | 7.52 | 10 |
"""Python client lib for Solarfocus"""
import importlib.metadata
from enum import Enum
from packaging import version
__version__ = importlib.metadata.version("pysolarfocus")
# Default port for modbus
PORT = 502
# This needs to be defined before the imports because of circular dependencies
class Systems(str, Enum):
... | LavermanJJ/pysolarfocus | src/pysolarfocus/__init__.py | .py | f718d259e1bd52e1 | 7.52 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.