sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
dbfef3447ba855fc1cc684caa6d266cadc9c430cbf633fa95a60792c7c022f84 | Python | 2,365 | 87 | from collections import defaultdict
import re
import os
from permacache import permacache
import pandas as pd
import torch
from modular_splicing.utils.io import load_model, model_steps
from .utils import dropped_motifs
def motif_substitutability(path):
accuracies = motif_change_accuracies(path)
actions = l... |
a16d3c2fa460e127ef046af93071199dddde57ab94bfc7ea8e8943176cbe6395 | Python | 2,366 | 79 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Selected(_BaseTraceHierarchyType):
_parent_path_str = "box"
_path_str = "... |
71eb755c09194585ae5da5d253e798f705ae1a7358e58bd490bfa11d293a1fef | Python | 2,367 | 79 | #!/usr/bin/env python
# =============================================================================
# MODULE DOCSTRING
# =============================================================================
r"""
Utility class to create a map-style PyTorch ``Dataset``\ s from a dictionary of tensors.
For usage examples se... |
874bb8e7ce28cd6ee948ee549a10190b8c21fe8332d6c330f4f6cddb303f9251 | Python | 2,367 | 67 | import numpy as np
from sklearn.metrics import roc_auc_score
import torch
from hn_cnn.constants import *
def get_accuracy(outputs, labels, threshold=0.5):
""" Calculate the accuracy
"""
preds = (outputs > threshold).int()[:,0]
return torch.tensor(torch.sum(preds == labels).item() / len(preds))
@torch... |
887e3b780df39efe0130ad4200db427c6b4d496d8f587b7589630d03d57c29ad | Python | 2,367 | 71 | #!/usr/bin/env python
import unittest
import numpy as np
import pandas as pd
from anndata import AnnData
import stlearn as st
from stlearn.tl.cci.base import calc_neighbours, get_lrs_scores
def _make_cci_adata(dtype=np.float64, n_side=8, n_extra_genes=40, seed=0):
rng = np.random.default_rng(seed)
n_spots ... |
a2fc79668f52444f1e943536320524532b23a07ea8534eef625315147fc8c663 | Python | 2,367 | 82 | import numpy as np
from . import mes
from . import leica
from . import ioraw as ioraw
from . import olympus
def write_table_csv(table, fname):
import csv
with open(fname, 'wt') as f:
writer = csv.writer(f, quoting=csv.QUOTE_ALL)
for row in table:
writer.writerow(row)
def write_d... |
06a7d0d64a9df86d6cf902e16e58f3b9ace7d9adc10263a5f5c748a3215fe28d | Python | 2,368 | 75 | import argparse
import numpy as np
import sys
def generate():
parser = argparse.ArgumentParser()
parser.add_argument('--vocab_file', default='vocab.txt', type=str)
parser.add_argument('--vectors_file', default='vectors.txt', type=str)
args = parser.parse_args()
with open(args.vocab_file, 'r') as f... |
c693f7c291295313b547b97096d74042f7f150903950125df73ac24eda4e64e9 | Python | 2,368 | 80 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Marker(_BaseTraceHierarchyType):
_parent_path_str = "choropleth.unselected"
... |
0f73ae6453c9b05f46adc0aad19bd162f6054703cc9d107df44b53d7a64affec | Python | 2,369 | 56 | import tensorflow as tf
import keras_tuner as kt
from sklearn.utils import shuffle
import pandas as pd
import numpy as np
def build_model(hp):
n_hidden = hp.Int("n_hidden", min_value=0, max_value=8, default=2)
n_neurons = hp.Int("n_neurons", min_value=32, max_value=1024, step = 32)
learning_rate = hp.Float... |
4990066455342048937ca1b7e43bc44f66cd70ee0bb984e0be92b4e850a73665 | Python | 2,369 | 67 | """r-b4 R27-5: display/summary walkers render bounded markers, never crash.
``format_call_arg`` crashed with a raw ``RecursionError`` on an ordinary
container cycle (probe: ``x=[]; x.append(x)``), and the module-hierarchy /
container-repr walkers shared the same unbounded shape. Display paths are now
TOTAL: cycles ren... |
44f63f963f8822ecb4edc6cd1e026cba6bc51ed036b160511f078d42f7b36d88 | Python | 2,370 | 79 | """
The fingerprint generation function.
"""
from argparse import Namespace
from logging import Logger
from typing import List
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from BatmanNet.data import MolCollator
from BatmanNet.data import MoleculeDataset
from BatmanNet.util.utils import g... |
7c6099a875d97a27d0f164cf0cf28497eb9240a3ac6d593becf49e9d4d161cbd | Python | 2,370 | 80 | # coding=utf-8
# Copyright 2023 The Google Research Authors.
#
# 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 applicab... |
cc7dbc6075794d701587564e1198ba67511d922bb6e9d376b577d1e956d0dc1e | Python | 2,370 | 76 | from __future__ import absolute_import
import contextlib
import errno
import hashlib
import logging
import os
from pip._internal.utils.temp_dir import TempDirectory
logger = logging.getLogger(__name__)
class RequirementTracker(object):
def __init__(self):
self._root = os.environ.get('PIP_REQ_TRACKER')... |
ff8728ff29f680ce6e18fefb163795a9f6bbc3a566ac40c64822cf497611a7ec | Python | 2,370 | 71 | """The ``celery call`` program used to send tasks from the command-line."""
import click
from celery.bin.base import (ISO8601, ISO8601_OR_FLOAT, JSON_ARRAY, JSON_OBJECT, CeleryCommand, CeleryOption,
handle_preload_options)
@click.command(cls=CeleryCommand)
@click.argument('name')
@click.... |
2302988b30ce42ae34acb6ec96b3206c0480b24579a1a5b24b5722ad0efe2dce | Python | 2,371 | 59 | from typing import Iterable, Optional, Tuple
import argparse
import torch
import torch.nn as nn
import transformers
from imodelsx.iprompt.utils import PrefixLoss, PrefixModel
class GumbelPrefixModel(PrefixModel):
args: argparse.Namespace
loss_func: PrefixLoss
model: transformers.PreTrainedModel
tok... |
bbad6d5cf05c2f25d45d7a2c2e789e8d0f5fd50a5fa24534ae7ee163f122cc34 | Python | 2,371 | 80 | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Loss functions."""
from functools import partial
import torch
import torch.nn as nn
from pytorchvideo.losses.soft_target_cross_entropy import SoftTargetCrossEntropyLoss
class ContrastiveLoss(nn.Module):
def __init... |
7a71d078d0923d1051074199c2a2a6a7361519d887a8174f04767a61f9d6ec8f | Python | 2,372 | 77 |
"""Utilities for extracting identifiers from MSA sequence descriptions."""
import dataclasses
import re
from typing import Optional
# Sequences coming from UniProtKB database come in the
# `db|UniqueIdentifier|EntryName` format, e.g. `tr|A0A146SKV9|A0A146SKV9_FUNHE`
# or `sp|P0C2L1|A3X1_LOXLA` (for TREMBL/Swiss-Pro... |
f078a02bbc2c1b8ac44286905b3fbc2a962482cd59e7ef3d98e3a9967e26a35a | Python | 2,372 | 65 | """Distance between predicted and observed frame embeddings.
LeWM and other continuous-latent, next-embedding predictors compare a predicted
embedding against an observed one. They differ only in the norm and in whether
the representations are normalized first, so the comparison lives here rather
than in the loss of a... |
459a67cf04e696d74d10f5bd0324be59fa8136d1ed1e59fcdfbea48f6ce6a28c | Python | 2,373 | 82 | __author__ = 'quentin'
#import futures
import concurrent.futures as futures
import concurrent
import urllib.request, urllib.error, urllib.parse
import time
import logging
import json
start = time.time()
def scan_one_device(ip, timeout=2.5, port=9000, page="id"):
"""
:param url: the url to parse
:param... |
66bc30c6de84ba9cc76f965981f7da573c5c3ddef39aa1c1b3c7e226bb7720ad | Python | 2,373 | 73 | import re
import pytest
from pytest_celery import RESULT_TIMEOUT, CeleryBackendCluster, CeleryTestSetup
from pytest_docker_tools.wrappers.container import wait_for_callable
from celery.signals import after_task_publish, before_task_publish
from t.smoke.tasks import noop
@pytest.fixture
def default_worker_signals(de... |
2d7c8583cf26dcebae0b9d7a54295c0e1da3aad36ae026fce50d0272f07d4dc2 | Python | 2,374 | 85 | """
Code from https://github.com/shenxn/rpi-bad-power
A library reading under voltage bit from the official Raspberry Pi Kernel.
Minimal Kernel needed is 4.14+
"""
import logging
import os
_LOGGER = logging.getLogger(__name__)
HWMON_NAME = "rpi_volt"
SYSFILE_HWMON_DIR = "/sys/class/hwmon"
SYSFILE_HWMON_FILE = "in0... |
cb7bd4f13d870e7404d52db592711877ceda74f7827cc62af2c4be450cb9aa84 | Python | 2,374 | 72 | import os
import random
import h5py
import numpy as np
import scanpy as sc
import tensorflow as tf
import sys
sys.path.append('../pkgs/ZIFA/')
from ZIFA import block_ZIFA
from scbig.utils import read_data, sample, louvain, calculate_metric
def seed(SEED):
os.environ['PYTHONHASHSEED'] = str(SEED)
random.seed... |
eea46cff4e6ba413a40b39153bd1710f5bd77a17d29d9cefc2661e1f8ba342ab | Python | 2,374 | 78 | # This example requires the following dependencies to be installed:
# pip install lightly
# Note: The model and training settings do not follow the reference settings
# from the paper. The settings are chosen such that the example can easily be
# run on a small dataset with a single GPU.
import pytorch_lightning as p... |
4842648c4bd5b49fb8d9d69890d6dcafd9879a63ba6630ecea986f9f24a53401 | Python | 2,375 | 75 | """Display changelog with links to GitHub issues
Usage
-----
The directive
.. include_changelog:: ../CHANGELOG
adds the content of the changelog file into the current document.
References to GitHub issues are identified as "(#XY)" (with parentheses
and hash) and a link is inserted
https://github.com/RI-imaging/... |
6686ee25de9a3d130b3c9d8c20fae3a8eb9074b33aea1eaedf5969c96e3ab561 | Python | 2,375 | 69 | import sys
from robustness import datasets
from robustness.attacker import AttackerModel
from robustness.model_utils import make_and_restore_model
import torch as ch
import numpy as np
import random
from model_analysis_folders.all_model_info import IMAGENET_PATH, MODEL_BASE_PATH
import os
def build_net(ds_kwargs={}, ... |
8f30d53061d576863524ef9e2e81b2792233d90cc8a4e66d6f903302555aa52d | Python | 2,375 | 80 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Decreasing(_BaseTraceHierarchyType):
_parent_path_str = "ohlc"
_path_str ... |
d4af2a34ea4119e9554eae2b97a5c808b17a889202fa67b34e0dfe0a12e0f964 | Python | 2,375 | 70 | """Currently the training process is slowed by
IO, so we want to pre-batch the data to speed things up,
this way reads will be more sequential.
"""
import numpy as np
import glob
import os
from pathlib import Path
import random
import logging
dataset = "validate"
data_dir = "/data2/cdcm/rescaled"
root_dir = f"{da... |
f5e132d58a37d242f543aff68bf5e6f8308288727c7c060939af436cbbffe433 | Python | 2,375 | 80 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Increasing(_BaseTraceHierarchyType):
_parent_path_str = "ohlc"
_path_str ... |
94389ff329d7a761467cebf5b4dc16d84e365bf1d64b39448663743ac188676a | Python | 2,376 | 100 | """Pytest configuration file for testing spiketools."""
import os
import shutil
import pytest
import numpy as np
from spiketools.objects import Unit, Session
from spiketools.utils import set_random_seed
from spiketools.tests.tsettings import BASE_TEST_FILE_PATH, TEST_PLOTS_PATH
#####################################... |
291edaa2ea5ff0d6c85ce81713e9ffcece5c1f13743dae53993675909e21bd70 | Python | 2,377 | 65 | import sys
sys.path.append('../TM2_segmentation')
import pandas as pd
import os
import numpy as np
import os
import shutil
import subprocess
import re
from settings import AGE_FROM, AGE_TO
path = "/media/sda/Anna/TM2_segmentation/data/curated_test/"
def find_file_in_path(name, path):
result = []
result = lis... |
466db419d1b435f308cb1b52a6cbdb61bd4cc3ec9abaea4d86170082c9286177 | Python | 2,377 | 67 | from typing import Dict, Any
from .atomistic import AtomicSchNet
from .atomistic_nn_model import AtomisticNNModel
from bioconfpred.data.split import DataSplit
from bioconfpred.params import (LOG_DIRPATH,
SCHNET_CONFIG,
SCHNET_MODEL_NAME)
class SchNetModel(AtomisticNNModel):
... |
56598ee8c98b41c983b64dcd6361a2d50e88371a66bc3e97f2f3b52b7734e703 | Python | 2,377 | 88 | import numpy as np
from numpy import testing as npt
from tns.astrocyte import math_utils as tested
def test_norm():
vector = np.array([0.24428195, 0.84795862, 0.70495863])
npt.assert_allclose(tested.norm(vector), np.linalg.norm(vector))
vector = np.zeros(3)
npt.assert_allclose(tested.norm(vector), 0.... |
6038b34c028fb7557966a46450394349495c89632ea8ceeec4c9e0253f15f62a | Python | 2,377 | 71 | import numpy as np
from anndata import AnnData
from stlearn.spatial.trajectory.utils import _correlation_test_helper
def set_root(adata: AnnData, use_label: str, cluster: str, use_raw: bool = False):
"""\
Automatically set the root index for trajectory analysis.
Parameters
----------
adata: AnnD... |
d6d3c5e0efce13c6bfb5bc04bd401707906c86ded1a870cb3270fc4e8fdc737d | Python | 2,377 | 83 | from pyrosm.utils import warn_empty_result
from pyrosm.data_manager import get_osm_data
from pyrosm.frames import prepare_geodataframe
def get_user_defined_data(
nodes,
node_coordinates,
way_records,
relations,
tags_as_columns,
custom_filter,
osm_keys,
filter_type,
keep_nodes,
... |
0d60a8e154017e661740268d805a3389a4e983e4faf66c2284ab3571e72aee01 | Python | 2,378 | 84 | import pandas as pd
from tlib import ttorch
from .. import config
info = {
'type': 'sentinel_2',
'n_channels': 10,
'image_size': (256, 256),
'n_targets' : 1,
}
def get_info_df():
info_df = pd.read_csv(config.info_path['anthroprotect'])
info_df['file'] = 's2/' + info_df['file'].astype(str) ... |
74c495f7046e04b1c7df246c9ad3a8d1b18b92d1c038d5eb572ce705901ff048 | Python | 2,378 | 81 | """
The main experiment, that goes in the paper
"""
from functools import lru_cache
from .analytics import Analysis, knockdown_analysis
from .models import short_donor_models
from .renderer import plot_knockdown_results
line_class = ("HepG2", "K562")
agg_spec = dict(
type="StandardAggregator",
query_combinat... |
846f6f878f58ddc36623ed6f505e2773e814b590c61f5994a005b6246836276c | Python | 2,378 | 74 | import numpy as np
#import pumpprobe as pp
import matplotlib.pyplot as plt
import pyneuronsegmentation as pyns
import struct
import time
import unmix as um
import mistofrutta as mf
#folder = "/home/francesco/tmp/"
filename = "/tigress/LEIFER/multicolor/data/20190215/multicolorworm_20190215_154313"
Image, Brightfield ... |
cbed82b6f7be5aa5b636a59a214f463cb4a953cf8e97890a8df30cd6583c54a4 | Python | 2,378 | 67 | """AUD-CODE 4.4 regression pins for OpAccessor / LayerAccessor.
``OpAccessor.__getitem__(int)`` is the 0-based POSITION while the write side
is the 1-based PASS INDEX (the storage key three finalization callers write
through). The in-fence part of the fix names the write basis explicitly
(``set_pass``) and pins the as... |
2490239fc3b50af4be747b8d5a11d85e5bb389f9943001a9c209b0d6c0a58baa | Python | 2,379 | 81 | from arguments.data_setting import DataSetting as DataSetting
from arguments.class_setting import ClassSetting as ClassSetting
from arguments.network_setting import NetworkSetting as NetworkSetting
from arguments.feature_setting import FeatureSetting as FeatureSetting
class Setting(object):
""" Class holding the d... |
584388751da383fdc950cc04e73a2622e544742fedb90b0a015311626677003b | Python | 2,379 | 65 | # LICENSE
#
# _This file is Copyright 2018 by the Image Processing and Analysis Group (BioImage Suite Team). Dept. of Radiology & Biomedical Imaging, Yale School of Medicine._
#
# BioImage Suite Web is licensed under the Apache License, Version 2.0 (the "License");
#
# - you may not use this software except in compl... |
89b426e84ca3e281125fd3622bd5aae4aa4582fe36327f79a12289871a1cae02 | Python | 2,379 | 92 | import pytest
import rpy2.rinterface as ri
ri.initr()
def test_init_from_seqr():
seq = ['foo', 'bar', 'baz']
v = ri.StrSexpVector(seq)
assert len(v) == 3
for x, y in zip(seq, v):
assert x == y
def test_init_from_seq_invalid_item():
seq = ['foo', 0, 'baz']
with pytest.raises(Exceptio... |
b29c8cfa19ae5c2afb28bc530e5c9580a1f01df8a8aca74277f7be32420f24e8 | Python | 2,379 | 60 | import glob
import h5py
import numpy as np
import os
import pandas as pd
from sklearn import preprocessing
import sys
"""
hi. this is going to read these in, you basically just need
subjects: path to subjects!
data_path: path to the actual features
phenotypes: path to a csv with the to-be-predicted and the noise
"""
... |
dcbcf6ad2820deb5b926048d378e717ed3604260638edc1feffcf576cac66886 | Python | 2,379 | 75 | # This example requires the following dependencies to be installed:
# pip install lightly
# Note: The model and training settings do not follow the reference settings
# from the paper. The settings are chosen such that the example can easily be
# run on a small dataset with a single GPU.
import pytorch_lightning as p... |
f5896c57f51969931567bdfe9381970e2f5c8e60f2ae96fcbf76fa7407e11dc2 | Python | 2,379 | 92 | """
Helpers for distributed training.
"""
import io
import os
import socket
import blobfile as bf
import torch as th
import torch.distributed as dist
from mpi4py import MPI
# Change this to reflect your cluster layout.
# The GPU for a given rank is (rank % GPUS_PER_NODE).
GPUS_PER_NODE = 8
SETUP_RETRY_COUNT = 3
d... |
78dbf2081ac1d52991587ebc5045b997a7f4561e3676b52d0904b016203032d0 | Python | 2,380 | 80 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
import copy as _copy
class Circle(_BaseLayoutHierarchyType):
_parent_path_str = "layout.map.layer"
... |
bcb52e73d5edc1303a89d9c840ef9227534a4a303904e0dbeaf9a11af91124ae | Python | 2,380 | 73 | # %% [markdown]
# # Read OME-ZARR images
# (basic:read)=
#
# This sample code reads an image stored on remote s3 server,
# but the same code can be used to read data on a local file system.
# In either case, the data is exposed as an instance of the {py:class}`ome_zarr.classes.image.OMEZarrMultiscale` class, which prov... |
d1f9b77414d9ba2bb42293d5455dc42a56490e789b125062637c5ac12b7dfc72 | Python | 2,380 | 78 | import re
from typing import List
import numpy as np
import os.path
from os.path import join
import pickle as pkl
def expand_keyword(
keyphrase_str: str = 'bad',
llm_prompt_context: str = '', # ' in the context of movie reviews',
cache_dir: str=None,
seed: int=0,
verbose: bool=False,
):
""... |
10c3c7f0476bea2aa4851ca7fff19e1730a14d869944c20483271d6feb8cc70d | Python | 2,381 | 77 | from keyword import kwlist
import numpy as np
from typing import Generator
from mirp._data_import.generic_file import ImageFile
from mirp._data_import.utilities import flatten_list
from mirp._images.generic_image import GenericImage
from mirp._masks.base_mask import BaseMask
def read_image(
image: ImageFile... |
258582b9ea0073e16f01a23d6c8f0a5dc9af66bd49e2ec5ec7f35574468af4b9 | Python | 2,381 | 60 | import os
import argparse
import logging
import autogluon.core as ag
from gluoncv.auto.tasks import ObjectDetection
from gluoncv.auto.estimators import SSDEstimator, YOLOv3Estimator, FasterRCNNEstimator, CenterNetEstimator
from d8.object_detection import Dataset
os.environ['MXNET_ENABLE_GPU_P2P'] = '0'
if __name__ ... |
6caace0f204e38d5b4d79d244b7fff39c75bac241c7ed343811361c4ff0e2861 | Python | 2,382 | 59 | from __future__ import annotations
import pytest
import torch
from lightly.loss.latent_distance import latent_distance
class TestLatentDistance:
@pytest.mark.parametrize("distance", ["l1", "l2"])
def test_forward__zero_for_identical_inputs(self, distance: str) -> None:
emb = torch.randn(4, 3, 16)
... |
a6e8efbd7e1583ced91f4b8950aa27988bd654680ef429c455011572bca9dd77 | Python | 2,383 | 64 | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Functions for computing metrics."""
import torch
def topks_correct(preds, labels, ks):
"""
Given the predictions, labels, and a list of top-k values, compute the
number of correct predictions for each top-k... |
057286c4492666d62c64129232a4954c08ce5ee7de2cf630c8a8ed73fed4ea76 | Python | 2,384 | 93 | from unittest.mock import Mock
from celery.worker.heartbeat import Heart
class MockDispatcher:
heart = None
next_iter = 0
def __init__(self):
self.sent = []
self.on_enabled = set()
self.on_disabled = set()
self.enabled = True
def send(self, msg, **_fields):
s... |
0f4e5dfb56830efa4978d7429c7480fdc22b8a87d20feea2983a359531d780d5 | Python | 2,384 | 73 | # This example requires the following dependencies to be installed:
# pip install lightly
# Note: The model and training settings do not follow the reference settings
# from the paper. The settings are chosen such that the example can easily be
# run on a small dataset with a single GPU.
import pytorch_lightning as p... |
6f8e4c6f52fd0ff60c45f7446645256062c688f49af3fc2061ee1224377b50db | Python | 2,384 | 80 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Marker(_BaseTraceHierarchyType):
_parent_path_str = "choroplethmap.unselected... |
9013faedf378bd5d1966d7f85507ada12eff51962d99e9f60c388a731004d2af | Python | 2,384 | 74 | import pandas as pd
import glob
import os
from statsmodels.stats.multitest import fdrcorrection
import seaborn as sns
import matplotlib.pyplot as plt
import argparse
import numpy as np
parser = argparse.ArgumentParser()
parser.add_argument("--sample", action = "store",
help = "name of sample")
parser.add_argument("--... |
da70edcaf6fe294f6acaa4a282e648eadd62632e07a81a26985980804f7fcd02 | Python | 2,384 | 79 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on May 2020
@author: Nathan de Lara <nathan.delara@polytechnique.org>
"""
from typing import Union
import numpy as np
from scipy import sparse
from scipy.sparse.linalg import LinearOperator
from sknetwork.linalg.polynome import Polynome
from sknetwork.ranking... |
2a71bf6a52bfe5ef8163c4435418aaaa800d0d842976d7769bb31380b4c1e3a9 | Python | 2,385 | 76 | # This example requires the following dependencies to be installed:
# pip install lightly
# Note: The model and training settings do not follow the reference settings
# from the paper. The settings are chosen such that the example can easily be
# run on a small dataset with a single GPU.
import torch
import torchvisi... |
a9f7861986e983676ff94911b5b8d162fdb6730933d6a1cbd359e569e7b91510 | Python | 2,387 | 70 | """Functions and converters for aperiodic parameters."""
import numpy as np
###################################################################################################
###################################################################################################
def compute_knee_frequency(knee, exponent... |
467f1dc3671392ac6b21a0cbbeba6706c759e26a3e375159f0a529707419c897 | Python | 2,389 | 66 | """
This module define how to manage configuration.
Classes :
ConfigManager
"""
from collections import namedtuple
import json
import torch
from utils.utils import function_not_implemented
class ConfigManager:
"""
A class to manage the config
"""
def __init__(self, json_path: str):
# Fixed a... |
038e665b85dad5d7d5b7bafc6556f4d9622ed6de860548ed368160cfeb951a38 | Python | 2,390 | 53 | import numpy as np
import tensorflow as tf
from angorapy import make_task
from angorapy.common.policies import BetaPolicyDistribution
from angorapy.utilities.model_utils import reset_states_masked, reset_states_masked_tf
from angorapy.utilities.core import flatten
from angorapy.models import get_model_builder
def te... |
94c42531a37223c6fd4a2b917933ebd23e4483056452b25df0788fe8523f1ce3 | Python | 2,390 | 66 | import os
import h5py
import numpy as np
import scanpy as sc
from dca.api import dca
from scbig.utils import read_data, setup_seed, sample, louvain, calculate_metric
for dataset in ['10X_PBMC', 'mouse_bladder_cell', 'mouse_ES_cell', 'human_kidney_counts', 'Adam',
'Human_pancreatic_islets', 'Macosko_m... |
83810d0b8c03bfd54d6b227b495c57f8c60adecee5b9ea79bc40e2944cb9903a | Python | 2,391 | 53 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
"""
.. _exa-impulse:
Impulse predictors for epochs
=============================
:func:`epoch_impulse_predictor` generates predictor variables for reverse
correlation in trial-based experiments with discrete events. The function
generates one impulse per trial, ... |
c82921be08af198734622412f8e590d1c19a4ff726a3a09a32d587bab35c8c69 | Python | 2,391 | 73 | from __future__ import division
import unittest
import numpy as np
from wyrm.types import Data
from wyrm.processing import clear_markers
from wyrm.processing import swapaxes
class TestClearMarkers(unittest.TestCase):
def setUp(self):
ones = np.ones((10, 5))
# cnt with 1, 2, 3
cnt = np.... |
5e6d89f1d4b55da02410e472be3d39a6342499440cf106c84361b546fd04303d | Python | 2,392 | 96 |
import torch
import sys
import os
import numpy as np
import torch.nn.functional as F
import torch.nn as nn
from torch.nn.parameter import Parameter
import math
class GraphConvolution(nn.Module):
"""
Simple GCN layer, similar to https://arxiv.org/abs/1609.02907
"""
def __init__(self, in_features, out_... |
133212880ff3b58bbcb2944291f56c16433fd4394c62100d5933f4f8afaddba1 | Python | 2,393 | 95 | ###############################################################################
"""This parser takes as input the .h5 file produced by create_datafile.py and
outputs a .h5 file with datapoints of the form (X, Y), which can be understood
by models."""
#####################################################################... |
13a466ab49e30308b162705b6631a3968ced9b2bd47b1d64f16066547edf5fbc | Python | 2,393 | 79 | """Information module."""
from typing import Dict, Optional
import datetime
import hashlib
import os
import sys
import time
import uuid
import warnings
import yaml
import pwd
def dump_info(output_dir: str, script: Optional[str] = None, parameters: Optional[Dict] = None, info_file: str ='info.yaml') -> Dict:
""... |
ff2ecf973cc2b6e40be26e3033cadb965c31add9c944fafcd0a2a2e03725d23a | Python | 2,393 | 81 | """
Chunk (N number of bytes at M offset to a source's beginning) provider.
Primarily for file sources but usable by any iterator that has both
seek and read( N ).
"""
import base64
import logging
import os
from . import (
base,
exceptions,
)
log = logging.getLogger(__name__)
class ChunkDataProvider(base.... |
20201081f81dab0cfb6682bb05995c3f40ec23a6b81f2d142a8f0c89f73c2f4e | Python | 2,394 | 81 | from flask_restplus import Namespace, Resource, reqparse
from werkzeug.datastructures import FileStorage
from imantics import Mask
from flask_login import login_required
from config import Config
from PIL import Image
from database import ImageModel
import os
import logging
logger = logging.getLogger('gunicorn.error'... |
b27d1875f98f5f8568b8b3ef73c2cc1fd2a94e61de806efa42d5e1bbc50c277f | Python | 2,394 | 79 | #!/usr/bin/env python
"""
Input: DNA Fasta File + Glimmer ORF File
Output: ORF-sequence as FASTA file
Author: Bjoern Gruening
"""
import sys
import Bio.SeqIO
from Bio.SeqRecord import SeqRecord as record
def __main__():
if len(sys.argv) >= 4:
glimmerfile = sys.argv[1]
sequence = sys.argv[2]
... |
e46bae9076615f39b82dbe93e82c6a911b3074cd3a20e1f7de2dac2b1f6ecac0 | Python | 2,394 | 64 | #!/usr/bin/env python
# -----------------------------------------------------------------------------
# Copyright (c) 2013, The Deblur Development Team.
#
# Distributed under the terms of the BSD 3-clause License.
#
# The full license is in the file LICENSE, distributed with this software.
# --------------------------... |
42f3f2c9812ba4cbbd11d7d691ebb687bb7661d973371eb7b3f6bf714d072b1d | Python | 2,396 | 103 | """"Functions for computing Jacobian matrices to be used during fitting.
Notes
-----
These functions line up with those in `funcs`.
The parameters in these functions are labeled {a, b, c, ...}, but follow the order in `funcs`.
These functions are designed to be passed into `curve_fit` to provide a computed Jacobian.
"... |
bd96f9337384ad2e6b504089b925d80cc67dd1e5575d29585589af8ca1670b66 | Python | 2,396 | 75 | '''
Parallel port wrapper interface
Wraps the Windows inpout32.dll (or inpoutx64.dll) from
http://www.highrez.co.uk/downloads/inpout32/
These DLLs require the windows driver included with the download.
The driver works on both 32-bit and 64-bit Windows 10.
Last tested with 1.5.0.1 of InpOut32
The address of your pa... |
bf535e814052790323a445e3a6424a4dc21c88f4f771df0f79bf8c168f14a07e | Python | 2,396 | 80 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Selected(_BaseTraceHierarchyType):
_parent_path_str = "splom"
_path_str =... |
20a0c3234b2960c33fb14c8496379f6f89ced838a8697f7b6bda1e498c3b55a6 | Python | 2,397 | 30 | from setuptools import Command, find_packages, setup
__lib_name__ = "GraphST"
__lib_version__ = "1.1.1"
__description__ = "Spatially informed clustering, integration, and deconvolution of spatial transcriptomics with GraphST"
__url__ = "https://github.com/JinmiaoChenLab/GraphST"
__author__ = "Yahui Long"
__author_emai... |
e09af66baf482b56ddfdf72d06b13c320b54fffed536aa41b141d2b6c391c181 | Python | 2,397 | 66 | """Regression tests for trajectory resolution in LarvaDataset.comp_spatial."""
from __future__ import annotations
import numpy as np
import pytest
def _strip_trajectory(d):
"""Remove every column comp_spatial could take the trajectory from."""
c = d.config
drop = [
p for p in list(c.traj_xy) + l... |
10c29629c852c07e96256a3682579fb2f40ba38dafb19f117d960efe33747cde | Python | 2,398 | 56 | import torch
import torch.nn as nn
import torch.nn.functional as F
from lib.utils import Swish, MemoryEfficientSwish
from lib.models.EfficientNet import VALID_MODELS, EfficientNet
from lib.modules.unet_modules import *
class EffUNet(nn.Module):
def __init__(self, in_channels, up_type='upconv', norm_type=None, ac... |
6ca6ef83ddb2a3e656a46181046e7f208e6f7c2d71dd72f47305036d97a4539b | Python | 2,398 | 63 | #!/usr/bin/env python
#
# Copyright 2015 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of... |
8b51ad64331aa6b18a1e957c4bf27f3d1c0fb67ea49ec4baf0f18dd24fe64e73 | Python | 2,398 | 71 | #######################################################################################################
##################### Preprocessing for multi-task models #############################################
#######################################################################################################
import... |
8b74602a2f5f06a5dd86bb79ae3e08e6897d627bd7b162b4250c69c0721ec770 | Python | 2,398 | 78 | """Parameter converter objects."""
###################################################################################################
###################################################################################################
class BaseParamConverter():
"""General class for parameter converters - to be i... |
14ce1d3b2751bb23cf31f9ada88a2985f6db39315144805315a7ecef8db093cc | Python | 2,399 | 89 | # 05/23/2023 Fengyao Yan
# helper functions
import numpy as np
import pandas as pd
from random import sample
data_raw = '../../data/raw'
def organs_composition(organs):
if len(organs) < 1:
return {}
if len(organs) == 1:
return {organs[0]: 1}
splits = sample([t for t ... |
91c9c122b01cb5d354f43c80a1b293660f23d7f10252aa6ea1cad9aed2280181 | Python | 2,399 | 88 | # -*- coding: utf-8 -*-
# Copyright (C) 2020 [COMET-ML]
#
# 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, copy, modify,
#... |
fd9d5975d4193ccd6f77b49b567ed6373dae761a8ecfdb4f53b048db29096eaf | Python | 2,399 | 72 | """Wrapper for resizing observations."""
from typing import Union
import numpy as np
import gym
from gym.error import DependencyNotInstalled
from gym.spaces import Box
class ResizeObservation(gym.ObservationWrapper):
"""Resize the image observation.
This wrapper works on environments with image observation... |
45b08f6c4b1a1d5516de55c34ae03ab0ccfe351f79940b54fa8f4a178e0f980f | Python | 2,400 | 72 | """Pre-floor .tlspec artifacts refuse typed; current restores stay clean."""
from __future__ import annotations
from pathlib import Path
import pytest
import torch
import torch.nn as nn
import torchlens as tl
from torchlens.data_classes.trace import Trace
from torchlens.ir.workspaces import (
LEGACY_TRACE_BUILD... |
6acf7a619600785fc4159e6b43c5fb675c8864e553d7ca80a7233d8c3a71c80c | Python | 2,400 | 80 | import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
class AntEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": [
"human",
"rgb_array",
"depth_array",
],
"render_fps": 20,
}
de... |
6de23dd58b83d3045442d0eeb08bc0fb6caaf212f4c9f33bb83456494654c2cf | Python | 2,400 | 82 | """Executable documentation tests for intervention examples."""
from __future__ import annotations
import runpy
import warnings
from collections.abc import Iterator
from pathlib import Path
import pytest
EXAMPLE_DIR = Path(__file__).resolve().parents[1] / "examples" / "intervention"
EXAMPLE_FILES = tuple(sorted(EXA... |
aa79c3ce60c07c1e984278542c10fb61f0fe4cb0ab351638a58b0c968d2d9069 | Python | 2,400 | 81 | """Tests for predicate-based module collapse visualization."""
from __future__ import annotations
from typing import Any
import torch
from torch import nn
import torchlens as tl
def _render_dot(log: tl.Trace, tmp_path: Any, **kwargs: Any) -> str:
"""Render a Trace to DOT using a temporary SVG output path."""
... |
390cab28ddbefcdbc7ce2c5ab5a7f1ec8d2cd33da3f08cb45d8b7d614c6d77d4 | Python | 2,402 | 85 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Fit peptides for degradation constant and half-life.
Project: SILAM
Step #1
Input data: Peptide mass spec readout, normalized based on long-lived proteins.
Output data: Results of single peptide fitting.
Created on 2022.04.24
Author: Kirsten Chen
Last changed: ... |
86cac91d101911c5f0751eca6aa3709f258027119c55199508bc706851876b94 | Python | 2,402 | 80 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Unselected(_BaseTraceHierarchyType):
_parent_path_str = "box"
_path_str =... |
9a1ee5ff7db9de0fedff0af07c92fbf53cccd25daabac31bc456490d61dcc256 | Python | 2,402 | 71 | """Wrapper for adding time aware observations to environment observation."""
import numpy as np
import gym
from gym.spaces import Box
class TimeAwareObservation(gym.ObservationWrapper):
"""Augment the observation with the current time step in the episode.
The observation space of the wrapped environment is ... |
076ba3e6429a5c98aa258f601d0fe1566526ed785ae54967acd46053dffde91c | Python | 2,403 | 77 | """Regression coverage for requires-grad cleanup after failed captures."""
from __future__ import annotations
import pytest
import torch
from torch import nn
import torchlens as tl
class UserBaseException(BaseException):
"""User-defined non-``Exception`` failure used by capture cleanup tests."""
class Frozen... |
c24fadf1779c453b028991bc59baf1654e02ac6e95579e1b89c0b26980e8bc9a | Python | 2,403 | 59 | """DO NOT EDIT.
This file was autogenerated. Do not edit it by hand,
since your modifications would be overwritten.
"""
from keras.src.backend.config import backend as backend
from keras.src.backend.config import (
disable_flash_attention as disable_flash_attention,
)
from keras.src.backend.config import (
en... |
964c67acfefb69b8bd9b0fd03684587fce79ccefb66c895b5ce8c2b757d814bb | Python | 2,404 | 65 | import os
import numpy as np
import torch
from torch.utils.data import Dataset
class Train_DataLoader(Dataset):
def __init__(self, data_dir, label_dir):
super(Train_DataLoader, self).__init__()
self.data_dir = data_dir
self.label_dir = label_dir
self.obj_pth = os.path.... |
e962059e185f569e62b9d7b74b725e9336ea79ea4468c1f74bb9acc0aae05202 | Python | 2,404 | 62 | # 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 app... |
1928d0128dc6bb964fb19c38b9936a985c25ae0c84701884a0e1db142283553e | Python | 2,405 | 76 | # !/usr/bin/env python
"""Tests for tiling function."""
import os
import shutil
import tempfile
import unittest
from pathlib import Path
import numpy as np
import stlearn as st
from tests.utils import read_test_data
adata = read_test_data()
class TestTiling(unittest.TestCase):
"""Tests for `stlearn` package.... |
5dc962bad2f96ca805bd2cb06e1a61872e9863bd6b22d19f6e71eb31a2001538 | Python | 2,405 | 61 | #!/usr/bin/env python
#=========================================================================
#
# Copyright NumFOCUS
#
# 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://... |
7957d6d00ef832b8557aed95b3bee34cdf3b25c5bc302c2367a32a1e692d9889 | Python | 2,405 | 75 | import tensorflow as tf
import tensorflow_datasets as tfds
import numpy as np
import os
tfds.disable_progress_bar()
def normalize_img(image, label):
"""Normalizes images: `uint8` -> `float32`."""
return tf.cast(image, tf.float32) / 255., label
def get_dataset():
(ds_train, ds_test), ds_info = tfds.load... |
ed874d0e7e7e8663b8d4fddbeb704f7e8c20cfbca9c0213b5b8b8c0d22f0236e | Python | 2,405 | 80 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Selected(_BaseTraceHierarchyType):
_parent_path_str = "violin"
_path_str ... |
c578129a9f2c2b7d96ca2761de991b030a5a616f03bfc90266864924ea1c6837 | Python | 2,406 | 82 | # This example requires the following dependencies to be installed:
# pip install lightly
# Note: The model and training settings do not follow the reference settings
# from the paper. The settings are chosen such that the example can easily be
# run on a small dataset with a single GPU.
import torch
import torchvisi... |
f92b7de1b81f8701c47ef3afd23334858662010f3abc37533d6e41394412c20d | Python | 2,406 | 43 | #==============================================================================#
# Author: Dominik Müller #
# Copyright: 2024 IT-Infrastructure for Translational Medical Research, #
# University of Augsburg ... |
15fc3a948333814e6c2c1742de942a94b6003d60bd5ea8e75cd201c9aa495fff | Python | 2,407 | 88 | # Copyright (c) 2025, Jay Shah, Ganesh Bikshandi, Ying Zhang, Vijay Thakkar, Pradeep Ramani, Tri Dao.
import enum
class NamedBarrierFwd(enum.IntEnum):
Epilogue = enum.auto() # starts from 1 as barrier 0 is reserved for sync_threads()
WarpSchedulerWG1 = enum.auto()
WarpSchedulerWG2 = enum.auto()
Warp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.