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 |
|---|---|---|---|---|---|---|
import argparse
import itertools
import os
import time
from collections.abc import Callable, Sequence
from importlib import metadata
from pathlib import Path
from typing import cast
import numpy as np
from PIL import Image
from skimage.metrics import peak_signal_noise_ratio
from pyvisim._base_classes import Similarit... | MechaCritter/Python-Visual-Similarity | docs/pixelwise/benchmarks/generate_benchmark.py | .py | 9983e53df400767f | 7.6 | 15 |
import argparse
import itertools
import os
import time
from collections.abc import Callable, Iterable, Sequence
from importlib import metadata
from pathlib import Path
from typing import cast
import numpy as np
import torch
from PIL import Image
from skimage.metrics import structural_similarity
from torchmetrics.funct... | MechaCritter/Python-Visual-Similarity | docs/structural/benchmarks/generate_benchmark.py | .py | fa481c76582348e9 | 7.6 | 15 |
import abc
import logging
import pathlib
from typing import Any, ClassVar, TypeVar
import numpy as np
from ._utils import get_similarity_func
from .serialization import load_embedder_state, save_embedder_state
from .typing import (
Float32NumpyArray,
FloatNumpyArray,
ImageInput,
MatLike,
Similarit... | MechaCritter/Python-Visual-Similarity | pyvisim/_base_classes.py | .py | 55955fbd1afd8734 | 7.6 | 15 |
import logging
import logging.config
import os
import pathlib
from typing import Any
# -Config for the dataset- #
ROOT = pathlib.Path(__file__).parent.parent
LOG_FOLDER = ROOT / "res/logs"
os.makedirs(LOG_FOLDER, exist_ok=True)
LOG_FILE_PATH = LOG_FOLDER / "log_msgs.log"
RES_FOLDER = ROOT / "pyvisim/res"
LOGGER_FILE ... | MechaCritter/Python-Visual-Similarity | pyvisim/_config.py | .py | 5e70db7499d8c25b | 7.6 | 15 |
from typing import cast
import numpy as np
from PIL import Image, UnidentifiedImageError
from . import distance
from .typing import (
SimilarityFunc,
UInt8NumpyArray,
)
def read_image_rgb(path: str) -> UInt8NumpyArray:
"""
Read an image from disk and convert it to RGB.
:param path: Path to the ... | MechaCritter/Python-Visual-Similarity | pyvisim/_utils.py | .py | 5497faadd9a6c8c7 | 7.6 | 15 |
import abc
from collections.abc import Iterator
import numpy as np
from .._base_classes import SimilarityMetric
from ..features._utils import grayscale_dims
from ..lazy_import import is_tensor
from ..typing import Float64NumpyArray, FloatNumpyArray, ImageInput, IntNumpyArray
from ..utils.image_utils import iter_image... | MechaCritter/Python-Visual-Similarity | pyvisim/base/base_classes.py | .py | fab38d36c6469a70 | 7.6 | 15 |
"""
Base classes for the clustering and decomposition models used by the
image embedders.
"""
import abc
from typing import Any, TypeVar
import numpy as np
from ..._errors import NotFittedError
from ...serialization import decode_array_node
from ...typing import FloatNumpyArray
_ClusteringModelT = TypeVar("_Cluster... | MechaCritter/Python-Visual-Similarity | pyvisim/classic/_clustering/_base_clustering.py | .py | bf55a3f24671c9a6 | 7.6 | 15 |
"""K-Means clustering class used by the VLAD embedder."""
import warnings
from collections.abc import Callable
from typing import Any, TypeVar, cast
import numpy as np
from scipy.cluster.vq import kmeans, vq
from ...typing import FloatNumpyArray, IntNumpyArray
from ._base_clustering import ClusteringModelBase, _deco... | MechaCritter/Python-Visual-Similarity | pyvisim/classic/_clustering/kmeans.py | .py | 2b94583ccc4e8212 | 7.6 | 15 |
import logging
from typing import Any, ClassVar, cast
import numpy as np
from .._base_classes import SerializableImageEmbedder
from ..typing import (
FloatNumpyArray,
ImageInput,
)
from ..utils.image_utils import iter_images
#: On-disk format version of the serialised pipeline state.
_PIPELINE_FORMAT_VERSION... | MechaCritter/Python-Visual-Similarity | pyvisim/classic/pipeline.py | .py | d048d762d1c398e0 | 7.6 | 15 |
"""Minimal reader for MATLAB Level-5 MAT-files.
This module implements just enough of the MAT-file format to load the numeric
arrays shipped with the Oxford 102 Flowers dataset (``imagelabels.mat`` and
``setid.mat``), which lets us drop the runtime dependency on SciPy. Only
numeric and character arrays are supported; ... | MechaCritter/Python-Visual-Similarity | pyvisim/datasets/_matloader.py | .py | 6d66e4f12cf089b3 | 7.6 | 15 |
import logging
import os
from functools import partial
from multiprocessing import Process
import requests
from platformdirs import user_cache_dir
from tqdm import tqdm
from pyvisim._config import setup_logging
from pyvisim._utils import read_image_rgb
from pyvisim.datasets._matloader import load_mat
from pyvisim.laz... | MechaCritter/Python-Visual-Similarity | pyvisim/datasets/datasets.py | .py | 9c897f8d477d3f4e | 7.6 | 15 |
"""
Pairwise distance and similarity metrics implemented in pure NumPy.
This module hosts pyvisim's own implementations of the vector metrics used to
compare image embeddings: :func:`cosine_similarity`, :func:`euclidean_distances`
and :func:`manhattan_distances`. All three operate on 2-D ``(N, D)`` matrices
and return... | MechaCritter/Python-Visual-Similarity | pyvisim/distance.py | .py | c4bb1e1d220dcaa9 | 7.6 | 15 |
"""
This module contains functions to evaluate the performance of a retrieval system.
"""
from collections.abc import Iterable
import numpy as np
from .distance import cosine_similarity
from .typing import EmbeddingStore, MatLike
__all__ = ["top_k_map", "top_k_accuracy"]
def top_k_map(
images: Iterable[MatLik... | MechaCritter/Python-Visual-Similarity | pyvisim/eval.py | .py | 69b0983fd0579b67 | 7.6 | 15 |
from __future__ import annotations
import warnings
from collections.abc import Callable
from typing import Any
import numpy as np
from .._base_classes import FeatureExtractorBase
from .._config import setup_logging
from ..lazy_import import OptionalImport
from ..typing import Float32NumpyArray, MatLike
from ._utils ... | MechaCritter/Python-Visual-Similarity | pyvisim/features/_deep_conv_feature.py | .py | f12c3186184c3c87 | 7.6 | 15 |
from collections.abc import Callable
from typing import Any
from .._base_classes import FeatureExtractorBase
from ..typing import Float32NumpyArray, MatLike, UInt8NumpyArray
from ._utils import _check_output_shape, _to_single_image
class Lambda(FeatureExtractorBase):
"""
Lambda feature extractor that allows ... | MechaCritter/Python-Visual-Similarity | pyvisim/features/_lambda.py | .py | 4a34c3a151e7d078 | 7.6 | 15 |
import numpy as np
from ..typing import Float32NumpyArray, MatLike
from ._sift import SIFT
from ._utils import _check_output_shape
__all__ = ["RootSIFT"]
class RootSIFT(SIFT):
"""
Scale-Invariant Feature Transform with Hellinger kernel (RootSIFT) normalizer.
References:
===========
[1] Arandjel... | MechaCritter/Python-Visual-Similarity | pyvisim/features/_root_sift.py | .py | df8b80faed20a046 | 7.6 | 15 |
from typing import Any
import numpy as np
from PIL import Image
from .._base_classes import FeatureExtractorBase
from ..typing import Float32NumpyArray, MatLike, UInt8NumpyArray
from ._utils import _check_output_shape, _to_single_image
from ._vendored.sift.sift import SIFT as _SIFT
__all__ = ["SIFT"]
class SIFT(Fe... | MechaCritter/Python-Visual-Similarity | pyvisim/features/_sift.py | .py | 5da29c61fcbb554c | 7.6 | 15 |
from collections.abc import Callable
from functools import wraps
from typing import Any, TypeVar, cast
import numpy as np
from .._base_classes import FeatureExtractorBase
from ..typing import (
Float32NumpyArray,
MatLike,
UInt8NumpyArray,
_to_image_list,
)
ExtractorCallT = TypeVar("ExtractorCallT", b... | MechaCritter/Python-Visual-Similarity | pyvisim/features/_utils.py | .py | 6aa991e61c4713bb | 7.6 | 15 |
"""
Shared array plumbing for the search indexes.
The helpers here validate and shape the matrices that go into an index and come
back out of it: the gallery matrix an index takes ownership of, the query batch
handed to a nearest-neighbour search, and the fixed-width result arrays a search
returns.
"""
from __future_... | MechaCritter/Python-Visual-Similarity | pyvisim/image_store/_index/_utils.py | .py | 6afd97dcce1eb292 | 7.6 | 15 |
"""Exhaustive nearest-neighbour search over a gallery."""
from __future__ import annotations
from typing import cast
import numpy as np
from ...typing import Float32NumpyArray, FloatNumpyArray, IntNumpyArray
from ._bindings import _hnswlib
from ._utils import (
Space,
as_decoded_gallery,
as_gallery_matr... | MechaCritter/Python-Visual-Similarity | pyvisim/image_store/_index/brute_force_index.py | .py | 9c6393bd4d961ad2 | 7.6 | 15 |
"""
Adapter for search indexes built outside of this library.
:class:`ExternalSearchIndex` lets a store search through an index somebody else
built, a FAISS index in particular, without this package depending on the
library that produced it. Everything it needs is read off the wrapped object at
construction time.
"""
... | MechaCritter/Python-Visual-Similarity | pyvisim/image_store/_index/external_index.py | .py | e4cb71f2ac978067 | 7.6 | 15 |
from typing import Literal, Optional
import dataclasses
import logging
import os
import re
logger = logging.getLogger(__name__)
_SAFE_PREFIX_RE = re.compile(r"^[A-Za-z0-9_\-]+$")
_STAC_EDITOR_ROLE = os.environ.get("STAC_EDITOR_ROLE", "stac_editor").strip()
_STAC_EDITOR_CLIENT_IDS = frozenset(
cid.strip()
for... | EOEPCA/eoepca-plus | argocd/eoepca/data-access/parts/stac-auth-proxy/eoepca_filters.py | .py | 650a8a983c544b41 | 7.42 | 6 |
"""Smoke tests for STAC API link integrity.
Catches regressions where internal ports (e.g. :9443) leak into response links.
"""
import os
import re
import httpx
import pytest
EOAPI = os.environ.get("EOAPI", "eoapi.develop-v2.eoepca.org")
STAC_URL = f"https://{EOAPI}/stac/"
# Matches URLs containing a non-standard ... | EOEPCA/eoepca-plus | tests/smoke/test_stac_links.py | .py | d299067860a69b92 | 7.92 | 6 |
# Standard library imports
import os
import pickle
from abc import ABC, abstractmethod
import warnings
from contextlib import nullcontext
# Third-party library imports
import pandas as pd
from tqdm import tqdm
# Typing imports
from typing import Optional, Union
import TINTOlib.utils.constants as constants
# Default ... | oeg-upm/TINTOlib | TINTOlib/abstractImageMethod.py | .py | 935c0e3dd2a959bd | 7.63 | 17 |
import pickle
import os
import matplotlib
import pandas as pd
import numpy as np
class BaseModel:
default_verbose = False # Verbose: if it's true, show the compilation text
def __init__(self, verbose=default_verbose):
self.verbose = verbose
def saveHyperparameters(self, filename='objs'):
"... | oeg-upm/TINTOlib | TINTOlib/base.py | .py | d0df1fbd6da50f5f | 7.63 | 17 |
from abc import abstractmethod
from sklearn.base import BaseEstimator,TransformerMixin
class CustomTransformer(BaseEstimator, TransformerMixin):
"""
Abstract class implementing a custom transformer following scikit-learn structure.
"""
@abstractmethod
def fit(self, x, y=None):
raise NotIm... | oeg-upm/TINTOlib | TINTOlib/utils/CustomTransformer.py | .py | 88866e042dbef695 | 7.63 | 17 |
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 7 18:41:14 2019
@author: obazgir
"""
#FOR REFINED
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
#%% NRMSE
def NRMSE(Y_Target, Y_Predict):
Y_Target = np.array(Y_Target); Y_Predict = np.array(Y_Predict);
Y_Target = Y_... | oeg-upm/TINTOlib | TINTOlib/utils/Toolbox.py | .py | 9718f913cf712343 | 7.63 | 17 |
from scipy.spatial import ConvexHull
import numpy as np
def get_minimum_rectangle(features_coord):
"""
This method computes the minimum bounding rectangle defined by vertex obtained by applying a convexHull algorithm to features coordinates.
Save in class variables the vertex's coordinates of t... | oeg-upm/TINTOlib | TINTOlib/utils/geometry.py | .py | 3676b7e1171af0c0 | 7.63 | 17 |
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 10 18:04:36 2019
@author: Ruibzhan
"""
from mpi4py import MPI
import paraHill
import pickle
import numpy as np
from itertools import product
import time
import datetime
import config
from config import *
#%% Comm set
comm = MPI.COMM_WORLD
my_rank = comm.Get_rank()
n_proc... | oeg-upm/TINTOlib | TINTOlib/utils/mpiHill_UF.py | .py | 66d7668c2940cf61 | 7.63 | 17 |
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 12 14:30:06 2019
@author: Ruibzhan & Omid Bazgir
"""
from scipy.stats import pearsonr
import numpy as np
import random
from scipy.spatial import distance
import pickle
import pandas as pd
import time
from itertools import product
#%%
def universial_corr(dist_matr, mappi... | oeg-upm/TINTOlib | TINTOlib/utils/paraHill.py | .py | 2d2242409bcfad20 | 7.63 | 17 |
#!/usr/bin/env python3
"""
Generate quick_check YAML summaries from docs/_data/datasets/*/*/dataset.yml
Output files:
docs/_data/quick_check/regression.yml
docs/_data/quick_check/binary.yml
docs/_data/quick_check/multiclass.yml
Logic:
- For each dataset.yml, read leaderboard_rows and select best_classical amo... | oeg-upm/TINTOlib | scripts/generate_quick_check.py | .py | ec7e4fbd647c9e8e | 7.63 | 17 |
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the ... | elastic/elastic-otel-python | conftest.py | .py | ddb51ed5a9ec3b02 | 7.1 | 15 |
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the ... | elastic/elastic-otel-python | src/elasticotel/distro/config.py | .py | be945c3451b3806c | 7.6 | 15 |
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the ... | elastic/elastic-otel-python | src/elasticotel/distro/resource_detectors.py | .py | 29971d54383545df | 7.6 | 15 |
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the ... | elastic/elastic-otel-python | src/elasticotel/instrumentation/bootstrap.py | .py | e152b21e78678245 | 7.6 | 15 |
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the ... | elastic/elastic-otel-python | src/elasticotel/sdk/resources/__init__.py | .py | cbf21f608cdcbcab | 7.6 | 15 |
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the ... | elastic/elastic-otel-python | src/elasticotel/sdk/sampler/__init__.py | .py | 01aaf3615ff9539f | 7.6 | 15 |
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the ... | elastic/elastic-otel-python | src/elasticotel/sdk/trace/tracer_configurator.py | .py | ba5a43746352bc2a | 7.6 | 15 |
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the ... | elastic/elastic-otel-python | tests/distro/test_resource_detectors.py | .py | 69e5a968a02d8652 | 7.1 | 15 |
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the ... | elastic/elastic-otel-python | tests/distro/test_sanitization.py | .py | 2e0f70484c81436b | 7.1 | 15 |
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the ... | elastic/elastic-otel-python | tests/resources/test_resources.py | .py | 49ec0a09b75e0acc | 7.1 | 15 |
# Copyright 2024, MASSACHUSETTS INSTITUTE OF TECHNOLOGY
# Subject to FAR 52.227-11 – Patent Rights – Ownership by the Contractor (May 2014)
# SPDX-License-Identifier: MIT
"""
assemble_docs_for_publish.py
A command-line script for assembling the documentation published to gh-pages
intended by be called in the gitlab... | mit-ll-ai-technology/maite | docs/assemble_docs_for_publish.py | .py | 5f8f8a5ce1c9b773 | 7.6 | 15 |
# Copyright 2025, MASSACHUSETTS INSTITUTE OF TECHNOLOGY
# Subject to FAR 52.227-11 – Patent Rights – Ownership by the Contractor (May 2014).
# SPDX-License-Identifier: MIT
from __future__ import annotations
from collections.abc import Callable, Sequence
from typing import Any, Literal
import numpy as np
import torch
... | mit-ll-ai-technology/maite | src/maite/_internals/interop/metrics/torchmetrics.py | .py | 3746e87530e50f8d | 7.6 | 15 |
# Copyright 2025, MASSACHUSETTS INSTITUTE OF TECHNOLOGY
# Subject to FAR 52.227-11 – Patent Rights – Ownership by the Contractor (May 2014).
# SPDX-License-Identifier: MIT
from __future__ import annotations
from collections.abc import Callable, Sequence
from typing import Any
import torch
import torchmetrics
import t... | mit-ll-ai-technology/maite | src/maite/_internals/interop/metrics/torchmetrics_detection.py | .py | 6ace850a2b903fca | 7.6 | 15 |
# Copyright 2024, MASSACHUSETTS INSTITUTE OF TECHNOLOGY
# Subject to FAR 52.227-11 – Patent Rights – Ownership by the Contractor (May 2014).
# SPDX-License-Identifier: MIT
from __future__ import annotations
from collections.abc import Sequence
from dataclasses import dataclass
from typing import Any, TypeAlias, cast
... | mit-ll-ai-technology/maite | src/maite/_internals/interop/models/yolo.py | .py | 2a894bb9ccdc4334 | 7.6 | 15 |
"""Resolve generic hints within signatures resulting from protocol introspection
This module's key contribution is `resolve_protocol_members`, which takes a typehint
for a protocol class (that may be a parametrized generic or a subclass of one) and
returns a fully-populated ProtocolMembers object with all TypeVars sub... | mit-ll-ai-technology/maite | src/maite/_internals/spotcheck/generic_hint_resolution.py | .py | 9b1498526c72194a | 7.6 | 15 |
"""A module for inspecting and extracting members from protocol classes."""
import inspect
from collections.abc import Callable, Mapping
from dataclasses import dataclass
from types import MappingProxyType
from typing import Any, get_type_hints
from typing_extensions import TypeForm, get_protocol_members, is_protocol... | mit-ll-ai-technology/maite | src/maite/_internals/spotcheck/protocol_introspection.py | .py | 6ffb8b182692e994 | 8.1 | 15 |
"""Define spotcheck runtime exceptions and a 'node-level' callable that
applies verification given a realized implementer and a typehint it purports
to satisfy.
"""
from collections.abc import Callable
from typing import Any, TypeAlias, cast
from beartype.door import die_if_unbearable
from beartype.roar import Bearty... | mit-ll-ai-technology/maite | src/maite/_internals/spotcheck/spotcheck_node.py | .py | c11c1a2ac97b7e3f | 7.6 | 15 |
"""Define a higher-level API that permits wrapping all arguments of a callable
that are MAITE protocol types. (This permits MAITE tasks to be decorated for
light-weight opt-in to spotchecking)
"""
import functools
import inspect
from collections.abc import Callable, Mapping
from types import GenericAlias, MappingProxy... | mit-ll-ai-technology/maite | src/maite/_internals/spotcheck/spotcheck_tasks.py | .py | cd413354030916b4 | 7.6 | 15 |
# Copyright 2024, MASSACHUSETTS INSTITUTE OF TECHNOLOGY
# Subject to FAR 52.227-11 – Patent Rights – Ownership by the Contractor (May 2014)
# SPDX-License-Identifier: MIT
from __future__ import annotations
from collections.abc import Iterable, Iterator, Sequence
from typing import Any, Generic, TypeVar
from maite._... | mit-ll-ai-technology/maite | src/maite/_internals/tasks/generic.py | .py | f204ca98b242b5c9 | 7.6 | 15 |
# Copyright 2024, MASSACHUSETTS INSTITUTE OF TECHNOLOGY
# Subject to FAR 52.227-11 – Patent Rights – Ownership by the Contractor (May 2014).
# SPDX-License-Identifier: MIT
# flake8: noqa
from __future__ import annotations
import re
from collections import defaultdict
from collections.abc import Collection
from inspe... | mit-ll-ai-technology/maite | src/maite/_internals/testing/docs.py | .py | 7af61405eb93cb4f | 8.1 | 15 |
# Copyright 2024, MASSACHUSETTS INSTITUTE OF TECHNOLOGY
# Subject to FAR 52.227-11 – Patent Rights – Ownership by the Contractor (May 2014).
# SPDX-License-Identifier: MIT
import importlib
import json
import subprocess
import sys
from collections.abc import Collection, Generator, Mapping
from copy import deepcopy
from... | mit-ll-ai-technology/maite | src/maite/_internals/testing/project.py | .py | cc175fbf0be89994 | 7.1 | 15 |
# Copyright 2024, MASSACHUSETTS INSTITUTE OF TECHNOLOGY
# Subject to FAR 52.227-11 – Patent Rights – Ownership by the Contractor (May 2014).
# SPDX-License-Identifier: MIT
from __future__ import annotations
import inspect
import json
import os
import re
import shutil
import subprocess
import tempfile
import textwrap
... | mit-ll-ai-technology/maite | src/maite/_internals/testing/pyright.py | .py | 42457e2fd5436b2a | 7.1 | 15 |
# Copyright 2024, MASSACHUSETTS INSTITUTE OF TECHNOLOGY
# Subject to FAR 52.227-11 – Patent Rights – Ownership by the Contractor (May 2014).
# SPDX-License-Identifier: MIT
import logging
import os
import tempfile
from collections.abc import Iterable
import pytest
@pytest.fixture
def cleandir() -> Iterable[str]:
... | mit-ll-ai-technology/maite | src/maite/_internals/testing/pytest.py | .py | 92d61fcf46047bf2 | 7.1 | 15 |
# Copyright 2024, MASSACHUSETTS INSTITUTE OF TECHNOLOGY
# Subject to FAR 52.227-11 – Patent Rights – Ownership by the Contractor (May 2014).
# SPDX-License-Identifier: MIT
from abc import ABCMeta, abstractmethod
from collections.abc import Callable, Iterable, Sequence
from functools import wraps
from typing import Any... | mit-ll-ai-technology/maite | src/maite/_internals/utils.py | .py | 431b2e7b992c8fd6 | 7.6 | 15 |
"""
This HTML Parser is based on the one from mkdocs-material:
https://github.com/squidfunk/mkdocs-material/blob/39c5171cef8394a2263a6fb81410c73e01890d8d/LICENSE
Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this sof... | timo-reymann/mkdocs-decision-records | mkdocs_decision_records/_html_parser.py | .py | e94be38515620950 | 7.54 | 11 |
import datetime
import json
import logging
import os
import sys
import json_log_formatter
class RequestJSONFormatter(json_log_formatter.JSONFormatter):
"""
Converts Gunicorn request log records to JSON.
See https://docs.gunicorn.org/en/stable/settings.html#access-log-format
"""
def json_record(... | proconnect-gouv/oidc2fer | docker/files/usr/local/etc/gunicorn/satosa.py | .py | a034e3af92725101 | 7.42 | 6 |
"""
Gitlint extra rule to validate that the message title is of the form
"<gitmoji>(<scope>) <subject>"
"""
from __future__ import unicode_literals
import re
import requests
from gitlint.rules import CommitMessageTitle, LineRule, RuleViolation
class GitmojiTitle(LineRule):
"""
This rule will enforce that e... | proconnect-gouv/oidc2fer | gitlint/gitlint_emoji.py | .py | 5386362559212575 | 7.42 | 6 |
"""
Retrieves trending subreddits from subriff.com and produces a blended list.
Algorithm:
1. Query multiple size filters for both daily and weekly
2. Count appearances across all queries (more appearances = more reliably trending)
3. Sort by appearance count, take top N
"""
import sys
import requests
from collection... | JeffreyCA/subreddits | scripts/gen_trending_subriff.py | .py | 4abefc973dbae8c9 | 7.42 | 6 |
"""Interact with folders in Nessus."""
import typer
from restfly import APIError
from rich.console import Console
from rich.table import Table
from tenable.nessus import Nessus
from typing_extensions import Annotated
app = typer.Typer()
@app.command()
def list(ctx: typer.Context):
"""List all folders."""
co... | audius/audiness | audiness/commands/folders.py | .py | 7525928d946e7248 | 7.45 | 7 |
"""Interact with scans in Nessus."""
import io
import time
from datetime import datetime
from pathlib import Path
from typing import Optional
import typer
from rich.console import Console
from rich.progress import track
from rich.table import Table
from typing_extensions import Annotated
from audiness.helpers import... | audius/audiness | audiness/commands/scans.py | .py | f268e53db9c0f979 | 7.45 | 7 |
"""Helper elements for various tasks."""
from datetime import datetime
from tenable.nessus import Nessus
def setup_connection(host, access_key, secret_key):
"""Connect to the Nessus instance."""
connection = Nessus(url=host, access_key=access_key, secret_key=secret_key)
return connection
def human_rea... | audius/audiness | audiness/helpers.py | .py | 7a67c8c89eff994f | 7.45 | 7 |
"""Tools to create compartmental models and ODE systems."""
import logging
from collections.abc import Sequence
import graphviz
import jax
import jax.numpy as jnp
from jaxtyping import Array, ArrayLike, PyTree
from .tree_tools import nested_indexing, walk_tree
# import jax.numpy as jnp
logger = logging.getLogger(_... | Priesemann-Group/icomo | icomo/comp_model.py | .py | 5f8cd1a372f655b1 | 7.56 | 12 |
"""Wrapper of diffrax functions for convenience."""
import inspect
from collections.abc import Callable
from typing import Optional
import diffrax
import jax
from jaxtyping import Array, ArrayLike, PyTree
def diffeqsolve(
*args,
ts_out: Optional[ArrayLike] = None,
ODE: Callable[[ArrayLike, PyTree, PyTre... | Priesemann-Group/icomo | icomo/diffrax_wrapper.py | .py | ff453c3d4d9c3e32 | 7.56 | 12 |
"""Tools for working with nested structures of lists, tuples or dictionaries."""
from collections.abc import Generator, Sequence
from types import EllipsisType
from typing import Any, Optional
from jaxtyping import ArrayLike, PyTree
def walk_tree(tree: PyTree) -> Generator[tuple[list, Any]]:
"""Walk through a t... | Priesemann-Group/icomo | icomo/tree_tools.py | .py | 2a06272f0b09b332 | 7.56 | 12 |
import jax
import jax.numpy as jnp
import numpy as np
import pymc as pm
import icomo
def delayed_copy_ode(t, y, args):
f_input_grad = args["f_input_grad"]
dy = {}
dy["start_comp"] = f_input_grad(t)
dy["erlang_comp"] = icomo.delayed_copy_kernel(
initial_comp=y["start_comp"],
delayed_co... | Priesemann-Group/icomo | tests/test_comp_model.py | .py | c8193bd53315d310 | 7.06 | 12 |
"""Tests for jax2pytensor package."""
import jax
import jax.numpy as jnp
import pymc as pm
import pytensor
import pytensor.tensor as pt
import pytest
from icomo import jax2pytensor
@pytest.fixture
def test_models():
# 2 parameters input, tuple output
with pm.Model() as model1:
x, y = pm.Normal("inpu... | Priesemann-Group/icomo | tests/test_jax_compilation.py | .py | f4a8ccd0b62ee211 | 7.06 | 12 |
# Copyright (C) 2025 Frederik Pasch
#
# 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 agreed to in writin... | cps-test-lab/scenario-execution | libs/scenario_execution_dataops/scenario_execution_dataops/actions/set_yaml_value.py | .py | 7cccb2af1d23ee8e | 7.48 | 8 |
# Copyright (C) 2024 Intel 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 agreed to in wri... | cps-test-lab/scenario-execution | libs/scenario_execution_docker/scenario_execution_docker/actions/docker_copy.py | .py | 1044b551224daeb5 | 7.48 | 8 |
# Copyright (C) 2024 Intel 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 agreed to in wri... | cps-test-lab/scenario-execution | libs/scenario_execution_docker/scenario_execution_docker/actions/docker_exec.py | .py | fd7bec8112321e6f | 7.48 | 8 |
# Copyright (C) 2024 Intel 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 agreed to in wri... | cps-test-lab/scenario-execution | libs/scenario_execution_docker/scenario_execution_docker/actions/docker_put.py | .py | 48ab2a349e358268 | 7.48 | 8 |
# Copyright (C) 2024 Intel 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 agreed to in wri... | cps-test-lab/scenario-execution | libs/scenario_execution_docker/scenario_execution_docker/actions/docker_run.py | .py | f417753f958c3471 | 7.48 | 8 |
# Copyright (C) 2024 Intel 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 agreed to in wri... | cps-test-lab/scenario-execution | libs/scenario_execution_gazebo/scenario_execution_gazebo/actions/gazebo_actor_exists.py | .py | 468cb914377c2c03 | 7.48 | 8 |
# Copyright (C) 2024 Intel 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 agreed to in wri... | cps-test-lab/scenario-execution | libs/scenario_execution_gazebo/scenario_execution_gazebo/actions/gazebo_delete_actor.py | .py | d840e0647a4a4782 | 7.48 | 8 |
# Copyright (C) 2024 Intel 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 agreed to in wri... | cps-test-lab/scenario-execution | libs/scenario_execution_gazebo/scenario_execution_gazebo/actions/gazebo_relative_spawn_actor.py | .py | f0515dc5aa79c8cb | 7.48 | 8 |
# Copyright (C) 2024 Intel 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 agreed to in wri... | cps-test-lab/scenario-execution | libs/scenario_execution_gazebo/scenario_execution_gazebo/actions/gazebo_wait_for_sim.py | .py | df4a12c4f42aa09a | 7.48 | 8 |
#!/usr/bin/env python3
"""Cleanup subcommand for removing junk files from directories."""
import logging
import os
import shlex
import shutil
import sys
from pathlib import Path
from typing import Annotated, Optional
import typer
from common import console, trash
from common.cli import (
DirectoryArg,
DryRun... | ICIJ/pystou | cleanup/main.py | .py | 14b8f7351846eeda | 7.45 | 7 |
"""Typed exceptions used to distinguish expected failures from bugs."""
class PystouError(Exception):
"""Base class for expected, explained PyStou errors."""
class InvalidDirectoryError(PystouError):
"""Raised when a target directory is missing or is not a directory."""
class CrossDeviceTrashError(PystouE... | ICIJ/pystou | common/errors.py | .py | f943b7a7988d0788 | 7.45 | 7 |
import contextlib
import logging
import os
import queue
import sqlite3
import sys
import threading
from collections.abc import Iterator
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from typing import Callable, NamedTuple, Optional
from common.errors import UndecodablePathError
EXCLUDED_D... | ICIJ/pystou | common/fs_walker.py | .py | 6f97556f6581d4f9 | 7.45 | 7 |
import hashlib
import logging
import os
import sqlite3
from pathlib import Path
from typing import Optional
from common import console, paths
from common.errors import PystouError
from common.fs_walker import collect_directories
def index_db_path(db_dir: Optional[str], directory: str) -> str:
"""Returns the inde... | ICIJ/pystou | common/indexer.py | .py | 21716fda533839c7 | 7.45 | 7 |
import json
import logging
import os
from datetime import datetime
from logging import handlers
from typing import Optional
from common import paths
def setup_logging(script_name: str = "script", log_dir: Optional[str] = None) -> None:
"""Sets up JSON logging to a timestamped file.
Idempotent: clears handle... | ICIJ/pystou | common/logger.py | .py | f245b74b1d59d85f | 7.45 | 7 |
# common/safe_extract.py
"""Member-validated archive extraction to prevent path traversal ("zip-slip")."""
import logging
import os
from pathlib import Path
from typing import Optional
def _safe_target(dest: Path, member_name: str) -> Optional[Path]:
"""Returns the resolved target path if it stays inside ``dest`... | ICIJ/pystou | common/safe_extract.py | .py | 3213e889fd11d99b | 7.45 | 7 |
# common/trash.py
"""Reversible deletion: move targets into a co-located, same-volume trash.
Layout under the operation root:
<op_root>/.pystou-trash/
runs/<run_id>.jsonl # write-ahead ledger, one line per moved item
<run_id>/<n>/<basename> # the moved files/dirs (n = holding dir)
"""
import ... | ICIJ/pystou | common/trash.py | .py | 3844c84e80b785c2 | 7.45 | 7 |
"""Directory validation shared by every subcommand."""
import logging
import sys
from pathlib import Path
from common.errors import InvalidDirectoryError
def validate_directory(directory) -> Path:
"""Validates that ``directory`` exists and is a directory.
Args:
directory: Path-like to validate.
... | ICIJ/pystou | common/validation.py | .py | c14aa34ff3ed3392 | 7.45 | 7 |
#!/usr/bin/env python3
"""Doctor subcommand: preflight check of required external CLI tools."""
import importlib.util
import re
import shutil
import subprocess
from dataclasses import dataclass
from typing import Annotated, Optional
import typer
from common import console
@dataclass
class ToolStatus:
"""Availa... | ICIJ/pystou | doctor/main.py | .py | 3222db373c240e06 | 7.45 | 7 |
#!/usr/bin/env python3
"""Empty subcommand for finding and removing empty directories."""
import errno
import logging
import os
from pathlib import Path
from typing import Annotated, Optional
import typer
from common import console
from common.cli import (
DirectoryArg,
DryRunOpt,
LogDirOpt,
Recursiv... | ICIJ/pystou | empty/main.py | .py | 2efc4a7ac0a605d3 | 7.45 | 7 |
#!/usr/bin/env python3
"""Normalize subcommand: make filenames valid, portable UTF-8 for S3."""
import contextlib
import logging
import os
import shlex
import sys
from collections.abc import Iterator
from enum import Enum
from pathlib import Path
from typing import Annotated, Optional
import typer
from rich.table imp... | ICIJ/pystou | normalize/main.py | .py | 244a3fbdfad6e97d | 7.45 | 7 |
"""JSONL rename manifest: the record an Elasticsearch update replays.
Both paths are stored in full and in two forms. The base64 fields are the
lossless ones consumers key on; the plain fields are a printable rendering.
A path that failed to decode as UTF-8 cannot be written as a JSON string:
a lone surrogate is inval... | ICIJ/pystou | normalize/manifest.py | .py | a141345b9b49292d | 7.45 | 7 |
"""Rules that turn a path component into a valid, portable S3 key component.
Every function here is pure: no filesystem access, no logging. That keeps the
rule matrix table-testable and keeps ``normalize/main.py`` about traversal.
"""
import re
import unicodedata
from collections.abc import Sequence
RULES: tuple[str... | ICIJ/pystou | normalize/rules.py | .py | 433a8baf90b01765 | 7.45 | 7 |
import os
import shutil
import tempfile
import unittest
from pathlib import Path
from unittest import mock
from cleanup.main import (
JUNK_DIRS,
JUNK_FILES,
find_junk,
is_junk_file,
remove_junk,
)
from common import trash
class TestCleanupJunkDetection(unittest.TestCase):
"""Tests for junk fi... | ICIJ/pystou | tests/test_cleanup.py | .py | 8cdc3a42f05b9bab | 7.95 | 7 |
import unittest
from types import SimpleNamespace
from unittest.mock import patch
from doctor.main import (
ToolStatus,
_tool_version,
check_environment,
)
class TestCheckEnvironment(unittest.TestCase):
"""Tests for the pure check_environment core."""
def test_all_available(self):
"""Whe... | ICIJ/pystou | tests/test_doctor.py | .py | aaa211501e6702af | 7.95 | 7 |
import errno
import shutil
import tempfile
import unittest
from pathlib import Path
from unittest import mock
from empty.main import (
find_empty_directories,
is_directory_empty,
remove_empty_directories,
)
class TestEmptyIsDirectoryEmpty(unittest.TestCase):
"""Tests for checking if a directory is em... | ICIJ/pystou | tests/test_empty.py | .py | cf144b5606b7829c | 7.95 | 7 |
import io
import shutil
import tempfile
import unittest
from pathlib import Path
import typer
from typer.testing import CliRunner
from common import console
from empty.main import empty_command
def _app():
app = typer.Typer()
app.command()(empty_command)
return app
class TestEmptyCommand(unittest.Test... | ICIJ/pystou | tests/test_empty_cli.py | .py | 4661ed5dd394973c | 7.95 | 7 |
from pathlib import Path
def check_key_elements(key: str, elements: list[str]) -> bool:
"""Function for checking if all elements are in key (logical AND)
:param key: Key to check
:param elements: List of elements to check if available in key
:return: True if all elements are pres... | es-ude/denspp.offline | denspp/offline/__init__.py | .py | 6aca7f9dd783e61e | 7.42 | 6 |
from fractions import Fraction
import numpy as np
from scipy.signal import resample_poly, square
from denspp.offline.analog.common_func import (
CommonAnalogFunctions,
CommonDigitalFunctions,
)
from denspp.offline.analog.dev_noise import (
DefaultSettingsNoise,
ProcessNoise,
SettingsNoise,
)
from... | es-ude/denspp.offline | denspp/offline/analog/adc/adc_basic.py | .py | 6f862d3e27c278d4 | 7.42 | 6 |
import numpy as np
from denspp.offline.analog.dev_noise import ProcessNoise
from denspp.offline.preprocessing import DownSampling, SettingsDownSampling
from .adc_basic import BasicADC
from .adc_settings import (
DefaultSettingsNon,
SettingsADC,
)
class DeltaSigmaADC(BasicADC):
_settings: SettingsADC
... | es-ude/denspp.offline | denspp/offline/analog/adc/adc_deltasigma.py | .py | fa0b2120bbdb7882 | 7.42 | 6 |
import numpy as np
from denspp.offline.analog.dev_noise import ProcessNoise
from .adc_basic import BasicADC
from .adc_settings import (
DefaultSettingsNon,
SettingsADC,
)
class NyquistADC(BasicADC):
_settings: SettingsADC
_handler_noise: ProcessNoise
def __init__(self, settings_dev: SettingsADC... | es-ude/denspp.offline | denspp/offline/analog/adc/adc_flash.py | .py | 656e17e925d4477b | 7.42 | 6 |
from dataclasses import dataclass
@dataclass
class SettingsADC:
"""Individual data class to configure the ADC
Attributes:
vdd: Positive supply voltage [V]
vss: Negative supply voltage [V]
dvref: Half Range of reference voltage [V]
fs_ana: Analogue input s... | es-ude/denspp.offline | denspp/offline/analog/adc/adc_settings.py | .py | 1ab5e1cc4dcc3b7b | 7.42 | 6 |
from dataclasses import dataclass
from logging import getLogger
import numpy as np
from denspp.offline.analog.common_func import (
CommonAnalogFunctions,
CommonDigitalFunctions,
)
@dataclass
class SettingsCOMP:
"""Individual data class to configure an analogue voltage comparator
Attributes:
... | es-ude/denspp.offline | denspp/offline/analog/amplifier/comparator.py | .py | 9c296c98db8234f9 | 7.42 | 6 |
from dataclasses import dataclass
import numpy as np
from denspp.offline.analog.common_func import CommonAnalogFunctions
from denspp.offline.analog.dev_noise import (
DefaultSettingsNoise,
ProcessNoise,
SettingsNoise,
)
@dataclass
class SettingsCUR:
"""Individual data class to configure the current ... | es-ude/denspp.offline | denspp/offline/analog/amplifier/cur_amp.py | .py | 968ad2c9ba37b984 | 7.42 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.