sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
fde4d7e5eef0b69d0c523c5ab16008bfa064a020e0132cb2efcddd8ec8c36bb7 | Python | 4,357 | 146 |
from sleepy.processing.mat.core import MatDataset
from sleepy.test.core import TestBase
import unittest
from unittest.mock import MagicMock
import numpy as np
import pdb
class MatDatasetTest(unittest.TestCase):
def basicRaw():
"""Basic raw data without sleepy content.
"""
r... |
0684039ca236ef1f33c9f7039748d437acbbc4e21d07315a79df0c509b7866e8 | Python | 4,359 | 111 | """
Plot snapshots of the input data showing the detected waves.
"""
import os
import numpy as np
import quantities as pq
import argparse
from pathlib import Path
import matplotlib.pyplot as plt
from utils.io_utils import load_neo, save_plot
from utils.neo_utils import analogsignal_to_imagesequence
CLI = argparse.Arg... |
e93eb6855f7502f172965e68e9f0f03a5ec7994ac0a7046603bffa4dd2d17b70 | Python | 4,359 | 150 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Convenience Utilities for DataFrame."""
from typing import Optional
import numpy as np
import pandas as pd
ROUND_PLACEHOLDER = 1000000
def _search(
self,
tensor_name: str = None,
origin: str = None,
fl_round: int = N... |
3906b4f6ea96e3400a38d60c77821c4d57087f7f249338c929d6f480af28faa3 | Python | 4,360 | 161 | """Apply Expectation Maximization on manifolds and plots the results.
Random data is generated in separate regions of the
manifold. Then Expectation Maximization deduces a Gaussian Mixture Model
that best fits the random data. For the moment
the example works on the Poincaré Ball hyperbolic space.
"""
import os
impo... |
408b0ed6f59d5cee479903c47d1ba0ed2c5e0bc121dd01645aff9e51927b696d | Python | 4,360 | 140 | import random
import pytest
import geomstats.backend as gs
from geomstats.metric_geometry.wald_space import (
NaiveProjectionGeodesicSolver,
SuccessiveProjectionGeodesicSolver,
WaldSpace,
_squared_dist_and_grad_autodiff,
make_topologies,
)
from geomstats.test.parametrizers import DataBasedParametr... |
bfcd280cdcd336d74dc869b123d10078fe19ee693e2fcfda7707eb8ab2e5af83 | Python | 4,363 | 106 | import logging
import numpy as np
from idtrackerai import Blob, conf
from idtrackerai.utils import track
def get_train_validation_and_eval_blobs(
blobs_in_video: list[list[Blob]],
number_of_animals: int,
ratio_val: float = 0.1,
max_images_per_class: int = conf.MAX_IMAGES_PER_CLASS_CROSSING_DETECTOR,... |
91f1c169e6d2468fce34f032a12b341fa4f300ecc59030a50c03403177399348 | Python | 4,365 | 136 | # 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.
"""isort:skip_file"""
import argparse
import importlib
import os
from fairseq.dataclass import FairseqDataclass
from fairseq.dataclass.utils ... |
84da6139bf7c32a1391abb4164d1db0e9bd25a025702cc29b4ffb8f54840e580 | Python | 4,366 | 159 | import os
import argparse
import logging
import h5py
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
from subprocess import Popen, PIPE
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from scipy.spatial.distance import squareform
# use this form... |
590402b73ee893cae02e5a89343700276f80b97698324eb083d89e35da614e2e | Python | 4,369 | 115 | """Base class for samplers
The sampling code is separate to facilitate sampling as a standalone module.
This class basically just serves as an "adaptor" of some kind because it
accepts all parameters needed for the model samplers. Some of these parameters
are only needed by some model samplers.
FIXME: The alternativ... |
1581e79e33086d4e76ba868b2be1545541c1a228cc0be6cad87eb8ebc423a693 | Python | 4,370 | 119 | import os
import shutil
import pandas as pd
import csv
# Read in sublist-all.txt and generate a list of sub-##### to be used for file filtering
def read_usable_subs(filename):
with open(filename, 'r') as file:
usable_subs = [line.strip() for line in file]
return usable_subs
# Eliminate any sub-#####... |
235a18222331d07eaf2d55121c227563456ca323306667755f4d8ba90216af58 | Python | 4,374 | 105 | # Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... |
77566af2756509e4c7ccfba30ed7b5f5fed8b9bb19d95536b92eff7838725f0a | Python | 4,377 | 165 | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 22 14:30:31 2021
@author: nicol
"""
import os, glob, tqdm
from skimage.io import imread, imsave
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib import rc
import matplotlib as mpl
import scipy.ndimage as ndi
fro... |
80a533185bc1ab2462215573ceb482449987abb79c11b2ad265da73679e6bf6b | Python | 4,377 | 142 | """Visualization for Geometric Statistics."""
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D # NOQA
import geomstats.backend as gs
from geomstats.geometry.special_orthogonal import SpecialOrthogonal
SO3_GROUP = SpecialOrthogonal(n=3, point_type="vector")
AX_SCALE = 1.2
class Arrow3D:
... |
a8503a33f1a40316d1022bf85f8d125e2e409f96656f70e372708e8b43e7895c | Python | 4,379 | 135 | '''
Class that handles the creation of a Feedforward Neural
Network (FNN).
'''
from numpy import real
import torch
import torch.nn as nn
import torch.optim as optim
import os
if torch.cuda.is_available():
device = torch.device('cuda')
else:
device = torch.device('cpu')
class FNN(nn.Module):
def __init__(... |
89b82a90937e457a0e33f8846700d0593893dfb35f7a4323cdc8e4c4e4d843cb | Python | 4,380 | 139 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# 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 appli... |
378c66fa20c181f4761d178008fea25d57d31029af081eac005dc57b03885859 | Python | 4,382 | 141 | import os
import sys
import time
import pathlib
import shutil
import pandas as pd
# april 5, removed (why did I remove???)
import tables.scripts.ptrepack # to save compressed .h5 file
from sanpy.sanpyLogger import get_logger
logger = get_logger(__name__)
def listKeys(hdfPath, printData=False):
"""List all key... |
5712fbf082772c259e568b8283c23f5557d826f8ac29a6e84fbf5f6de8d73760 | Python | 4,385 | 122 | import random
import pytest
import geomstats.backend as gs
from geomstats.geometry.euclidean import Euclidean
from geomstats.geometry.matrices import Matrices
from geomstats.numerics.finite_differences import (
centered_difference,
forward_difference,
second_centered_difference,
)
from geomstats.test.para... |
3db247f891b76f39cd2bfdcca671f36b6749026cb2f47fb8856e772eddcd871f | Python | 4,386 | 129 | import os
import glob
import nrrd
import torch
from torch.utils.data import Dataset
import yaml
import json
class OCTSample():
def __init__(self, sample_folder) -> None:
self.sample_folder = sample_folder
self.idx = int(os.path.basename(sample_folder).split("_")[1])
def load_metadata(self, me... |
92321957985b27bdc5f3b2e4809e89b0874a2e903bbff86a4455dc95651ae05d | Python | 4,387 | 137 | """Open hemisphere.
For more details, check section 7.4.1 of [T2022]_.
Lead author: Olivier Bisson.
References
----------
.. [T2022] Yann Thanwerdas. Riemannian and stratified
geometries on covariance and correlation matrices. Differential
Geometry [math.DG]. Université Côte d'Azur, 2022.
"""
import geomsta... |
0ad7629d1164aec94c9515ef6392563be7b9b1a94a7e7d5c369784cdf3a587c5 | Python | 4,388 | 84 | """Exact bounded inference for frozen discrete record-score networks."""
import numpy as np
import polars as pl
TARGET = "validated"
def predict_network(model, data, *, epitopes=None, max_cells=4_000_000, bounds=False):
"""Exact batched posteriors, summing joint tables over missing predictors.
The small evi... |
f4412dfe273a77f1b1af6bf30d6808a13ad1668cc7a77bc448af87471fb73cbe | Python | 4,389 | 111 | """
Plot snapshots of the input data showing the detected waves.
"""
import os
import numpy as np
import quantities as pq
import argparse
from pathlib import Path
import matplotlib.pyplot as plt
from utils.io_utils import load_neo, save_plot
from utils.neo_utils import analogsignal_to_imagesequence
CLI = argparse.Arg... |
a924737528ce087ec7d83838091026c0e8c6bf4b8f02296e6316c6751bc00c19 | Python | 4,390 | 142 | import numpy as np
import pytest
from ase.io import write
from nequip.data import AtomicDataDict
from nequip.data.dataset import ASEDataset, HDF5Dataset, EMTTestDataset, NPZDataset
from nequip.data.transforms import NeighborListTransform
from omegaconf import OmegaConf
from hydra.utils import instantiate
import temp... |
648ea676cf2f9921f3943406062b0b6c6cf62875879cb6c7d29932984b6a5685 | Python | 4,391 | 92 | """The input to this script is a corpus document, and the output is a set of binary relation tuples.
Segmentation must be performed using spaces to tokenize the entire document. A pre-trained model from HanLP is employed
to extract dependency syntactic relationships. The final generated binary relation tuples are dedup... |
cd80e7affcb5632bdbd06908181dc7db4fb1167e5aeafa9d4eb5918ac05b4419 | Python | 4,392 | 119 | """Example of use of pymanopt with geomstats.
Simple example that demonstrates how geometries from geomstats can be
used in pymanopt to perform optimization on manifolds. It uses the Riemannian
steepest descent solver.
The example currently requires installing the pymanopt HEAD from git:
pip install git+ssh://gi... |
0745d0ea8088e8b45db8f0023dcdb25c0ad9cf8c9a7bfed783fddadaca1051a3 | Python | 4,395 | 106 | import json
import multiprocessing
import os
import packaging
import re
import shutil
import subprocess
import sys
import tempfile
import tqdm
import urllib
from chromadb import RustClient
from chromadb.config import Settings
from chromadb.segment.impl.manager.local import LocalSegmentManager
from chromadb.test.proper... |
0a8787635389d6558905565da82b3ef357945e7dd44eac905ff81dbee5dc72b1 | Python | 4,395 | 117 | '''
Finds CRISPR spacers in a metagenome; then looks to see if those spacers have good BLAST matches to other contigs in that metagenome.
The implication is the CRISPR spacer will be on a host contig and the BLAST match on the other contig could be a phage it is targeting.
'''
import sys
import argparse
import subproc... |
620d9d176eed1306169a3ca5d25fc5a94c81db4f1345c2377eae0a9cd7f6a031 | Python | 4,399 | 129 | import torch
import torch.nn.functional as F
import numpy as np
import math
from torch import nn
device = torch.device("cpu")
class ETM(nn.Module):
def __init__(self, num_topics, vocab_size, t_hidden_size, rho_size, emsize,
theta_act, embeddings=None, train_embeddings=True, enc_drop=0.5):... |
51b41723c6badb6198bf200f320b60e0ec00ab9bec48593fcb57d08ec194df73 | Python | 4,401 | 127 | import geomstats.backend as gs
from geomstats.learning.radial_kernel_functions import (
biweight_radial_kernel,
bump_radial_kernel,
cosine_radial_kernel,
gaussian_radial_kernel,
inverse_multiquadric_radial_kernel,
inverse_quadratic_radial_kernel,
laplacian_radial_kernel,
logistic_radial_... |
b0620f35e304dd9c6b96e56d52f135e71f313d0130aa71619aeb899309e424fc | Python | 4,403 | 127 | """Export a development SanPy ``analysisDir`` into a local Dandiset."""
from __future__ import annotations
import logging
from datetime import datetime
from pathlib import Path
from tempfile import TemporaryDirectory
from zoneinfo import ZoneInfo
from export_sanpy_collection import (
CollectionExportReport,
... |
cc4e530a56647908fa5f2b8c4b23cef293a8836800340f99d53966f781f6c721 | Python | 4,405 | 121 | import logging
from shutil import copyfileobj
from idtrackerai import ListOfBlobs, ListOfFragments, ListOfGlobalFragments, Session
from idtrackerai.utils import TMP_LOG_FILE, Timer
from .animals_detection import animals_detection_API
from .crossings_detection import crossings_detection_API
from .fragmentation import ... |
c5cf78b0ebebdcf5cbdbc75d33dd2b010c6bf41f3e13e9758179371d3ccf20b4 | Python | 4,406 | 151 | import numpy as np
import sys
import time
from shapely.geometry import Polygon
import paddle
import unittest
from ext_op import rbox_iou
def rbox2poly_single(rrect, get_best_begin_point=False):
"""
rrect:[x_ctr,y_ctr,w,h,angle]
to
poly:[x0,y0,x1,y1,x2,y2,x3,y3]
"""
x_ctr, y_ctr, width, height... |
10137e90898c536d69dc682d67eb01de3ffe62b23603d91323dcc5f8e23c8417 | Python | 4,408 | 130 | import math
import numpy as np
from imgaug.augmentables.lines import LineString
from scipy.interpolate import InterpolatedUnivariateSpline
def lane_to_linestrings(lanes):
lines = []
for lane in lanes:
lines.append(LineString(lane))
return lines
def linestrings_to_lanes(lines):
lanes = []
... |
e1148cdc80d3d85a94085b44c8ba8da600c115150bf7ba8314e7ca9297789d40 | Python | 4,411 | 146 | import os
import numpy as np
import multiprocessing as mp
import ctypes
from ctypes import c_int, c_float, POINTER
N_POOL_PROC = mp.cpu_count()
this_dir = os.path.dirname(os.path.abspath(__file__))
clib = ctypes.CDLL(os.path.join(this_dir, "mlspm_lib.so"))
fp_p = POINTER(c_float)
int_p = POINTER(c_int)
# fmt: off
c... |
f5cb3239dba558f4be958fa5267b80613c07a3c27d8e8939a348fef9a6759f77 | Python | 4,411 | 164 | from scipy.signal import blackman
from scipy.fftpack import fft
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
class HigherOrderSpectrum(object):
"""
Higher order spectrum analysis
"""
def __init__(self, time, signal, window_size=N... |
82ae712c96e86e3a1a8e18c34eb415787225533c21d355f17b118c45b4562ced | Python | 4,412 | 116 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Static grouped assigner module."""
from openfl.component.assigner.assigner import Assigner
class StaticGroupedAssigner(Assigner):
r"""The task assigner maintains a list of tasks.
Also it decides the policy for which collabora... |
bcd3e2bb11036826e174926fae6d44f5120ef73ca226a2de2a4ed467c818915c | Python | 4,413 | 170 | from Purkinje_morpho_1 import Purkinje_Morpho_1
from neuron import h,gui
import multiprocessing
import random as rnd
from Purkinje_morpho_1_number import number_ind_1
import numpy as np
import matplotlib.pyplot as plt
#per disabilitare tutti i generatori random
seed = 123456
rnd.seed(seed)
h.use_mcell_ran4(1)
h.mcell_... |
9aaa78ac1c03aa14dee67ddec5ecbb523720065b83635ad6736c54a4db670e97 | Python | 4,414 | 155 | """
Misc shared utility functions
"""
import os
import glob
import hashlib
import logging
from typing import *
import requests
import numpy as np
def is_huggingface_hub_id(s: str) -> bool:
"""
Return True if s looks like a repo ID
>>> is_huggingface_hub_id("wukevin/foldingdiff_cath")
True
>>> is... |
be6e8b77060a2c3cba4d7ff834de023a755f77f7d072623dc44d87d6f6a8b660 | Python | 4,414 | 104 | """The contract suites stay black-box, and this is what enforces it.
The whole value of the end-to-end contracts is that the live parity run can
re-execute them against a different engine without editing them. That
property survives exactly as long as nobody reaches into ``mace`` for an
assertion, and it is the kind o... |
f1a44426cefa8beb978ac9ed1b5ca3b04ceb14f79aef0d858b7194db2e23122f | Python | 4,416 | 150 | import random
import pytest
from geomstats.geometry.symmetric_matrices import (
ConstantValueRowSumsDiffeo,
HollowMatricesPermutationInvariantMetric,
NullRowSumsPermutationInvariantMetric,
NullRowSumsSymmetricMatrices,
SymmetricHollowMatrices,
SymmetricMatrices,
)
from geomstats.test.parametri... |
44531ee4c865ba2db5c7e2ad3f798599ba59155f33a0fe80408154a148cb7c3f | Python | 4,417 | 134 | from itertools import combinations
from pathlib import Path
import click
from scipy.stats import mannwhitneyu
from nnunetpaper._utils import get_multi_method_dataframe
from nnunetpaper.data import read_json
@click.group()
def main():
...
@main.command()
@click.argument("files", nargs=-1, type=click.Path(reada... |
60d27a6cf21054757c8b73a30f3249ec048d5fc6b4095e9c0813f383e7e3f5df | Python | 4,417 | 136 | # ==============================================================================
# Copyright 2023 Technical University of Denmark
# Author: Nikolas Borrel-Jensen
#
# All Rights Reserved.
#
# Licensed under the MIT License.
# ==============================================================================
import os
import... |
d75088d8a05d755c43d2df6aedbaeeaf0cd38ccb4fd5ebafabc3b02a66cb021b | Python | 4,419 | 125 | from typing import List, Tuple
import logging
from torch import Tensor
from torch.autograd import Variable
from torch.utils import data as tud
import numpy as np
import torch
from reinvent.models.transformer.core.dto.batch_dto import BatchDTO
from reinvent.models.transformer.core.network.module.subsequent_mask import... |
fa7b051f0304895b89a281323a979d8b164ba3ac6768c60aea66161be1494915 | Python | 4,420 | 123 | # This file is a part of the `nequip` package. Please see LICENSE and README at the root for information on using it.
from typing import Union, Callable, List, Tuple
import copy
import numpy as np
import torch
import ase
import ase.build
from ase.calculators.emt import EMT
from .. import AtomicDataDict
from ..dict i... |
34ce598ea96c08d438944318baa78a38e7d6f34c96c4a6bab5acfd45a3047e95 | Python | 4,424 | 149 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 16 15:52:15 2021
@author: nicol
"""
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 12 15:25:17 2018
@author: ngritti
"""
import time, os, glob
from tqdm import tqdm
import numpy as np
from skimage.io import imread
import seaborn as sns
import pand... |
5825972fd05cfc5bc6eec0c8047457a6bc64b8ec219ec9acd64657a84ff365d5 | Python | 4,424 | 133 | import click
from corgie import scheduling, helpers, stack
from corgie.log import logger as corgie_logger
from corgie.layers import get_layer_types, DEFAULT_LAYER_TYPE, str_to_layer_type
from corgie.boundingcube import get_bcube_from_coords
from corgie.argparsers import (
LAYER_HELP_STR,
create_layer_from_spe... |
87b757f8de022b61c3b199da9a14bd562d4db77c593541ada8bc55a1c3730845 | Python | 4,424 | 120 | # 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.
import inspect
from typing import Any, Dict, List
from fairseq import metrics, utils
from fairseq.dataclass import FairseqDataclass
from fair... |
adea571118828eddb6653cd5ef7440f9d671aaf80c4e2417adfe7df120a11eaf | Python | 4,430 | 130 | # 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.
"""isort:skip_file"""
from .dictionary import Dictionary, TruncatedDictionary
from .fairseq_dataset import FairseqDataset, FairseqIterableDat... |
e2033fac9d87a6cecb606a458c9f4fd14fa45bbec76cfabb324c8d8e431fb35e | Python | 4,431 | 126 | #!/usr/bin/env python2
## This script trains hyperalignment using one half of the movie,
## and applies the transformation matrix to the other half.
## Author: GUO-Jiahui
## Cloned from: https://github.com/GUO-Jiahui/budapest_hyperalignment
import os
from glob import glob
import numpy as np
from scipy.stats import zs... |
ff7e18b0891ff147c64895b06505ee2a3351c9f7fb2df530424be61b3f524d57 | Python | 4,431 | 93 | # Courtesy of Rustam Aliyev https://gist.github.com/rstml/bbd491287efc24133b90d4f7f3663905 with minor edits
import random
import keras_preprocessing.image
import config
def load_and_crop_img(path, grayscale=False, color_mode='rgb', target_size=None,
interpolation='nearest'):
"""Wraps keras_preprocess... |
bc886cbd6ae7ab4d7403b9ad4c90806fcb5d8500e858e2df0676c2ac5f5575f8 | Python | 4,436 | 130 | """The array API, the surface adjacency, and the things that must be refused."""
import numpy as np
import pytest
from tfce import TfceError, adjacency_from_faces, tfce
def tetrahedron():
"""The smallest closed mesh there is: 4 vertices, 4 faces, 1-based."""
faces = np.array([[1, 2, 3], [1, 2, 4], [1, 3, 4]... |
a6cd5b55ef08e47f2b23171687b5587038f0cfda98b7532758bb1cca2c3ce660 | Python | 4,437 | 124 | """Tests for detection-preset access."""
import json
from pathlib import Path
import pandas as pd
import pytest
from pydantic import ValidationError
from sanpy.bDetection import DetectionParameters, bDetection, detectionTypes_
from sanpy.sanpy_paths import SanPyPaths
def test_detection() -> None:
"""Load the a... |
bbc3b945cc7e2be6c7d1c3103d406ee444ed64accbfbc78b92f14cdd503fc680 | Python | 4,437 | 159 | """Lilly PAINS pattern to score for various assays
This uses the substructure tool to match for known PAINS patterns. Matches
are not counted.
"""
__all__ = ["LillyPAINS"]
import os
import csv
import re
import operator
import shlex
from dataclasses import dataclass
from typing import List, Dict
import logging
impor... |
4a14350349371fa51f35c12481f90010a4983ffa72c5d6e7e7159d40f6cc4adf | Python | 4,439 | 155 | """Class to provide a (mostly) unified interface to all the models
The base class holds code that is generic to the models.
"""
from __future__ import annotations
__all__ = ["ModelAdapter", "SampledSequencesDTO", "BatchLikelihoodDTO"]
import logging
from abc import ABC, abstractmethod
from dataclasses import datacla... |
8998d80f7fe1ca53d68d7c5e49086fbca8db2d06dad4fea927db9085518011b6 | Python | 4,441 | 111 | # Copyright 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import json
import os
from pathlib import Path
from openfl.federated.data.sources.azure_blob_data_source import AzureBlobDataSource
from openfl.federated.data.sources.local_data_source import LocalDataSource
from openfl.federated.data.sources.s... |
5c825206c5d4a522307e35630831b8d37ac6a1f412230712bf83e7a9aa35425c | Python | 4,443 | 131 | import torch
from torch.nn import Parameter
import torch.nn.functional as F
import torch.nn as nn
from torch_scatter import scatter_mean
from torch_scatter import scatter_sum
from torch_geometric.utils import remove_self_loops, add_self_loops, softmax
# torch_geometric import
from torch_geometric.nn.inits import uni... |
12747903c8f624c9997ddcffbe1423b509f7f09185f127950f140b2d3f20dbfa | Python | 4,447 | 130 | import os
import csv
import re
from openpyxl import Workbook, load_workbook
prjdir = '/Users/hastingj/Work/Onto/HBCP/ontologies/BehaviourChangeTechniques/'
os.chdir(prjdir)
file_name = "BCTO_Wide.xlsx"
id_root = 7001 # BCI content is BCIO:007000
wb = load_workbook(file_name)
sheet = wb.active
sheet_data = sheet.r... |
baefce9ef37939016fa4fe3a30258e55e7ecf4de8cd7a6cf883932d7026559a1 | Python | 4,447 | 145 | import argparse
import os
from typing import List
import google.generativeai as genai
import chromadb
from chromadb.utils import embedding_functions
model = genai.GenerativeModel("gemini-pro")
def build_prompt(query: str, context: List[str]) -> str:
"""
Builds a prompt for the LLM. #
This function buil... |
c5ab0d101b846355c310dd7ec67ac75df7bc32dd9b09ab19e6bd9fdafbbd4763 | Python | 4,447 | 82 | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... |
493c28559b64ccaaea7418ea9af3e9ff1a45084a5867f027ac365429babe99be | Python | 4,450 | 76 | import argparse
from typing import Optional
def _bool_type(value):
if value.lower() == "true":
return True
elif value.lower() == "false":
return False
raise KeyError(f"`{value}` can't be interpreted as a boolean.")
def parse_args(argv: Optional[list[str]] = None) -> dict:
"""
Par... |
8c2f5e4dd9b6e0389bb3e7d9674c7eb673937bf317c08364d03af0de7ce26f08 | Python | 4,450 | 118 | """
Run Time Optimization
=====================
In this tutorial, we will go through some of the options you have to improve the run-time of vector-field evaluations
based on the equation files generated by PyRates.
As an example, we will use a model of :math:`N = 100` interconnected leaky integrator units, the evolut... |
9cbff22d9c6675c6f3e5fd9c828f082a7ec2127a18e26348142d9848ca6d156d | Python | 4,450 | 111 | from typing import List, Dict
import numpy as np
from reinvent.chemistry.library_design import FragmentReactions
from reinvent.chemistry.library_design.reaction_filters.base_reaction_filter import (
BaseReactionFilter,
)
from reinvent.chemistry.library_design.reaction_filters.reaction_filter_configruation import ... |
9262b735c01be0cfc8694837951352f6cfc51fca81da95040600b0f33ff7579d | Python | 4,456 | 121 | """Chunk lint: the cheap text-level checks, before anything is parsed as a table.
These run in milliseconds over all 230 chunks and catch the class of problem that otherwise appears
as a confusing pandas error three stages later: a file that is not UTF-8, a CRLF file, a header with
an empty or duplicated column name, ... |
fb69ba263c12abebd9ef7a44437f162fe55b29cd47e7393c05e527620d23e9c6 | Python | 4,456 | 129 | from chromadb.api.types import (
Embeddings,
Documents,
EmbeddingFunction,
Space,
)
from chromadb.utils.embedding_functions.schemas import validate_config_schema
from typing import List, Dict, Any, TypedDict, Optional
import os
import numpy as np
class NomicQueryConfig(TypedDict):
task_type: str
... |
a461ca950c8a9225aa7260fe37423ff1f20e7f994cd0334efed2a7c45a0be9c3 | Python | 4,457 | 116 |
import numpy as np
import torch
from torchvision import transforms
import data.segmentation_transforms as segmentation_transforms
from data.image_transforms import GammaAugmentor, GaussianBlurAugmentation, GaussianNoiseAugmentation, \
ResolutionAugmentation, ZscoringNormalize
from data.utils import ImgAndTargetPl... |
21ffdfc8a4f0ccd1142aab44452b4ec2860d1aba4b7aa829670ae9d73a6de13f | Python | 4,458 | 101 | """
This script will
a) generate .fasta and .pssm files for each individual protein sequence.
b) process the pssms into a dict with the sequence IDs.
# May first need to run perl /home/ec2-user/SageMaker/efs/data/CAMP/tools/ncbi-blast-2.13.0+/bin/update_blastdb.pl swissprot.fa
This script will run the following ps... |
7655dfd1e8f6a258111d21482abfc2cdd9433913581c4a62e2041cdd9e4ed3d8 | Python | 4,460 | 105 | # This file is a part of the `nequip` package. Please see LICENSE and README at the root for information on using it.
from typing import Optional, Iterator
import torch
from torch.utils.data import Sampler
class PartialSampler(Sampler[int]):
r"""Samples elements without replacement, but divided across a number o... |
1841b8b7746705f26941c508a7c5723355868802309d2d5ce510be80fe2404b7 | Python | 4,462 | 103 | from PymoNNto.Exploration.Network_UI.TabBase import *
class weight_tab(TabBase):
def __init__(self, title='Weights', weight_attrs=['W']):
super().__init__(title)
self.weight_attrs = weight_attrs
def add_recorder_variables(self, neuron_group, Network_UI):
return
def initialize(sel... |
fe120ec6a21b21e5d9a8e9fc0d327bc0725136478ec173ce7930bc4f838f9e7b | Python | 4,466 | 135 | """Send information to a remote server"""
from __future__ import annotations
import time
from typing import List, TYPE_CHECKING
import logging
import numpy as np
if TYPE_CHECKING:
from reinvent.scoring import ScoreResults
from reinvent.runmodes.RL.reports import RLReportData
logger = logging.getLogger(__na... |
cb879de8e2ac1d1ccc0fffdfe2c82b1c59b07cac96290dcdb8090d8c13cc8b58 | Python | 4,468 | 122 | """
Calculate the wave propagation velocity for each wave.
"""
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
import argparse
import scipy
import pandas as pd
from utils.io_utils import load_neo, save_plot
from utils.parse import none_or_str
CLI = argparse.ArgumentParser()
CLI.add_argumen... |
c22c12edf72f6cccfa0e41898806bd17cbd8b8f7c67574a0262bf3391a04018e | Python | 4,469 | 132 | import torch
import torch.nn as nn
import torch.nn.functional as F
from .mol_tree import Vocab, MolTree
from .nnutils import create_var, index_select_ND
class JTNNEncoder(nn.Module):
def __init__(self, hidden_size, depth, embedding):
super(JTNNEncoder, self).__init__()
self.hidden_size = hidden_s... |
87ee41969d0eddceff679e0a577ed6ca432765d1d402b341f9c2b2c7c5e55d36 | Python | 4,470 | 122 | """
Calculate the wave propagation velocity for each wave.
"""
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
import argparse
import scipy
import pandas as pd
from utils.io_utils import load_neo, save_plot
from utils.parse import none_or_path
CLI = argparse.ArgumentParser()
CLI.add_argume... |
f1c9204e510874024b0e67c343fdd09a249212c37d51f8d5f7d43991747e28f5 | Python | 4,470 | 116 | # Copyright 2020-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging
from openfl.experimental.workflow.interface import FLSpec
from openfl.experimental.workflow.placement import aggregator, collaborator
log = logging.getLogger(__name__)
class TestFlowIncludeExclude(FLSpec):
"""
Testfl... |
172423e6d2b4ed025fac69b2b84c455990841b063ae1997255ed37794c5307ed | Python | 4,472 | 169 | import os
import time
import hdf5storage
import numpy as np
import scipy.io as sio
from functions.dFC_funcs import *
os.environ["MKL_NUM_THREADS"] = "64"
os.environ["NUMEXPR_NUM_THREADS"] = "64"
os.environ["OMP_NUM_THREADS"] = "64"
print(
"################################# CODE started running ... ##############... |
4c86a7156f1dfee67f6092e72431021e49aaae59e169f92b6a6e16ab6060643d | Python | 4,480 | 122 | """
Calculate the wave propagation velocity for each wave.
"""
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
import argparse
import scipy
import pandas as pd
from utils.io_utils import load_neo, save_plot
from utils.parse import none_or_str
CLI = argparse.ArgumentParser()
CLI.add_argumen... |
78b19ae85b6dfca7e803631a2dfcc1bc58402562e2e2c96d286d53237bb4dd89 | Python | 4,480 | 122 | """Tests for the Search API endpoint."""
from typing import Tuple
from uuid import uuid4
import pytest
from chromadb.api import ClientAPI
from chromadb.api.models.Collection import Collection
from chromadb.api.types import Embeddings, ReadLevel
from chromadb.execution.expression import Knn, Search
from chromadb.test... |
b997d063de0485b14bcf92ce6f47f399c3a11373fb2d7d5cb6d12efa3b3a7e72 | Python | 4,481 | 129 | import pytest
import geomstats.backend as gs
from geomstats.test.data import TestData
from ...test_geometry.data.base import VectorSpaceOpenSetTestData
from ...test_geometry.data.diffeo import DiffeoTestData
from ...test_geometry.data.riemannian_metric import RiemannianMetricTestData
from .base import InformationMani... |
e2db23e8d4964b8cf74ac630a050e65fb71df4c2c2401eaa9676d55359cfd00a | Python | 4,482 | 136 | from pathlib import Path
import mne
import numpy as np
from .find_event_channel import find_event_channel
from ... import io
from .... import logger
def change_event_values_arr(timearr, event_value_old, event_value_new):
"""
Replace the values 'event_value_old' with 'event_value_new'
for the channel tim... |
f83aba7b9358fc5d4184f6b232632cf665075e383a5741d007a4ebdc5fce4ebb | Python | 4,485 | 142 | """
For Fig 2B go to:
Z:\people\gritti\IRIR\supFig2_3
"""
import os
import matplotlib.pyplot as plt
from matplotlib import rc
import pandas as pd
import seaborn as sns
# from scipy.stats import ttest_ind
plt.rcParams.update({'font.size': 15})
rc('font', size=8)
rc('font', family='Arial')
# plt.style.use('dark_backg... |
2ee569ad759f0921134ce0859ab568b93d111a7e7418d085cf663a337fa1756a | Python | 4,488 | 137 | import os
import argparse
import warnings
warnings.simplefilter(action="ignore", category=FutureWarning)
import pandas as pd
import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
from torchvision.transforms import Grayscale
from activation_models.generators import get_activation_model... |
b9a36c9ca1be4cd45c7f171de4464099aa0eae52b916bd66abdcd369cf00be3f | Python | 4,490 | 180 | from unittest import TestCase
import unittest
import numpy as np
import os
from filecmp import cmp
from smithers.io.obj import ObjHandler
from smithers.io.obj.objparser import save_obj, WavefrontOBJ
data = ObjHandler.read("tests/test_datasets/file.obj")
def test_vertices():
expected = [
[0.109625, 0.06,... |
5790abf1b4993c37c1fc3766c4ed12fd143ffcd0d77dbb86df70d5df2cfff7eb | Python | 4,491 | 78 | # -*- coding: utf-8 -*-
import pandas as pd
"""
BEFORE THIS STEP: (Jasleen added):
1a. Prepare pepbdb-2020/pepbdb directory from .tgz download at http://huanglab.phys.hust.edu.cn/pepbdb/db/download/ [DONE] - /home/ec2-user/SageMaker/efs/data/CAMP/paper/pepbdb
1b. Run crawl.py to generate crawl_results.csv [ONGOING]... |
82822db3b7dd5698f6484a7cd8a917304e6019e0e0c2308ed2ec6aa4af084fcc | Python | 4,491 | 121 | import unittest
import inspect
import os
from unittest.mock import patch, Mock
import pytest
import chromadb
import chromadb.config
from chromadb.api.segment import SegmentAPI
from chromadb.db.system import SysDB
from chromadb.ingest import Consumer, Producer
class GetDBTest(unittest.TestCase):
@patch("chromadb.d... |
0171782422a6e4ecc034bca82ae47d2348dd91830dac0945727527afc45e4d5b | Python | 4,499 | 127 | import torch
import torch.nn as nn
from .bert import BERT
def save_bert_model(bert_model, model_pth):
dict = {}
embed = {}
embed['token'] = bert_model.embedding.token.state_dict()
if hasattr(bert_model.embedding, 'segment'):
embed['segment'] = bert_model.embedding.segment.state_dict()
embed... |
4afd7a21120c6551f222bf998483f8419a453e6475032b3fa3089d36bb8eb912 | Python | 4,501 | 101 | """``method.frequency`` as three independent columns (#696).
The column held at least three different things - a ratio, a bare float and a percentage - and the
one thing the confidence score wants, the read count, was reachable in only two thirds of the
non-blank cells and unreachable in all of them without parsing fr... |
ca2df3bd231069611c2f7821f970001a1477a2df5b70181bb0d36df9c1c9d8c0 | Python | 4,502 | 141 |
import random
import time
from pathlib import Path
import numpy as np
import ppafm.ml.AuxMap as aux
import ppafm.ocl.field as FFcl
import ppafm.ocl.oclUtils as oclu
import ppafm.ocl.relax as oclr
import torch
from ppafm.ml.Generator import InverseAFMtrainer
from ppafm.ocl.AFMulator import AFMulator
import mlspm.prep... |
4e68c1b21e0e125e1a07cc8cd8053d5bd4f68c17caab32b37c6fb70e8ef4543e | Python | 4,507 | 158 | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# 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 appli... |
77522ed2defefd60e8f488896dcd4b193a6a10d20b4bf041b555c7a51e0d009c | Python | 4,509 | 123 | import argparse
import numpy as np
import sys
def check_file(expres):
checkset = set(["", "NA", "Na", "na", "nan", "null"])
for c in checkset:
loc = np.where(expres == c)
if loc[0].size:
expres[loc] = "0"
print(f"Notice! There is {c} in the 'gene expression m... |
ebe19f191a108369f57678bdffedb99c459403d3cb9f3cce2ca07b69d0da927d | Python | 4,509 | 143 | from __future__ import annotations
import argparse
import json
from pathlib import Path
from typing import Any
import pytest
from hypothesis import given
from pytest_mock import MockerFixture
from snakebids.app import SnakeBidsApp
from snakebids.cli import add_dynamic_args
from snakebids.tests import strategies as s... |
71150405e44a68000b609eab57b31e30b1b8e22f11950456469eaab010803f2e | Python | 4,511 | 132 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pandas as pd
import matplotlib.pyplot as plt
import json
from scipy.stats import linregress
from fpdf import FPDF
from fpdf.enums import XPos, YPos
class PDF(FPDF):
def header(self):
self.set_font("Helvetica", "B", 14)
... |
1c9aff1b6c78797e8d30c1b6d85cb8d2b989260bb52e7ad509574e87c36e28f3 | Python | 4,512 | 126 | import tensorflow as tf
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Input, Conv2D, Concatenate, MaxPool2D, \
UpSampling2D, BatchNormalization, Activation, Add
def convlayer(x, filters, activation, name, residual=None, use_batchnorm=True):
"""Convolutional layer with normalizat... |
380508ca8ce37dae4ded949dd7897fd396e38019cf66c14ca07a2e4618ceda55 | Python | 4,512 | 122 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
#
# 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
#
# Un... |
61065e07b3f4f9f8509cf790cfbd1e961814dea893285a94473675baa8a9d34b | Python | 4,518 | 171 | from Purkinje_morpho_1 import Purkinje_Morpho_1
from neuron import h,gui
import multiprocessing
import random as rnd
from Purkinje_morpho_1_number import number_ind_1
import matplotlib.pyplot as plt
import numpy as np
#per disabilitare tutti i generatori random
seed = 123456
rnd.seed(seed)
h.use_mcell_ran4(1)
h.mcell_... |
5d5da8951648c2b1aa2873152af1bae7c743e87fc683c779212460f278be62ad | Python | 4,519 | 148 | """Module providing the SkewSymmetricMatrices class.
This is the Lie algebra of the Special Orthogonal Group.
As basis we choose the matrices with a single 1 on the upper triangular part
of the matrices (and a -1 in its lower triangular part), except in dim 2 and
3 to match usual conventions.
Lead author: Nicolas Gui... |
d8839bcc8b6de65bf7b82b47ec7bfb018d833f6726bd72dea3d2aa0002ced131 | Python | 4,522 | 85 | # =====================================================================================
# RE-MEASURE D-Fine A100 latency (clean, FP32, warmup+median). FRESH NOTEBOOK, A100 GPU.
# =====================================================================================
# HOW TO RUN:
# 1) A100 runtime (Runtime > Change run... |
9d2ea508512f23b69c829a4ddcf85b56352d8fed69ae522e38620724340fd68b | Python | 4,525 | 148 | """
Run heirarchical clustering on the pairwise distance matrix between all pairs of files
"""
import os, sys
import re
import json
import logging
from glob import glob
from pathlib import Path
import itertools
import argparse
from typing import *
import multiprocessing as mp
import numpy as np
import pandas as pd
im... |
f8b708e8b5506c5f01f0bf0b0594b9e1e1703fbd899315f2cd1ea987fac4374c | Python | 4,526 | 76 | ########################################################################
class Basic:
"""
Contains the basic parameters for the offline modality of Motor Imagery protocol
"""
#-------------------------------------------
# PATH TO SAVE DATA
#-------------------------------------------
para... |
30cac8b7c6353378bf0e1ce485928644a54b2e3c5cd0dfc302e098c4344fba66 | Python | 4,528 | 146 | from chromadb.api.types import (
Embeddings,
Documents,
EmbeddingFunction,
Space,
)
from typing import List, Dict, Any, Optional
import os
from chromadb.utils.embedding_functions.schemas import validate_config_schema
from typing import cast
import warnings
ENDPOINT = "https://api.together.xyz/v1/embedd... |
b142e681101544f91a471262d1e3eafcd6e95df58757b8a71ff1174af1568f0f | Python | 4,528 | 226 | import statistics
import numpy as np
import scipy
# Van der Pol oscillator: dx/dt = y, dy/dt = μ(1-x²)y - x
def u(x, y):
return y
def v(x, y):
return mu * (1 - x**2) * y - x
def du_dx(x, y):
return 0
def du_dy(x, y):
return 1
def dv_dx(x, y):
return -2 * mu * x * y - 1
def dv_dy(x, y... |
1294b0ead5b5cbee7d13506c9e37f8602bfd77efdbb6393b42bca390711c5745 | Python | 4,534 | 80 | # Copyright (c) 2021 Big Data and Multi-modal Computing Group, CRIPAC
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, c... |
2a091b9d1c2752b0f055754eb8df38d033055306b27514a867dfdc103d2a7e68 | Python | 4,534 | 181 | # -*- coding: utf-8 -*-
import sys
import os
import re
from sphinx.locale import _
from pyrates import __version__ as version
# Prefer to use the version of the theme in this repo
# and not the installed version of the theme.
sys.path.insert(0, os.path.abspath('../../'))
sys.path.append(os.path.abspath('sphinxext'))... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.