sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
5a6f218acafccb298fcaec78efe0eca161e8947e1ba5497a92f61205b0e4ca17 | Python | 283 | 21 | from ._logging import (
error,
hint,
info,
msg,
print_version,
ProgressReporter,
switch_verbosity,
warn,
)
__all__ = [
"error",
"hint",
"info",
"msg",
"print_version",
"ProgressReporter",
"switch_verbosity",
"warn",
]
|
0479d79c569c9b70dea25b00df91a323aaa40c0a6fb9afb5176d24bf705f6561 | Python | 285 | 9 | try:
import tomllib
except ImportError:
try:
from pip._vendor import tomli as tomllib # type: ignore[no-redef, unused-ignore]
except ModuleNotFoundError: # pragma: no cover
tomllib = None # type: ignore[assignment, unused-ignore]
__all__ = ("tomllib",)
|
110814f8f103a9d727e3ecb716fdbf5d662375eed8099c4c02ace85b8e0b5e01 | Python | 288 | 10 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from smac.env.starcraft2.maps import smac_maps
def get_map_params(map_name):
map_param_registry = smac_maps.get_smac_map_registry()
return map_param_registry[map_name]
|
1894cf57e37596c1b801365e230d6709226384be7feb30697020b80e42135b3e | Python | 288 | 13 | r"""
It's used to check basic rnn features with cpu-only.
For example, it would throw exception if missing some components are missing
"""
import torch
import torch.nn as nn
rnn = nn.RNN(10, 20, 2)
inputs = torch.randn(5, 3, 10)
h0 = torch.randn(2, 3, 20)
output, hn = rnn(inputs, h0)
|
fb0af4f9453ee6fafc324b272c8ae01991271afe950fbc526cf8d4c1eff50b87 | Python | 288 | 6 | # coding: utf-8
from .exponential_moving_average import ExponentialMovingAverage
from .hamiltonian_dataset import *
from .lookahead import Lookahead
from .parse_command_line_arguments import parse_command_line_arguments
from .util import compute_error_dict, empty_error_dict, generate_id
|
594152785762235eefc013c44f9d2018f98af7e181726fa3669d8f3506dd5cdd | Python | 289 | 12 | import numpy as np
import reza
def test_import():
assert hasattr(reza, "bandpass")
def test_bandpass_shape():
fs = 100.0
t = np.arange(0, 2, 1/fs)
x = np.sin(2*np.pi*1.0*t) + 0.2*np.sin(2*np.pi*30.0*t)
y = reza.bandpass(x, fs, 0.5, 5.0)
assert y.shape == x.shape
|
ca07ad5f758ea9ba9631f7c973670b88c85e7993ef09e874b7803a7661d54225 | Python | 289 | 15 | from setuptools import setup, Extension
import numpy
setup(
ext_modules = [
Extension(
"CrystalTracer3D.gwdt.gwdt_impl",
["CrystalTracer3D/gwdt/gwdt_impl.pyx"],
language="c++",
include_dirs=[numpy.get_include()]
)
]
)
|
0c5fa239ae52a2f0eb991bcc46158d74a3e765f0c1cc6cdbc7fb6445d74ddcac | Python | 291 | 12 | """
Unit and regression test for the pimms package.
"""
# Import package, test suite, and other packages as needed
import pimms
import pytest
import sys
def test_pimms_imported():
"""Sample test, will always pass so long as import statement worked"""
assert "pimms" in sys.modules
|
3d44b82e9bf6d367a762c058c5f9a8db1f2519c0082e88aa06ae99125cec4208 | Python | 291 | 10 | import numpy as np
from arcos4py.tools import clipMeas
def test_clipping():
data = np.linspace(1, 10, 10).astype(int)
out = clipMeas(data).clip(0.3, 0.7)
true_val = np.array([3.7, 3.7, 3.7, 4.0, 5.0, 6.0, 7.0, 7.3, 7.3, 7.3])
np.testing.assert_almost_equal(out, true_val)
|
b05e3e07eca66cf047673585cdb4cf6c23653ca3f6251e841ad6c83e3a338f96 | Python | 291 | 9 | """
Experimental module, no software agnostic unified interface for now,
only reserve for internal use
"""
from .composed_compiler import Compiler, DefaultCompiler, default_compile
from .symbolic_compiler import lightcone_compile
from . import simple_compiler
from . import qiskit_compiler
|
ed27868eb82881b449f76082d158bfd7b47cafa07fd437088a04f09341c0d19b | Python | 291 | 14 | from __future__ import annotations
import pytest
from textstat.backend import counts
@pytest.mark.parametrize(
"text,expected",
[
# TODO
],
)
def test_count_arabic_syllables(text: str, expected: int) -> None:
assert counts.count_arabic_syllables(text) == expected
|
fcae6446adc2d8c8cdeaf81ef1e7295f37512b610815da239b12e706de72ed3e | Python | 291 | 16 | '''
Created on 2016.6.29
@author: liangqian
'''
import pygame,sys
pygame.init()
pygame.mixer.init()
pygame.time.delay(1000)
pygame.mixer.music.load("do.wav")
pygame.mixer.music.play()
while 1:
for event in pygame.event.get():
if event.type==pygame.QUIT:
sys.exit()
|
8c92d2212eb24a51a7d374518fe4b4cf7f51c1c9890ccd27a3a5ad75c86418d4 | Python | 293 | 11 | from .channel import ChannelModel
from .imc_file import IMCFileModel
from .imc_file_acquisition import IMCFileAcquisitionModel
from .imc_file_panorama import IMCFilePanoramaModel
__all__ = [
"ChannelModel",
"IMCFileModel",
"IMCFileAcquisitionModel",
"IMCFilePanoramaModel",
]
|
9ac7a62c6cfaea6f72be5b2abc2c12dc56b288b3ab6df58e897e52b88f93ec32 | Python | 293 | 14 | from __future__ import annotations
import pytest
from textstat.backend import counts
@pytest.mark.parametrize(
"text,expected",
[
# TODO
],
)
def test_count_arabic_long_words(text: str, expected: int) -> None:
assert counts.count_arabic_long_words(text) == expected
|
b5e508ecfdecc1563aad259164787c96c9149ebdf47ea8d04f50ed7f32ac8c60 | Python | 293 | 11 |
"""
Module to expose more detailed version info for the installed `numpy`
"""
version = "2.2.4"
__version__ = version
full_version = version
git_revision = "3b377854e8b1a55f15bda6f1166fe9954828231b"
release = 'dev' not in version and '+' not in version
short_version = version.split("+")[0]
|
e1825c4a62d3ea24d671e560c46352c9126af75c3186b82c36be3bb9ce11c3e2 | Python | 293 | 13 | # ruff: noqa: TCH004
from typing import TYPE_CHECKING
if TYPE_CHECKING:
# import modules that have public classes/functions
from pandas.io import (
formats,
json,
stata,
)
# mark only those modules as public
__all__ = ["formats", "json", "stata"]
|
c8fc4ad517bb4433cb8b9bf6afd7adae0b147d22fd34de39080bee477b585700 | Python | 296 | 9 | from pandas import Series
class TestSparseAccessor:
def test_sparse_accessor_updates_on_inplace(self):
ser = Series([1, 1, 2, 3], dtype="Sparse[int]")
return_value = ser.drop([0, 1], inplace=True)
assert return_value is None
assert ser.sparse.density == 1.0
|
01e96300ce75bb8372d952115c3e674ddb02bbe32a15633e994fbe6223f83380 | Python | 297 | 7 | """Tools for describing fNIRS data with general linear models."""
import cedalion.models.glm.design_matrix
from .basis_functions import TemporalBasisFunction, GaussianKernels, Gamma, DiracDelta
#from .design_matrix import hrf_regressors
from .solve import fit, predict, predict_with_uncertainty
|
6f6f3b471baf205f9ff5506fd2969fa1517cf5d781991b50c0da726c378ac7fd | Python | 297 | 14 | """Contains enums relating to genbank components"""
# from python
from enum import Enum
class COMPONENTS(Enum):
GBK = "gbk"
REGION = "region"
PROTOCLUSTER = "protocluster"
PROTO_CORE = "proto_core"
CAND_CLUSTER = "cand_cluster"
CDS = "CDS"
CONCAT_CDS = "concat_cds"
|
cfbceb9f8c5d00c3eb9d86bf94f1f048907d0ec5fd551c278920fcf4f85d56b3 | Python | 297 | 15 | # -*- coding: utf-8 -*-
import os
import sys
import torch.nn as nn
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
class LambdaLayer(nn.Module):
def __init__(self, expr):
super().__init__()
self.expr = expr
def forward(self, x):
return self.expr(x)
|
03c4ea8ef291e21e1668bb68bc647d84350ba56b38ad5fb5271fd0e19cf90dec | Python | 298 | 7 | from pandas.core.groupby.base import transformation_kernels
# There is no Series.cumcount or DataFrame.cumcount
series_transform_kernels = [
x for x in sorted(transformation_kernels) if x != "cumcount"
]
frame_transform_kernels = [x for x in sorted(transformation_kernels) if x != "cumcount"]
|
12b722caa13e69248b6e6362328a3ad5c39a0464be7ac04bc915010a2a459ffc | Python | 299 | 14 | from __future__ import annotations
import pytest
from textstat.backend import counts
@pytest.mark.parametrize(
"text,expected",
[
# TODO
],
)
def test_count_complex_arabic_words(text: str, expected: int) -> None:
assert counts.count_complex_arabic_words(text) == expected
|
1e7b863b1eed400fdb731148277751a0c011d1fa1c931838946a90e20ecb188c | Python | 299 | 18 | from numpy.lib import NumpyVersion
version = NumpyVersion("1.8.0")
version.vstring
version.version
version.major
version.minor
version.bugfix
version.pre_release
version.is_devversion
version == version
version != version
version < "1.8.0"
version <= version
version > version
version >= "1.8.0"
|
eff6c0edcff10e92dce3ff2f3df1f7dbe2f19fd7dc513823436e6caddbf0bc03 | Python | 299 | 9 | def f2py_build_generator(name):
if name == "meson":
from ._meson import MesonBackend
return MesonBackend
elif name == "distutils":
from ._distutils import DistutilsBackend
return DistutilsBackend
else:
raise ValueError(f"Unknown backend: {name}")
|
8e706e7685fad293144495c2bd7f1218e51517d15d83f84b51748544044ab429 | Python | 300 | 15 | from ._metabolic_labeling import (
get_labeling_time_mask,
get_labeling_times,
get_n_neighbors,
get_obs_dist_argsort,
get_parameters,
)
__all__ = [
"get_labeling_time_mask",
"get_labeling_times",
"get_n_neighbors",
"get_obs_dist_argsort",
"get_parameters",
]
|
29a998f5623907870c6a9ff7c19e7270c75733facec4648bed1b6828a3df8c0a | Python | 301 | 15 | from pandas.core.groupby.generic import (
DataFrameGroupBy,
NamedAgg,
SeriesGroupBy,
)
from pandas.core.groupby.groupby import GroupBy
from pandas.core.groupby.grouper import Grouper
__all__ = [
"DataFrameGroupBy",
"NamedAgg",
"SeriesGroupBy",
"GroupBy",
"Grouper",
]
|
1b4a46375d2548bde57ce1e708cc2772f20f3e4ca05977b23619d965d43d44ab | Python | 302 | 11 | import torch
import torch.nn as nn
class UnmapPredictor(nn.Module):
def __init__(self, channels_in):
super().__init__()
self.out = nn.Linear(channels_in, 1)
self.activation = nn.Sigmoid()
def forward(self, x: torch.Tensor):
return self.activation(self.out(x))
|
41eb014e1136d816b5ede51d1b6d6558da8f46f061caea4b9cfb17b9e2dacc7c | Python | 302 | 11 | from pandas import timedelta_range
import pandas._testing as tm
class TestPickle:
def test_pickle_after_set_freq(self):
tdi = timedelta_range("1 day", periods=4, freq="s")
tdi = tdi._with_freq(None)
res = tm.round_trip_pickle(tdi)
tm.assert_index_equal(res, tdi)
|
cd1d6c35a37f6dc97aa82718df39b426b2767327a0b522e6b8732109ca2aea6d | Python | 302 | 12 | """
Constants for the DendCompOsc project
Author: Drew B. Headley
"""
sim_dt = 0.0001 # unit is seconds, simulation time step is 0.1 ms
sim_dur = 150 # unit is seconds, typically simulations are 150 seconds
sim_step_num = sim_dur / sim_dt
# sim_dt / sim_dur # number of time steps in simulation
|
1cc60d63550468619f39aa1e257c1df558bc9159d9704be72d1c158eb4a0940e | Python | 303 | 8 | # Import decorated command line interface functions first
from .imod import fiducials_cli
from .imod import patch_tracking_cli
from .aretomo import aretomo_cli
from ._job_utils import write_global_output
# Then import the cli, it will be decorated with all programs (subcommands)
from ._cli import cli
|
76daebae82b90670034751968c2675f5a674b45b0c7ef141b4b410535b29fda8 | Python | 303 | 8 | # SPDX-FileCopyrightText: 2015 Eric Larson
#
# SPDX-License-Identifier: Apache-2.0
from pip._vendor.cachecontrol.caches.file_cache import FileCache, SeparateBodyFileCache
from pip._vendor.cachecontrol.caches.redis_cache import RedisCache
__all__ = ["FileCache", "SeparateBodyFileCache", "RedisCache"]
|
8741b330032e9d9846ea6bbe15ce3b915cdba894c6419f46e2d37042e1eff5b9 | Python | 303 | 8 | #!/usr/bin/env python3.7
"""Initialize the src package.
The copyrights of this software are owned by Duke University.
Please refer to the LICENSE and README.md files for licensing instructions.
The source code can be found on the following GitHub repository: https://github.com/wmglab-duke/ascent
"""
|
ab87dd6935030d007093d038c2cc1314ca36bb4d87816e057886d484d9136269 | Python | 303 | 14 | from .textstat import textstat
from . import backend
__version__ = (0, 7, 12)
for attribute in dir(textstat):
if callable(getattr(textstat, attribute)):
if not attribute.startswith("_"):
globals()[attribute] = getattr(textstat, attribute)
__all__ = ["textstat", "backend"]
|
3097a2021a00ef24e4d33fb4c2983674c99cbe3e29a1cfbcf743eb14d0b31594 | Python | 306 | 21 | '''
Created on 2016.5.24
@author: liangqian
'''
import json
import os
def readjsonFile(filename):
#print(os.path.abspath(os.curdir))
f = open(filename,'r')
jsonstrs = f.read()
#print(jsonstrs)
jdata = json.loads(jsonstrs)
return jdata
#readjsonFile('../jsondata.txt') |
a037eac00480df54f693c4f8527960d722c1ef8981cd53c81565c63994da8c1b | Python | 307 | 9 | from __future__ import annotations
from pathlib import Path
# debugging recording
RECORDER: bool = False # whether to record the buffer raw data
RECORDER_BUFSIZE: float = 300 # in seconds
RECORDER_PATH: Path = Path.home() / "Documents" / "cas-data" / "debug-buffer-raw.fif"
TRG_CHANNEL: str = "TRIGGER"
|
c41ceb5cfa0a8da342095246a56a48ed47a37452b83e03a88a82e721b4c4f891 | Python | 307 | 13 | import torch.nn as nn
from protgps.utils.classes import ProtGPS
from abc import ABCMeta, abstractmethod
# from efficientnet_pytorch import EfficientNet
import math
class AbstractModel(nn.Module, ProtGPS):
__metaclass__ = ABCMeta
def __init__(self):
super(AbstractModel, self).__init__()
|
00d2a7d928ab651036007699a020c7081d408cb12e51381753699723a9f74efc | Python | 309 | 11 | from pandas import Index
import pandas._testing as tm
def test_pickle_preserves_object_dtype():
# GH#43188, GH#43155 don't infer numeric dtype
index = Index([1, 2, 3], dtype=object)
result = tm.round_trip_pickle(index)
assert result.dtype == object
tm.assert_index_equal(index, result)
|
46437c0db6122b7729f4f596e121a88d6d510feaa83c65bb97436f5e9596d2c6 | Python | 309 | 10 | import numpy as np
# defines scenario upon which the world is built
class BaseScenario(object):
# create elements of the world
def make_world(self):
raise NotImplementedError()
# create initial conditions of the world
def reset_world(self, world):
raise NotImplementedError()
|
bc5c87fb87de0ccddccc0e65700ca53891afbe4fcbb6cf6d423293e4eefdf5f6 | Python | 311 | 12 | import numpy as np
# defines scenario upon which the world is built
class BaseScenario(object):
# create elements of the world
def make_world(self):
raise NotImplementedError()
# create initial conditions of the world
def reset_world(self, world):
raise NotImplementedError()
|
f7af71d3255bef5412c6ccabe3dbf112190e1b3582ebed5ee82d8a7ae4522a89 | Python | 311 | 12 | from .moments import moments
from .neighbors import neighbors, remove_duplicate_cells
from .utils import filter_and_normalize, filter_genes, normalize_per_cell
__all__ = [
"filter_and_normalize",
"filter_genes",
"moments",
"neighbors",
"normalize_per_cell",
"remove_duplicate_cells",
]
|
576e086ecd85b315dddb46b0150286a83f8b8461540f4e89087ac30a0fed3f98 | Python | 313 | 9 | import pandas as pd
def save_loss_curve(history, out_csv: str):
df = pd.DataFrame({
"epoch": list(range(1, len(history.history.get("loss", [])) + 1)),
"loss": history.history.get("loss", []),
"val_loss": history.history.get("val_loss", []),
})
df.to_csv(out_csv, index=False)
|
dd74c7b98e38d257b35bbaf1c382d6f607f1cc311aeecd25d7a71d9e4458c303 | Python | 313 | 18 | """
Public testing utility functions.
"""
from pandas._testing import (
assert_extension_array_equal,
assert_frame_equal,
assert_index_equal,
assert_series_equal,
)
__all__ = [
"assert_extension_array_equal",
"assert_frame_equal",
"assert_series_equal",
"assert_index_equal",
]
|
0de3ac494bd42f0b4b39021e6b222499e68e93da6dbb7d66e193ff2d69c66773 | Python | 314 | 11 | """Initializer for ASCENT tests.
The copyrights of this software are owned by Duke University. Please
refer to the LICENSE and README.md files for licensing instructions. The
source code can be found on the following GitHub repository:
https://github.com/wmglab-duke/ascent
"""
import sys
sys.path.append('..')
|
ab310697c40786a8103c2b8bcdf2b23c8b87dca28fb297fe5153db674a69043e | Python | 314 | 8 | # SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2021 Taneli Hukkinen
# Licensed to PSF under a Contributor Agreement.
__all__ = ("loads", "load", "TOMLDecodeError")
__version__ = "2.3.0" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
from ._parser import TOMLDecodeError, load, loads
|
f1d8a5872c6cce42a02eca2cfa12ccb3e63de4bd3e3ae2f74bd67dc7a5f579a9 | Python | 314 | 8 | AdaLiConfig={
'Epoch':500,#总数
'epoch':1,#当前
'Vth':1.,
'Left':[1.5,0.3],#最大边界和最小边界
'Right':[1.5,0.3],#只有使用AdaLi方法的时候,第二个参数才是最小边界值,否则第一个参数代表别的方法的边界值,第二个参数无意义
} |
73592a673f1d3ab98b1d2eeda31607d9092e379e1f92552ce560b412243540ff | Python | 315 | 7 | from datetime import datetime
def generate_date_prefix():
"""Generate a date prefix in the format YYMMDD_HHMMSS."""
date_for_prefix = datetime.now().strftime('%Y%m%d')[2:]
time_for_prefix = datetime.now().strftime('%H%M%S')
date_prefix = f'{date_for_prefix}_{time_for_prefix}'
return date_prefix |
eb6087ec56d02fab77c01b15d42b645a3fc854ad8f8b9f621993bf7bd5c5c824 | Python | 315 | 9 | from qcportal import PortalClient
from qcportal.record_models import RecordStatusEnum
import sys
dataset_name = sys.argv[1]
client = PortalClient.from_file()
ds = client.get_dataset('singlepoint', dataset_name)
ids = [r.id for e, s, r in ds.iterate_records(status=RecordStatusEnum.error)]
client.reset_records(ids) |
4732f2e90402765f7bf3868585bd845fd10a1822638343f73e294675e5d7731f | Python | 316 | 15 | from typing import Any, Union
from .core import decode, encode
def ToASCII(label: str) -> bytes:
return encode(label)
def ToUnicode(label: Union[bytes, bytearray]) -> str:
return decode(label)
def nameprep(s: Any) -> None:
raise NotImplementedError("IDNA 2008 does not utilise nameprep protocol")
|
566c3a07991a269b92b1a7d70c51d5ffc24003363d7a1e70ecb6a3398a5e5ac2 | Python | 316 | 15 | from abc import abstractmethod
import torch
import torch.nn as nn
class BaseModel(nn.Module):
def __init__(self) -> None:
super().__init__()
@abstractmethod
def forward(self,
time_seires: torch.tensor,
node_feature: torch.tensor) -> torch.tensor:
pass
|
00045245f8b241ad05bba8c205d871f37c893977425ad7ecd2ad1877c98cc708 | Python | 317 | 13 | from pandas.core.arrays import IntervalArray
def test_repr():
# GH#25022
arr = IntervalArray.from_tuples([(0, 1), (1, 2)])
result = repr(arr)
expected = (
"<IntervalArray>\n"
"[(0, 1], (1, 2]]\n"
"Length: 2, dtype: interval[int64, right]"
)
assert result == expected
|
23611d66aa72e0bca35f5ec79f5cb32465828de2da55a3f3b0c80790b7e3fdc4 | Python | 317 | 17 | from __future__ import annotations
from .base import ANY
from .base import default_namespace
from .base import NamedSignal
from .base import Namespace
from .base import Signal
from .base import signal
__all__ = [
"ANY",
"default_namespace",
"NamedSignal",
"Namespace",
"Signal",
"signal",
]
|
6e3d6c100e20b267b3a9b61da8a9d5b4acd8fdf6fae30ecf12867036f69a51d0 | Python | 317 | 19 | from __future__ import annotations
from io import StringIO
import numpy as np
import numpy.lib.array_utils as array_utils
FILE = StringIO()
AR = np.arange(10, dtype=np.float64)
def func(a: int) -> bool:
return True
array_utils.byte_bounds(AR)
array_utils.byte_bounds(np.float64())
np.info(1, output=FILE)
|
7fa29bb16621e684e3dff1561e2a7f76be7505d7334c0b4caa0a67f7f787733e | Python | 318 | 9 | def __getattr__(attr_name):
from numpy._core import umath
from ._utils import _raise_warning
ret = getattr(umath, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core.umath' has no attribute {attr_name}")
_raise_warning(attr_name, "umath")
return ret
|
1457e5a9753f4f44c6b083abadcc479269d5beff5553dd2a73dc6c9baf8a3c2c | Python | 319 | 6 | from .calculator import PyGBatchwiseCalculator, SpkBatchwiseCalculator
from .optimizers import ASEBatchwiseLBFGS
from .pyg_ase_interface import PYGAseInterface
from .task import BatchwiseOptimizeTask
__all__ = [PyGBatchwiseCalculator, SpkBatchwiseCalculator, ASEBatchwiseLBFGS, PYGAseInterface, BatchwiseOptimizeTask]
|
15c99a811e13c8c0c2931448b5dbf78c27c65f288def569f6a9cb2231cc03a60 | Python | 321 | 14 | import numpy as np
import os
def remove_high_fr_units(n_spikes, rec_len_sec,
threshold=70, units_in=None):
if units_in is None:
units_in = np.arange(len(n_spikes))
# units_keep
units_keep = units_in[
n_spikes[units_in]<=threshold*rec_len_sec]
return units_kee... |
94a5b4577b890c56d7619f8103b820fd5a7f4cf486874ceaad4783ddf6e8f6ca | Python | 321 | 14 | import numpy as np
import os
def remove_low_fr_units(n_spikes, rec_len_sec,
threshold=0.5, units_in=None):
if units_in is None:
units_in = np.arange(len(n_spikes))
# units_keep
units_keep = units_in[
n_spikes[units_in]>=threshold*rec_len_sec]
return units_kee... |
9913b567e7c6e07445e1d44ff7822c41f01cd909ebdd34ad5d0729279d21e770 | Python | 321 | 9 | from grimace.frame_cropper import FrameCropper
from grimace.frame_quality_model import FrameQualityModel
class FrameExtractor:
def __init__(self, frame_quality_model: FrameQualityModel, frame_cropper: FrameCropper):
self.frame_quality_model = frame_quality_model
self.frame_cropper = frame_cropper
... |
dd29cdb23c652a86c3f039fc07d7a08c842e40b75b5b3f4eb55019e3fc250f0f | Python | 322 | 9 | def __getattr__(attr_name):
from numpy._core import _dtype
from ._utils import _raise_warning
ret = getattr(_dtype, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core._dtype' has no attribute {attr_name}")
_raise_warning(attr_name, "_dtype")
return re... |
2f35f8ecc004788fefb77e1464783fa00726fb4602d3aaf660995da3f3409069 | Python | 323 | 16 | """Module containing file loading automation"""
from .load_files import (
load_dataset_folder,
get_mibig,
load_gbks,
get_all_bgc_records,
get_all_bgc_records_query,
)
__all__ = [
"load_dataset_folder",
"get_mibig",
"load_gbks",
"get_all_bgc_records",
"get_all_bgc_records_query",... |
7690ed550bd20e2a392f65b96fa5d456af50385fc4ef472faa1bc1d29172fc92 | Python | 323 | 16 | from __future__ import annotations
import click
from .. import sys_info
@click.command(name="sys-info")
@click.option(
"--developer",
help="Display information for optional dependencies.",
is_flag=True,
)
def run(developer: bool) -> None:
"""Run sys_info() command."""
sys_info(developer=develope... |
cca088bb1db2e0c167bb2f7b5a2e0a7c89802d5df51a5fe1f29b9e6fdff85013 | Python | 324 | 10 | from .data import AijData
from .graph import Collater, get_graph, load_orbital_types
# from .model import Net
from .maceh import Net
from .utils import LossRecord
from .e3modules import Rotate, e3TensorDecomp
from .kernel import DeepHE3Kernel
from .analyzer import testResultAnalyzer
from .calculator import MACEHCalcul... |
8fd05fb502cb96355d704353e357867e51bb0c0ee689743bab761fe77fb361c6 | Python | 326 | 9 | def __getattr__(attr_name):
from numpy._core import records
from ._utils import _raise_warning
ret = getattr(records, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core.records' has no attribute {attr_name}")
_raise_warning(attr_name, "records")
retur... |
e3a5e0781134b1e8a6a77c03e0ec742aeb5878bc1db1d452886102706d6262ef | Python | 328 | 15 | from numpy.testing import IS_WASM, IS_EDITABLE
import pytest
if IS_WASM:
pytest.skip(
"WASM/Pyodide does not use or support Fortran",
allow_module_level=True
)
if IS_EDITABLE:
pytest.skip(
"Editable install doesn't support tests with a compile step",
allow_module_level=Tru... |
209b73ce33d2c38d7d3fe7364f8393e3ca7e66ee09a21a05f6cbd6aa10ec8609 | Python | 329 | 16 | from numpy.testing import IS_WASM, IS_EDITABLE
import pytest
if IS_WASM:
pytest.skip(
"WASM/Pyodide does not use or support Fortran",
allow_module_level=True
)
if IS_EDITABLE:
pytest.skip(
"Editable install doesn't support tests with a compile step",
allow_module_level=Tr... |
8d8b5bbd5ca0f2e399b1d70278b85a5c8751ecc39f321d63d386976c935b7caf | Python | 329 | 14 | import pytest
from . import util
class TestValueAttr(util.F2PyTest):
sources = [util.getpath("tests", "src", "value_attrspec", "gh21665.f90")]
# gh-21665
@pytest.mark.slow
def test_gh21665(self):
inp = 2
out = self.module.fortfuncs.square(inp)
exp_out = 4
assert out ==... |
93df198b488874a9055a5a416107a69e477613d3154c17f960fbe0f6b7451c64 | Python | 329 | 12 | """Contains utility functions for various applications"""
from .multiprocess import start_processes, worker_method
from .filters import domain_includelist_filter, class_filter, category_filter
__all__ = [
"start_processes",
"worker_method",
"domain_includelist_filter",
"class_filter",
"category_fi... |
d3133175e2cece20e61ec44cffc96e121e12fa441d328320e86c4d0c36acebd9 | Python | 329 | 18 | """
A set of methods retained from np.compat module that
are still used across codebase.
"""
__all__ = ["asunicode", "asbytes"]
def asunicode(s):
if isinstance(s, bytes):
return s.decode('latin1')
return str(s)
def asbytes(s):
if isinstance(s, bytes):
return s
return str(s).encode('... |
ea78bc0479dbc3bddde2c6208b8ceafd96f12f9530200f5eed54bbd66a7be29f | Python | 329 | 14 | from pathlib import Path
from typing import List, Optional
from pydantic import BaseModel
class GuiTiltSeries(BaseModel):
name: str
tilt_image_files: List[Path]
tomogram_file: Optional[Path] = None
denoised_tomogram_file: Optional[Path] = None
def __len__(self):
return len(self.tilt_imag... |
f5e5d7d303c15686fdf4e8cb16b67807401047bb6dcd2f534c56b1e25e73000f | Python | 330 | 13 | import pandas
import numpy
import pytest
import sbmlcore
@pytest.mark.skip(reason="need to work out how to install msms on GitHub actions")
def test_residue_depth():
a = sbmlcore.ResidueDepth('tests/3pl1-mod-chains.pdb', segids=['A'])
assert float(a.results[a.results.resid==1].depth) == pytest.approx(2.10304... |
eb1e9e37dfb936c49051273aadfddf622792da9a18118d2dfee8dbc2017d4b94 | Python | 331 | 17 | import numpy as np
np.isdtype(np.float64, (np.int64, np.float64))
np.isdtype(np.int64, "signed integer")
np.issubdtype("S1", np.bytes_)
np.issubdtype(np.float64, np.float32)
np.ScalarType
np.ScalarType[0]
np.ScalarType[3]
np.ScalarType[8]
np.ScalarType[10]
np.typecodes["Character"]
np.typecodes["Complex"]
np.typeco... |
9a53b6643dc5a6ce31dc113b1e9bd21d0923d831bd2d694a2c2a9d1c4f7ed2ef | Python | 333 | 15 | from __future__ import annotations
from pathlib import Path
import locate
def data_path(filename: str | None = None) -> Path:
"""
Get a path to a file in the data directory.
"""
if filename is None:
return Path(locate.this_dir(), "data")
else:
return Path(locate.this_dir(), "data... |
698255695aa24862ae3df4886bbaf430c64c42424fd8d44d27b65dd9db33ca05 | Python | 334 | 9 | def __getattr__(attr_name):
from numpy._core import getlimits
from ._utils import _raise_warning
ret = getattr(getlimits, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core.getlimits' has no attribute {attr_name}")
_raise_warning(attr_name, "getlimits")
... |
b1668081b1ffa623b49960de56aaa8aa416aaa93c733cec5a8e64527700ef255 | Python | 334 | 9 | def __getattr__(attr_name):
from numpy._core import overrides
from ._utils import _raise_warning
ret = getattr(overrides, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core.overrides' has no attribute {attr_name}")
_raise_warning(attr_name, "overrides")
... |
4f9671c21df18ec00cbb4f93a7e2e9320e6ff5e9e4e9b5da7097a578a9d42ace | Python | 337 | 19 | def toMath(angle):
if -90 < angle < 90:
angle = 90 - angle
elif 90 <= angle <= 180:
angle = 90 + (360 - angle)
elif -180 <= angle <= -90:
angle = 270 - (180 + angle)
return angle
def toVizard(angle):
if 0 <= angle < 270:
angle = 90 - angle
elif 270 <= angle <= 360:
angle = 90 + (360 - angle... |
ec93b6b199cd7f1ceb109b32032d7d034b74431d82a2b508cd6973a20f81a9ac | Python | 337 | 15 | import logging
import yass
from yass import preprocess
# configure logging module to get useful information
logging.basicConfig(level=logging.INFO)
# set yass configuration parameters
yass.set_config('config.yaml', 'example-preprocess')
# run preprocessor
(standardized_path,
standardized_params,
whiten_filter) = ... |
321bb13d1c30839848747709f8b001750d28604606571783f9aa26685b3df9fe | Python | 338 | 9 | def __getattr__(attr_name):
from numpy._core import shape_base
from ._utils import _raise_warning
ret = getattr(shape_base, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core.shape_base' has no attribute {attr_name}")
_raise_warning(attr_name, "shape_base... |
333575f798daa0d53f49c80eb0e7bcf79692e9c3fa66fadf16fd4363e90951bc | Python | 338 | 12 | from torchvision import transforms
def get_eval_transforms(mean, std, target_img_size = -1):
trsforms = []
if target_img_size > 0:
trsforms.append(transforms.Resize(target_img_size))
trsforms.append(transforms.ToTensor())
trsforms.append(transforms.Normalize(mean, std))
trsforms = transforms.Compose(trsforms)... |
6b50e44ad9414ac555892270e76dcc9be95ba15680b4296804d0ab8a0c8ea5b2 | Python | 338 | 9 | def __getattr__(attr_name):
from numpy._core import arrayprint
from ._utils import _raise_warning
ret = getattr(arrayprint, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core.arrayprint' has no attribute {attr_name}")
_raise_warning(attr_name, "arrayprint... |
85f151036d2d458997240a0964b188d38275df567b41a6846c8366dc5c1f55b4 | Python | 338 | 16 | from pandas import (
DataFrame,
Timedelta,
)
def test_no_overflow_of_freq_and_time_in_dataframe():
# GH 35665
df = DataFrame(
{
"some_string": ["2222Y3"],
"time": [Timedelta("0 days 00:00:00.990000")],
}
)
for _, row in df.iterrows():
assert row.... |
a71fab48f93000c6d1366a79b882e0542d904abef72272857ef5bb2d27cd186c | Python | 338 | 9 | def __getattr__(attr_name):
from numpy._core import einsumfunc
from ._utils import _raise_warning
ret = getattr(einsumfunc, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core.einsumfunc' has no attribute {attr_name}")
_raise_warning(attr_name, "einsumfunc... |
b6f89ea72bb02b207a48f576f2dd9e672ff93dc0a94f9eb3ed0663cdb329910c | Python | 338 | 10 | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.app.wsgiapp import run
if __name__ == "__main__":
# see config.py - argparse defaults to basename(argv[0]) == "__main__.py"
# todo: let runpy.run_module take care of argv[0] rewriting
run... |
d5c1ea8ec7c50ab3057f7079b70ce87314c951d1cc2e85d4a72e6526816a522f | Python | 338 | 12 | from __future__ import annotations
def main(args: list[str] | None = None) -> int:
"""This is preserved for old console scripts that may still be referencing
it.
For additional details, see https://github.com/pypa/pip/issues/7498.
"""
from pip._internal.utils.entrypoints import _wrapper
retu... |
baaee807e964eebb206107abf2a794b2a0f9692102b513d21147cace7f750621 | Python | 341 | 13 | import numpy as np
from pandas import Index
import pandas._testing as tm
class TestWhere:
def test_where_intlike_str_doesnt_cast_ints(self):
idx = Index(range(3))
mask = np.array([True, False, True])
res = idx.where(mask, "2")
expected = Index([0, "2", 2])
tm.assert_index_... |
68daae2e77d95f55d9440cf9309cdae594fb225809a344cc1e547ad984f66e23 | Python | 342 | 9 | def __getattr__(attr_name):
from numpy._core import fromnumeric
from ._utils import _raise_warning
ret = getattr(fromnumeric, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core.fromnumeric' has no attribute {attr_name}")
_raise_warning(attr_name, "fromnum... |
c5fa97880ff9a84b5d84a212ccb6ade1c5d30fe12db41938d4b2c3f8bfa6bbcc | Python | 342 | 9 | import numpy as np
from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
def compute_metrics(y_true: np.ndarray, y_pred: np.ndarray):
return {
"MSE": float(mean_squared_error(y_true, y_pred)),
"MAE": float(mean_absolute_error(y_true, y_pred)),
"R2": float(r2_score(y_... |
d0c4f62dc39cb093d934b08d862adfaa70a43dbddc16e3d66cc89fe67a9919fd | Python | 342 | 21 | from setuptools import setup, find_packages
setup(
name='campy',
version='2.0.1',
packages=find_packages(),
install_requires=[
'imageio',
'matplotlib',
'numpy',
'pyserial',
'pyyaml',
'scikit-image',
'PyQt5',
],
entry_points={
"console_scripts": [
"campy-acquire = campy... |
129efaf7680640c76b6220b1c6e76a5d7f8203a4b5b0edcbd8fd88e0d1c8adea | Python | 344 | 11 | from pandas import Interval
def test_interval_repr():
interval = Interval(0, 1)
assert repr(interval) == "Interval(0, 1, closed='right')"
assert str(interval) == "(0, 1]"
interval_left = Interval(0, 1, closed="left")
assert repr(interval_left) == "Interval(0, 1, closed='left')"
assert str(int... |
dcaa2bc92ad9520c300f5fbf5f75591aaa7ba8f7f09edc220c1e51af3ea7481f | Python | 344 | 17 | # Re-export the ACF-facing API from internal module(s)
from .scripts.calculate_acf import (
acf_pearsonr_trial_avg,
acf_sttc_trial_avg,
acf_sttc_trial_concat,
acf_sttc,
acf_sttc_fast,
)
__all__ = [
"acf_pearsonr_trial_avg",
"acf_sttc_trial_avg",
"acf_sttc_trial_concat",
"acf_sttc",... |
98afe5fadb85fd37a82b8819a919dc9be1427b63d4824d804b7abaab43356085 | Python | 345 | 14 | import pytest
import pandas.util._test_decorators as td
import pandas as pd
import pandas._testing as tm
@td.skip_if_installed("tables")
def test_pytables_raises():
df = pd.DataFrame({"A": [1, 2]})
with pytest.raises(ImportError, match="tables"):
with tm.ensure_clean("foo.h5") as path:
d... |
1bd4ba8e47577a04645e5e7c852a4f9e69dd8ddca6e3cd35633ab6973ce60293 | Python | 346 | 9 | def __getattr__(attr_name):
from numpy._core import defchararray
from ._utils import _raise_warning
ret = getattr(defchararray, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core.defchararray' has no attribute {attr_name}")
_raise_warning(attr_name, "defc... |
46f85f58587d291d123c335cac06275be3cef53280343ef938d5e12f90e3b3c4 | Python | 346 | 9 | def __getattr__(attr_name):
from numpy._core import numerictypes
from ._utils import _raise_warning
ret = getattr(numerictypes, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core.numerictypes' has no attribute {attr_name}")
_raise_warning(attr_name, "nume... |
1ff88d229c7dfa1635710371aa34f677fe525d98496cca3f71aab8feae8b07b2 | Python | 347 | 13 | """Simple script to compute the api hash of the current API.
The API has is defined by numpy_api_order and ufunc_api_order.
"""
from os.path import dirname
from code_generators.genapi import fullapi_hash
from code_generators.numpy_api import full_api
if __name__ == '__main__':
curdir = dirname(__file__)
pri... |
585c494ac9e3159bd2c326d7c8748210ce1a136c8c010a37fd8e4be82757ad8d | Python | 349 | 14 | r"""
It's used to check basic rnn features with cuda.
For example, it would throw exception if missing some components are missing
"""
import torch
import torch.nn as nn
device = torch.device("cuda:0")
rnn = nn.RNN(10, 20, 2).to(device)
inputs = torch.randn(5, 3, 10).to(device)
h0 = torch.randn(2, 3, 20).to(device)
... |
8995526e56d98954ba32e3110051928a8e1a0127c253ce93bc2d15f78344c4a2 | Python | 349 | 8 | ## ...........................................................................
##
## PIMMS (Polymer Interactions in Multicomponent Mixtures)
## Alex Holehouse, Pappu Lab, Holehouse Lab
## Copyright 2015 - 2026
## ...........................................................................
"""Compiled kernels for the l... |
9afe50509f9376a7a211db598abbaef48e9e3ec35c2a92f5a104d5305f409b1a | Python | 349 | 12 | #replace this code with code to read inputs from file, normalize, and sort into lists
import tensorflow as tf
import numpy as np
import pulse2percept as p2p
import random
def parse_inputs(inputsfile):
inputlist = []
#CODE TO READ IN AN INPUT FILE AND CONVERT IT INTO A LIST OF INPUTS
return inputlist
# pri... |
bd367877c19abfc1d0942429a839325d037aba0c18ed1875952e37676e18ac03 | Python | 349 | 16 | import pandas
import numpy
import pytest
import sbmlcore
def test_amino_acid_rogov_change_value():
a = {'mutation': ['A1D', 'E2K']}
df = pandas.DataFrame(a)
a = sbmlcore.AminoAcidRogovChange()
df = a._add_feature(df)
assert 'd_rogov' in df.columns
assert df.d_rogov.values == pytest.approx(n... |
d15abe348c5bba947280577db7395991b866478c14097d4acdafe158ced6eb2e | Python | 349 | 11 | from setuptools import setup
setup(name='scribblescreator',
version='2.0.1',
description='Automatic scribble creation based on ground truth data.',
author='Roman Schwob',
author_email='roman.schwob@students.unibe.ch',
license='GNU GPLv3',
packages=['.', 'scribbles_testing'],
package_dir={''... |
49af44736636d643e68e7e17b21ed8d55d5cedb51dc588f38b12301d9278b02a | Python | 350 | 9 | def __getattr__(attr_name):
from numpy._core import function_base
from ._utils import _raise_warning
ret = getattr(function_base, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core.function_base' has no attribute {attr_name}")
_raise_warning(attr_name, "f... |
7c9a2bd3d03d2904d4d5556a0a98244dd3fba1a6deecc4ce7bc98a0483fde9d4 | Python | 350 | 13 | from e3nn import o3
def tp_path_exists(irreps_in1, irreps_in2, ir_out):
irreps_in1 = o3.Irreps(irreps_in1).simplify()
irreps_in2 = o3.Irreps(irreps_in2).simplify()
ir_out = o3.Irrep(ir_out)
for _, ir1 in irreps_in1:
for _, ir2 in irreps_in2:
if ir_out in ir1 * ir2:
... |
94bcf16ae03c3d59e8a53b8687d512b759d5c36a8223c67b6cbeba7abdc9a075 | Python | 350 | 9 | def __getattr__(attr_name):
from numpy._core import _dtype_ctypes
from ._utils import _raise_warning
ret = getattr(_dtype_ctypes, attr_name, None)
if ret is None:
raise AttributeError(
f"module 'numpy.core._dtype_ctypes' has no attribute {attr_name}")
_raise_warning(attr_name, "_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.