sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
d149cd1853fe66c7444828797bde815d7cd0ace0802c17cce4e52b08a22ac965 | Python | 7,071 | 254 | """
Miscellaneous utilities to support uncaging analyses
Designed to accompany the paper "Network-level encoding of local
neurotransmitters in cortical astrocytes" (DOI: TODO)
"""
## ------------------------------------------------------------------------ ##
## Imports
## --------------------------------------------... |
e3765edd8f101a1925a17d0ab4721284db37596cdea3f56ff344773d4c3d706b | Python | 7,071 | 265 | import re
import pytest
from pandas._libs.tslibs import (
Timedelta,
offsets,
to_offset,
)
from pandas.errors import Pandas4Warning
import pandas._testing as tm
@pytest.mark.parametrize(
"freq_input,expected",
[
(to_offset("10us"), offsets.Micro(10)),
(offsets.Hour(), offsets.Ho... |
c8286e11160206248220e17764a4339fcfd21f8c64bfbebd57d37e4f09e91d81 | Python | 7,072 | 212 | """ Pytorch Distributed utils
This piece of code was heavily inspired by the equivalent of Fairseq-py
https://github.com/pytorch/fairseq
"""
import os
import signal
import math
import pickle
import torch.distributed
from onmt.utils.misc import set_random_seed
from onmt.utils.logging import init_logger, logger... |
c375def2133939040b48b9f0cd5b7bef46f0f765f645d770a4d3e9d4ef7f9eb9 | Python | 7,077 | 189 | """Model specification based on selected genes attention and attentive rnn."""
import tensorflow as tf
from ...layers import (
dense_attention_layer, embedding_layer,
sequence_attention_layer, contextual_attention_layer
)
from ...hyperparams import RNN_CELL_FACTORY, ACTIVATION_FN_FACTORY
def rnn_fn(features, ... |
a31bc18a9ba6daf586947a1c70a9924906cde81f0ef621150ef3180bb0e59d1d | Python | 7,078 | 187 | import numpy as np
import matplotlib.pyplot as plt
def update_plot_defaults():
plt.rcParams.update({'font.size': 6,
'axes.spines.right': False,
'axes.spines.top': False,
'axes.linewidth':0.5,
'xtick.major.size': 3,
... |
91d36ff093aa5ede7da87bdc158c50ce27be7e78f9574c0b617b698b0fc712de | Python | 7,079 | 200 | # Copyright 2026 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... |
ecdb6708ac6b9f10bcdf27a92e28886677750017fd823a9598773741ea70aa0a | Python | 7,079 | 214 | """
Tests that comments are properly handled during parsing
for all of the parsers defined in parsers.py
"""
from io import StringIO
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
@pytest.mark.parametrize("na_values", [None, ["NaN"]])
def test_comment(all_parsers, na_values):
... |
17fd117e29f76ebde6c5e8f58da3e0c316ac8f18522916ea0da036336195b2f9 | Python | 7,081 | 205 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
pa = pytest.importorskip("pyarrow")
from pandas.core.arrays.arrow._arrow_utils import pyarrow_array_to_numpy_and_mask
arrays = [pd.array([1, 2, 3, None], dtype=dtype) for dtype in tm.ALL_INT_EA_DTYPES]
arrays += [pd.array([0.1, 0.2, 0... |
e0be01c24c3e2aef1f87b2158e87955550f63e3fa10f2228f6e0077d3e5eec5d | Python | 7,081 | 270 | # ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.15.0
# kernelspec:
# display_name: ol-connectome
# language: python
# name: ol-connectome
# ---
# %%
##
# Original author: @PavithraaSeen... |
486cc9c2be3838017dcab3810c82c80c0e5e98f350d9dd2979681e800b1ec869 | Python | 7,084 | 298 | from __future__ import annotations
from typing import (
TYPE_CHECKING,
Any,
ClassVar,
)
import numpy as np
from pandas.util._decorators import set_module
from pandas.core.dtypes.base import register_extension_dtype
from pandas.core.dtypes.common import is_integer_dtype
from pandas.core.arrays.numeric i... |
71d5cb057095f0ef7cf2bde5b4f9d35b7e1e4caf840d5b76c9d2a72ca895fec2 | Python | 7,086 | 217 | import numpy as np
import pytest
from pandas._libs.tslibs import IncompatibleFrequency
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
class TestSeriesAsof:
def test_asof_nanosecond_index_access(self):
ts = pd.Timestamp("20130101").as_unit("ns")._value
d... |
cd4f808569f7846e149734426f3d1ffc29a6f8e3e3db1e76d48563315d618eec | Python | 7,086 | 185 | import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import numpy as np
import os
import argparse
import matplotlib as mpl
label_size = 16
#mpl.rcParams['xtic... |
b3e3c0398efb092623cd60b3d6b141c176b7807eda9c9245e3fb59b277b9fd50 | Python | 7,091 | 236 | import copy
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def test_assert_numpy_array_equal_shape_mismatch():
msg = """numpy array are different
numpy array shapes are different
\\[left\\]: \\(2L*,\\)
\\[right\\]: \\(3L*,\\)"""
with pytest.raises(AssertionError, match=... |
0f9777543ab53d3dedb8f1e6f1a51723f2a734c970807ed7880860c3d60d338d | Python | 7,092 | 140 | import pandas as pd
from brainflow.board_shim import BoardShim, BrainFlowInputParams, LogLevels, BoardIds
from brainflow.data_filter import DataFilter, DetrendOperations
import time
import numpy as np
#-------------------- CODE FOR EEG DEVICE CONNECTION AND DATA PROCESSING --------------------#
def EEG(second, folder,... |
81d9a097bb679766e56833dbd28b2bbb89521a569fe7d13315cdf5852f3f16fb | Python | 7,092 | 234 | # coding: utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Function
class ShakeFunction(Function):
@staticmethod
def forward(ctx, x1, x2, alpha, beta):
ctx.save_for_backward(x1, x2, alpha, beta)
y = x1 * alpha.data + x2 * (1 - alpha.data)
... |
f1af46270c3b5d9e6353c0e9d0581041fbe777eea87a8819beed043dcccf19c9 | Python | 7,092 | 199 | # Copyright 2024 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... |
23b967a650a49b0d23c5f7cbba5d9d4adcc32959833760e7ffd05de18a9c0f38 | Python | 7,095 | 163 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 15 22:22:41 2021
@author: Wladek
"""
import numpy as np
import pylab as py
from scipy.signal import filtfilt, butter, detrend, argrelmax, argrelmin
from scipy.stats import pearsonr
from kcsd import oKCSD3D
from mayavi import mlab
from basicfunc import model_data, kaji_s... |
bfc36f74c493a780dd39c04729ee3a9a68c1027f9913ed5ce5a994191c719050 | Python | 7,097 | 178 | #!/usr/bin/env python3
__author__ = 'etseng@pacb.com'
"""
After running collapse, combine with the cluster FL/nFL assignment to get abundance information.
cluster_report.csv format in IsoSeq3:
cluster_id,read_id,read_type
transcript/0,m54056_171130_193019/8388911/ccs,FL
where .group.txt is:
PB.1.1 transcript/0,tra... |
769fb1e5d157e485d1e51b4acbc549f8e4ed694d53118c2dcf2a8c0b4ad6a3c8 | Python | 7,099 | 189 | # Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
0b81eceae5bef9359dd17d6ebb971fa0af4e08f693cabe5dcf196a7267399b38 | Python | 7,102 | 250 | """Test scatter view."""
# ------------------------------------------------------------------------------
# Imports
# ------------------------------------------------------------------------------
from types import MappingProxyType
import numpy as np
from phylib.utils import emit
from pytest import raises
from phy.... |
202bc0adb8c5221489a8b1f10ce75709b9b66bab8262c0e7ccd8f2c5d4df1dd3 | Python | 7,103 | 182 | #!/usr/bin/env python
# coding: utf-8
import sys
import numpy as np
import pandas as pd
import pickle
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.feature_selection import SelectKBest, f_classif
from sklearn.linear_model import LogisticRegression
from skl... |
f2300f92727ea5f42569162d6a3d192534f7432e838c67480f364db682b17205 | Python | 7,105 | 220 | import os
from typing import Any, cast
import numpy as np
import pandas as pd
np.seterr(all="raise")
from deepglyco.speclib.common.rtcalibrate import RetentionTimeCalibrator
from deepglyco.speclib.common.rtcombine import NonRedundantRetentionTimeConsensus
from deepglyco.speclib.pep.hdf import PeptideSpectralLibrary... |
f1cb87f6b20a5f0bcfcacbd332f19293c82159782cfd863c0417cc68a4e799ea | Python | 7,107 | 192 | #!/usr/bin/env python3.9
import pandas as pd
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
import sys
import argparse
import os
import gc
from utils import create_pytorch_geometric_graph_data_list_from_smiles_and_labels, init_weights, KFoldGen, JSONLogger
import pickle
from ... |
a177dc6d6cda9e2ae693b3594b12ec0f3d55bbaf5b2fab0c635c3678eea7cf89 | Python | 7,108 | 141 | #!/usr/bin/env python3
"""
Description:
This module helps control for the confounding factors inherently present in the experimental design. By fitting a random forest regressor on each detected DTU transcript the module determines which covariates might be contributing into observable variance in isoform fraction... |
dbbaddb551d09fe42e92633f0d0337aab57cc7c070011659c9519c1b29b170a6 | Python | 7,108 | 201 | # Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
14f61a819039e10cf52efc9094e68bcb64f6a80aa7b03f6a30407df3a0128840 | Python | 7,109 | 253 | import collections
import numpy as np
import allel
import sys
sys.path.append('..')
import multiprocessing
# 对应dihh部分,后期一起优化删除
from multiprocessing.pool import ThreadPool
# *优化为具体函数
from util.window_tools import *
# 表征sfs的统计量
def eng_compute(matrix):
logp = np.log2(matrix)
logp[np.isinf(logp)... |
a6331eac9b38a1ae114a4909eddac9025417155275d6bdf1fe38d637a4af270d | Python | 7,109 | 185 | import numpy as np
import pytest
import pandas as pd
def test_is_monotonic_increasing_lexsorted(lexsorted_two_level_string_multiindex):
# string ordering
mi = lexsorted_two_level_string_multiindex
assert mi.is_monotonic_increasing is False
assert pd.Index(mi.values).is_monotonic_increasing is False
... |
1960870ac45610cb4bb198d7f7e5610f06b809bc920f00b12c06cc1c62dce481 | Python | 7,111 | 201 | from torch import nn, ones_like, hub, no_grad
from torchvision import models
from PrivateModelArchitectures import ResNet9
from opacus import validators
from twoandahalfdimensions.models.twoandahalfdmodel import (
TwoAndAHalfDAttention,
TwoAndAHalfDLSTM,
TwoAndAHalfDTransformer,
TwoAndAHalfDPool,
)
fro... |
4c79681d7a56ea44dda97899c1d42ddb0f2898a884c89849d57791098e915b86 | Python | 7,111 | 205 | import torch
import numpy
import matplotlib.pyplot as plt
import bionetwork
import pandas
import seaborn as sns
def generateKO(Yin, knockOutLevel):
nrKO = Yin.shape[1]
inputKO = Yin.repeat(nrKO, 1)
inputKO = inputKO + knockOutLevel * torch.eye(nrKO)
return inputKO
def runKO(curModel, inputX, knockOutL... |
a99455fe8903ba43e4450b8b59bc8b16694c42e0f3a0f57e7863ebcadc08e7d6 | Python | 7,111 | 194 | #!/usr/bin/env python
import os, sys
import pdb
import bisect
from bx.intervals import Interval
from Bio.Seq import Seq
def iter_cigar_string(cigar_string):
num = cigar_string[0]
for s in cigar_string[1:]:
if str.isalpha(s):
yield int(num), s
num = ''
else:
n... |
dde8ae765287da8a32d4635ad4f174beff6e0eaf14bf5c79295fbfca338e4713 | Python | 7,111 | 207 | # Copyright (c) 2018-2023, NVIDIA Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of condit... |
53f9c6df91c75d8ca1a6d9744828f0fb2e05b148b71a4dc71f8c90c94e36290e | Python | 7,117 | 208 | """
Tests that quoting specifications are properly handled
during parsing for all of the parsers defined in parsers.py
"""
import csv
from io import StringIO
import pytest
from pandas.compat import PY314
from pandas.errors import ParserError
import pandas as pd
import pandas._testing as tm
if PY314:
# TODO: wr... |
56b84b9e6c9553f69fb1e041ba4513c439d3685ddec0bfed2b210f4655543870 | Python | 7,117 | 214 | """
Read SAS sas7bdat or xport files.
"""
from __future__ import annotations
from abc import (
ABC,
abstractmethod,
)
from collections.abc import Iterator
from typing import (
TYPE_CHECKING,
Self,
overload,
)
from pandas._libs import lib
from pandas.util._decorators import set_module
from pandas... |
f8fbb16e1e0f55eb678c2fb6fd2b761cc78312a08ec17966530aa7b5d380bce1 | Python | 7,120 | 301 | """
System-level calls to external tools, directory creation, etc.
Authors:
Thomas A. Hopf
"""
import os
from os import path
import tempfile
import subprocess
import urllib.request
import shutil
import requests
class ResourceError(Exception):
"""
Exception for missing resources (files, URLs, ...)
"""... |
5caa8a4aa7bd01b0a961e0171191178216fbcaa3854bf9342529e709db57f71f | Python | 7,122 | 133 | from Environment import *
from Network.model.hrnet3D import HRNet
from Network.model.swin_transform import swin_tiny_patch4_window8_256, swin_base_patch4_window8_256
from Network.model.FCN_resnet3d import fcn_resnet34
from Network.model.unet3d import UNet3D
from Network.model.ASPP_unet3d import UNet3D
from Network.mode... |
7eb6d776514903f4c7792b88dace219f8dbe282198e349aa422deea4779507d0 | Python | 7,122 | 212 | import math
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
class TestSeriesCov:
def test_cov(self, datetime_series):
# full overlap
tm.assert_almost_equal(
datetime_series.cov(datetime_series), datetime_series.std() ** 2
)
# partial... |
5e996cc1fbf361e48735b14fc5cf576f56db0c6b40b9557f74e75336be61cecc | Python | 7,125 | 163 | import numpy as np, matplotlib.pyplot as plt, sys
import pumpprobe as pp, wormdatamodel as wormdm
from scipy.optimize import curve_fit
import matplotlib.colors as mcolors
sort = "--sort" in sys.argv
pop_nans = "--pop-nans" in sys.argv
stamp = "--no-stamp" not in sys.argv
SIM = "--sim" in sys.argv
ds_list = "/projects... |
058392752cfbc2c084f501415e9f04256da73181b2f792809b0523c2294533aa | Python | 7,130 | 164 | #!/usr/bin/env python3
"""Project aligned external participant-by-feature matrices through one round.
This utility performs inference only. It never learns dictionaries, refits
normalization, updates neural parameters, or selects a checkpoint. Each input
must use the exact ADNI feature support/order recorded in the bu... |
36f62ca8e66663eb4a0f0d6eac51a3c9b3a077a57dce543b3449bc3a39c3b85e | Python | 7,131 | 165 | """
@author: Hongao ZHU
@description:
deduplication based on 'naturalstories.sentitems' and 'naturalstories.unigram.itemmeasures' files
@example usage:
cd ~/zhu.3986
conda activate deduplication
python3 scripts/deduplicate_new.py -B 0_142998 -N 10 -T modelblocks-release/workspace/genmodel/naturalstori... |
a216c65dab311376b0beac72a0fa9bc5db3c9ac71fb9f787120e117153f39627 | Python | 7,131 | 190 | import pandas as pd
from glob import glob
import warnings
import numpy as np
def activity_to_number(row):
activity_map = {"Y":1, "N":0}
activity = row["activity"]
if pd.isna(activity):
warnings.warn(f"{row['id']} {row['family']} {row['model']} {row['round']}: activity is null")
else:
... |
cde0ed2e77d211952ec6acd4adc3cbba0f5b9c0218b8e16ce8488dc0887f9849 | Python | 7,134 | 168 | import os
import glob
import cPickle
import copy
import argparse
import time
import pandas as pd
def read_information_file(information_file):
interaction_info = {}
interaction_ddi_type_info = {}
fp = open(information_file, 'r')
fp.readline()
for line in fp:
sptlist = line.strip().split(... |
749ea429d16fdc349b9ef3dfa37bc0ada9266fe1ceccab4dedc1d03d5e368fcf | Python | 7,136 | 171 | """Phases 8 + 11 — notebooks + analyses tables.
Revision ID: c3d4e5f6a8b9
Revises: b2c3d4e5f6a8
Create Date: 2026-05-15 11:00:00.000000+00:00
Schemas added:
- Phase 8: ``notebooks``, ``notebook_sessions``.
- Phase 11: ``analyses``.
"""
from __future__ import annotations
from collections.abc import Sequence
import... |
84e717c3422216d61addce754ae8e73e5e01338b077da95450df1d7d6639566d | Python | 7,139 | 237 | import numpy as np
import matplotlib.pyplot as plt
# increase the figure size
plt.rcParams["figure.figsize"] = [12, 10]
# remove the top and right spines from plot in the global plt setting
plt.rcParams["axes.spines.top"] = False
plt.rcParams["axes.spines.right"] = False
# change the linewidth of the axes and spines
... |
765e2ec496f78b2557443f44cba689bf80ed21772d59fe0e2bad94ee554dfdd4 | Python | 7,140 | 143 | import os
from functools import partial
import pandas as pd
from simrun3.somatic_summation_model import ParseVT
import model_data_base.IO.LoaderDumper.dask_to_msgpack
dask_to_msgpack = model_data_base.IO.LoaderDumper.dask_to_msgpack
from collections import defaultdict
import single_cell_parser as scp
class Ce... |
6b108f95a7eeed3e54a4212062a188ad2a5bf47e4f2c81f9a3bf416644d6f568 | Python | 7,143 | 187 | # Copyright 2018-2024 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
1c7352d1b7b145b88915bf77a0e1cf046c8631caab4befbe3d893eb306f48862 | Python | 7,150 | 164 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 21 15:59:04 2020
@author: vman
"""
import numpy as np
import pandas as pd
import nilearn as nl
import nilearn.image as nlimg
import xml.etree.ElementTree as ET
def is_odd(num):
return num % 2 != 0
class Channel(object):
d... |
a01dfa14e167d23897cf39172f1db0eea0e70b2773fa6c501ca55e4ea2dfd99c | Python | 7,150 | 171 | # Copyright 2018-2025 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
2334d78433006053e90fa97059a7692c3a290a2708018968c47a6e3f00d87581 | Python | 7,154 | 196 | # Copyright 2026 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... |
aac45453f1129f6d983807d376fbe9c024d14d6187a20b10c83aaba054698822 | Python | 7,158 | 186 | from torch.utils.data import Dataset
import numpy as np
import os, cv2, time
from PIL import Image
from torchvision import transforms
from datasets.data_io import *
s_h, s_w = 0, 0
class MVSDataset(Dataset):
def __init__(self, datapath, split='intermediate', nviews=3, img_wh=(1920, 1056), ndepths=192):
s... |
54d482119030b4ad724e32f214a69da035e67e4f492d14a97c63db264cb2356b | Python | 7,165 | 195 | import os, sys
import pdb
import bisect
from bx.intervals import Interval
from Bio.Seq import Seq
def iter_cigar_string(cigar_string):
num = cigar_string[0]
for s in cigar_string[1:]:
if str.isalpha(s):
yield int(num), s
num = ''
else:
num += s
def make_exo... |
a3a79f1c1c059cdbb23ea65d2c3c6e917384269cde6e77e803cb80d6f81dfc49 | Python | 7,169 | 208 | #! /usr/bin/env python
##############################################################################
## DendroPy Phylogenetic Computing Library.
##
## Copyright 2010-2015 Jeet Sukumaran and Mark T. Holder.
## All rights reserved.
##
## See "LICENSE.rst" for terms and conditions of usage.
##
## If you use this wo... |
9a442b3bbe16328ad5cb56a61ef18fca1b79d30eb3befc9ef8df62d119af7a2b | Python | 7,171 | 228 | import torch
import numpy
import matplotlib.pyplot as plt
import bionetwork
import plotting
import saveSimulations
import pandas
from scipy.stats import pearsonr
#import pandas as pd
batchSize = 1
#Load network
networkList, nodeNames, modeOfAction = bionetwork.loadNetwork("data/toyNFKB-Model.txt")
annotation = pandas... |
44be9b6140db2766e685e4b3753bb8d4a477775e18d449305f7f0151324f7ab3 | Python | 7,173 | 176 | # Copyright 2024 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... |
37ba139882a7d1c57ce3936ce244405371ae2f82f13d450c2bac21ae6171ff01 | Python | 7,174 | 248 | import numpy as np
import pickle
import os
import fnmatch
import random
def select_class(data_x, data_y, labels):
"""
:param float data_x : trial x channel x time
:param ndarray data_y : string/numerical label x 1
:param list of str or int labels : list of string/numerical c... |
b9e515d5d3c04ca4f13542ba53af2ad3f592dc2e0002c2fb971f31af4573c033 | Python | 7,174 | 155 | """Total Variation (TV)-Regularized Reconstruction using PDHG."""
from __future__ import annotations
from collections.abc import Callable, Sequence
import torch
from mrpro.algorithms.optimizers.pdhg import pdhg
from mrpro.algorithms.prewhiten_kspace import prewhiten_kspace
from mrpro.algorithms.reconstruction.Direc... |
251c74750dc33b79ae24a8a9cb59cac7048c4b9c978db0145638aef8f72f979c | Python | 7,181 | 194 | import re
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.tseries import offsets
class TestPeriodIndex:
def test_asfreq(self):
pi1 = pd.period_range(freq="Y", start="1/1/2001", end="1/1/2001")
pi2 = pd.period_range(freq="Q", start="1/1/2001", end="1/1/2001")
p... |
58015fb5baef03471b4851c8a76ff3e8e3e7bc24f221fce401e82c75f0b95f2c | Python | 7,181 | 140 | ###############################################################################
# This script organizes the tables that we used in the analysis for publication
# #
# Author: ana.trianahoyos@aalto.fi #
... |
f11b642039923876028d6a7fef7bf8fb8f329ba796de123cb6edd8c06d792f99 | Python | 7,182 | 166 | """Class for Fast Fourier Operator."""
from collections.abc import Sequence
from dataclasses import astuple
import torch
from mrpro.data.SpatialDimension import SpatialDimension
from mrpro.operators.LinearOperator import LinearOperator
from mrpro.operators.ZeroPadOp import ZeroPadOp
class FastFourierOp(LinearOpera... |
453bd0ab1bcd97cd7835cee76727d64d0ea2baf2e55f2c0cb0829a4e902aec10 | Python | 7,185 | 181 | #%%
from pathlib import Path
import pandas as pd
from src.config_handler import read_yaml, get_entry
from src.data_wrangler import DataWrangler, DataSpec
from src.cv import CVGenerator, CVSpec
from src.fs_roi_lut import read_roi_names
from src.trainer import Trainer
from src.workflow import WorkFlowSpecs, WorkflowBuild... |
ad9b445db357fed623e874921519d3ac8bcf33513c486acc91a1eff5c6fdab92 | Python | 7,186 | 178 | # Copyright 2018-2024 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
061d2f30339388e13f8ae5407497aa31f42a616497027daee83b959861180006 | Python | 7,187 | 194 | """Test the sleap converter's convert function and its private extraction helpers."""
import io
import json
import h5py
import numpy as np
import pytest
from PIL import Image
from lightning_pose.converters.sleap import (
_extract_frames,
_extract_labels,
_extract_video_names,
convert,
)
def _make_p... |
5ea2f32ed5d9eeae84da9f799f44cf809843d8775bdacda4e5d345cc35db898b | Python | 7,188 | 182 | """ Translation main class """
import os
import torch
from onmt.constants import DefaultTokens
from onmt.inputters.text_dataset import TextMultiField
from onmt.utils.alignment import build_align_pharaoh
class TranslationBuilder(object):
"""
Build a word-based translation from the batch output
of translato... |
b355b63ee7907a5e31b8c33d3041bac3b521f3fcabee78dba813e6cc1faa2044 | Python | 7,189 | 207 | from sys import path as sys_path
sys_path.append('..')
sys_path.append('../base')
import os
import matplotlib
if 'DISPLAY' in os.environ:
matplotlib.use('qt5Agg')
else:
matplotlib.use("Agg")
os.environ['CUDA_VISIBLE_DEVICES'] = '1'
import matplotlib.pyplot as plt
import numpy as np
import pygalmesh
from base im... |
eed3e8f4947b4e15deadb0a29697ed5bd5d34c17e23d45efe1b906e51f0ac115 | Python | 7,189 | 299 | from __future__ import annotations
from typing import (
TYPE_CHECKING,
Any,
ClassVar,
)
import numpy as np
from pandas._libs import lib
from pandas.util._decorators import set_module
from pandas.core.dtypes.base import register_extension_dtype
from pandas.core.dtypes.common import is_integer_dtype
from... |
f8afebac60b27140a04c5452a095fe765a16703f83b5edf8d07ae4b4ce01de5b | Python | 7,190 | 219 | from itertools import product, repeat
from pathlib import Path
import time
from tabulate import tabulate
import numpy as np
from joblib import Memory
from tqdm import tqdm
from mtscomp import compress, decompress, load_raw_data
dtype = np.uint16
def mtscomp_perf(**kwargs):
ds = kwargs.pop('ds', None)
asse... |
7dfcedbc11bf5df63e1a796254c40cdaca916f55ea4b10bf854f66fea45ac617 | Python | 7,197 | 174 | """Session 25 — god-class drain: ``tune_model`` (supervised path).
Supervised ``Experiment.tune_model`` no longer delegates to
``self._legacy.tune_model``. It runs ``sklearn.model_selection
.RandomizedSearchCV`` over the base estimator on the experiment's
transformed training data + returns a fitted Pipeline + the sea... |
f21281c920d3240c740f6179ac3dc2d1457d3bbe534085ca442d39c16f6fdc61 | Python | 7,198 | 234 | # -*- coding: utf-8 -*-
"""uniqueManhattan.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1salVwdBdbl1Zg2IVidU3C-9yxFEV8KZB
"""
# Commented out IPython magic to ensure Python compatibility.
from google.colab import drive
drive.mount('/content/dr... |
f7e825f029d304bf16a62a35a682fff02c5a7196d617e0068cdf57ba457deeda | Python | 7,202 | 229 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Created by Roberto Preste
import os
from collections import defaultdict
from abc import ABC, abstractmethod
import allel
import vcfpy
class Field:
"""Class to represent a header field.
This class is used to represent INFO headers and to store annotations
f... |
539390b8a25734991e9ba46d62b2b3db6b935e464bb1fb3ea8a2b44f03576b3d | Python | 7,209 | 238 | import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
import pandas._testing as tm
def test_shares_memory_numpy():
arr = np.arange(10)
view = arr[:5]
assert tm.shares_memory(arr, view)
arr2 = np.arange(10)
assert not tm.shares_memory(arr, arr2)
def test... |
7f3f99f88d6a2008938712cc901e1e5440ff076482f45962baeda4c600878a53 | Python | 7,209 | 237 | """Module contains 2D-specific plotting functions."""
from typing import Optional
from matplotlib import pyplot as plt
import numpy as np
from sklearn.metrics import confusion_matrix
from moseq2_lda.util import dict_merge
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import seaborn as sns
import matplotl... |
0ea0a1b12c8f0aae2a737b66ed9975e68519e6e70ddcc9d26fdf592391ce62e2 | Python | 7,212 | 164 | #!/usr/bin/env python
import argparse
import warnings
import torch
import numpy as np
import pandas as pd
import time
from models.model_rnn import RNN
from MCMG_utils.data_structs import Vocabulary, Experience
from MCMG_utils.properties import get_scoring_function, qed_func, sa_func,multi_scoring_functions_one_hot
f... |
d2306366d2520fe119c30ad7cb09b9d48eb563c42566b496d69f420e6b05b4b5 | Python | 7,215 | 211 | __all__ = ["SpectrumFilter"]
from typing import Generic, Iterable, Optional, TypeVar, Union
import numpy as np
import numpy.typing as npt
from .spec import MS2SpectrumProto
MS2SpectrumType = TypeVar("MS2SpectrumType", bound=MS2SpectrumProto)
class SpectrumFilter(Generic[MS2SpectrumType]):
def filter_spectra(
... |
31bf4a97a14f3814e7f569f1c6a19e166904e99592b3ca7be1dd2bf7428788af | Python | 7,221 | 228 | """
@author: mbejtka
"""
import os
import numpy as np
from numpy.linalg import LinAlgError
import matplotlib.pyplot as plt
from figure_properties import *
import matplotlib.gridspec as gridspec
import scipy
from kcsd import KCSD1D
import targeted_basis as tb
__abs_file__ = os.path.abspath(__file__)
def csd_into_eig... |
1f33da8b1eb1a29dfa738035b49df607fce95f799cb022a1e3e1aeb2b8da8770 | Python | 7,223 | 162 | from NeMeAn_Seg2Data import getCellData, getPixelData
from NeMeAn_Data2Reg import loadCellSamples, loadPixelSamples, trainRegs
#### Setup image parameters
imgLinearRes = 0.125 #um/px
path_img = 'example_images'
sampleName_list = ['Example_control', 'Example_sham', 'Example_stim']
# Manually generated masks
fascicle... |
56a095d136b5825bcb78e5515d2c130bfa7233b5f9002cfe9d01b24f271f0418 | Python | 7,225 | 231 | # -*- coding: utf-8 -*-
"""uniqueMinkowskip4.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1RMxYatJKDTUPJ8P0SRXarpDYlXIcZ-9P
"""
# Commented out IPython magic to ensure Python compatibility.
from google.colab import drive
drive.mount('/content/... |
5c6c953af6c424a9186165c752511b3949408b5720abc4783fde3cce9df83290 | Python | 7,225 | 258 | import inspect
import linecache
import pathlib
import warnings
from functools import cache, cached_property, partial
from itertools import chain
from typing import *
import anndata as an
import numpy as np
import torch
from scipy.sparse import issparse
from sklearn.model_selection import train_test_split
from torch.ut... |
31ca3bd99ab4a6ae6625df84352fbd5e40c179adc7791cc22a5faa62ee64ceb9 | Python | 7,226 | 244 | """
Non-invasive Dependency Injection Container.
It fills given constructors or factory methods
based on their named arguments.
See the demo usage at the end of file.
https://code.activestate.com/recipes/576609-non-invasive-dependency-injection/
Created by Ivo Danihelka on Sun, 11 Jan 2009 (MIT)
Modifications:
- Por... |
3be12e393f0d90b3870d6307383285a7a2ba29f817aafed62b4a5a488109d3b4 | Python | 7,228 | 230 | # -*- coding: utf-8 -*-
"""uniqueMinkowskip10.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1gkmAwkjjCdjcE8baIqBQxtPwb_7cGsUm
"""
# Commented out IPython magic to ensure Python compatibility.
from google.colab import drive
drive.mount('/content... |
10db3e7d236ba52fc7029d0bf4e238eb3f5b256a7c2cfe20bde2f96fe4eeb08b | Python | 7,232 | 162 | import torch
import os
import numpy as np
import time
import logging
import random
from torch.optim import Adam
from torch.optim.lr_scheduler import ExponentialLR
from torch.utils.data import DataLoader
import torch.nn as nn
from torch.nn.utils import clip_grad_norm_
from tqdm import tqdm
import json
from sklearn impor... |
6d8a122000fc3c60431bea73dc3be725ad2da11fd111145def0621981f732399 | Python | 7,234 | 253 | import matplotlib.pyplot as plt
import numpy as np
from skimage import draw
def line_22(x_start, y_start, width):
y_list = []
x_list = []
for i in range(0,100,2):
if x_start-i-1 > 0:
x_i = list(range(x_start-i-1, x_start-i+1))
y_i = [y_start-i//2] * len(x_i)
... |
4f0825beb8d6391402a51a1a2cf03b3938433e4c8b97ac3880d8326acbee58df | Python | 7,237 | 215 | from PyQt5 import QtCore, QtGui, QtWidgets
from kilosort.gui.sorter import KiloSortWorker
from kilosort.gui.sanity_plots import (
PlotWindow, plot_drift_amount, plot_drift_scatter, plot_diagnostics,
plot_spike_positions
)
class RunBox(QtWidgets.QGroupBox):
setupContextForRun = QtCore.pyqtSignal()
... |
0df3802c1010dff8c2474145ede3b6b15c95b78adc865e297b9650665fc86066 | Python | 7,238 | 225 | # JN 2016-03-02
"""
show resposes in css-gui
"""
from __future__ import print_function, division, absolute_import
import logging
logger = logging.getLogger(__name__)
import os
import numpy as np
import scipy.signal as signal
from .sort_widgets import MplCanvas
from matplotlib.pyplot import imread
from matplotlib.offs... |
ecd64b75cbb08cbc1afb3c6e4eec87a99ceade4acbb695e9980d72f266f42461 | Python | 7,238 | 195 | """
.. module:: tool_livewire
:platform: Linux, Windows
:synopsis: Livewire tool (2D only)
.. moduleauthor:: Fredrik Nysjo
"""
from tool_common import *
from tool_polygon import PolygonTool
import numpy as np
import scipy as sp
import scipy.sparse
import scipy.sparse.csgraph
import scipy.ndimage
import glm
c... |
6a2b3cb840fe9bea07c74b5672fd857d7cc187b9a3740533822967addeb38661 | Python | 7,239 | 199 | import os
import torch
import pickle
import matplotlib.pyplot as plt
import matplotlib as mpl
load_dir = '/Users/elizabethnewman/Desktop/tnn_results/autoencoder/tensor/'
subdir_names = []
for subdir_name in os.listdir(load_dir):
if subdir_name == '.DS_Store':
continue
subdir_names.append(subdir_name)
... |
ecfd99039b8bcb7f763c7a934bfdc868195b4d0ae5a70ed4a497a5bac907d17f | Python | 7,241 | 174 | #!/usr/bin/python
from __future__ import division
import collections
from itertools import product
import numpy as np
import pandas as pd
from sklearn import linear_model
from scipy.stats import norm
from numpy.linalg import inv
def calculate(gwas_snps, ld_scores, annots, N1, N2):
np.seterr(invalid='ignore')
... |
3875c3797b1703677bd3b53eac978b57e728c31980f5302d4ff0015366ecaa7a | Python | 7,243 | 206 | import torch
import torch.nn as nn
import logging
from typing import Optional, Union, Tuple, cast
from ..image import Stack, Volume
from .reconstruction import simulate_slices
from ..utils import ncc_loss, ssim_loss
class EM(nn.Module):
def __init__(
self,
max_intensity: float,
min_intensi... |
361b1529c731e0e306ca3be52e1109a0dd1c6ec9927248d654ad17e90e714929 | Python | 7,247 | 174 | #%%
# -*- coding: utf-8 -*-
import os
import numpy as np
import pickle as pkl
from scipy.optimize import minimize
from scipy.interpolate import interp2d
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon as matplotlib_polygon
import imageio
factor1 = 15 #1e+5 #1e+10 ... |
9121254ac5d3df773d6dd1c664910866170e2ce455477ad5d430f7c045ba21b6 | Python | 7,248 | 137 | import numpy as np
import pandas as pd
import warnings
import random
from collections import defaultdict
def select_dtu_genes(IFs, ctrl_samples, gene_names, p_dom=0.75, n_splicotypes=5, n_dtu_genes=30):
pot_dtu_genes = gene_names.copy()
random.shuffle(pot_dtu_genes)
dtu_IFs = IFs[IFs.gene_id.isin(pot_dtu_... |
e17197ea2a41f3d82b3a29560e4c0376fe29007ab059e6199fd1481ce44318ba | Python | 7,248 | 201 | """End-to-end parity for the tAge clocks against the authors' own pipeline.
``tests/data/tage`` holds predictions produced by the reference R preprocessing
and the published sklearn models (see its README); nothing there came from a
pyaging code path, so a pass here means the whole chain -- the in-predict cohort
trans... |
ecedec4eb2202c84de4b51225a26957504214e3ca15bb0b5b1853ee34e584265 | Python | 7,250 | 202 | import pandas as pd
import dask
import dask.dataframe as dd
import matplotlib.pyplot as plt
from ._decorators import *
# from compatibility import multiprocessing_scheduler
from ..analyze._helper_functions import is_int
from ._figure_array_converter import fig2np
from .. utils import convertible_to_int
def ras... |
7c37af308c8d2961741e11f226a380b3e150c6eb477bff695e1dc7bef74a5dfe | Python | 7,255 | 188 | import torch
from torch import Tensor
import torch.nn.functional as F
from torch.nn import Sequential, Linear, ReLU, BatchNorm1d, GRU
import torch_geometric
from torch_geometric.nn import (
Set2Set,
global_mean_pool,
global_add_pool,
global_max_pool,
NNConv,
)
from torch_scatter import scatter_mean,... |
55373ecc83e14d8e3aaec3b0beb2ff1af8a5149c250f377b3daf4e16b763e2ff | Python | 7,257 | 193 | """Cron-scheduled slurm test dispatcher."""
import logging
import os
import subprocess
import requests as r
"""
This script is intended to run periodically by the cron.
Add the following line into the list of cron jobs:
*/5 * * * * . /path/to/mrpro.rc; /path/to/python /path/to/slurm_cronjob.py >> /path/to/err.log 2... |
bf0bac7b4b2e025992069654d898ab7d79daf617c6f2410e01b6b820495269a2 | Python | 7,260 | 238 | import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
import pandas._testing as tm
def test_shares_memory_numpy():
arr = np.arange(10)
view = arr[:5]
assert tm.shares_memory(arr, view)
arr2 = np.arange(10)
assert not tm.shares_memory(arr, arr2)
def test... |
d5bceffa802d0bd354814e6e7c9c5557ab81d814581b8aff56c5240d85fe8043 | Python | 7,260 | 177 | """Test imgaug pipeline functionality."""
import os
import numpy as np
import pytest
from PIL import Image
from lightning_pose.data.augmentations import imgaug_transform
class TestImgaugTransform:
@pytest.fixture
def image(self, base_dataset):
idx = 0
file_name = os.path.join(base_dataset.... |
bd682b201343234d01240d6d8541e99dfcc3a4c30ed82c975ab7a9d19e00b597 | Python | 7,263 | 208 | """
Functions for concatenating based on best hit or
best reciprocal hit to target
Authors:
Anna G. Green
"""
import pandas as pd
import numpy as np
from evcouplings.align.alignment import (
Alignment, parse_header
)
from evcouplings.utils import InvalidParameterError
SPECIES_ANNOTATION_COLUMNS = ["OS", "Tax"]
... |
c3abcb90d2c3a4d672f8655a5c851a94de0340da1f658a3d5376cc470ac26301 | Python | 7,264 | 231 | import numpy as np
from typing import Tuple, List
from skimage.feature import peak_local_max
from sbrnet_core.utils.constants import CM2_SIZE, FOCUS_LOC, NUM_VIEWS
from sbrnet_core.utils import (
linear_normalize,
read_tiff,
uint8_to_float,
normalize_psf_power,
shift_array,
)
# Functions
def load_... |
b05107ac6197305fcaa1864c4a0d54b23ad22edfecfd53b652af19ef4b1b76fb | Python | 7,267 | 203 | import os
import numpy as np
from kcsd import csd_profile as CSD
from kcsd import KCSD2D
from scipy.integrate import simps
from scipy.interpolate import griddata
from figure_properties import *
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.gridspec as gridspec
def fetch_folder(csd_type='... |
e88e25e270178515bdd4b7834ce5f4858d9bec4327ece8fd188a523c954269a8 | Python | 7,270 | 205 | import os, torch, cv2, random
import numpy as np
from torch.utils.data import Dataset, Sampler
import torchvision.transforms as transforms
from scipy.ndimage.morphology import binary_erosion
import torchvision.transforms.functional as TF
from PIL import Image, ImageOps
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED... |
87a97c83a4a0dbdc9ef018f1ab3bbdb3dc7c6a5c52a3e3f82d3ad82524446e6f | Python | 7,272 | 223 | import functools
import os
import numpy as np
import pandas as pd
import torch
from pymatgen.core.composition import Composition
from torch.utils.data import Dataset
from roost.core import Featurizer
class CompositionData(Dataset):
"""
The CompositionData dataset is a wrapper for a dataset data points are
... |
9e9eac4ce8d9987229f00e54760329540b59cf088870bc62ad90eeb2b8163de0 | Python | 7,272 | 232 | # Copyright 2018-2025 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.