sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
c543bf4be731757d0897e0eef134ae192b96ffa9b3c2af3a838bb0438db746da | Python | 6,113 | 206 | """
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 math
import numpy as np
import torch
from scipy.special import binom
from torch_geometric.nn.models.schnet import GaussianSmearing
... |
349c60c1cbf6fa31dc26a8a5565afd2595cc60db5c4f8750b09c8670de9dad78 | Python | 6,114 | 159 | """
This module contains the GarphAnnTorchDataset class to provide a standardized
dataset format for the training of Garfield model.
"""
from typing import Literal, List, Optional, Tuple, Union
import numpy as np
import torch
import scipy.sparse as sp
from scipy.sparse import csr_matrix
from torch_sparse import Spar... |
8eca20e5a815978f10a8c13adf356c328396eb0c334ab9f00b8f1b67eae6482b | Python | 6,116 | 178 | #!/usr/bin/env python
# ENCODE DCC TSS enrich wrapper
# Author: Daniel Kim, Jin Lee (leepc12@gmail.com)
import matplotlib as mpl
mpl.use('Agg')
import pybedtools
import numpy as np
from matplotlib import mlab
from matplotlib import pyplot as plt
import sys
import os
import argparse
from encode_lib_common import (
... |
05172f6fc55d42ae5d87fac62197bd8f897f01966a05e196013dd40e2def0193 | Python | 6,119 | 196 | import numpy as np
import zarr
from .io_utility import open as img_open, read_attributes, get_voxel_spacing
class ImageData:
def __init__(self, image_path=None, image_subpath=None,
image_arraydata=None, image_attrs=None,
image_timeindex=None, image_channel=None,
... |
de82b3e4adabfe8dbdfd4e2228c0f5407551d1e67894a8288838e0fa02646ba4 | Python | 6,121 | 183 | """Geometry-based filters for generated peptide poses."""
from __future__ import annotations
import math
from pathlib import Path
from typing import Iterable
Coord = tuple[float, float, float]
DEFAULT_SURFACE_FILTER = {
"radial_min": 0.60,
"outward_nearby_max": 0.25,
"occupied_octants_max": 5,
"mi... |
b4a4525443242d8f2fead187dc78357f8ffca6d99fc7d0855fc929f7bf4d61bd | Python | 6,122 | 164 | import torch
import torch.nn as nn
import torch.nn.functional as F
from .resnet import ResidualBlock1D, ResidualBlock2D
from .se import SEBlock
class Conv2d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1, relu=True, same_padding=False, bn=False):
super(Conv2d, self).__init_... |
fd0028b8458f71a0555196955a48b96df35ed800e1313d553e5d44dbcca16c12 | Python | 6,122 | 148 | from src.utils import read_gtf, read_SJ, gtf_to_SJ
import polars as pl
from pathlib import Path
import os
from SingleCell.ryp import to_r, to_py, r
def read_refmap(file):
out = pl.read_csv(file, separator="\t")\
.filter(pl.col("class_code")=="=")\
.with_columns(
pl.col("qry_id_list").str.split(",")... |
4a83024a75e863cbe12eab011221d26c85ec78ce3cd3545e653cc84d70283cb7 | Python | 6,125 | 165 | #!/usr/bin/env python
"""Score the dictionary linker on NLP4Pheno's strain spans, by deposit number.
Read what this measures before reading the number. The gold accession is
extracted from the span and joined against BRENDA's own `cultures` table, and
that table is also part of the surface-form index the linker querie... |
13349906165a8aeae9c5775c39b59eb68705cc9e1762e931e15be3a4169d11ff | Python | 6,126 | 178 | import scanpy as sc
import harmonypy as hm
import sys
sys.path.append('./scctools)
from scctools import *
# # Load and check data
#monkey
ad=sc.read('data/Figure/FM27_cell_133454_wk.h5')
gaba = ad[ad.obs['class']=='Inh',:]
gaba
#human
adhu=sc.read("./gaba_huMK_500Marker1.h5")
#match .obs
adhu.obs['class'] = adhu... |
704085324fc5caef101a35bdccd771ffa1c287ccfc8905874e27fe5ea43bf2b5 | Python | 6,126 | 166 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import fnmatch
import os
from dataclasses import asdict, dataclass, field
from functools import cached_property
from pathlib import Path
from typing import Any, Literal, Protocol
import numpy as np
from huggingface_hub import hf_hub_download
fro... |
c5d5ea0680002ee62dfa865cec410e33c5c3242971a4ee487ed75cd7a5003801 | Python | 6,127 | 197 | #!/usr/bin/env python3
# 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.
"""
Scoring script for computing pairwise BLEU and multi-ref BLEU over a set of
candidate hypotheses.
See `"Mixture Mod... |
ea109ab8474510d4ac67296c0ba6029dfb6d0e5341948eb26d7045f0a4228f30 | Python | 6,131 | 172 | import numpy as np
from sklearn.metrics.pairwise import pairwise_distances
import torch
from PIL import Image
import tqdm
import torchsort
import cv2
from msi_visual.percentile_ratio import TOP3
from sklearn.cluster import KMeans, kmeans_plusplus
from msi_visual.utils import normalize
class SpearmanOpti... |
9dee03349cf8308157ec4e2d84d3108b1351cd6e0529f771df529f3a27d8a06c | Python | 6,132 | 97 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'about_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_AboutDialog(object):
def setupUi(self, AboutDialog):
A... |
8d2de50f028699d8949e858fa589966629f897bb1ebfdffa2b30b3d6c6e35bb3 | Python | 6,134 | 178 | """Manages data from a DAVID Chart file."""
__copyright__ = "Copyright (C) 2016-2018, DV Klopfenstein, H Tang, All rights reserved."
__author__ = "DV Klopfenstein"
import os
import sys
import collections as cx
from goatools.wr_tbl import wr_xlsx
from goatools.wr_tbl import prt_txt
class DavidChartReader(object):
... |
6e3fbb25b42b66e3acd9b6e89657c4961286b2f7eaa9f1a797c107c944657136 | Python | 6,136 | 158 | # 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 math
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.logging import metrics
from fairseq.criterion... |
9bb4ad22b3fe38f9e179b2af999ffdad8d6e759e608cb091782840549372c8ce | Python | 6,136 | 197 | from enum import Enum
import torch
import shutil
from analysis.metrics import accuracy
class Summary(Enum):
NONE = 0
AVERAGE = 1
SUM = 2
COUNT = 3
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __init__(self, name, fmt=':f', summary_type=Summary.AVERAGE... |
dc02b5b2fefb8b629b6bc22aced8dc1e20e00c6fd356e4dae0a0e15927710454 | Python | 6,137 | 169 | #!/usr/bin/env python
# ENCODE DCC IDR wrapper
# Author: Jin Lee (leepc12@gmail.com)
import sys
import os
import argparse
import math
from encode_common import *
from encode_common_genomic import peak_to_bigbed, peak_to_hammock
from encode_blacklist_filter import blacklist_filter
from encode_frip import frip, frip_sh... |
a9f0aa79b5f8af96957f36e652a91d9c834de43ffbf754525b4325a6041cd6ad | Python | 6,138 | 159 | #!/usr/bin/env python3
# Florian Bénitière 16/03/2025
# This script processes VEP outputs per chromosome, extracts necessary columns
# and merges them into a PySpark DataFrame before saving the output as a Parquet file.
import os
import sys
import pandas as pd
import subprocess
import psutil # System and process ut... |
2948c4e6611e697a546ab9268163cdae4ca6617c8bafe10a306ce4a61170757b | Python | 6,139 | 154 | from concurrent.futures import ThreadPoolExecutor
import os
import tempfile
import unittest
import numpy as np
import toml
import torch
from medaka import models
from medaka.common import Sample
from medaka.features import BaseFeatureEncoder
from medaka.labels import BaseLabelScheme
import medaka.options
import medak... |
8d1af6a2c1179a66012d0cdf8d680935e2e5151deac0bf4dc5ac3468bb21bd2c | Python | 6,140 | 161 | """Keyword args for selecting annotation lines."""
__copyright__ = "Copyright (C) 2016-2019, DV Klopfenstein, H Tang. All rights reserved."
__author__ = "DV Klopfenstein"
# pylint: disable=too-few-public-methods
class AnnoOptions(object):
"""Keyword args for selecting annotation lines."""
keys_exp = set(['e... |
01057bc6de51b0caf2dab750d1c3d94b12616e73425326a9b085ca47280c32f7 | Python | 6,141 | 146 | """The per-step weight update: backward, unscale, clip, step.
Its own module rather than part of `trainer` because `Model.run_epoch` — which
stays on the model — is what calls it, while `trainer` imports the model
classes; putting the two together would make that a cycle.
"""
import torch
from jaxtyping import Float
... |
f5a669fc9c45602ac60dc99b4fbb42fa2c15f8fa18f13eff739e1d680ed4e495 | Python | 6,144 | 180 | # %%
from os.path import join as ospj
import pandas as pd
import numpy as np
import mne
from glob import glob
import os
from tqdm import tqdm
from fractions import Fraction
from scipy.signal import resample_poly
import pickle
from config import CONFIG
from utils import *
TARGET_SF = 256
# CLIP_SIZE = 45 # seconds
CL... |
26a945d9a65289891a9deea5616ebc9b7c9dcb79bcf9a138710bfcbf4b23889a | Python | 6,147 | 190 | # 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 json
import os
import numpy as np
import torch
from fairseq.data import (
Dictionary,
IdDataset,
ListDataset,
NestedDi... |
cb34834d4d35fed3fd79a65ccba9c9ab46180419d7752939f086b9fe9d1527db | Python | 6,147 | 114 | from pathlib import Path
import shutil
# Define the project paths
project_path = Path("/data/elevchenko/MovieProject2")
raw_data_path = project_path / "raw_data"
bids_data_path = project_path / "bids_data/sourcedata"
# Define exceptions for specific subjects and sessions where the first run was paused
paused_files_ex... |
612592292d5fd0f813f7e1154afc599d5d100b1fda3cf18299f4409aa56a52f5 | Python | 6,148 | 181 | import glob
import h5py
import numpy as np
import bigstream.utility as ut
from ClusterWrap.decorator import cluster
@cluster
def distributed_directory_of_hdf5_to_zarr(
directory,
write_path,
dataset_path=None,
chunks=None,
suffix='.h5',
cluster=None,
cluster_kwargs={},
):
"""
Cop... |
e17756e813d479f9708c418896691431b267f098fc23148a69e882bae2fdbf64 | Python | 6,149 | 161 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from dataclasses import dataclass
from functools import cached_property
import numpy as np
import numpy.typing
from pandas import DataFrame
from mattergen.evaluation.metrics.core import BaseAggregateMetric, BaseMetric, BaseMetricsCapability
fro... |
6c2f5e743f851f65cd68d81681202ec203686443a8a10658cef28ddea1a0db26 | Python | 6,152 | 159 | from collections.abc import Hashable
import networkx as nx
class _GraphPlotting:
"""Plotting / export methods (graphviz, daft) for ``_CoreGraph``-based classes."""
def to_graphviz(self):
"""
Returns a pygraphviz object for the graph for visualizing the network structure.
Returns
... |
be8124814e574d5df28a217f4576534256edec40ead14e86bd6e1fe01eaa42b4 | Python | 6,153 | 200 | """
Tests for readimagejrois.py.
"""
import json
import os
import sys
import unittest
import numpy as np
from .base_test import BaseTestCase
from .. import readimagejrois
class TestReadImageJRois(BaseTestCase):
"""readimagejrois testing class."""
def __init__(self, *args, **kw):
super(TestReadImag... |
8422ee31f1f92f74274a7e8b266b2f54ffff8d1a80a9716aa408efb0087e2d55 | Python | 6,161 | 173 | from typing import Literal, Optional, Protocol, Tuple
import jax
import jax.numpy as jnp
from pyscf.dft import gen_grid
from ..molecule import Molecule
from ..wf.transferable_hf.pyscfext import pyscf_from_mol
def get_dft_grid(mol: Molecule, level: int = 3) -> Tuple[jnp.ndarray, jnp.ndarray]:
mol_pyscf, *_ = pys... |
b4a8299353ffcc0cc8064f8c7de15ff9dc083606c1a6cf68554a06561af30581 | Python | 6,165 | 164 | #!/usr/bin/env python3
"""Run the Phase 2 symlink spike and print a link audit summary."""
from __future__ import annotations
import re
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
REPO = Path(__file__).resolve().parents[1]
AUDIT_PAGES = [
(
'examples/AMBER/index.h... |
247aa51609c9c47868e2270031668911192d39c9733ba8e049f6a5d169776b7f | Python | 6,167 | 151 | #!/usr/bin/env python3
"""
Author: Ken Chen
Email: chenkenbio@gmail.com
Date: 2022-11-24
"""
import os
import sys
import json
import pickle
import gzip
from glob import glob
import argparse
from tqdm import tqdm
import numpy as np
import pandas as pd
from importlib import reload
from collections import defaultdict, Or... |
8b476ee7fb54cd474a3ee7d6e8d9fec6863199646b2d8db563072d6f24e41230 | Python | 6,168 | 152 | import numpy as np
import torch
from pathlib import Path
import sys
from torch.utils.tensorboard import SummaryWriter
'''
## ############################################################################
Refer to the paper
"Phase-field modeling of fracture with physics-informed deep learning"
for details of the mode... |
a291285b64279a90f4ca4793dc8e63b0d45d253f658f3b54d80abcb97f80462a | Python | 6,168 | 168 | # 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 os
import json
import collections
import argparse
import shutil
import subprocess
import sys
import tempfile
from multiprocessing impor... |
a681cfe4b39fa16e496bd52e0bcd8dc1e6e21bb3f0d593b844e7161bcb5d3449 | Python | 6,168 | 192 | import os
import torch
import torchaudio
import sox
import json
import argparse
from examples.mms.data_prep.text_normalization import text_normalize
from examples.mms.data_prep.align_utils import (
get_uroman_tokens,
time_to_frame,
load_model_dict,
merge_repeats,
get_spans,
)
import torchaudio.fun... |
97b45696669fbe970112e85e45da9eaa6093e505a90866561cb0d4317ee44182 | Python | 6,170 | 155 | import torch
from collections import OrderedDict
import numpy as np
from pytorch_grad_cam.utils.svd_on_activations import get_2d_projection
class AblationLayer(torch.nn.Module):
def __init__(self):
super(AblationLayer, self).__init__()
def objectiveness_mask_from_svd(self, activations, threshold=0.01... |
f6a6a1e2469e2f1e132abe7230ae9118bc1367f5c1bc64dda5ea4ee7174dd829 | Python | 6,170 | 137 | # Copyright 2021 DeepMind Technologies Limited
#
# 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 agr... |
4c307b2edb22767f1f18957f3ee53017bb53b117174bf0706875d82bc83de272 | Python | 6,179 | 138 | """Fit OCE Wave-1.5 on SIESTA-PBE cohesive energies, rank, and compare.
The scientific question: with a TRUSTWORTHY DFT target (unlike xtb on oxides),
can OCE-with-formal-charges reproduce the SIESTA polymorph/stability ranking?
Target = cohesive energy per atom: (E_cell - sum_i E_atom_ref[el_i]) / n_atoms.
Reuses t... |
56be80b60b6786616ec110c77a659523773f367c7f81be246d17ad8b64858de4 | Python | 6,179 | 139 | """Page 1: Dataset Overview."""
import streamlit as st
import plotly.express as px
import pandas as pd
import numpy as np
import os
from utils import PIPE_ORDER, style_figure
def render(store, dataset):
st.header("Dataset Overview")
st.markdown(
"Interactive dashboard for comparing cross-session EEG ... |
9431c52c6d84f61e149ca409cc17988e6b32e9f9d48df2238acbcce213a7c9c2 | Python | 6,180 | 184 | import torch
import pytest
import neurovfm.systems.classification as cls_mod
import neurovfm.models.mil as mil_mod
from neurovfm.models import (
AggregateThenClassify,
ClassifyThenAggregate,
)
class _LinearDense(torch.nn.Module):
"""CPU-friendly stand-in for flash_attn FusedDense used in MIL modules."""
... |
69503701759b43bd26fae9e593c8ef12f9b2346781eac48b7155a6775bb4cd53 | Python | 6,181 | 128 | import glob
import os
from itertools import filterfalse
from mdt.lib.batch_utils import SimpleBatchProfile, BatchFitProtocolLoader, SimpleSubjectInfo
from mdt.component_templates.base import ComponentBuilder, ComponentTemplate
__author__ = 'Robbert Harms'
__date__ = "2017-02-14"
__maintainer__ = "Robbert Harms"
__ema... |
c07e36d9eba1e0c7c040d7e72424866fbdd106d9e6782bc3d0a78aa7c2629ef1 | Python | 6,182 | 212 | # 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 argparse
import logging
import os
import time
import numpy as np
from sklearn.cluster import MiniBatchKMeans
import joblib
from examp... |
9610f67259eabf1460e124c1f7a5501f3300f017f8ae853831f356632cfa07ba | Python | 6,189 | 160 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script to compute asymmetric ODF by filtering an input symmetric ODF image.
The filtering is accelerated with numba and opencl for python.
The script supports any spherical signal expressed as a series of spherical
harmonics (SH) coefficients. For an explanation of th... |
5d0f05e2c4e538b8ddf4da8494d47e3c924d0be55eec5fe3f945b5572f0b6104 | Python | 6,190 | 161 |
from sklearn.ensemble import HistGradientBoostingClassifier, HistGradientBoostingRegressor
from sklearn.preprocessing import LabelEncoder, OrdinalEncoder, MinMaxScaler
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.decomposition import PCA
from sklearn.metrics ... |
38b2bb5d1715625d0ce2503f57176fdd8a6acbb4ab67986647903b5316b70604 | Python | 6,192 | 170 | import json
import logging
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scanpy as sc
import seaborn as sns
from anndata import AnnData
from .. import utils
from .._constants import Keys
log = logging.getLogger(__name__)
def _weights_clustermap(... |
36c610138b4ea1e5bfec77eeddadacc77c9ac6c1ad19231142b7fd3dca6bb71d | Python | 6,195 | 159 | import numpy as np
import pandas as pd
from pgmpy.utils import preprocess_data
from ._base import BaseCITest, _CITestResult, _ResidualMixin
class GeneralizedCov(_ResidualMixin, BaseCITest):
r"""
Residual cross-covariance determinant CI test with permutation-based p-values [1].
This test first residuali... |
f1687402ae53dbe01e1d667504a62b998524caf22a38a00ccd46c16d7f5c4cb2 | Python | 6,198 | 194 | """Script to pre-annotate Documents with the entities found in them.
Annotations are marked by their offsets in the text. The following, for example, marks
the string starting at position 17 in the text up to (but not including) position 36 as
an enzyme in the D3O ontology.
``EntityMarkup(start=17, end=36, label... |
44dca2e6e9943c7ab276582ca6222905a937b7c3bb6cf16081deade271db98c4 | Python | 6,200 | 161 | """The culture-number grammar, and the comma that means two things at once.
`DSM 22,228` is one deposit number and `ATCC 35984, 35983` is two, so neither
stopping at the comma nor stripping every comma is right. Both failures are
silent and both fabricate an identifier that BRENDA can answer for: `DSM 22`
is a strain ... |
81e224b5f40a99dd78b85c41916d960c822eee9ea1e2bdc18b3a1885924d0dfe | Python | 6,201 | 177 | # 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 math
from dataclasses import dataclass, field
import torch
from fairseq import utils
from fairseq.logging import metrics
from fairseq... |
eb971ed2f5c3f5f96bf9f149cb69ab40cc2811d2f0b801ba93041dbc296fdf34 | Python | 6,203 | 142 | """Read an NCBI gene2go GO Association File and store the data in a Python object.
Annotations available from NCBI:
ftp://ftp.ncbi.nih.gov/gene/DATA/gene2go.gz
"""
import sys
import collections as cx
import timeit
import datetime
__copyright__ = "Copyright (C) 2016-present, DV Klopfenstein, H Tang. All ... |
7e85f608c47b9429df8f0eee5211f27f6ab5b15226a0390c21e3f88537745b08 | Python | 6,207 | 204 | #!/usr/bin/env python
# Author_and_contribution: Niklas Mueller-Boetticher; created template
# Author_and_contribution: Zaira Seferbekova; wrote the code for SpaceFlow
import argparse
# TODO adjust description
parser = argparse.ArgumentParser(description="Method ...")
parser.add_argument(
"-c", "--coordinates",... |
3e4db0755530a26951d541019d2dd31fa91c8429f01c5fb416fd049e92c21bbc | Python | 6,214 | 151 | """
Functions for downstream work with outputs of remove-background.
Courtesy of Stephen Fleming
"""
import tables
import numpy as np
import scipy.sparse as sp
from typing import Dict
import anndata
def dict_from_h5(file: str) -> Dict[str, np.ndarray]:
"""Read in everything from an h5 file and put into a dictiona... |
0bf9ca219c8bc39c1fe9519afcca77743745465a3751eeedea9cdf055643ba3c | Python | 6,215 | 154 | import timm
import torch
from torch import nn
from typing import Literal
class FE_Additional(nn.Module):
"""CNN Feature extractor that can incorporate additional features"""
def __init__(
self,
model_name: str = "seresnet18",
dropout: float = 0.3,
additional_features: int = 2,... |
a7dc017f91d33171efa6cccf7f9a6938247bd5f2257036e634dc261fa7f1f7cf | Python | 6,218 | 159 | #!/usr/bin/env python
# Author_and_contribution: Niklas Mueller-Boetticher; created template
# Author_and_contribution: Florian Heyl (heylf); created code
import argparse
import os
import tempfile
import requests
import pandas as pd
import scipy
import json
import pandas as pd
import numpy as np
from scipy.io import... |
0809aafee99ab3f9f4658188792549661bb2a145fe77262d992167b86af1bb4b | Python | 6,219 | 205 | from __future__ import annotations
import logging
import numpy as np
import pytest
import shiboken6
from PySide6.QtWidgets import QApplication, QWidget
from src.dashboard.dashboard import QtDashboard
from src.features.raw_photometry.photometry_processing_widget import (
RawPhotometryProcessingQt,
)
from src.gui.... |
cf7dce292cc9aacda25bbe65e351b74dc68e08b6e95bf01da8a1732e0e299286 | Python | 6,220 | 161 | from functools import partial
from typing import Any, Dict, Tuple
import jax
from ..types import InitialiserParams, ModelDimensions
from ..wf.base import WaveFunction
from .sample_initializer import MolecularSampleInitializer
from .samplers import (
DecorrSampler,
LangevinSampler,
MultiSystemElectronSampl... |
df4beacddfa3b47bf3fd32037f930d18a62254f77fe03cb2f36c202cf62316d1 | Python | 6,221 | 198 | # -*- coding: utf-8 -*-
import csv
import pandas
import nibabel as nib
import numpy as np
from functools import reduce
from .utils import run_shell
def maskFromAtlas(atlasPath, indices, output):
# input
atlas = nib.load(atlasPath)
atlasData = atlas.get_data()
maskData = np.empty_like(atlasData)
... |
46b76fe450c94dd5ac294e09cff71eb35269c3026dae71927618a18bb0d731cb | Python | 6,222 | 167 | #!/bin/env python
import polars as pl
from tqdm import tqdm
from src.utils import read_gtf
import argparse
def make_IL_regex(seq: str) -> str:
pattern = ''.join('[IL]' if c in 'IL' else c for c in seq)
return f'{pattern}'
def read_fasta(fasta_file, gencode = False):
"""
Reads a FASTA file and converts... |
1a8fc5f34d397f661fb8f10131598d135617eec423bf58f89df67028c8b85d67 | Python | 6,223 | 168 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Title : RSA_predictor.py
# Created by: julse@qq.com
# Created on: 2022/12/7 14:17
import glob
from pathlib import Path
import pickle
import random
import re
import os
from argparse import ArgumentParser
import matplotlib.pyplot as plt
import torch
from Bio import SeqI... |
44187126c80787d1bbeb88e0ab7c99a5b91ba6bef70266e54327d5b360ae9112 | Python | 6,225 | 194 | import torch
import math
import torch.nn as nn
import torch.nn.functional as F
import random
from torch_geometric.nn import GINConv, JumpingKnowledge, global_mean_pool, SAGEConv
class GIN_Net2(torch.nn.Module):
def __init__(self, in_len=2000, in_feature=13, gin_in_feature=256, num_layers=1,
hidde... |
80ba89321adc25182a84fc1b3a400636ac20615fca3042b48056a52637f568f5 | Python | 6,225 | 172 | # 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 torch
import torch.optim
from . import LegacyFairseqOptimizer, register_optimizer
@register_optimizer("adamax")
class FairseqAdamax(... |
ff74fbace9ef8cffd04c880775dc1fb654bd31b7753bf38596287dca0d7b2a6e | Python | 6,225 | 191 | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import os
import sy... |
72974883229aeb4b1a08ed441cc71fa42044d2d7e6f5f16932dd38462a62ee6d | Python | 6,228 | 149 | import sys
sys.path.append("..")
import torch.nn as nn
from modelR.backbones.darknet53_npattention import Darknet53_NPAttention
from modelR.backbones.darknet53 import Darknet53
from modelR.backbones.cspdarknet53__npattention import CSPDarknet53_NPAttention
from modelR.necks.panet_fpn import PANet_FPN
from modelR.necks... |
dd767ab674598a7b61330ae48ea76be7f23659afad2f24507d1a0d694dd2ba77 | Python | 6,230 | 197 | # 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 hashlib
import json
import subprocess
import tempfile
from typing import Hashable
try:
import pyarrow.plasma as plasma
PYARR... |
1e8c70cd854cb73d0ce492d45091944703df37b519a769edd3c3aab99bcc1a0b | Python | 6,232 | 172 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from __future__ import annotations
from collections import deque
from typing import Any, Dict, Generic, Optional, Protocol, Sequence, TypeVar, Union
import numpy as np
import pytorch_lightning as pl
import torch
from hydra.errors import Instant... |
e41395e3bb0224b430447ebe48a70dbde94780555fe0e0f53c4d5f15e2987252 | Python | 6,234 | 168 | """The column order a checkpoint records, and what it refuses to record.
Everything here is about *positions*. A class head is a matrix of the right
width and nothing more, so a vocabulary that comes back off disk in a different
order than it went in is not a loud failure — it is a model scoring every class
against an... |
9bc5f3370afa1c1c67a22f6ab130063b7799f885d4ce9018ef45f6609b5b3c35 | Python | 6,238 | 202 | import importlib
import logging
from typing import Literal
import numpy as np
import pandas as pd
import torch
from anndata import AnnData
from lightning.pytorch.trainer.connectors.accelerator_connector import _AcceleratorConnector
from .._constants import Keys
log = logging.getLogger(__name__)
def unique_obs(adat... |
9626db07d73b35661846e1d8d7eae1deec7ffaeae3374ae8417ca06c42afddfe | Python | 6,242 | 221 | import argparse
import os
from datetime import datetime
from typing import List, Optional
import h5py
import nibabel.freesurfer.mghformat as mgh
import numpy as np
from spacestream.core.fit import extract_and_fit
from spacestream.core.paths import BETA_PATH, DATA_PATH, RESULTS_PATH
from spacestream.utils.get_utils im... |
5177166b55a58cf7d0d71c97cac86ba0695c0a3ade66d4cc2e51259fb9a9dc2f | Python | 6,243 | 186 | # @license
# Copyright 2020 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in... |
ba74bbddeccd795334305d1641ea311e4c5586acf0815d577c2bea279237cde0 | Python | 6,244 | 196 | import itertools as it
from typing import Any, Callable, Generator, Iterable, Sequence, TypeAlias, TypeVar
import jax
import jax.numpy as jnp
from .molecule import Molecule
from .types import ModelDimensions, MolecularConfiguration, RandomKey
T = TypeVar("T")
S = TypeVar("S")
U = TypeVar("U")
IntegerLike: TypeAlias... |
9008d6dff7b7dd79d93ffc9e2ae12291c5ea97cebdaa062e87868d814af88572 | Python | 6,245 | 157 | """Joint Embedding SCVI model."""
from __future__ import annotations
from typing import TYPE_CHECKING
from scvi.external.joint_embedding_scvi._module import JointEmbeddingVAE
from scvi.model._scvi import SCVI
if TYPE_CHECKING:
from typing import Literal
from anndata import AnnData
class JointEmbeddingSCV... |
0fca5ec7d940064d761e2b863d20771e2bb6f9c2a659a7c871b776436825294e | Python | 6,247 | 165 | # 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 torch
from fairseq import utils
from . import FairseqDataset
def backtranslate_samples(samples, collate_fn, generate_fn, cuda=True):... |
5aaff85b406d994f6e54da76d167750f143006d15b00b555b2bf3e28ad6a6046 | Python | 6,250 | 177 | # 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 logging
from dataclasses import dataclass, field
from typing import Dict, List
import torch
from fairseq import utils
from fairseq.lo... |
b2cb98b18f7aebceb1e73c0ea1fc78640d87f38c4d985c6995da592c79e1b1d4 | Python | 6,250 | 160 | # %%
"""Curve-level noise-robustness metrics (Reviewer 1, point 3).
Beyond the per-sigma Welch tests, this script summarizes each model's whole
R^2(sigma) degradation curve with three interpretable metrics and compares the
training conditions with effect sizes and confidence intervals:
* AUC: area under the R^2(sigma... |
7b7076dde2a50b89d9fbb842643c142f4931925b4844ecb04688ae867cf89dcd | Python | 6,254 | 160 | #!/usr/bin/env python
# ENCODE DCC reproducibility QC wrapper
# Author: Jin Lee (leepc12@gmail.com)
import sys
import os
import argparse
import multiprocessing
from encode_common import *
from encode_common_genomic import peak_to_bigbed, peak_to_hammock
def parse_arguments():
parser = argparse.ArgumentParser(pro... |
b190b1465d3658d99d7ef8ccc3f81285224efb07442dd93d830cc4f0576aec1c | Python | 6,255 | 158 | """Ablation 1F/+2F/+3F/+Madelung at the n=180 non-strain pool.
Decisive test of the hypothesis that the optimal OCE basis depth scales with
n/p ratio. At n=93 we observed 1F+2F won and full ablation (n/p≈0.06) lost.
At n=180, n/p ratio rises to 0.107 for the full basis — does +3F now win?
Sweeps α ∈ {1, 10, 100, 100... |
0260dadf4bb964bc127f3f425f141455ef8cb3aa889942a9d33df31a984dcccc | Python | 6,256 | 187 | #
# Copyright 2017-2023 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with
# Sandia Corporation, the U.S. Government retains certain rights in this software.
#
# See LICENSE for full license details
#
import numpy as np
from scipy.optimize import minimize
import time
import os
# Use ... |
9df6d9b0263b9b4a3ab5ef782d03922b47c91bfa89b7b8596f4a69d8d9833186 | Python | 6,259 | 147 | import theano
from .. import init
from .. import nonlinearities
from .base import Layer
from .conv import conv_output_length, BaseConvLayer
from ..utils import as_tuple
from theano.sandbox.cuda.basic_ops import gpu_contiguous
from theano.sandbox.cuda.blas import GpuCorrMM
__all__ = [
"Conv2DMMLayer",
]
if n... |
3d8b0d53a92ff380d9f8206cbde1d03a82a3adf4e616d7fb8d151f589e04f394 | Python | 6,264 | 192 | import torch
import torch.nn as nn
import torch.nn.functional as F
#from .linear import Linear_gaussian_init
class ScaledSiLU(nn.Module):
def __init__(self, inplace=False):
super(ScaledSiLU, self).__init__()
self.inplace = inplace
self.scale_factor = 1.6791767923989418
def forward(s... |
c4153ab69cde16e2614749e63d247c91e5c277c3ad25034d5660e8752b69ded4 | Python | 6,264 | 200 | import pytest
import torch
import pandas as pd
import numpy as np
from binn.model.binn import BINN
def get_dummy_connectivity_matrices(n_layers: int):
"""
Create a list of dummy connectivity matrices as pandas DataFrames.
For example, let’s assume n_layers=3. Then we create:
- Matrix 0: shape (5,... |
8fe6eb75e44f1e600df6286293a70dbc19ccc7edb3b8e8aaefeeff11dbc6cbb6 | Python | 6,265 | 163 | #
# Copyright 2017-2023 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with
# Sandia Corporation, the U.S. Government retains certain rights in this software.
#
# See LICENSE for full license details
#
##
## The following code has been adapted from Sandia's open-source Whetstone package
## to be... |
9eaed82505e600d41f0fc1fa36a9253d8b1037977b35d25718afa424988fc151 | Python | 6,265 | 157 | """Class that represents ``[vak.train]`` table of configuration file."""
from attrs import converters, define, field, validators
from attrs.validators import instance_of
from ..common.converters import bool_from_str, expanded_user_path
from .dataset import DatasetConfig
from .model import ModelConfig
from .trainer im... |
fe27347d9d0fb7fe83a278b77dea9e246254e76abf9e520dd02a9e8d1cce342a | Python | 6,265 | 186 | from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from poetry.inspection.info import PackageInfo
from poetry.utils.dependency_specification import RequirementsParser
if TYPE_CHECKING:
from collections.abc import Collection
from pytest_mock import Mo... |
2bd6907326499dc42f2b7b0da126d65c3063eb91a2dee5578c202c529c85ae78 | Python | 6,267 | 189 | # @license
# Copyright 2020 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in... |
cef7d68547850dbab3739eb93c51266fd52befc00a1cf23bcedd8510487b387b | Python | 6,268 | 155 | #!/usr/bin/env python3
import pandas as pd
import numpy as np
import csv
import argparse
import gtfparse
import multiprocessing
REQUIRED_COLUMNS = [
"seqname",
"source",
"feature",
"start",
"end",
"score",
"strand",
"frame",
]
def make_attribute_column(row):
attribute = ''
fo... |
f87a710eefe5b0d7a82a0f031ac1e87ee0086a4bb125db36cc70432efa0c4b83 | Python | 6,268 | 180 | #!/usr/bin/env python
# ENCODE DCC IDR wrapper
# Author: Jin Lee (leepc12@gmail.com)
import sys
import os
import argparse
import math
from encode_lib_common import (
assert_file_not_empty, log, ls_l, mkdir_p, rm_f, run_shell_cmd)
from encode_lib_genomic import (
peak_to_bigbed, peak_to_hammock)
from encode_li... |
cd091bde7da4c4a491456c1ba5119937a87b4dea2011b2670344abce1d0eeec7 | Python | 6,271 | 162 | import torch
import numpy as np
from sklearn.metrics import classification_report, confusion_matrix
from torch.utils.data import DataLoader
import os
from celltype_ibl.utils.c4_vae_util import VAEEncoder, vae_encode_model, load_acg_vae
# Assuming the following classes and functions are defined as in your training scri... |
ffe88c399ffc27fc10f864fd266fbe77bd630c03488948ed703845aeda85147c | Python | 6,274 | 162 | import torch
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
import numpy as np
def extend_sequence_interpolation(tensor, target_size):
"""
Extend a sequence to target_size by interpolating additional points within the existing boundaries.
If the sequence is already longer... |
d9ba0bc20d04e7cc93470eceafd76c4dfbe9e3ebde018b390d02a13daaa0197b | Python | 6,276 | 177 | """A dataclass that represents metadata
associated with a frame classification dataset,
as generated by
:func:`vak.core.prep.frame_classification.prep_frame_classification_dataset`"""
from __future__ import annotations
import json
import pathlib
from typing import ClassVar
import attr
def is_valid_dataset_csv_file... |
1f0331a5abde9f0b37f9110fcf14c5540b6c913c051754cf5a0571d6d7599c1d | Python | 6,281 | 168 | import os
import random
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tifffile import tifffile
import ramanspy as rp
from sklearn.decomposition import PCA
def set_seed(seed=None):
# Set seeds for reproducibility
os.environ['TF_CUDNN_DETERMINISTIC'] = '1'
os.environ['TF_DE... |
c973ef4a41f46d9bb20ac059dd5a615d5f1f20c691ad8f46c2c1389c93861417 | Python | 6,283 | 156 | from typing import Sequence
from ... import options as opts
from ... import types
from ...charts.chart import Base
class Timeline(Base):
"""
`Timeline` provides functions like switching and playing between multiple charts.
"""
def __init__(
self,
init_opts: types.Init =... |
68351e7ec135f546e57958e85144c099ebc5cfb233d75cbc213bb6e93dec92a3 | Python | 6,288 | 206 | from __future__ import annotations
import abc
from abc import abstractmethod
import torch
from torch.distributions import Normal, kl_divergence
class Prior(torch.nn.Module, abc.ABC):
"""Abstract class for prior distributions."""
@abstractmethod
def kl(
self,
m_q: torch.Tensor,
v... |
5471c0b4979f5719c8b8661e783bd66698eb1f448412df7cbe0fa928666ca545 | Python | 6,291 | 168 | # 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 math
from dataclasses import dataclass, field
import torch
from fairseq import utils
from fairseq.logging import metrics
from fairseq.... |
eb14e7f6ed8809616aac0a3f15cb4756eb4460a068fd7b881a086d5c5bd055ee | Python | 6,292 | 179 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import argparse
import logging
import os
import random
import re
from glob import glob
from typing import Any, Mapping, TypeVar
import numpy as np
import pytorch_lightning as pl
import torch
import yaml
from hydra.utils import instantiate
from o... |
fafb135e4bcd0e3b552ce5ba325a1bef3153e91f035d56b7f6bbe25f17b85a6e | Python | 6,292 | 166 | #!/usr/bin/env python
# Made by Paul Kiessling pakiessling@ukaachen.de
import argparse
import json
import os
import tempfile
import urllib.request
from urllib.parse import urlparse
import anndata
import pandas as pd
import scipy
LINKS = [
"https://ftp.cngb.org/pub/SciRAID/stomics/STDS0000172/stomics/STSP000537... |
fca6758cda81c4b92c228d423f55722999d735db41b5a859e4350b1c134f2985 | Python | 6,292 | 154 | #!/usr/bin/env python
import sys
import os
import io
import gzip
import metax.Gene
if "DEBUG" in sys.argv:
sys.path.insert(0, "..")
sys.path.insert(0, "../../")
sys.path.insert(0, ".")
sys.argv.remove("DEBUG")
import unittest
class GeneEntry(object):
def __init__(self, chr, start, end, ensid, na... |
72dacb9bedf08cead1ecc14bbad8383369551002830664b539f00d7805ae8654 | Python | 6,294 | 216 | import sys
root_dir = __file__.rsplit("/", 5)[0]
if root_dir not in sys.path:
sys.path.append(root_dir)
import uvicorn
import os
import torch
import json
import requests
import numpy as np
import argparse
from init_index import init_index
from fastapi import FastAPI
from tqdm import tqdm
from utils.server_tool i... |
33aef0eb4ae0f9c52140515f86a43e5f97d7c8a9e378b77dd7531981b49bd603 | Python | 6,297 | 162 | import os
import h5py
import shutil
import numpy as np
from scipy import io
from types import SimpleNamespace
from voluseg._tools.load_volume import load_volume
from voluseg._tools.save_volume import save_volume
from voluseg._tools.constants import ori, ali, nii, hdf, dtype
from voluseg._tools.ants_registration import ... |
1c505137f4d90038f5ce60f83edd4df2effd3b714ecffadc18c11f75aaefeb3f | Python | 6,299 | 176 | import torch
import torch.nn.functional as F
from torchmetrics import Metric
from torch import Tensor
from typing import Any
from jaxtyping import Float
class AUPRC(Metric):
"""Class for AUPRC metric.
:param compute_on_cpu: Whether to compute the metric on CPU,
defaults to ``True``.
:type comp... |
075e9e772fc3a9932a03d76514f1b12533c1d3addf1284aaf737c07a18c719f9 | Python | 6,301 | 162 | import torch
import numpy as np
from sklearn.metrics import classification_report, confusion_matrix
from torch.utils.data import DataLoader
import os
from celltype_ibl.utils.c4_vae_util import VAEEncoder, vae_encode_model, load_acg_vae
# Assuming the following classes and functions are defined as in your training scri... |
f721357fd1d646c9a9d91010cd022b5dc0837275f82a4116098843d9d4e5c58f | Python | 6,304 | 160 | #!/usr/bin/env python
# ENCODE DCC reproducibility QC wrapper
# Author: Jin Lee (leepc12@gmail.com)
import sys
import os
import argparse
import multiprocessing
from encode_common import *
from encode_common_genomic import peak_to_bigbed, peak_to_hammock
def parse_arguments():
parser = argparse.ArgumentParser(pro... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.