sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
217755bdeac416ff5a42d162add39355cc90893793d49b689da3e5b0174f2f84 | Python | 666 | 33 | # __anti_pattern_start__
import ray
import numpy as np
ray.init()
@ray.remote
def generate_rollout():
return np.ones((10000, 10000))
@ray.remote
def reduce(rollout):
return np.sum(rollout)
# `ray.get()` downloads the result here.
rollout = ray.get(generate_rollout.remote())
# Now we have to reupload `rol... |
c3eb625083875266e82fae80ca4b332ab6bc691fd92bbf50e423dce18151f198 | Python | 666 | 30 |
def fit_gene_model(gene_counts, umi_counts):
tj = gene_counts.sum()
tis = umi_counts
total = tis.sum()
N = gene_counts.size
min_size = 10**(-10)
mu = tj*tis/total
vv = (gene_counts - mu).var()*(N/(N-1))
my_rowvar = vv
# size = (tj**2) * (tis**2).sum()/total**2 / ((N-1)*my_rowv... |
3a336f4603fae3f7268fb9c8aea33f6e5d464491e8fd91c460c2f8e6da8ab4df | Python | 667 | 21 | try:
from hic3defdr.analysis import HiC3DeFDR
from hic3defdr.plotting.roc import plot_roc
from hic3defdr.plotting.fdr import plot_fdr
from hic3defdr.plotting.fn_vs_fp import plot_fn_vs_fp
from hic3defdr.plotting.distance_bias import plot_distance_bias
from hic3defdr.plotting.dispersion import co... |
8001938a8f9bafd8629f7294e6dceecdc43b64cc7d917ef8467e8b252daeb4c8 | Python | 667 | 27 | import vcf
import sys
import argparse
def main():
args = parse_args()
vcf_reader = vcf.Reader(open(args.vcf_file, 'r'))
print 'Reference\tPosition\tReference Base\tCalled Base'
for record in vcf_reader:
cb = record.INFO['CB']
ref = record.REF
pos = record.POS
ref_seq = r... |
a78ccee31fe64a6fd6d86b0729ce4b55985c4a9b26553c94e0424fef0cf4a247 | Python | 667 | 22 | #!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rapppid_org.settings")
try:
from django.core.management import execute_from_command_line
except ... |
31476877d224b36b988600be76b313f4a276b66d1a8db127b1d2227c44d28193 | Python | 669 | 13 | from emp import *
import time
D=load_wt(); Y=counts(D.t_court.values,D.defbehav.values); N=len(D)
extra={"C+D, a=0":[k for k in BASE if k!="a"]+["b_gen","b_c"],
"C+D, d1=0":[k for k in BASE if k!="d1"]+["b_gen","b_c"],
"C+D":BASE+["b_gen","b_c"],"B+D":BASE+["b_th","b_c"],"B+C+D":BASE+["b_th","b_gen","b_c"... |
85d1813a4739e25c792eae492d8a3341b09b88cb7373c8efd88d51d0ea9820ca | Python | 669 | 15 | # project dependencies
from deepface.api.src.modules.auth.service import AuthService
from deepface.api.src.modules.models.service import ModelService
from deepface.api.src.dependencies.variables import Variables
# pylint: disable=too-few-public-methods
class Container:
def __init__(self, variables: Variables) -> ... |
566dfea168d6ceedf401031b127e58891cecf3a2890fbd543d970a88f5ad7a54 | Python | 670 | 14 | # Copyright (c) 2017-present, Facebook, Inc.
#
# 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... |
838778a65149b9a88564c436d1086adb4d97b0e368c2b6ec7dd91e44e9e11eed | Python | 670 | 32 | class CFG:
output_dir = './logs/'
# model and save model
experiment = 'densenet121'
model = 'densenet121'
pretrained = True
# training
epochs = 150
lr = 0.0003
min_lr = 1e-6
batch_size = 32
T_max = int(30000/batch_size*epochs)+50
T_0 ... |
650db4f5705a5b560c9b07cb24ccc8f66b1c1e8864b9fd702bdcab08541e87be | Python | 671 | 27 | import socket
from contextlib import closing
from ray._raylet import ( # noqa: F401
build_address,
get_all_interfaces_ip,
get_localhost_ip,
is_ipv6,
is_localhost,
node_ip_address_from_perspective,
parse_address,
)
def find_free_port(family: socket.AddressFamily = socket.AF_INET) -> int:
... |
e905d664cc6a13071e023a6c114a92ede11f3b80c15cb4d5accf2208c42535fb | Python | 673 | 25 | from setuptools import setup
#import warnings
#from pkg_resources import DeprecationWarning as pkg_warning
#warnings.simplefilter("ignore", pkg_warning)
setup(
name='bio-allo',
version='1.2.0',
author='Alexis Morrissey',
author_email='anm5579@psu.edu',
packages=['Allo'],
python_requires='>=3.10... |
285b92c6b9c217876504e06be291e9d9409b52fbaca83457e9920c1d27670c2f | Python | 674 | 21 | from data_profiling.report.presentation.flavours.html import HTMLHTML
from data_profiling.report.presentation.flavours.html.templates import template
def test_report_title_strip_tags():
html = template("report.html").render(
title="<strong>Title</strong>: with <em>tags</em>",
theme=None,
b... |
a0b04b2d0dfec4943ca8b155c4f5f86f01292ea447ac6ba365f78dfc2a821d9c | Python | 675 | 20 | from mmdet.datasets import CocoDataset
from lqit.registry import DATASETS
RUOD_METAINFO = {
'classes': ('holothurian', 'echinus', 'scallop', 'starfish', 'fish',
'corals', 'diver', 'cuttlefish', 'turtle', 'jellyfish'),
'palette': [(235, 211, 70), (106, 90, 205), (160, 32, 240), (176, 23, 31),
... |
013cd0f7a3f761b6217f76756997f3cca3266e2401769d89f780a3510dfe7f1f | Python | 676 | 30 | from pickle import (
_Pickler,
_Unpickler as Unpickler,
_loads as loads,
_load as load,
PickleError,
PicklingError,
UnpicklingError,
HIGHEST_PROTOCOL,
)
__all__ = [
"PickleError",
"PicklingError",
"UnpicklingError",
"Pickler",
"Unpickler",
"load",
"loads",
... |
ee6b9515681f87c10feb595f65e42e9584f1ad8bff8e27239ba8202b6aa57296 | Python | 676 | 23 | import numpy as np
def mylog(mat, log=True, del_diag=True, del_subdiag=True):
mat = np.where(np.isnan(mat) == True, 0, mat)
matmin = mat.ravel()[np.nonzero(mat.ravel())].min()
logmat = np.where(mat == 0, matmin / 2, mat)
if log:
logmat = np.log2(logmat)
if del_diag:
np.fil... |
313ad55eacedaf027a59d4d8af5278b9abadd96a58ce68182c032f1fcce5d7b8 | Python | 678 | 22 |
from lisa import FromCoverage
import numpy as np
import argparse
def main(args):
coverage_array = FromCoverage.convert_bigwig(args.bigwig_file, args.species)
np.save(args.name, coverage_array)
if __name__ == "__main__":
bw_parser = argparse.ArgumentParser()
bw_parser.add_argument('species... |
8ce2cdca685d779e1bd08c98ca04f72d3727b73e6ee9c0284de9a1b54ed2e778 | Python | 678 | 13 | from emp import *
import time,os,sys
D=load_wt(); Y=counts(D.t_court.values,D.defbehav.values); N=len(D)
M={"A":BASE,"C+D":BASE+["b_gen","b_c"],"B+D":BASE+["b_th","b_c"],"C":BASE+["b_gen"],"B":BASE+["b_th"]}
fn="boot.json"; B=json.load(open(fn)) if os.path.exists(fn) else []
rng=np.random.default_rng(len(B)+1); t=time.... |
bf3d7d9b849a950d7545949abd6d38e02ce66fdd066555fd56f876a4b47bf725 | Python | 678 | 20 | import pandas as pd
from data_profiling import ProfileReport
from data_profiling.utils.cache import cache_file
if __name__ == "__main__":
# Read the Titanic Dataset
file_name = cache_file(
"titanic.csv",
"https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv",
)
... |
f477a82388179bbd7e1d5148c75c7b00b0c2502d81f1844f5a7da6264ba403cf | Python | 678 | 22 | import setuptools
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setuptools.setup(
name="scorect",
version="0.0.2",
author="Lucas Seninge",
author_email="lseninge@ucsc.edu",
description="scoreCT: Automated cell type annotation in scRNA-seq data",
long_de... |
2e1de428611d7e1fae8dff405dab0853bb641a653953bcb4056c54ff4bea2c86 | Python | 679 | 24 | # flake8: noqa
from ray import serve
# Stubs
def connect_to_db(*args, **kwargs):
pass
# __health_check_start__
@serve.deployment(health_check_period_s=10, health_check_timeout_s=30)
class MyDeployment:
def __init__(self, db_addr: str):
self._my_db_connection = connect_to_db(db_addr)
def __call_... |
5d933c8f106c0c4aaf46a53ddf1278421de85d190a036b3a2d92859aa3ae5f7a | Python | 679 | 21 | """
Test for issue 243:
https://github.com/Data-Centric-AI-Community/data-profiling/issues/243
"""
import pandas as pd
from data_profiling import ProfileReport
def test_issue243():
df = pd.DataFrame(data=[[1, 2], [3, 4]], columns=["Col 1", "Col 2"])
columns_before = df.columns
_ = ProfileReport(df, progr... |
683528f9772f8d1d098b681ad9077d88f8624745eabad547a6246962b7795179 | Python | 680 | 17 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
b6571fa5a0ebe333752514e130e34db71af42862322a25b80d86658a7d9840cd | Python | 680 | 30 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from .client import ( # noqa
Client,
NonRetryableRequestException,
RateLimitExceededException,
RequestException,
)
from .mo... |
41df88b6cba4d297049903dddfad100f9e750c70b5484d0627f0afc1f6fc580a | Python | 681 | 23 | import random
import torch
import numpy as np
from agent.classifiers.utils.device_mgmt import is_a_cuda_device
def set_random_seed(seed_val, use_gpu):
random.seed(seed_val)
np.random.seed(seed_val)
torch.manual_seed(seed_val)
# para que "torch.use_deterministic_algorithms(True)" funcione:
# nano... |
4b0e54a9c5f8ec6c37fd8a805fd2b93ccb1d0270f77f4907e17b9a3b146dd9a3 | Python | 681 | 16 | from typing import List
import numpy as np
def generate_crossval_split(train_identifiers: List[str], seed=12345, n_splits=5) -> List[dict[str, List[str]]]:
splits = []
from sklearn.model_selection import KFold # lazy: ~0.2 s per process, only needed to create splits
kfold = KFold(n_splits=n_splits, shuf... |
8017ad8991184eb517965f1802a4d1a91d326b78b9ff35d64d35649fb41a2981 | Python | 681 | 16 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
f7ce1c6fecb67f6af7f1277a453377a36cd57190ed76f87eda5c287385db2ecd | Python | 681 | 18 | # Copyright 2026 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
91d3b99bebe49308081f7fe15d684188a912b67b735ac833e305eccef4b5aa19 | Python | 682 | 19 | #
# Copyright (c) 2021, NVIDIA 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 ... |
cd7fc97dfe50b934fdce1c33e919b36ee65d408443abf2f183f1373333eb88da | Python | 682 | 28 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import sys
import hydra
import fairchem.core.common.gp_utils as gp_utils
from fairchem.core._cli impo... |
2a400690721fcc776815f37b412765dff9ad07e0a0c3844437ef5f9ce0ccbeb8 | Python | 684 | 23 | """Generate the code reference pages."""
from pathlib import Path
import mkdocs_gen_files
for path in sorted(Path("src").rglob("*.py")): #
module_path = path.relative_to("src").with_suffix("") #
doc_path = path.relative_to("src").with_suffix(".md") #
full_doc_path = Path("reference", doc_path) #
... |
2e77f7d2c2a6b80e49540a15f2bb803bef59927a3f4071368302293a17354414 | Python | 684 | 26 | import pytest
import samna
from sinabs.backend.dynapcnn import io
from tests.hw_utils import find_open_devices
def test_is_device_type():
devices = find_open_devices()
if len(devices) == 0:
pytest.skip("A connected Speck device is required to run this test")
devices = samna.device.get_all_devic... |
6860e35fb5f644814318e809a6b79e467ababc2aa4ddf8756b3e9eb883d3ee8c | Python | 684 | 27 | from typing import Tuple
from pyspark.sql import DataFrame
from data_profiling.config import Settings
def describe_boolean_1d_spark(
config: Settings, df: DataFrame, summary: dict
) -> Tuple[Settings, DataFrame, dict]:
"""Describe a boolean series.
Args:
series: The Series to describe.
... |
deca87613cc26a1729b64be8f04b922e2c505a564f49b2012e314ef595dfaf01 | Python | 684 | 51 | """
Fixed constants (units, atom types, etc.)
"""
import qcelemental as qcel
au2ang = qcel.constants.conversion_factor("bohr", "angstrom")
elem_to_z = {
'H' : 1,
'B' : 3,
'C' : 6,
'N' : 7,
'O' : 8,
'F' : 9,
'NA' : 11,
'Na' : 11,
'P' : 15,
'S' : 16,
'CL' : 17,
... |
39bc05c7bcdddb24d17b050f413d6fbaea3486037d44911a2c8034114f4691fb | Python | 685 | 24 | #!/usr/bin/env python
from setuptools import setup
setup(name='svqc',
version='0.1',
description='QC package for the GATK SV pipeline',
classifiers=[
'Development Status :: 3 - Alpha',
'Programming Language :: Python :: 2.7',
],
url='https://github.com/talkowski-lab/g... |
a8c86f4dacb78059af41b298d79f2e7b0e1762389ef7730458f75ebb2d023afd | Python | 687 | 17 | __author__ = "Marko van Treeck"
__copyright__ = "Copyright 2022, Kather Lab"
__license__ = "MIT"
__version__ = "0.8.0"
__maintainer__ = "Marko van Treeck"
__email__ = "mvantreeck@ukaachen.de"
__changelog__ = {
"0.2.0": "Update marugoto.features from 0.1.0 to 0.2.0",
"0.3.0": "Update marugoto.features from 0.2.... |
c93a7919689091f52cdc756e0848a492d5026bbe78a164942410435ae9784b60 | Python | 687 | 20 | from pfrl import action_value # NOQA
from pfrl import agent # NOQA
from pfrl import agents # NOQA
from pfrl import distributions # NOQA
from pfrl import env # NOQA
from pfrl import envs # NOQA
from pfrl import experiments # NOQA
from pfrl import explorer # NOQA
from pfrl import explorers # NOQA
from pfrl impor... |
e5b0d97e6cb2ade36165299aa3da176cca4f87234a95cbd979bdf44b853ec071 | Python | 688 | 17 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
47d695d54f6c4351a8f10d68f25b48265d86a8dd3b0029d5ae5cceb50503af7d | Python | 689 | 24 | import numpy as np
import pandas as pd
class ThetaPost:
def __init__(self, theta, theta_cv):
self.theta = theta
self.theta_cv = theta_cv
def new(bulk_id, cell_type, gibbs_list):
n = len(bulk_id)
k = len(cell_type)
assert len(gibbs_list) == n
theta = np.zeros((n... |
0c6fc7a8864653d553f81cf4195f4d47b15f68cb9bf408c81ada5700f99b04f9 | Python | 690 | 28 | from pathlib import Path
import numpy as np
import pandas as pd
import pytest
from data_profiling.config import Settings
from data_profiling.model.spark.missing_spark import missing_bar
@pytest.fixture
def missing_data(spark_session):
missing_testdata = pd.DataFrame(
{
"test_num_1": [1, np.n... |
83024278334b221d3c712aed7ac67d048433c3ffa29403e4c70b8bb3727383ff | Python | 690 | 25 | import unittest
import torch
from rising.random import NormalParameter, UniformParameter
class TestContinuous(unittest.TestCase):
def test_uniform(self):
self.check_distribution(UniformParameter(0, 2), torch.distributions.Uniform(0, 2))
def test_normal(self):
self.check_distribution(NormalP... |
f05e74a5b885843719f91f4b6549855df30e6f4bd0afd1b14b1bb9f3aa78f2f7 | Python | 690 | 20 | from ray._private import ray_constants
def is_python_ray_event_enabled(event_type: str) -> bool:
"""Whether events of the given type should be emitted through the Python
EventRecorder (Ray event export framework).
Args:
event_type: Name of a RayEvent.EventType, e.g. "PLATFORM_EVENT".
Returns... |
14d68d9d372c6f150eea6d7794c58b944f48c4c23c38e3c1bd80bb28e006ad2c | Python | 691 | 24 | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
__all__ = [
"BaseTrainerV2",
"ForcesTrainerV2",
"EnergyTrainerV2",
"ComputeStatsTask",
"MyRelaxationTask",
"LmdbDatas... |
65785065317d040bc648ad1e95485e1ccfb727cec09314bfd3dd8840460876e0 | Python | 691 | 26 | #!/bin/python
import sys
import collections
[_, fil, batch, ev, chroms_file] = sys.argv
dct = collections.defaultdict(dict)
with open(fil, 'r') as f:
f.readline()
for line in f:
dat = line.rstrip().split()
sample = dat[0]
chrom = dat[1]
number = dat[2]
dct[sample][chro... |
05a76c680900a1fae67cc41e002ab1fa8bbe3ec0759ba1eabedb3a851f6325ce | Python | 692 | 24 | # rate_limiter.py
import time
import os
class RateLimiter:
def __init__(self, limit_seconds):
self.limit_seconds = limit_seconds
self.last_request_time = None
def can_make_request(self):
if not self.last_request_time:
return True
time_since_last = time.time() - sel... |
b6b7139e8e0c7e80d5ee2c30b795dabcd6d3c7c34522e703a9b1064e84f5012b | Python | 692 | 23 | from os.path import exists
from sak.data_structures import ExecutionInformation
from numpy.random import permutation
from math import ceil
def check_weights_exist(config, KFolds):
for fold in range(len(KFolds)):
(train_keys, test_keys) = KFolds[fold]
execinfo = ExecutionInformation(config, fold, t... |
64a7c8ccf73df19ff2c3483ef93a73f94895003b0fa6a663c738a8e20a2d763f | Python | 693 | 20 | import pathlib
from setuptools import setup, find_packages
here = pathlib.Path(__file__).parent.resolve()
# Get the requirements from the requirements file
requirements = (here / 'docker/vm_boot_images/config/tensorflow-requirements.txt').read_text(encoding='utf-8')
long_description = (here / 'README.md').read_text(en... |
b51929a0530a94f07ef476a6a20e5d35e72c7035787742266d49f66800db47f6 | Python | 693 | 26 | import pandas as pd
from data_profiling.config import Settings
from data_profiling.utils.dataframe import rename_index
def pandas_preprocess(config: Settings, df: pd.DataFrame) -> pd.DataFrame:
"""Preprocess the dataframe
- Appends the index to the dataframe when it contains information
- Rename the "in... |
43c9f62daf4cb1e0340ddf26933f33d3d47befff34979439bcdbaea597fd0ba7 | Python | 695 | 19 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
adb3e1039cb6e15a173cbab721114672916c4767966cb46a62d01b6bc610ca63 | Python | 695 | 24 | import importlib
import numpy as np
import pytest
from nir.ir.utils import _index_tuple
_TORCH_SPEC = importlib.util.find_spec("torch") is not None
def test_index_tuple():
assert _index_tuple(1, 0) == 1
assert _index_tuple([1, 2], 0) == 1
assert _index_tuple(np.array([1, 2]), 0) == 1
assert np.all(... |
c0b47ee01cc479ead697b53840791ad656468e00dd90db7686953537da5c4125 | Python | 695 | 24 | import numpy as np
import pytest
from nir.ir.utils import _index_tuple
import importlib
_TORCH_SPEC = importlib.util.find_spec("torch") is not None
def test_index_tuple():
assert _index_tuple(1, 0) == 1
assert _index_tuple([1, 2], 0) == 1
assert _index_tuple(np.array([1, 2]), 0) == 1
assert np.all(... |
e50595efd816e78c93e1e16db6e166b86316e3f50802ded391b030b9ab29eec7 | Python | 695 | 15 | """Vendored Bonsai core (upstream v1.0.0), CC BY-NC 4.0.
Modifications from upstream, all mechanical:
* ``from bonsai.X import ...`` -> ``from .X import ...`` and
``import bonsai.X as Y`` -> ``from . import X as Y``, so the modules import as
a package instead of relying on the script's own ``sys.path.append`` of ... |
3bd2ee2e820c3eaaed43209d42213613ab124cfb9d3a9fdc2282f9b0f2ccd10d | Python | 696 | 28 | import numpy as np
def normal(shape, dtype='float64', **kwargs):
return(np.random.normal(size=shape, **kwargs).astype(dtype))
def uniform(shape, dtype='float64', **kwargs):
return(np.random.random(size=shape, **kwargs).astype(dtype))
def randbool(shape, prob=0.5, dtype='bool', **kwargs):
mask = unifor... |
612e196bad3e4a44322b4273a2c8400c6cd29d17eb876fbce1d25bf133217b3a | Python | 697 | 26 | ### Modified https://qiita.com/bee2/items/4e462b545140a81abd44
import sys
class SeterrIO():
"""with構文でI/Oを切り替えるためのクラス"""
def __init__(self, stdErrFilename: str):
self.stderrfilename = stdErrFilename
def __enter__(self):
sys.stderr = _STDLogger(out_file=self.stderrfilename)
def __exit... |
6e75d69ded8a4d47b0d3e5c90f63c1b62a4f3b4f8b658d6878747cc4b49e6ff0 | Python | 697 | 32 | """
Test for issue 94:
https://github.com/Data-Centric-AI-Community/data-profiling/issues/94
Test based on:
https://stackoverflow.com/questions/52926527/pandas-profiling-1-4-1-throws-zerodivisionerror-for-valid-data-set-which-pandas
"""
from pathlib import Path
import pandas as pd
import data_profiling
def test_is... |
dec48a13c60dee73266dde563ac3b36d159429a359b9854d58fe5a3f80a9512d | Python | 697 | 27 | # flake8: noqa
# __nccl_full_example_start__
import torch
import ray
from ray.experimental.collective import create_collective_group
@ray.remote(num_gpus=1)
class MyActor:
@ray.method(tensor_transport="nccl")
def random_tensor(self):
return torch.randn(1000, 1000).cuda()
def sum(self, tensor: to... |
195bb729befa48d56341d75fb27068f728427e4ebeb94cdc08d9095885396d2f | Python | 698 | 27 | # -*- coding: utf-8 -*-
"""
Hook for PyInstaller.
"""
from PyInstaller.utils.hooks import collect_data_files
datas = []
# These lines can be removed to skip specific unwanted data files.
# Icon used by QtFigure2.add_screenshot_button().
datas += collect_data_files("vtkplotlib", includes=["**/screenshot.... |
365c3426876f4e2cb87061f355cd6220ae3e97d90820b39073737caf5070c6fe | Python | 698 | 24 | from torch_pgn.train.Trainer import Trainer
from torch_pgn.args import TrainArgs
def run_training(args):
"""
Wrapper for running training given TrainArgs
:param args: TrainArgs object with parameters to be used in training
:return: torch_pgn.train.Trainer.Trainer object
"""
trainer = Trainer(ar... |
6be8dbf35f45c96dd791e6ce58f4855ae421c9a7ee5d0556f319927bc5256345 | Python | 698 | 26 | import os
import ray
def run():
ray.init()
@ray.remote(runtime_env={"env_vars": {"FOO": "bar"}})
def get_task_working_dir():
# Check behavior of working_dir: The cwd should contain the
# current file, which is being used as a job entrypoint script.
assert os.path.exists("per_task... |
98ad7acb9cf51de6a6f3d872d0ab131728997673e13569adeb5ef3343377b955 | Python | 698 | 27 | import pytest
import torch
from torch import nn
from pfrl.nn import Branched
from pfrl.testing import torch_assert_allclose
@pytest.mark.parametrize("batch_size", [1, 2])
def test_branched(batch_size):
link1 = nn.Linear(2, 3)
link2 = nn.Linear(2, 5)
link3 = nn.Sequential(
nn.Linear(2, 7),
... |
1f4d2595d4c21ed52b9e474bd8ebcc168f1d0f9364926170e48b2ac5ddf64846 | Python | 699 | 24 | from typing import Union
import numpy as np
import pandas as pd
def cpm_norm(X: Union[np.ndarray, pd.DataFrame]) -> Union[np.ndarray, pd.DataFrame]:
"""Counts-per-million normalize a genes-by-cells matrix.
Parameters
----------
X
Genes-by-cells count matrix.
Returns
-------
Norm... |
288c742497e9999c7862e2f30a7091512c9438952c3494fbb807c497367c603f | Python | 699 | 25 | import os
import ray
noset_env = ray._private.accelerators.nvidia_gpu.NOSET_CUDA_VISIBLE_DEVICES_ENV_VAR
visible_devices_env = ray._private.accelerators.get_accelerator_manager_for_resource(
"GPU"
).get_visible_accelerator_ids_env_var()
if os.environ.get("RAY_TEST_RESOURCES_SPECIFIED") == "1":
assert noset_en... |
79e8789af1155b270652513c8bf9e7283cb1270293067316edb166532574ee31 | Python | 700 | 17 | # Copyright 2023 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
8f04b52f9ed0c1e3f622a68c1b835d772e47af175f785a0a28c6aed40aea3a3c | Python | 700 | 24 | #!/usr/bin/env python3
import torch
from diffusers import DiffusionPipeline
class UnetSchedulerOneForwardPipeline(DiffusionPipeline):
def __init__(self, unet, scheduler):
super().__init__()
self.register_modules(unet=unet, scheduler=scheduler)
def __call__(self):
image = torch.randn... |
d4457c0d71bbf16d74ae351852a8a4f0a8f84938f455e66cf88bd51a7c28b847 | Python | 700 | 20 | from ray._private.ray_constants import env_float, env_integer
from ray.core.generated import event_pb2
LOG_ERROR_EVENT_STRING_LENGTH_LIMIT = 1000
# Monitor events
SCAN_EVENT_DIR_INTERVAL_SECONDS = env_integer("SCAN_EVENT_DIR_INTERVAL_SECONDS", 2)
SCAN_EVENT_START_OFFSET_SECONDS = -30 * 60
CONCURRENT_READ_LIMIT = 50
EV... |
2ed7e3d30f74777ffbc295a82bc7224768edc0f7189c68c98b7ef600a5d0632f | Python | 701 | 16 | """Recurrent multicellular structure — ``ov.space.niche``.
Three ways to ask the same question, kept apart because they are not the same
question::
ov.space.niche.neighborhood(adata, 'cell_type') # cluster the local mix
ov.space.niche.utag(adata, use_rep='X_pca') # cluster smoothed expression
ov.s... |
eeec3b3f924433aa55a0b61b3172e9f5ff383c8ec02e0335538efbe4f308183a | Python | 701 | 34 | """
Simplest Model - just assumes expression data is normal
UMI counts are regressed out
"""
import numpy as np
def fit_gene_model(gene_counts, umi_counts):
X = np.vstack((np.ones(len(umi_counts)), umi_counts)).T
y = gene_counts.reshape((-1, 1))
if umi_counts.var() == 0:
mu = gene_counts.mean()... |
e75fbf92d0b734e861658e5af04b0e01f4cefe69a4d2deb403584d1e5b215b05 | Python | 703 | 22 | import math
from ..base import Transform, as_range, uniform
class AmplitudeScale(Transform):
"""Multiply the signal by a log-uniform random factor.
Args:
scale: factor or (low, high) range, all positive.
per_lead: draw an independent factor for each lead.
"""
def __init__(self, scal... |
0e33435c3b60ace4a524df4cf1419309a73f2516a071955a1dfee440055145d8 | Python | 704 | 42 | # flake8: noqa
# __nested_start__
import ray
@ray.remote
def f():
return 1
@ray.remote
def g():
# Call f 4 times and return the resulting object refs.
return [f.remote() for _ in range(4)]
@ray.remote
def h():
# Call f 4 times, block until those 4 tasks finish,
# retrieve the results, and ret... |
189265587cc1ed2d0a59508e4b00723cf7e9be6179ee564069b6b55d8c8d0595 | Python | 704 | 23 | _base_ = [
'./base_detector/faster-rcnn_r50_ufpn_1x_urpc-coco.py',
'./base_ehance_head/enhance_head.py'
]
# model settings
model = dict(
_delete_=True,
type='lqit.DetectorWithEnhanceHead',
detector={{_base_.model}},
enhance_head={{_base_.enhance_head}},
vis_enhance=False)
# dataset setting... |
6f5ee433a2c5a7b73e9a1cae08ed40a56adab61510692aaac12856e94424cde5 | Python | 704 | 27 | """
Protein-related API clients for DataCollect.
This module provides API clients for protein databases including:
- UniProt: Protein sequences, annotations, features
- PDB: 3D protein structures
- AlphaFold: AI-predicted protein structures
- InterPro: Protein domains and families
- STRING: Protein-protein interacti... |
7ccd150f2681718acd6e71ab3445d3fe14be53014e3a1f4fa97c100e02d7f2c0 | Python | 704 | 19 | from typing import Tuple
# these values are determined empirically for each model from unit test items
minmax_values = {
"VGG-Face": (0.0, 0.27054874177488775),
"Facenet": (-3.541942596435547, 3.247769594192505),
"Facenet512": (-4.388302803039551, 3.643190622329712),
"OpenFace": (-0.34191709756851196, ... |
9a8845d335e52b4f9302e0b866680cf4686ca1ae8f05b94bfc6f56731dec88ca | Python | 704 | 23 | import usb.core
import usb.core
def reset_usb(venders = ['Basler', 'Flir'], verbose=False):
# Find all USB devices
devs = usb.core.find(find_all=True)
basler_devices = []
# Iterate over the devices and save their details if the manufacturer is 'Basler'
for dev in devs:
try:
... |
f51477a819c440477fbb02a62d66138c6879f87db92cfe204d1c44b292fee4a6 | Python | 705 | 24 | import io
from typing import Any, Dict
import pyarrow
from ray.data.datasource.file_datasink import RowBasedFileDatasink
class ImageDatasink(RowBasedFileDatasink):
def __init__(
self, path: str, column: str, file_format: str, **file_datasink_kwargs
):
super().__init__(path, file_format=file_... |
1b9afd546c43623ca1369ecd915351d69a4eacc7e81dbb00eff7ddacff527da5 | Python | 706 | 23 | from typing import List
from unittest import mock
from ci.ray_ci.windows_tester_container import WindowsTesterContainer
def test_init() -> None:
install_ray_cmds = []
def _mock_subprocess(inputs: List[str], stdout, stderr) -> None:
install_ray_cmds.append(inputs)
with mock.patch("subprocess.che... |
d6bf79dadd3b5b22ec1d7c311c83ce558cc2c18cb654b33d3330ae66844befa2 | Python | 706 | 27 | # flake8: noqa
# fmt: off
# __resource_allocation_1_begin__
import ray
from ray import tune
# This workload will use spare cluster resources for execution.
def objective(*args):
ray.data.range(10).show()
# Create a cluster with 4 CPU slots available.
ray.init(num_cpus=4)
# By setting `max_concurrent_trials=3`, ... |
e58b8fe237a2f8efea2b30ec85999f4edf79fe214e2768ab8dec275fce5e59df | Python | 706 | 15 | # This file is part of the INTREPPPID programme.
# Copyright (c) 2023 Joseph Szymborski.
#
# This programme is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, version 3.
#
# This programme is distributed i... |
1db6def22405f6130bfcfe36cf4cf1f7da5c4d0b0a7ee1919f67df64da42f597 | Python | 707 | 26 | #!/usr/bin/env python
# import
from __future__ import print_function
## batteries
import os
import sys
import pytest
# data dir
test_dir = os.path.join(os.path.dirname(__file__))
data_dir = os.path.join(test_dir, "data")
# tests
def test_help(script_runner):
ret = script_runner.run("acc2gtdb_tax.py", "-h")
... |
8e21c3b7cde5c52e00d953830ea2e64c43803a6be4b06a4325c0ae2e63cf3702 | Python | 707 | 25 | import logging
import sys
import pytest
from ray.dashboard.utils import close_logger_file_descriptor
def test_close_logger_file_descriptor():
logger_format = "%(message)s"
logger = logging.getLogger("test_job_id")
job_driver_log_path = "/tmp/ray.log"
job_driver_handler = logging.FileHandler(job_dri... |
ac42f4cf9ac5888c161ab050069239042ec49eb3151ab99d8278a7f9e5299244 | Python | 708 | 32 | import logging
from dataclasses import dataclass
from typing import Any
from pokeformer.config_wrapper import load_class, obj_from_config
logger = logging.getLogger(__name__)
@dataclass
class GenericDatasetBuilderConfig:
scratch: Any
dataset: Any
class GenericDatasetBuilder:
@classmethod
def get_c... |
cad6ba25ee4d9ed66807d09f642d19574d4b97a16089362eafbab7c5f3d30b0c | Python | 708 | 23 | # -*- coding: utf-8 -*-
"""
"""
import matplotlib
matplotlib.use('Agg')
from analysis_and_visualization import perform_analysis_and_visualization, perform_analysis_and_visualization_stc, perform_analysis_and_visualization_spont
from mozaik.storage.datastore import Hdf5DataStore, PickledDataStore
from mozaik.controller... |
f69ea815f94487e0ea4fed33009f6273cfc5d0de796ff05e0434b444138eec68 | Python | 708 | 24 | import numpy as np
import pytest
from pfrl.explorers.additive_ou import AdditiveOU
@pytest.mark.parametrize("action_size", [1, 3])
@pytest.mark.parametrize("sigma_type", ["scalar", "ndarray"])
def test_additive_ou(action_size, sigma_type):
def greedy_action_func():
return np.asarray([0] * action_size, dt... |
9eebc2934117d6f93485507082322891fa0c5c7f098c4b215f5904600fbfd177 | Python | 710 | 27 | from dataclasses import dataclass, field
from typing import Any, Dict, Optional
import numpy as np
from .node import NIRNode
@dataclass(eq=False)
class Delay(NIRNode):
r"""Simple delay node.
This node implements a simple delay:
.. math::
y(t) = x(t - \tau)
"""
delay: np.ndarray # Del... |
19430d5a62a5124b13525fcba5be623bfd2adb2a52e8a263e3861e4afba92dc1 | Python | 712 | 11 | import json,glob,numpy as np
from scipy.stats import spearmanr
out={}
for n in ["pub","late","wide","wide4"]:
t=[];e=[]
for f in sorted(glob.glob(f"c1_design_{n}_*.json")):
d=json.load(open(f)); t+=d["true"]; e+=d["est"]
t=np.array(t); e=np.array(e); eb=e[:,5]-t[:,5]; ec=e[:,2]-t[:,2]; ok=abs(eb)<2
... |
376067888292032868b756e1ba6349c65a24d12111c752921dece7881414193c | Python | 712 | 23 | # -*- coding: utf-8 -*-
"""
"""
import matplotlib
matplotlib.use('Agg')
from analysis_and_visualization import perform_analysis_and_visualization, perform_analysis_and_visualization_stc, perform_analysis_and_visualization_spont
from mozaik.storage.datastore import Hdf5DataStore, PickledDataStore
from mozaik.controller... |
84e1eb5c53691150b8562b99713715190618b55780c9cfeedceb6ed687a93060 | Python | 712 | 19 | #
# Copyright (c) 2021, NVIDIA 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 ... |
65eba2eb97e4353974926821cd2c798900c08297ed8632857e56e749649f5d90 | Python | 713 | 13 | # TODO: this import is the reason svtk needs an old setuptools. Recent setuptools
# releases dropped pkg_resources, so every svtk command dies on this line unless
# something holds setuptools back. That is 'setuptools<81' in setup.py
# install_requires, plus the cap in dockerfiles/sv-pipeline/Dockerfile. Replacing
# it... |
c392f5ff16a01f0afbcbe5a24c982b0f5a6c859b8c46a02ba4f4604cd959c33d | Python | 713 | 20 | # Copyright 2023 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
60db3764ecb60a8ae41a1bc5ca8e1ff04ae42876b1af4b5fdfbc9d481c8201cf | Python | 714 | 19 | #
# Copyright (c) 2021, NVIDIA 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 ... |
8b6ce7e6bb3928fce1d1d7ab438b3e3c74d559b7970619a7fa2eeb154b428376 | Python | 714 | 25 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import os
from unittest.mock import patch
from fairchem.core.scripts import download_large_files as dl... |
aad311da3d1860a1c6ddecf40747891ee116f93cdd7eb4c9deebbe8b0dfdcdab | Python | 714 | 33 | from .key_dataset import KeyDataset
from .normalize_dataset import (
NormalizeDataset,
)
from .remove_hydrogen_dataset import (
RemoveHydrogenDataset,
)
from .tta_dataset import (
TTADataset,
TTAPKADataset,
)
from .cropping_dataset import CroppingDataset
from .distance_dataset import (
DistanceData... |
b042abfc5fe69a3d626c24260e8927fc100ae5f8e1e82dbfe05eeb4846a99faa | Python | 714 | 21 | # Copyright 2023 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
bc15e48d94fe502a6ed9d3bc90aaf2c89700ff3de99ba9da8733af2b3a94c721 | Python | 714 | 26 | import pytest
from testbook import testbook
pytest.importorskip("torch")
pytestmark = pytest.mark.tensorflow
@testbook("examples/01b-Getting-started-Pytorch.ipynb", execute=False)
def test_getting_started_pytorch(tb):
tb.inject(
"""
import pandas as pd
import numpy as np
!mkdir ... |
ea8d8ffe345f6a7b92d9878ca323e8b368384245c9356b55c3cc16ba7ac985cf | Python | 714 | 26 | from pathlib import Path
from siapy.entities import SpectralImage
from siapy.utils.plots import pixels_select_lasso
# Set the path to the directory containing the data
# !! ADJUST THIS PATH TO YOUR DATA DIRECTORY !!
data_dir = "./docs/examples/data"
# Get arbitrary image
header_path_img0 = sorted(Path(data_dir).rglo... |
fcbb8f4aaa23b704b75a796b90ce44fff74659e025645f935de198bfd5e3aed3 | Python | 716 | 31 | # Vendored from `decoupler` (https://github.com/scverse/decoupler) by
# omicverse for in-tree GPU acceleration work. Original copyright by
# the decoupler authors, redistributed under decoupler's GPL-3.0
# license. Cross-module imports rewritten from `decoupler.*` to
# `omicverse.es.*` (see scripts/vendor_decoupler.py)... |
3c7ef8ff1f73d56ca71923d945ad3f33913d11c0ac2198567c25fe034c306d5d | Python | 717 | 24 | from python.utils import yaml_to_dict
CONFIG = yaml_to_dict('config/config.yaml')
MIN_OBS_REQUIRED = CONFIG['min_obs_required']
MAX_HOURS = CONFIG['max_hours']
RESAMPLING_AGG_FUNC = CONFIG['resampling_agg_func']
RESAMPLING_MINUTES = CONFIG['resampling_minutes']
DATE_START = CONFIG['date_start']
DATE_END = CONFIG['d... |
bed53f184328af64f8d59fadffcaaaae6059106c6c393005647decda659fd5f1 | Python | 717 | 27 |
import spacy
from collections import OrderedDict
def get_key_terms(text):
nlp = spacy.load("en_core_web_sm")
candidate_pos = ["PROPN"]
candidate_deps = ["nsubj"]
doc = nlp(text)
selected_words = []
for sent in doc.sents:
for token in sent:
if (token.pos_ in candidate_po... |
0a8ffb10903c7df0ca9b552f3264cdc85fb41fdd270ddb62b6ec60519531e842 | Python | 718 | 18 | import subprocess
from projectmetis.proto.metis_pb2 import ControllerParams, GlobalModelSpecs, CommunicationSpecs, ServerEntity
def cmd(args):
process = subprocess.Popen(args, stdout=subprocess.PIPE)
out, _ = process.communicate()
return out.decode('ascii').strip()
def default_controller_params():
r... |
070d7806c12aaa1d5bda3f144a32be958724b3234ab7db27c330109dc2ea8ed4 | Python | 719 | 30 | #!/usr/bin/env python
from setuptools import find_packages, setup
__version__ = '0.0.2'
requires = ['scipy >= 1.1',
'numpy',
'pandas',
'statsmodels',
'phenograph == 1.5.2',
'umap-learn',
]
extras_require = {'diffusion embeddings' : 'dmaps'}
se... |
0a971dd205f9ee8e6bb238ee49ad7e0bd34ae920f4de9b03fa62c6b94f11476e | Python | 719 | 19 | #
# Copyright (c) 2021, NVIDIA 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 ... |
264fe0edfd5ade37f9271d26565377c42cc7f7e07bca1cd98cf678ee68bd3f42 | Python | 719 | 32 | """
Test for issue 523:
https://github.com/Data-Centric-AI-Community/data-profiling/issues/523
"""
from dataclasses import asdict
import pandas as pd
from data_profiling import ProfileReport
def test_issue523():
# https://github.com/pandas-dev/pandas/issues/33803
data = [
1871248,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.