sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
3932dfaf5659eb733aacfc83d035ea4f9e02554faf2e318b46a5b75b951e8d40
Python
511
21
import torch import sys class AbstractTorchModule(torch.nn.Module): def __init__(self): torch.nn.Module.__init__(self) def save(self, path): print("Saving to path " + path, file=sys.stderr) torch.save(self.state_dict(), path) def load(self, path): print("Loading from pat...
a739222af41d1b2a003d60ec954795276fc5389544793bfad1a5c4a7ab711721
Python
512
15
from pathlib import Path import pandas as pd from data_profiling import ProfileReport from data_profiling.utils.cache import cache_file if __name__ == "__main__": file_name = cache_file("auto2.dta", "http://www.stata-press.com/data/r15/auto2.dta") # Suggested by @adamrossnelson df = pd.read_stata(file_na...
4a19d811ed5b6bfb76f6a551f61026f7496cdce90bfea18a8a7fb92f2ec1d34f
Python
513
8
from agent.data.entities.config import EXTERNAL_ITEM_FILTER, EXTERNAL_LABEL from agent.classifiers.data.tr_ffnn_fd_dataset_mgmt import get_datasets_from_filter def get_datasets(pretrained_model, max_lenght, binary_classifier=False, _expand_tokenizer=False, _use_saved_model=True, _tokenizer_type="text"...
8cd93aef298d45c842e8a0aa9fd0491d8ee31cf52dd8e0b01e99b16d782a93e2
Python
513
9
from ..reducers.avg_non_zero_reducer import AvgNonZeroReducer from ..reducers.base_reducer import BaseReducer from ..reducers.class_weighted_reducer import ClassWeightedReducer from ..reducers.divisor_reducer import DivisorReducer from ..reducers.do_nothing_reducer import DoNothingReducer from ..reducers.mean_reducer i...
f264fd7d6766276ca539c293010ad8e92d638d6eb856379f6b4c043e194e2b75
Python
514
17
from pathlib import Path import pandas as pd from data_profiling import ProfileReport if __name__ == "__main__": df = pd.read_csv( r"https://raw.githubusercontent.com/aliceriot/russian-vocab/master/words.csv", names=["russian", "english", "part of speech"], ) profile = ProfileReport( ...
feef8c2f2691ac51dd88936c6754b719f502b9798b7137eb3cef01b63aa0b5f7
Python
514
18
def get_numeric_rating(class_values, text_rating, binary_classifier=False): if binary_classifier: if class_values.index(text_rating) == len(class_values) - 1: return 1 else: return 0 else: return class_values.index(text_rating) def get_textual_rating(class_value...
1a2193be10e6f608ff0896b96f98ef2ff47908b9c072c04c76adba7a8a49e4c6
Python
516
20
from typing import Any, Optional import pandas as pd from data_profiling.report.presentation.core.item_renderer import ItemRenderer class Sample(ItemRenderer): def __init__( self, name: str, sample: pd.DataFrame, caption: Optional[str] = None, **kwargs ): super().__init__( "sampl...
5da1b8995be08baa9aece7c172c599c08806bd73cfd4585dd50155923c09302c
Python
516
19
KEEP_COLS = ["responseN", "participant", "blockOrder", "age", "sex", "date", "frameRate", "imageFile", "trials.thisN", "trials.thisIndex", "winsize", "numerosity", ...
adb482999b5a6ccfd3f6aa8011344280dccea3fced49fe44905127ae67a595c1
Python
516
23
import ray from ray.util.queue import Queue, Empty ray.init() # You can pass this object around to different tasks/actors queue = Queue(maxsize=100) @ray.remote def consumer(id, queue): try: while True: next_item = queue.get(block=True, timeout=1) print(f"consumer {id} got work {n...
d0984e6b6d3f4dd7e1cec3a538cfd01f7843c3d3380994943ab46a5120709689
Python
516
17
""" 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 from .adsorbate import Adsorbate from .adsorbate_slab_config import AdsorbateSlabConfig from .bulk impo...
ae07cf29b1f2919ce0b1865325619a6664d607f53e7e291a8af8d6a35a85e927
Python
517
19
"""Remove facial features from structural MRI data""" import subprocess import glob # Set data path ROOT = '/Users/sebastiandresbach/data/neurovascularCouplingVASO/openNeuro' # Set subjects to work on subs = ['sub-05', 'sub-06', 'sub-07', 'sub-08', 'sub-09'] # Loop over participants for sub in subs: images = so...
11eeee1e5c4bcc5bc5f61d9ac05afb29f92f95d9673bc4fe3a82538c5d65221d
Python
518
25
import os def makedirs(path): ''' Creates the directories of the given path if they do not exist. :param path: Directory path. :return: ''' if not os.path.isdir(path): os.makedirs(path) def makedirs_for_file(filepath): ''' Creates the directory of the given filepath if it d...
81e08f30674c4291be6a060ffca59d7c4c3ad2d844a783a8114a421f98ce4296
Python
518
14
import logging from pyro.distributions import constraints from pyro.distributions.transforms import SoftplusTransform from rich.console import Console from rich.logging import RichHandler from torch.distributions import biject_to, transform_to from .cell_comm.around_target import compute_weighted_average_around_targe...
9e7e80dd6ffb2124c874dcc993e100606ea4a0b8fd6bd2d3fcc11d5f9056e174
Python
518
21
#!/usr/bin/env python """ Useful utilities for IO. """ def read_samples_list(path, fail_on_empty=True): with open(path, 'r') as f: samples = f.read().splitlines() if fail_on_empty and len(samples) == 0: raise ValueError("Samples list empty") return samples def read_contig_list(path, fai...
8cd8187ba19e5f4c1c5e3f77904f93b2684b3b7dd5c099ed44b505ab725fa12a
Python
520
22
import torch from sinabs.layers import NeuromorphicReLU def test_forward(): t_inp = torch.tensor([-5.5, -3.23, 2.3, 0.0]) relu = NeuromorphicReLU() t_out = relu(t_inp) assert (t_out == torch.tensor([0.0, 0.0, 2.0, 0.0])).all() def test_backward(): t_inp = torch.tensor([-5.5, -3.23, 2.3, 0.1], ...
2be2cb171ac189384404bd20f7adf5f427ca772e116fa9eb1eca27125071f441
Python
521
8
from agent.data.entities.config import CTT3HEALTH_ITEM_FILTER, CTT3HEALTH_LABEL from agent.classifiers.data.tr_ffnn_fd_dataset_mgmt import get_datasets_from_filter def get_datasets(pretrained_model, max_lenght, binary_classifier=False, _expand_tokenizer=False, _use_saved_model=True, _tokenizer_type="t...
91d4805498bad0a33e1b60bb3f33abe15e43691d160c7cbe5a68f5ad5ca2eec3
Python
521
12
from .vcfcluster import main as vcfcluster from .bedcluster import main as bedcluster from .standardize_vcf import main as standardize from .count_svtypes import main as count_svtypes from .bincov import main as bincov from .rdtest2vcf import main as rdtest2vcf from .resolve import main as resolve from .annotate import...
f1e1f7020c73d9cb61ae80f4b3ab8250b4c972e65661e5fdd84e0193482b3173
Python
521
19
# flake8: noqa # __owners_begin__ import ray import numpy as np @ray.remote def large_array(): return np.zeros(int(1e5)) x = ray.put(1) # The driver owns x and also creates the value of x. y = large_array.remote() # The driver is the owner of y, even though the value may be stored somewhere else. # If the nod...
104d0bbcfec2dd6d571a66f9274ad71f2a6641c5e4bf55ec230c50dcfb4d5668
Python
523
25
import numpy as np import matplotlib.pyplot as plt from lib5c.util.plotting import plotter @plotter def plot_pvalue_histogram(data, xlabel='pvalue', **kwargs): """ Plots a p-value or q-value distribution. Parameters ---------- data : np.ndarray The p-values or q-values to plot. kwarg...
4b567f831bc4243d49412eae18680bb4b2855dafa540105e09f2c326e0a04ed7
Python
523
14
#Keep datasets loaded in memory. import wrapt from moabb.datasets.base import BaseDataset for dataset in BaseDataset.__subclasses__(): dataset._preloaded_data = {} @wrapt.patch_function_wrapper(dataset, "_get_single_subject_data") def _get_single_subject_data(wrapped, self, args, kwargs): key = (s...
81e8ea283310e2f3502b4fa038752b0c40690340b0d85ae7f37711b686d269cd
Python
523
30
#!/usr/bin/env python # -*- coding: utf-8 -*- # """ """ import sys import itertools def make_link_combos(): pass def main(): # parser = argparse.ArgumentParser( # description=__doc__, # formatter_class=argparse.RawDescriptionHelpFormatter) # args = parser.parse_args() for line in...
9c3d200bd25d6bc8cf4a69fbce125ef8fe2ed35045cb9865d29dc0b1f1753ba1
Python
523
15
from data_profiling.report.presentation.core import FrequencyTableSmall from data_profiling.report.presentation.flavours.html import templates class HTMLFrequencyTableSmall(FrequencyTableSmall): def render(self) -> str: html = "" kwargs = self.content.copy() del kwargs["rows"] for...
c945ce835fe7a70c6c8e14bd7b38088bd4716dbf3d975cf921b7d088bb4aef03
Python
523
16
import numpy as np from siapy.entities import SpectralImage from siapy.utils.plots import pixels_select_click # Create a mock spectral image with 4 bands rng = np.random.default_rng(seed=42) image_array = rng.random((50, 50, 4)) # height, width, bands image = SpectralImage.from_numpy(image_array) # Interactive pixe...
79ba9ffebbdce57eb15d2cfb19a042ac36aa29fc71d0d924b03397fd3d79a4aa
Python
524
22
""" 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 pytest from ase import build @pytest.fixture() def atoms_list(): atoms_list = [ bu...
fd58b1f477fd79f1ce6c607fd8584021d0b096fe3255f0cd85ae5ae1435c472b
Python
524
20
"""The Neuromorphic Intermediate Representation reference implementation. Documentation: https://nnir.readthedocs.io """ from importlib.metadata import version as metadata_version, PackageNotFoundError try: __version__ = version = metadata_version("nir") del metadata_version except PackageNotFoundError: ...
b655f4ae983c733f9673aefc16b5a22137af13b8d6657d786f36a2ef3b93c7c3
Python
525
24
import setuptools from setuptools import setup setup( name='gym_sted', version='0.0.1', packages=setuptools.find_packages(where="."), install_requires=[ "gym>=0.26", "h5py", "scikit-learn", "scikit-image", "numpy", "scipy", "matplotlib", ...
5c5524fa046c58faa437b1474e75b1889c5d881f35332cf33215b0617e41489b
Python
526
34
# flake8: noqa # __env_var_start__ import ray import os ray.init() @ray.remote def myfunc(): myenv = os.environ.get("FOO") print(f"myenv is {myenv}") return 1 ray.get(myfunc.remote()) # this prints: "myenv is None" # __env_var_end__ ray.shutdown() # __env_var_fix_start__ ray.init(runtime_env={"env_var...
5240ed2e75c87b3610ea3e68f6e2065b8c3e29c55baf218ac8f29648b040e2ac
Python
527
17
# -*- coding: utf-8 -*- # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """tedana: A Python package for TE-dependent analysis of multi-echo data.""" import warnings from tedana.__about__ import __copyright__, __credits__, __packagename__, __version__ #...
5ed8dff7280e84e60515fa55f997f21602fb3fe31e1cb99ab88f52cb6f0c95cd
Python
527
12
if __name__ == "__main__": import argparse from evaluate.evaluate import evaluate parser = argparse.ArgumentParser( description="Evaluation code to compare annotations from a seizure detection algorithm to ground truth annotations." ) parser.add_argument("ref", help="Path to the root folder...
71c3ddcdd93597e7c9474245ad093e34e129a106f0c3277fbd086fd94f12b1e0
Python
528
25
from lop.envs.slippery_ant import SlipperyAntEnv, SlipperyAntEnv3 from gym.envs.registration import ( register, load_env_plugins as _load_env_plugins, ) # Hook to load plugins from entry points _load_env_plugins() register( id="SlipperyAnt-v2", entry_point="lop.envs.slippery_ant:SlipperyAntEnv", ...
b4a026c271b7d5f8278974d12dc8da2df670f5dd65d38aaf171c026dba0952ea
Python
528
22
import logging from pokeformer.config_wrapper import load_class logger = logging.getLogger(__name__) class PredictorFactory: def __init__(self): self.data = {} def create(self, config, vocab_dict): cls = self.data[config.model] result = cls(config, vocab_dict) return result ...
ef52a5511f9675dc6eab1a06afc697e1c7a60699dd86a9dc32643201d65b023f
Python
528
20
""" 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 __all__ = [ "ATOMIC_RADII", "KHOT_EMBEDDINGS", "CONTINUOUS_EMBEDDINGS", "QMOF_KHOT_EMBE...
04a5aeec86f7716169164a2828882a8120b424c1ad079ebd1f8d2fc899e2a474
Python
529
30
import ray import sys # Add the RAY_DEBUG_POST_MORTEM=1 environment variable # if you want to activate post-mortem debugging ray.init( runtime_env={ "env_vars": {"RAY_DEBUG_POST_MORTEM": "1"}, } ) @ray.remote def my_task(x): y = x * x breakpoint() # Add a breakpoint in the Ray task. retu...
104b6225482020fd8d1b62a5c4b5d1ba85cd45e1a215720e257487f27317a101
Python
529
15
from .batch_data_preprocessor import BatchDataPreprocessor from .batch_process import stack_batch from .gt_pixel_preprocessor import (GTPixelPreprocessor, MultiGTPixelPreprocessor) from .multi_input_data_preprocessor import MultiInputDataPreprocessor from .multi_input_multi_batch imp...
30cf4e4ca1565fdf9abc07a00b168d2dc5923c51670f7bf3911cffa5b19c0ed2
Python
529
14
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Apr 19 13:31:16 2022 @author: sam """ import keras from analysisScripts.neuralModel_paperMethod.keras_dynamicLayers import trainableInput from analysisScripts.dualNet.keras_dynamicLayers_RNNcell_dualModel import rnnCell_dualNet_ as rnnCell_ model = ker...
6372c7c3e6f49290d972a94bbe51aa41372cdf79c4c51c1853baf835169e56bc
Python
529
19
#!/usr/bin/env python from unittest import TestCase from svqc.evaluator import QCEvaluator import svqc.tests.constants as const import os class TestSVQC(TestCase): def tearDown(self): os.remove(const.OUT_FILE_PATH) def integration_test(self): eval = QCEvaluator(const.METRICS_FILE_PATH, cons...
0f8b546fb041f4de5d91ae990a54e2b2e0075498527738d5e85dd94b871c2862
Python
530
27
""" Test script that attempts to set its own runtime_env, but we should ensure we ended up using job submission API call's runtime_env instead of scripts """ def run(): import os import ray ray.init( runtime_env={ "env_vars": {"TEST_SUBPROCESS_JOB_CONFIG_ENV_VAR": "SHOULD_BE_OVERRIDE...
9aa7e98d5c492e22b1d6c12cdc0a5af8a064bc24a0d0bff0a8fb4d0e3490850f
Python
530
25
from distutils.core import setup from setuptools import find_packages setup( name="luminance_analysis", version="0.1", author="Luigi Petrucco & Ot Prat", author_email="lpetrucco@neuro.mpg.de", packages=find_packages(), install_requires=[ "ipython", "numba", "numpy", ...
a4dbcc294097e0a7ec6e8a07f767b3d78e9a72bf00b180a725df386714705701
Python
530
8
from agent.data.entities.config import TEST_ITEM_FILTER, TEST_LABEL from agent.classifiers.data.transformer_text_fd_dataset_mgmt import get_datasets_from_filter def get_datasets(pretrained_model, max_lenght, val_split=0.8, binary_classifier=False, _expand_tokenizer=False, _use_saved_model=True, _token...
b4ce510eb587da6673156fd0cff68ef86b268babf365e9c00607446d7f9b10d8
Python
530
18
from __future__ import print_function, absolute_import __all__ = ['accuracy'] def accuracy(output, target, topk=(1,)): """Computes the precision@k for the specified values of k""" maxk = max(topk) batch_size = target.size(0) _, pred = output.topk(maxk, 1, True, True) pred = pred.t() correct =...
35262f996b4e3deec1a08126cd0080be2c27ead0b9238c693f9ef8f0004eb8c7
Python
531
25
#usage: conv_uniq_fa.py <fa> <mark> import sys fa = sys.argv[1] if 1 < len(sys.argv) else None mark = sys.argv[2] if 2 < len(sys.argv) else None mark = "" if not mark else "mark:%s;" % mark def do(f): n = 0 while True: head = f.readline().strip("> \t\n") seq = f.readline().strip("> \t\n") ...
98a234328f20b9994933855679569a0a8258d6b618618b06e4b48c1a9a718875
Python
531
19
import unittest import torch from rising.utils.checktype import check_scalar class TypeCheckTestCase(unittest.TestCase): def test_scalar_check(self): expectations = [True, True, False, False, False, True, False] inputs = [0.0, 1, None, "123", [1, 1], torch.tensor(1), torch.tensor([1, 2])] ...
cb26d260104315589e8f10efaaeb179415d3a6eadb1681feb59c40da951abd45
Python
531
28
#!/usr/bin/env python3 # vim: set ts=4 sw=4 tw=0 : from distutils.core import setup from distutils.extension import Extension import numpy try: from Cython.Build import cythonize USE_CYTHON = True EXT = "pyx" except ImportError: USE_CYTHON = False EXT = "c" cythonize = lambda ext: ext exte...
e5956f325781374fbf20236a935c4858d6656396689c2e0213c13e696a75d301
Python
531
23
# __anti_pattern_start__ import ray import numpy as np ray.init() @ray.remote def func(large_arg, i): return len(large_arg) + i large_arg = np.zeros(1024 * 1024) # 10 copies of large_arg are stored in the object store. outputs = ray.get([func.remote(large_arg, i) for i in range(10)]) # __anti_pattern_end__ #...
9c9fd1a99251800634a498e8106b78a0fea01912af9774eae1081796a7b896de
Python
532
21
# -*- coding: utf-8 -*- # (C) Copyright 2026 IBM. All Rights Reserved. # # Licensed under the MIT license. See LICENSE file in the project root for details. """Base class for an Experiment Runner.""" # pylint: disable=too-few-public-methods from typing import Any from aihwkit.experiments.experiments.base import Ex...
0ac875c0134b00b5adab921dbf0ffb5ac3781b6db753dd558be87ce3b6d83f28
Python
533
21
from ray.air.config import ( CheckpointConfig, FailureConfig, RunConfig, ScalingConfig, ) from ray.air.data_batch_type import DataBatchType from ray.air.execution.resources.request import AcquiredResources, ResourceRequest from ray.air.result import Result import ray.data # noqa: F401 # TODO: This is ...
45d8abb02a803df3199910747cbc6449798582b47acaef240fcdfd6cfa63ff58
Python
533
17
""" Test for issue 200: https://github.com/Data-Centric-AI-Community/data-profiling/issues/200 """ import pandas as pd from data_profiling import ProfileReport def test_issue200(): df = pd.DataFrame([0, 1, 2], columns=["a"], index=["0", "1", "2"]) assert df.index.dtype == "object", "Index type should be 'ob...
a1e6a93b03a680f0886145fee525950d79d30195eca879ee354fa9ac060863fa
Python
534
15
from samri.pipelines.preprocess import generic, legacy from samri.pipelines import manipulations BIDS_BASE = '/usr/share/samri_bidsdata/bids' # Takes too long #def test_generic(): # generic(BIDS_BASE, # '/usr/share/mouse-brain-templates/dsurqec_200micron.nii', # registration_mask='/usr/share/mouse-brain-templates/d...
45f84a37fb12e5ff1ba77831c7b4397c0bc5057e2be69a5269bdf09cb8be1ed3
Python
535
17
import pandas as pd import numpy as np import oddt.pandas as opd import sys def low_energy_filter(mol_file, out_file): mol2_df = opd.read_mol2(mol_file, skip_bad_mols=True) mol2_df['best_energy'] = mol2_df.groupby(['mol_name'])['Total Energy'].transform(min) mol2_df = mol2_df[mol2_df['Total Energy'] == mol...
c1dd809200e4fe8f2a13931c6466999ce5a12d4259e7215a69226f6df4f6a09f
Python
535
25
import pandas as pd import os import code # code.interact(local=dict(globals(), **locals())) import math from math import isnan result_dir = "./tsmr_result_individual" results = [os.path.join(result_dir, f) for f in os.listdir(result_dir)] df1 = None for f in results: temp = pd.read_csv(f, sep=",", index_col=F...
428d92a999e55d1a103b873ab679a2fe2ee0274da090e24ac6b083d2a9d4663d
Python
536
23
import unittest import numpy as np import pfrl class TestLinearInterpolationHook(unittest.TestCase): def test_call(self): buf = [] def setter(env, agent, value): buf.append(value) hook = pfrl.experiments.LinearInterpolationHook( total_steps=10, start_value=0.1,...
713a9f148786c0fdb07d17b7bff5683ceebac5ce0a414aaa89f172ec987d2dee
Python
536
22
"""TxGNN version file """ # Based on NiLearn package # License: simplified BSD # PEP0440 compatible formatted version, see: # https://www.python.org/dev/peps/pep-0440/ # # Generic release markers: # X.Y # X.Y.Z # For bug fix releases # # Admissible pre-release markers: # X.YaN # Alpha release # X.YbN # Beta release # ...
9ce3769058b46339edd48d1423ef4cf8b7ad456ba28cc8d8e7edb25fa002abb0
Python
536
25
"""Domain Research (alias). This package is an alias for `omicverse.llm.dr`, provided to expose the domain research helpers under a clearer module name while maintaining backward compatibility. It re-exports the primary public API. """ from __future__ import annotations from ..dr import ( # type: ignore F401 Re...
b6c19a74dd01d6163d1d47321e94c2424c8b3587659078568f8ea05e9749b920
Python
536
13
# -*- 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. #...
cce2dd9aa6ed99ae676a491d620a04ac8495dbcc9aced9812c8df0ac2d99fdb5
Python
537
17
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..utils import DummyObject, requires_backends class LMSDiscreteScheduler(metaclass=DummyObject): _backends = ["torch", "scipy"] def __init__(self, *args, **kwargs): requires_backends(self, ["torch", "scipy"]) @class...
338a27e45dac460de5d43c02816552cea890f0bbff6833dc885aa0fb2773ae0b
Python
538
25
'''numpy-stl: fast STL file handling powered by NumPy. Read, write, and manipulate STL files with vectorized array operations. Quick start:: from stl import mesh m = mesh.Mesh.from_file('model.stl') print(len(m), 'triangles') ''' from .base import Dimension, RemoveDuplicates from .mesh import Mesh from ....
575142fceff08ef1f91e0dd82d4a8d36ca0222d16cfc3837457d876ab1e33fc9
Python
538
8
from agent.data.entities.config import CTT3FR_ITEM_FILTER, CTT3FR_LABEL from agent.classifiers.data.transformer_text_fd_dataset_mgmt import get_datasets_from_filter def get_datasets(pretrained_model, max_lenght, val_split=0.8, binary_classifier=False, _expand_tokenizer=False, _use_saved_model=True, _t...
5f1656a4ee73ab870cd367103a245ea8e29eba7c82e9b3e79e7f7e5a73bfe1da
Python
539
29
# __start__ from ray import serve import logging import requests logger = logging.getLogger("ray.serve") @serve.deployment class Counter: def __init__(self): self.count = 0 def __call__(self, request): self.count += 1 logger.info(f"count: {self.count}") return {"count": self...
8f1c52690b954a922f1469cb134bd46e954b04348a04ade57c5b604d39885b2d
Python
539
21
""" Test for issue 671: https://github.com/Data-Centric-AI-Community/data-profiling/issues/671 """ import numpy as np import pandas as pd from data_profiling import ProfileReport def test_issue671(): test = pd.DataFrame([0, 5, 22, 32, 65, np.nan], columns=["a"]) for i in range(0, 10): ...
0200bb27cd1ac0e3b4fc5751f13bc10cc538d2c3aa667e21864f50da322883e8
Python
540
8
from agent.data.entities.config import CTT3_TEST_ITEM_FILTER, CTT3_LABEL from agent.classifiers.data.transformer_text_fd_dataset_mgmt import get_datasets_from_filter def get_datasets(pretrained_model, max_lenght, val_split=0.8, binary_classifier=False, _expand_tokenizer=False, _use_saved_model=True, _...
62143272a478fd4c9d7f9994645d22a9e0e3c2989ccce4a52ed0ed7190ef360a
Python
540
20
import threading class StoppableThread(threading.Thread): """Thread with an event object to stop itself. Args: stop_event (threading.Event): Event that stops the thread if it is set. *args, **kwargs: Forwarded to `threading.Thread`. """ def __init__(self, stop_event, *args, **kwargs)...
d0ffedc859d6f0a46913ffd996ce0f86d401f3cde195300841f261b2b0db6c2e
Python
540
20
import ray @ray.remote def echo(a: int, b: int, c: int): """This function prints its input values to stdout.""" print(a, b, c) # Passing the literal values (1, 2, 3) to `echo`. echo.remote(1, 2, 3) # -> prints "1 2 3" # Put the values (1, 2, 3) into Ray's object store. a, b, c = ray.put(1), ray.put(2), ray...
3b38f5fe5431688a9a1a60187ec6f74b30d48ff4eeb165c7b6ebbb6b19c065dc
Python
541
15
def group_in_dict(normalized_ent): normalized_ents = {} for k, v in [(key, d[key]) for d in normalized_ent for key in d]: if k not in normalized_ents: if isinstance(v, list): normalized_ents[k] = v else: normalized_ents[k] = [v] else: ...
738e06734879d4f9f5ece6e152f9111b9e6b02f25a69bbfaad5838ada3c61b54
Python
541
18
import pandas as pd from data_profiling import ProfileReport def test_decorator(get_data_file): people_example = get_data_file( "people_example.csv", "https://raw.githubusercontent.com/ydataai/coursera-ml/master/week-1/people-example.csv", ) df = pd.read_csv(people_example) report = P...
0418028e5bd1624d469b543015ef5466a44dcd9f1c6539105424b145ca0062e8
Python
543
9
from agent.data.entities.config import DEV_ITEM_FILTER, DEV_LABEL from agent.classifiers.data.transformer_text_fd_dataset_mgmt import get_datasets_from_filter def get_datasets(pretrained_model, max_lenght, val_split=0.8, binary_classifier=False, _expand_tokenizer=False, _use_saved_model=True, _tokeni...
1aa22dfc2e8b11955952b7cab97d69ac253993cf5798b404590449a53ac902e6
Python
543
9
from pfrl.replay_buffers.episodic import EpisodicReplayBuffer # NOQA from pfrl.replay_buffers.persistent import PersistentEpisodicReplayBuffer # NOQA from pfrl.replay_buffers.persistent import PersistentReplayBuffer # NOQA from pfrl.replay_buffers.prioritized import PrioritizedReplayBuffer # NOQA from pfrl.replay_b...
aad708c78b6cedb6c7a50b50ad2d1a22b7cb905ad6c238e8873e039e3f526900
Python
543
15
#test patches import os from src import patches from src import __file__ as ROOT import geopandas as gpd import rasterio ROOT = os.path.dirname(os.path.dirname(ROOT)) def test_crop(tmpdir): gdf = gpd.read_file("{}/tests/data/crown.shp".format(ROOT)) rgb_path = "{}/tests/data/2019_D01_HARV_DP3_726000_46...
d80446683cd4f3f20552204b64970f5a4ac2d23beb969dbfceed955e45dd4e42
Python
544
22
class Learner(object): def log_update(self, o, a, r, op, logpb, dist, done): self.log(o, a, r, op, logpb, dist, done) info0 = {'learned': False} if self.learn_time(done): info = self.learn() self.post_learn() info0.update(info) info0['learned']...
e7f6bdcf8e4f9a46897c2482f9f4c3bfbad40f67a5e438fe6695b6b4fff3e42e
Python
544
9
from case1 import * import time,os; t0=time.time(); fn="c1_phi2.json" d=json.load(open(fn)) if os.path.exists(fn) else {"true":[],"full":[],"q":[],"full_noarm_c0":[]} while len(d["true"])<int(sys.argv[1]) and time.time()-t0<230: p=TRUE.copy(); p[7]=rng.uniform(-1.5,0.3) D=design(275,60,80,0); Y=simulate(p,D,"M2...
f4dd428e20c1b99eab53cee3cc5ba45f579e3ed0cb5ea4e13539c7e0a2a9901a
Python
544
21
from typing import Any import pandas as pd from data_profiling.report.presentation.core.item_renderer import ItemRenderer class CorrelationTable(ItemRenderer): def __init__(self, name: str, correlation_matrix: pd.DataFrame, **kwargs): super().__init__( "correlation_table", {"corr...
68e37c1768db622fb500c5061f9faa083a95062a6d6cc76e55544d60d8f866b0
Python
545
25
from dataclasses import dataclass import numpy as np from .node import NIRNode @dataclass(eq=False) class Threshold(NIRNode): r"""Threshold node. This node implements the heaviside step function: .. math:: z = \begin{cases} 1 & v > v_{thr} \\ 0 & else \end{cases...
ff098e5c0782868748a77198fa955e9c15f012440c6ad1e748839f05d7e4a720
Python
545
13
# -*- 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. #...
29ee4465f07d00d60edb96eab6f6faef0f63a8a4dd907cdc46c4640895f4ea7c
Python
546
13
# -*- 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. #...
b08f4d038dccfd412329ee7d98d0ee2924f6b2a97324d6208f4c1bce19f9bcab
Python
546
19
import logging from datetime import datetime from agent.pipeline.review_level_mgmt import update_sentence_review_level, update_item_review_level logging.basicConfig(format='%(levelname)s : %(message)s', level=logging.INFO) if __name__ == "__main__": logging.info("Launching review level updater 9...") star...
bcec29d1643fbbf7af7110558e2eba8ec0d0d5362f0c30c176ac0b232a724107
Python
546
21
#cand = open('rcnn-bond/model-300-3/test.cbond') cand = open('att-rcnn-bond/test.cbond') gold = open('data/test.single') tot,good = 0,0 for line in cand: tot += 1 cand_bonds = [] for v in line.split(): x,y = v.split('-') cand_bonds.append((int(x),int(y))) line = gold.readline() ...
cf576d1d7c1435c02a2b6b639fbfc8665f3928f2ea1af9b70cc68567d450b4c9
Python
546
25
import numpy as np def to_array(array, round): __tracebackhide__ = True if not isinstance(array, np.ndarray): array = np.array(array) if round: array = array.round(round) return array def array_equals(left, right, round=6): __tracebackhide__ = True left = to_array(left, ro...
39c257e5ac2f62c6b04ad310037a0ab7536a2a7c83088cb60627b2f09e9a8ce3
Python
547
17
from ipywidgets import widgets from data_profiling.report.presentation.core import ToggleButton class WidgetToggleButton(ToggleButton): def render(self) -> widgets.HBox: toggle = widgets.ToggleButton(description=self.content["text"]) toggle.layout.width = "fit-content" toggle_box = widge...
452d9f0d2140170e2c2c32494f26faa942a8b8700aee480f173cce89c1edb67b
Python
548
15
import numpy as np import cebra neural_data = np.random.normal(0, 1, (1000, 30)) # 1000 samples, 30 features cebra_model = cebra.CEBRA(model_architecture="offset10-model", batch_size=512, learning_rate=1e-4, max_iterations=10, ...
783de443fbedcd41592221e84a8304f8ae5dc46db1a208798a42bd1f8bc7e3b5
Python
548
9
from pfrl.utils import env_modifiers # NOQA from pfrl.utils.batch_states import batch_states # NOQA from pfrl.utils.clip_l2_grad_norm import clip_l2_grad_norm_ # NOQA from pfrl.utils.conjugate_gradient import conjugate_gradient # NOQA from pfrl.utils.contexts import evaluating # NOQA from pfrl.utils.is_return_code...
a2a36ff241e20bc0bfe16602a7c0c5a54599468a7e000c75a86600dbb1262e1b
Python
548
14
import numpy as np def get_ordered_experiment_ids_from_descriptions(experiment_descriptions): """ Returns a sorted list of experiment ids according to the order in the experiment descriptions. """ if not experiment_descriptions: return [] experiment_descriptions_values = list(experiment_d...
a79825aabe6d77402ecbaca79b31b44d0e4fd1763beeb51a0e13d2c4df43067a
Python
548
13
# -*- 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. #...
d807356c09e05c31aab96da2262b4d73eb3d956b82c255dd6042ab37f7839a6e
Python
548
18
from typing import Any, Dict, List, Union from data_profiling.config import Style from data_profiling.model.alerts import Alert from data_profiling.report.presentation.core.item_renderer import ItemRenderer class Alerts(ItemRenderer): def __init__( self, alerts: Union[List[Alert], Dict[str, List[Alert]]]...
8dc98249abdd4e00b993ffd1a2f98bce02cc77d031cb49471c3cfa494d8c46bb
Python
549
13
# -*- 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. #...
9cf439f52f0a2bb561cd991be62518acd6e3611fc0fb30194375402d9fc8a092
Python
549
19
# 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 from .ase_datasets import AseDBDataset, AseReadDataset, AseReadMultiStructureDataset from .base_dataset i...
d51c90e2b60aa87c723beb63dad64214e8dde15b58f70966ed6b6d2c72543f0f
Python
549
18
from transformers.models.auto.tokenization_auto import AutoTokenizer def convert_to_features( # example_batch, model_name="prajjwal1/bert-mini", max_length=512 example_batch, model_name="EMBO/BioMegatron345mCased", max_length=512 ): tokenizer = AutoTokenizer.from_pretrained(model_name) inputs = list(ex...
eab91b9d05ba71902fea00134e8a1c14bc4837d900656b0eaf0bee2c4b8f627a
Python
549
19
import torch class SurrGradSpike(torch.autograd.Function): scale = 10.0 # controls steepness of surrogate gradient @staticmethod def forward(ctx, input): ctx.save_for_backward(input) out = torch.zeros_like(input) out[input > 0] = 1.0 return out @staticmethod def bac...
8070c57382940e706856473860f8858c34e1b2ee9bccef5df54727c8cf123b12
Python
550
16
import argparse def parse_arguments(default_subjects: list) -> list: """ Argument parser for parsing from command-line. """ parser = argparse.ArgumentParser(description='Process EEG for later analysis') parser.add_argument('-s', '--subjects', type=str, help='Subject numbers separated by commas (no spaces...
849d70004b1991dcf7ce2c1a8d3e7c5c9a05728baa3a38b65734a3e2f0dcf452
Python
550
19
import os import subprocess def is_return_code_zero(args): """Return true iff the given command's return code is zero. All the messages to stdout or stderr are suppressed. """ with open(os.devnull, "wb") as FNULL: try: subprocess.check_call(args, stdout=FNULL, stderr=FNULL) ...
2c7e7b6581e726992a7a3bf7092db4f45496dc845a449e53c99b6fe9c605a050
Python
551
29
# -*- coding: utf-8 -*- import matplotlib matplotlib.use("Agg") from model import SelfSustainedPushPull from experiments import create_experiments import mozaik from mozaik.controller import run_workflow from mpi4py import MPI import nest nest.Install("stepcurrentmodule") from pyNN.nest.cells import UNITS_MAP UNIT...
120fd338ebc9259e46708247e605365ec1e2f35ea167dbf01b0d30af0d7cf78d
Python
552
14
# __init__ file from ._cot import cot_dense from ._cot import cot_row_dense from ._cot import cot_col_dense from ._cot import cot_blk_dense from ._cot import cot_combine_sparse from ._cot import cot_sparse from ._cot import cot_row_sparse from ._cot import cot_col_sparse from ._cot import cot_blk_sparse from ._usot imp...
cf1727338b961e03f7f73ee6eef3ef43138e31b545c364ced82b25c05b12736e
Python
552
16
r"""``ov.epi.single`` — single-cell-specific epigenomics tooling. Passthrough to :mod:`epione.single` (``epione.single.atac`` / ``epione.single.hic``): scATAC peak calling (``macs3``), pseudobulk generation, and single-cell Hi-C imputation/embedding. Names resolve lazily from epione on first access. >>> ov.epi.single...
cfaff9ed2a3cf3256dee849ba3ef9cddd1c80aafcb40a5f5316cca5cb58cc753
Python
552
19
import ray @ray.remote class Greeter: def __init__(self, value): self.value = value def say_hello(self): return self.value # Actor `g1` doesn't yet exist, so it is created with the given args. a = Greeter.options(name="g1", get_if_exists=True).remote("Old Greeting") assert ray.get(a.say_hel...
2a44d7e6da6cb8e74b18a3f41b0f6a0de747856c1eec8c5686d27d7ba99461ab
Python
553
23
# -*- coding: utf-8 -*- """ Project: Psychophysics_exps Creator: Miao Create time: 2021-01-08 22:31 IDE: PyCharm Introduction: """ from scipy.optimize import curve_fit from scipy.stats import poisson import numpy as np def fit_poisson_cdf(input_np_array) -> float : """ :param input_np_array: 2 columns, first...
c5c27e7133efb8807f3e81e8b99950d04c2318ac8df9f82cb1b979e0e0f2d836
Python
553
23
""" 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 import shutil CACHE_DIR = os.environ.get( "FAIRCHEM_CACHE_DIR", os.path.join(os.path.exp...
b0b3936c07b4193b96789504a2d38f78943a01edc3e7cf3412bb8169e18ebc71
Python
554
8
from agent.data.entities.config import CTT3HEALTH_ITEM_FILTER, CTT3HEALTH_LABEL from agent.classifiers.data.transformer_text_fd_dataset_mgmt import get_datasets_from_filter def get_datasets(pretrained_model, max_lenght, val_split=0.8, binary_classifier=False, _expand_tokenizer=False, _use_saved_model=...
e0cce8fdba94c14981dbcc4008b96e646d70b58d45063cd6f2f78ea17218b5b5
Python
554
27
"""Compatibility layer for bulk alignment API.""" from ._old import ( Alignment, AlignmentConfig, EnhancedAlignmentConfig, ISeqHandler, geo_data_preprocess, fq_data_preprocess, load_config, get_example_configs, check_all_tools, check_tool_availability, ) __all__ = [ "Alignm...
a2bc5d6cbc7f307674566ef1875f05c135067452db57916dbfa6401158231b8b
Python
555
19
# -*- coding: utf-8 -*- # (C) Copyright 2026 IBM. All Rights Reserved. # # Licensed under the MIT license. See LICENSE file in the project root for details. # pylint: disable=import-error, no-name-in-module, invalid-name """AIHWKIT extension""" from importlib.util import find_spec EXTENSION_COMPILED = find_spec("....
b5dd1d9a3b3cc35ac713ae12fc58dfbc0d5a4d128527f42023aa91e5525c2cd1
Python
555
16
# Modified from https://github.com/dbolya/tide # This work is licensed under MIT license. # Note: # 1. We removed several unused codes, improved TIDE's output images, # and optimized the code format. # 2. Right now, only COCO dataset is available, others # (LVIS, PASCAL VOC, and CityScapes) are not fully tested. from...
db0393a67806e3313560302dcc49668ff0bc07ef044d89dbab6602a4a55ec96f
Python
555
29
# -*- coding: utf-8 -*- """ @author: wnchang """ from torch.utils.data import Dataset class MyDataset(Dataset): def __init__(self, data, label, info, transform=None): self.data = data self.label = label self.info = info self.transform = transform def __getitem__(self, index)...
ff84798d7306469accfbb14f1f52747f0df2fc2f9cd5bfa6e00ca00750fb55be
Python
556
13
# -*- 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. #...