sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
e6761045adb996c978ba00b5c84c2061b892b0ef153837df362873eff42e131d | Python | 22,591 | 566 | """Routines for fitting models on multiple subjects.
The most important part of this are the batch profiles. These encapsulate information about the subjects
and about the modelling settings. Suppose you have a directory full of subjects that you want to analyze with a
few models. One way to do that is to write some s... |
6de5ff93aa573530f59af2d315202d005c26440ba10cb679c6dc4623d2bd62c8 | Python | 22,609 | 597 | # 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 logging
import math
from argparse import Namespace
from pathlib import Path
from typing import List
import torch
import to... |
3e79e8c5490a4d0499347082a3ac225c6ad5d57a1b1a3dbaf8ed605cdedd4478 | Python | 22,610 | 559 | from collections import deque
from difflib import get_close_matches
from itertools import chain
from warnings import warn
import theano
import numpy as np
from lasagne import utils
__all__ = [
"get_all_layers",
"get_output",
"get_output_shape",
"get_all_params",
"count_params",
"get_all_para... |
85c1eab60776887a812c4de23fb5d7d2924eceabf58923a96c490622a42334c5 | Python | 22,616 | 540 | from __future__ import annotations
import logging
import warnings
from typing import TYPE_CHECKING
import torch
from scvi import settings
from scvi.data._utils import _validate_adata_dataloader_input
from scvi.utils import unsupported_if_adata_minified
if TYPE_CHECKING:
from collections.abc import Iterator, Seq... |
26f5801d2e01521774c28bd1d68035d9ef3bf59628574aa985a9b6728344711d | Python | 22,617 | 577 | from typing import Tuple, NamedTuple
from dataclasses import dataclass
import math
import torch as th
from torch import nn, Tensor
from config_base import BaseConfig
from .blocks import ResBlockConfig, AttentionBlock, normalization, \
TimestepEmbedSequential, Downsample, Upsample
from .nn import conv_nd, linear, t... |
62662cea90d3d75cac311b13cc2834ef9bb32f394adfc79db886c19bcb3d25b0 | Python | 22,627 | 594 | #!/usr/bin/env python3
"""
Generate DWI variants (both low-b and high-b) by warping with B0 variants (PARALLEL VERSION).
This is a parallelized version using multiprocessing for faster generation.
Uses 10 worker processes by default.
Differences vs v1:
- Processes NPZs from three preprocessed roots (raw data, NOT nor... |
85ccc19a06a57402b552fb9220967466dc669ed65600dc38d2cdc9ef60d8b54f | Python | 22,687 | 600 | # 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 collections import namedtuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import option... |
3b9c942b5c320d383e6764985a173cb0d2349b352c3b9a5ea387acb868a76061 | Python | 22,690 | 504 | import torch
import torch.nn as nn
import torch.nn.functional as F
from dropblock import DropBlock2D, LinearScheduler
from modelR.layers.convolutions import Convolutional, Deformable_Convolutional
from modelR.layers.shuffle_blocks import Shuffle_new, Shuffle_Cond_RFA, Shuffle_new_s
import config.cfg_lodet as cfg
... |
534dc7540dffeda2ef2f9215dea83f41d0ea39719e4d2cb8eedd919a80704c49 | Python | 22,690 | 615 | """What `evaluate` scores a checkpoint against, and why.
`load_evaluation_dataset` decides the corpus: every checkpoint this code reads
records its vocabulary, and it is scored against *that*.
`token_labels_provenance` decides nothing and reports which dictionary the
distant labels the detection metrics count came fro... |
2e88351fe9ae088e24a519be121fcc899374d5dcfe56fe8ae1e74d0212c715d7 | Python | 22,707 | 614 | # 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 contextlib
import logging
import re
from dataclasses import dataclass, field
from typing import Any, Optional
import torch
import torc... |
edb2c3ec95f787f7d1350750e0c17ee0639b5e0db556ea99d8c87c5c92ba888d | Python | 22,707 | 571 | import copy
import logging
import sys
import types
import unittest
from pathlib import Path
from tempfile import TemporaryDirectory
from types import SimpleNamespace
from unittest.mock import patch, mock_open
from GMXMMPBSA.exceptions import InputError, MMPBSA_Error
from GMXMMPBSA.input_parser import input_file
def ... |
3a3a5b97307bef12237def649ea8a3cfc2acf8571e57adabcdd308f6360de284 | Python | 22,726 | 655 | from __future__ import annotations
import argparse
import logging
from contextlib import suppress
from importlib import import_module
from pathlib import Path
from typing import TYPE_CHECKING
from typing import cast
from cleo._utils import find_similar_names
from cleo.application import Application as BaseApplicatio... |
3069e6ed70da1f8ffc77c07c9ca4bcf850a6a5fb2c6aece56ae514d9eadda4a0 | Python | 22,840 | 553 | #### ::: utils for DNABERT-viz motif search ::: ####
import os
import pandas as pd
import numpy as np
def kmer2seq(kmers):
"""
Convert kmers to original sequence
Arguments:
kmers -- str, kmers separated by space.
Returns:
seq -- str, original sequence.
"""
kmers_list = kmers... |
aeaca17b68f188e971a6a0cf2a63fb3fe0bc54d6a6b2ce9b7b5ed323c3c4beb3 | Python | 22,871 | 608 | import logging
from functools import partial
from typing import Literal, Tuple
import jax
import jax.numpy as jnp
from jax.experimental import pallas as pl
from .mhsa import mhsa_kernel, reference_mhsa_kernel
from .mhsea import mhsea_kernel, reference_mhsea_kernel
from .utils import (
big_number,
compiler_par... |
2b1f94044fbc3ebad6f76fcd9e82241a9f7c818b3f94f6a698947079b0b046f5 | Python | 22,873 | 451 | """
Parsing and length/attribute extraction for genome-annotation files (GTF and GFF3).
This module is the single home for all GTF/GFF parsing in RNAlysis. The three public helpers
(:func:`map_transcripts_to_genes`, :func:`get_genomic_feature_lengths`, :func:`map_gene_to_attr`) are
consumed from ``filtering`` and ``fa... |
58f95385f2fbfec8a23a81896f7875b9b902b13259c5f8cbedc1b7de9d734ec8 | Python | 22,903 | 613 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 7 14:15:46 2023
Formerly titled 'AFOF3D_OL_record.py'
@author: nagellab/mayc06
"""
## To use this code, simply hit run in a python ide like spyder. This code has
## three sections: the importer section first, then the definition of the
## Handler class, which... |
b1963d42be5ec807a30785b39080c2ce28f810f22e4c8a110d35675243604487 | Python | 22,903 | 539 | import argparse
import numpy as np
import os
import bigstream.io_utility as io_utility
import bigstream.utility as ut
from dask.distributed import (Client, LocalCluster)
from bigstream.configure_bigstream import (configure_logging)
from bigstream.configure_dask import (ConfigureWorkerPlugin,
... |
0f3059d21edcd40871feead010148e95fd89c38a29fc415425c10c0393ecb981 | Python | 22,920 | 620 | # /usr/bin/env python
'''
Written by Kong Xiaolu and CBIG under MIT license:
https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
'''
import os
import numpy as np
import torch
import time
import math
import scipy.io as sio
import CBIG_pMFM_basic_functions_main as fc
import warnings
def torch_max(A, B):
if... |
16d07cbddd88b57568d06c613fac16140ac5bdb76c03f41d88044425fe1cf92c | Python | 22,943 | 656 | from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn as nn
from torch.distributions import Categorical, Dirichlet, MixtureSameFamily, Normal
from torch.distributions import kl_divergence as kl
from scvi.distributions.... |
abb7a4d0c0927c7cc002fcfbc448bd435dc6e2d4d6ad43b1b90335e60ceecfcf | Python | 22,945 | 687 | # 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.
from dataclasses import dataclass
from enum import Enum, auto
import math
import numpy as np
from typing import Tuple, List, Optional, Dict
i... |
f3f7c80cb41f98cb690928f0e97cbc566126faf7ec9b7a1ed7f7b9d68fac1d8b | Python | 22,957 | 486 | """Page 7: Mechanism Explorer."""
import streamlit as st
import plotly.express as px
import plotly.graph_objects as go
import pandas as pd
import numpy as np
from utils import PIPE_ORDER, PIPE_COLORS, ROLE_COLORS, DEGRADE_COLORS, style_figure
# ── Lazy utilization computation (cached) ───────────────────────────────... |
a06c2c9ac63866766b4b770bcd58f92617da9af13c0533786bfd6012d08695a4 | Python | 22,960 | 627 | # 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
import os
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
import torch
from omegaconf ... |
232eda763e1109dca1e5fc9ffd7c78ce53e246528a0a9ec2d886d6d63598b76d | Python | 22,982 | 762 | import os
import tempfile
import unittest
import numpy as np
from skbase.utils.dependencies import _check_soft_dependencies
from pgmpy import config
from pgmpy.example_models import load_model
from pgmpy.factors.discrete import TabularCPD
from pgmpy.models import DiscreteBayesianNetwork
from pgmpy.readwrite import NE... |
d83ecf621682259d7a8a446634a39059f6e0d64f9b6ef6ab071c8785c2ff4e60 | Python | 23,011 | 551 | # call py.test from <PROJECT_ROOT> folder.
import os, sys, subprocess
sys.path.append(os.getcwd())
import pandas as pd
import numpy as np
import pytest
# features:
# E - extract
# C - complete tag indices
# A - awk a subset of SNPs
tests_overview = '''
test_ld[21,22] - generate --ld-file ... |
87f55783543768da60cacd4cbc90f6c58eba3e248dbf786f1f0949cd9130280e | Python | 23,028 | 646 | from __future__ import annotations
import base64
import hashlib
import os
import plistlib
import re
import subprocess
import sys
from functools import cached_property
from pathlib import Path
from subprocess import CalledProcessError
from typing import TYPE_CHECKING
import tomlkit
import virtualenv
from cleo.io.nul... |
d8e9e7a39ac52b24806eb36520faed61d9936477354cf38c322c76a75e091aed | Python | 23,064 | 665 | import math
import numpy as np
import torch as th
import torch.nn.functional as F
from torch import nn
from numbers import Number
from einops import rearrange
from abc import abstractmethod
from dataclasses import dataclass
from timm.models.vision_transformer import Mlp
from torch.nn.functional import scaled_dot_produ... |
b3ae16a17cabf7c284d0d49c166be126e0e88fa4e1c1fa8ab819ab2b8107d649 | Python | 23,067 | 628 | """
Pure Excel export functions for photometry-behaviour alignment.
No UI framework dependencies — all Tkinter widget values must be resolved
by the caller before passing into these functions.
"""
from __future__ import annotations
import re
from pathlib import Path
import numpy as np
import pandas as pd
from src.... |
b0dc806dcd2efbed3796408dd051229919019a15c078ab851381d8e9b5f503d6 | Python | 23,095 | 594 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
from collections import defaultdict
from dataclasses import dataclass, field
from functools import cached_property, lru_cache
from typing import Iterable, Protocol, Sequence, Type, TypeVar
import numpy as np
import numpy.typing
import ... |
3a3af98938bc6327453a15bbf9aa7e9a9e88b8b32ed22292f5ba3f7a42768af5 | Python | 23,098 | 620 | # /usr/bin/env python
'''
Written by Kong Xiaolu and CBIG under MIT license:
https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
'''
import os
import numpy as np
import torch
import time
import math
import scipy.io as sio
import CBIG_pMFM_basic_functions_main as fc
import warnings
def torch_max(A, B):
if... |
81aa3aa22d79847e981e3d6fd0e75a25c28399b55175927b340a63138f314ff0 | Python | 23,103 | 540 | import sys
import os
import argparse
import numpy as np
import pandas as pd
import torch
import wandb
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import balanced_accuracy_score, confusion_matrix
from sklearn.preprocessing import LabelEncoder
from sklearn.model_selection import StratifiedKFol... |
6475c83089f4979be2ce1090ce2c4a82d46b5c91d36f86596fa365ca666bb2a1 | Python | 23,117 | 601 | import itertools
from collections import namedtuple
import numpy as np
import pandas as pd
from tqdm.auto import tqdm
from pgmpy import config
from pgmpy.factors import factor_product
from pgmpy.models import DiscreteBayesianNetwork, DiscreteMarkovNetwork, MarkovChain
from pgmpy.sampling import BayesianModelInference... |
52d4f74eea52126b6fd1cf5da1a5f6861e1ca90894db83ed184f3fea2e041235 | Python | 23,125 | 595 | # 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 random
import json
import numpy as np
import torch
import pickle
import math
from tqdm import tqdm
class Predictor(object):... |
7037498ba78e8a67a5621ba85035479afe4ecdb38db0d0aa2711f33532230594 | Python | 23,145 | 639 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Copy of OSS-DBS LeadSettings
"""
import os
import numpy as np
#from scipy.io import loadmat
import h5py
from dataclasses import asdict
AMPLITUDE = -1.0 # in mA
HEMI_SUFFIX = ['_rh','_lh']
from ossdbs.electrodes.defaults import default_electrode_parameters
class Lea... |
d3cba64623d8ff6d6b11b05c5fd3ebd30a410494d708a8a225a34b2fe3b3fcc9 | Python | 23,149 | 607 | #!/usr/bin/env python3
from ast import literal_eval
from typing import List, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import checkpoint_utils, utils
from fairseq.data.data_utils import lengths_to_padding_mask
from fairseq.models import (
FairseqEncoder,
FairseqEnc... |
41b481a757534319d63a4f5b2cdd6ba2000a766d3ef809a5fd994f203cffdef6 | Python | 23,199 | 609 | import pytest
from rnalysis.exceptions import InternalError
from rnalysis.utils.parsing import *
from rnalysis.utils.parsing import _parse_r_arg
class DummyClass:
def __init__(self):
pass
def __eq__(self, other):
return type(self) == type(other)
@pytest.mark.parametrize('is_input_path', [T... |
33facfd5eb0396be42a34a73a30226ac88b0738c2d8f6d6fc04886a5d751a93e | Python | 23,204 | 562 | import os
import warnings
import dill
import numpy as np
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import classification_report, confusion_matrix, roc_curve, ... |
80e1008fea621617f76d332f3646732592f6efd86b91b6136ba125d3067f6da7 | Python | 23,235 | 724 | from __future__ import annotations
import warnings
from typing import TYPE_CHECKING
import torch
import torch.nn.functional as F
from torch.distributions import Distribution, Gamma, constraints
from torch.distributions import Poisson as PoissonTorch
from torch.distributions.utils import (
broadcast_all,
lazy_... |
0bf6c6dd261b002085801615567616c87f7ccbf24a0c49cbd66b2a28049f66e0 | Python | 23,248 | 644 | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 cop... |
afbe14a2ac4aca25e5dde6565fffae65c627fd9a4b51623e72641799c7e85ca5 | Python | 23,260 | 669 | from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from packaging.utils import canonicalize_name
from poetry.core.constraints.version import parse_constraint
from poetry.core.packages.dependency import Dependency
from poetry.core.packages.dependency_group import MAIN_GROUP
from poetry.... |
3856a3d7be37f78e0f214ee7d4f29d05f1ca14218b67539d67c9a16e992f670c | Python | 23,316 | 847 | #!/usr/bin/env python
#
# Copyright 2008, 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... |
82f3985be420f3a572aae2f8824b5043f1feec5719f15a6864048796c616efa5 | Python | 23,343 | 681 | import os
import tempfile
import unittest
import numpy as np
import numpy.testing as np_test
from skbase.utils.dependencies import _check_soft_dependencies
from pgmpy import config
from pgmpy.factors.discrete import TabularCPD
from pgmpy.models import DiscreteBayesianNetwork
from pgmpy.readwrite import XMLBIFReader, ... |
d20b0e2acbfb7494baba81d4c3545d69398a644a6c83ce2de20d36270866ac6e | Python | 23,369 | 620 | from __future__ import annotations
import csv
import os
import platform
import shutil
from importlib.util import cache_from_source
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from poetry.installation.uninstaller import UninstallPathSet
from poetry.installation.uninstaller import _normali... |
aaf051051cb26a3394c9c695896b44fcbb8f4c4d257e12a86115f864b90dfbef | Python | 23,375 | 610 | """PyTorch module for Contrastive VI for single cell expression data."""
import numpy as np
import torch
import torch.nn.functional as F
from torch.distributions import Normal
from torch.distributions import kl_divergence as kl
from scvi import REGISTRY_KEYS
from scvi.distributions import ZeroInflatedNegativeBinomial... |
95d6ed6e3d48a7563c7752373a28f763c035b9c48e7c8e65e0a9877c9fca7f36 | Python | 23,398 | 550 | import fly_plot_lib_plot as fpl
import matplotlib.colors as mcolors
import matplotlib
import matplotlib.pyplot as plt
import cvxpy
import pandas as pd
import numpy as np
import scipy
import pynumdiff as pynd
red_cmap = mcolors.LinearSegmentedColormap.from_list('red_cmap', ['orange', 'orange'])
def plot_trajectory(ax... |
14f075171a02e6032598fddcd6882cce80c7d417c156899190c7234b1ce4609f | Python | 23,402 | 576 | """
Fast cross-correlogram functions.
"""
import numpy as np
from bombcell.save_utils import global_bc_cacher
def acg(spike_train, cbin, cwin,
fs=30000, normalize="hertz",
log_window_end=None, n_log_bins=10,
again=False, cache_results=True, cache_path=None):
"""
Compute auto-correlogr... |
f422bf15735dbf883ce9ff7bf5b9d9e24b60082f35a917865b3c46e4dbaba6a3 | Python | 23,412 | 675 | # 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 contextlib
import copy
import logging
import math
from argparse import Namespace
from dataclasses import dataclass, field
from typing i... |
b8ab4aa208a75a87f0e640f384caa41d677c3015815d984b7d6c3720f11cef7e | Python | 23,439 | 518 | # 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 typing import Any, Dict, Optional, List, Tuple
import torch
import torch.nn as nn
from fairseq import utils
from fairseq.... |
b780342d769c1f3a21ab1fc66f962e4da76f38d23f5a3270eb1fb5a068c3b06d | Python | 23,440 | 553 | import numpy as np
import pdb
import os
import h5py
import random
from sklearn.model_selection import StratifiedKFold
import math
import time
from matplotlib import pyplot as plt
# import seaborn as sns
import pandas as pd
plt.switch_backend('agg')
import glob
import pdb
import argparse
import sys
d... |
a68146a0e58dcf5faccf647f08ecb231a62d97ec26fcd5e56722bf701b2abdb3 | Python | 23,441 | 698 | #!/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.
from dataclasses import dataclass
import hydra
from hydra.core.config_store import ConfigStore
import logging
from ome... |
676de784196213c4d7b8298fa93fca89485c2f00a47642156841a49d2f046a84 | Python | 23,444 | 515 | #!/usr/bin/env python
"""Applicability diagnostic for first-order slip apparent-permeability correction.
This standalone post-processing script follows the Step 5 physics definitions in
app.py. It does not retrain the CNN and does not rerun LBM. The purpose is to
identify the Knudsen-number range where k_app = k_int(1... |
a4f4924479b7d452a2e688015d48c5e44d828e4c9bf6b5fe02758cabc9a8b9d3 | Python | 23,461 | 642 | from dataclasses import dataclass, field
from typing import Callable, Dict, Optional
import haiku as hk
import jax
import jax.numpy as jnp
from haiku import initializers
from nucleotide_transformer.chatNT.gpt_rotary import (
RotaryEmbedding,
RotaryEmbeddingConfig,
)
from nucleotide_transformer.chatNT.types im... |
5122da7bf866cfa2024b463d85300974acc5d7773e31b46724274ea3da37ded4 | Python | 23,499 | 577 | from __future__ import annotations
import argparse
import csv
import json
import os
import platform
import statistics
import subprocess
import sys
import threading
import time
from concurrent.futures import ProcessPoolExecutor, as_completed
from contextlib import nullcontext
from pathlib import Path
from typing import ... |
ddca73ad8525989297676e8ca82e4e6a5dd9cc4290993d60b88ffe905327ac36 | Python | 23,512 | 541 | import numpy as np
import json, h5py, os, timeit, logging, argparse
import acoustic_inverse_simulation
import func.utility_func as uf
from scipy.ndimage import convolve1d
from scipy.fft import fft, ifft, fftshift, fftfreq
from scipy.linalg import cholesky
from copy import deepcopy
import matplotlib.pyplot as pl... |
2c283c29914104798e2e42313bfe7b83ad310068b8c457007521321f758dd8d7 | Python | 23,515 | 675 | import numpy as np
import nibabel as ni
import os
from nipype.interfaces.base import (
traits,
TraitedSpec,
File,
BaseInterface,
BaseInterfaceInputSpec,
)
from fetpype.nodes.utils import get_run_id
import logging
log = logging.getLogger("nipype.workflow")
class CropStacksAndMasksInputSpec(BaseInt... |
cfb12ae845311877af3a989701b7d0e3c184e04a24b7641cb79afdb765abf459 | Python | 23,525 | 601 | '''Spectral Event Analysis functions'''
# Authors: Tim Bardouille <tim.bardouille@dal.ca>
# Ryan Thorpe <ryvthorpe@gmail.com>
import numpy as np
import scipy.signal as signal
import scipy.ndimage as ndimage
import scipy.ndimage.filters as filters
import matplotlib.pyplot as plt
def tfr(timeseries, freqs, s... |
3c81da121424e4effb0c9c1df9d55d2d4dda87f33c3b744627b12b5bf348f906 | Python | 23,533 | 705 | """
"""
import argparse
from datetime import datetime
from pathlib import Path
import gc
import h5py
import nibabel.freesurfer.mghformat as mgh
import numpy as np
import scipy.io
import torch
from numpy.random import default_rng
from scipy.optimize import linear_sum_assignment
from scipy.spatial import distance_matri... |
6ebfc46d179c9d8dd9adf4331482d00a35fdb0e80de7f45977b36390a274cf8c | Python | 23,536 | 530 | import numpy as np
from typing import List, Literal, Optional, Tuple, Union
import torch
import torch.nn as nn
from torch import Tensor
from torch.nn.functional import normalize
from torch_geometric.data import Data
from torch_geometric.utils import to_dense_adj
from torch_geometric.utils import negative_sampling, rem... |
27a0f3e287b8f8a209042d64c15773ca8b77153497b41e6d80345e1db502316d | Python | 23,601 | 690 | # Copyright 2022 InstaDeep Ltd
#
# Licensed under the Creative Commons BY-NC-SA 4.0 License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://creativecommons.org/licenses/by-nc-sa/4.0/
#
# Unless required by applicable law or a... |
03177af5b5968c750931087190af45185f4f599f381d459d87ad6b70496b0477 | Python | 23,647 | 519 | import logging
import os
import sqlite3 as sqlite
import sys
from collections import defaultdict
from typing import Dict, List
import numpy as np
import pandas as pd
import cytograph.plotting as cgplot
import loompy
from cytograph.annotation import AutoAnnotator
from cytograph.clustering import ClusterValidator
from ... |
81ada1731dddd7103f49899a4c0d6a9cf27fcccf571f6a80246477802224e05b | Python | 23,650 | 730 | # 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 numpy as np
import scipy
import torch
import torch.multiprocessing as mp
from fairseq import checkpoint_utils, options
from ... |
00b423ecc1e316cd1394834f53dc036899b3ff79fc4f5600ba0ba824c74b7b87 | Python | 23,652 | 621 | """
Mask R-CNN
Display and Visualization Functions.
Copyright (c) 2017 Matterport, Inc.
Licensed under the MIT License (see LICENSE for details)
Written by Waleed Abdulla
"""
import os
import sys
import random
import itertools
import colorsys
import numpy as np
from skimage.measure import find_contours
import matplo... |
32b56f404881513e3ed7d7aad98926775af67c7c7ebdc7bd6975dc9a534657f0 | Python | 23,662 | 642 | #!/usr/bin/env python3
"""
Generate DWI test set for FSL topup/fugue and diffusion model evaluation.
This script generates a small test set (10% of subjects) with:
- pe_axis=0 only
- Both pe_sign directions (+1 and -1) saved in each NPZ
- Ground truth DWI for quantitative comparison (PSNR, SSIM, NMSE)
Each output NPZ... |
9569c5f4436bb0008ecaafa9d53bf5186ab69e71209469bf371d0a5a164e7afc | Python | 23,677 | 524 | import itertools
from itertools import chain
from pathlib import Path
import h5py
import joblib
import numpy as np
import pandas as pd
from joblib import Parallel, delayed
from scipy.integrate import quad
from scipy.stats import gaussian_kde, spearmanr
from sklearn.model_selection import train_test_split
from analysis... |
9ebbf7181e82ac8606bedaa9b809a2460a1cf78d6ad3708e50046f9a514e58ee | Python | 23,686 | 627 | """Main user interface for FISSA.
Authors:
- Sander W Keemink (swkeemink@scimail.eu)
- Scott C Lowe
"""
from __future__ import print_function
from past.builtins import basestring
import collections
import glob
import os.path
import sys
import warnings
import numpy as np
from scipy.io import savemat
from . ... |
7a6bac10fe62212b501b930eea3c73b9ee229ac7ad3d17e705dd0f213c8e66d4 | Python | 23,702 | 494 | import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
# Set random seed
import random
import numpy as np
import torch
from DENNs import PINN2D
import torch
import torch.nn as nn
from utils.NodesGenerater import genMeshNodes2D
from utils.NN import stack_net
... |
48ab7bbc249da8769532117853a65d28e9a93a452592f7a0b08d005c9cae9730 | Python | 23,713 | 645 | # Authors: Christian O'Reilly <christian.oreilly@sc.edu>
# Scott Huberty <seh33@uw.edu>
# License: MIT
"""class to wrap an mne.raw object in a dash plot."""
import dash
from dash import dcc, html, no_update
from dash.dependencies import Input, Output
import dash_bootstrap_components as dbc
# time series plo... |
e90148282492134452655e27b9698e5120267c61ffb5d0b77bb5a9c2f518647f | Python | 23,713 | 438 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import os
import sys
class opts(object):
def __init__(self):
self.parser = argparse.ArgumentParser()
# basic experiment setting
self.parser.add_argument('--task', default='ctdet',... |
9f485ffcab6a827401b05a6a86a84893e32d2600ef8d5763a195442e1b4f8ddd | Python | 23,718 | 624 | import re
from collections.abc import Hashable
from itertools import product
from string import Template
import numpy as np
import pandas as pd
import pyparsing as pp
try:
from pyparsing import (
CharsNotIn,
Group,
OneOrMore,
Optional,
Suppress,
Word,
ZeroOr... |
80c38ef76de485a565c33fe7527b9623faa8131641212d5d8fd8b1c22c8a1380 | Python | 23,734 | 531 | import numpy as np
from typing import List, Literal, Optional, Tuple, Union
import torch
import torch.nn as nn
from torch import Tensor
from torch.nn.functional import normalize
from torch_geometric.data import Data
from torch_geometric.utils import to_dense_adj
from torch_geometric.utils import negative_sampling, rem... |
ac79810a89dff3dced0351a920f6e1014ab007f79f2376c2c90c7c5dad851ad9 | Python | 23,754 | 685 | import os
import torch
from torch import nn
from torch.utils.data import Dataset, DataLoader
import time
import traceback
import numpy as np
from anndata import AnnData
import scanpy as sc
from typing import List, Tuple, Dict, Optional
from scgpt.tokenizer import tokenize_and_pad_batch, random_mask_value
from scgpt im... |
6920b3d3cefaaf462bbc40ff276839e5b265887982c87e7f74d3ee00867a7a6c | Python | 23,762 | 695 | #!/usr/bin/env python3
"""
unit_func_eval.py
---------------------------
Standalone: Unit-level kNN neighborhood GO enrichment on segment embeddings
(no prototypes, no clustering).
Do segments exhibit functional coherence beyond discrete prototype assignments?
Method:
- Each segment has an embedding.
- For each quer... |
4e82c6e14f4d3127de6b9277e0fbaf612471132f40f744787ee0132c5bd4f05c | Python | 23,766 | 566 | import logging
import warnings
from collections.abc import Sequence
from functools import partial
import numpy as np
import pandas as pd
import torch
from anndata import AnnData
from pyro import infer
from scvi import settings
from scvi.model._utils import _get_batch_code_from_category, parse_device_args
from scvi.ut... |
6cc5b7cb71043f498411f1a320fd056b15364cd208905c2301ca76189ac5bb4e | Python | 23,830 | 622 | import pytest
from pgmpy.base import DAG, PDAG
class TestPDAG:
def test_init_normal(self):
# Mix directed and undirected
ebunch_mix = [("A", "C", "->"), ("D", "C", "->"), ("B", "A", "--"), ("B", "D", "--")]
pdag = PDAG(edge_list=ebunch_mix)
assert set(pdag.nodes()) == {"A", "B", "... |
d040c15c54649d3435bb40bf7363d68c89db7289574475f12f8056e7b78b76cd | Python | 23,830 | 586 | import os
from typing import Tuple, Any, Dict, Optional, List
from datetime import datetime
import numpy as np
def _describe_scipy_struct(obj, indent: int = 2) -> None:
pad = " " * indent
try:
# scipy mat_struct-like
fields = getattr(obj, "_fieldnames", None)
if fields:
fo... |
a8997afb526211b9b40c9ee07dc0b6f89cd5bc837c72642dc02a9df1cb44f477 | Python | 23,835 | 468 | import numpy as np
from tqdm import tqdm
import matplotlib.pyplot as plt
import sklearn.cluster as clust
from scipy.linalg import inv, sqrtm, eigh
from collections import Counter
from sklearn.manifold import TSNE
from warnings import warn
from copy import deepcopy
from matplotlib.lines import Line2D
import torch
from m... |
bd76504c29e84ff031cc0cbd98ef09b93ff50d7f303b4f9d80040cd52b2f494f | Python | 23,845 | 449 | from typing import Union, List, Tuple
import argparse
import itertools
import multiprocessing
import numpy as np
import os
from os.path import join
from pathlib import Path
from time import time
import torch
from torch._dynamo import OptimizedModule
from tqdm import tqdm
import openvino as ov
import openvino.propertie... |
51cc1bbf978b84fa0929ea7773137bd93cea5bb6a94ce79cbc8ee21ec11c5c55 | Python | 23,849 | 607 | import functools
from typing import Callable, Sequence
import jax
import jax.flatten_util as jfu
import jax.numpy as jnp
import jax.tree_util as jtu
import numpy as np
from .ad import hessian, jacrev
from .api import (
JAC_DIM,
Array,
Axes,
CustomTraceJacHessianJac,
ExtraArgs,
ForwardFn,
F... |
b9cf7aaea829f5d0fc3ae8c75d92d6024e57ea51c165f12c2dd0df781c0a1138 | Python | 23,983 | 430 | from typing import Dict, Tuple, Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
# Reuse proven building blocks from existing MegaNet
from dgr.models.phc_e2e_mega_net import (
DeeperModalityEncoder,
AttentionBlock,
DeformableCrossAttention,
CrossModalFuse,
HybridTransfor... |
9b81f1f9a01051841c6d767dad6bf510cec88897051bc3672a7ce989598245db | Python | 24,020 | 650 | """Spanning read clustering module."""
from abc import ABC, abstractmethod
import collections
from copy import copy
from itertools import filterfalse
import edlib
import numpy as np
from medaka import abpoa
import medaka.common
import medaka.smolecule
from medaka.tandem.abpoa_utils import run_abpoa_consensus
from m... |
d31584e80fe63b5310493a0b973ace203342b7dd7f7a44d81b58826c998ad4b4 | Python | 24,031 | 622 | # Copyright 2015 Google Inc. 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 applicable law or a... |
669e24d510c20eb057f444bbe1924ba2e8450b2851be1979eb66e2e76103dfdd | Python | 24,051 | 668 | # @license
# Copyright 2023 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... |
315d3190ffae35eb5c9f837ffb85ea33db384ad7c90a44d49178f258a8f2140c | Python | 24,073 | 548 | """
figures/plot_driven.py
======================
Figures for the input-driven regime comparison (memory experiment).
Figure 1 — Phase diagram heatmaps (2 panels)
(a) C_mem_lmc_corrected_k20 in (g, η) ε=0.25, T_bit=50ms
(b) KQ in (g, η) ε=0.25, T_bit=50ms
Figure 2 — ε-dependence at ... |
5c6a60e6d48602d6aff48416d9d84171e2a703ac201e5c9c084056645e3b62f6 | Python | 24,086 | 698 | # -*- coding: utf-8 -*-
"""Preprocessing utilities for the working-memory EEG analysis."""
from pathlib import Path
import mne
import pandas as pd
import numpy as np
import scipy.signal
import scipy.stats
import matplotlib.pyplot as plt
import pickle as pkl
#%%
#################### LOADING INFORMATION AND DATA ... |
1f74804257233fd644f8b8c8ac6a969664774cd8229739f9355d287a6f3f250b | Python | 24,115 | 580 | """Provenance stamp for the `precompute-encodings` HDF5.
Neither the tokenizer, the window nor the stride is recoverable from the stored
arrays: a mismatched tokenizer yields an array of exactly the right shape over
the wrong vocabulary, and the aggregated row count comes to the document's
token count under any window... |
b0f6b2231c379820a250b4c6c8f235347b1c02d40f2caebd9824c38a558ac121 | Python | 24,130 | 653 | #!/usr/bin/env python3
"""
Author: Ken Chen
Email: chenkenbio@gmail.com
"""
import argparse
import os
import sys
import numpy as np
import gzip
import json
import warnings
import pickle
import time
import shutil
import random
import torch
from collections import OrderedDict
from typing import Any, Dict, Iterable, List... |
4bce533e04f574435914221168984f1b6fb56ed11c53a5fa5b502100814ab670 | Python | 24,137 | 594 | """A LightningModule that represents a task
where a model predicts a label for each frame
in a time series, e.g., each time bin in
a window from a spectrogram."""
from __future__ import annotations
import logging
from typing import Callable, Mapping
import lightning
import torch
from .. import common, transforms
fr... |
623f41e9b403e1ac676ad079335538c30f132b6208e70f3f9a4dad6bb46b3e74 | Python | 24,142 | 797 | # 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 json
import os
import random
import shutil
import string
import sys
import typing as tp
from io import StringIO
import... |
f6f363c4ec8cd1da04435d7f639a4d72412e6cd41379c829b91a295184b98513 | Python | 24,158 | 540 | ## script for plotting boxplots and scatter plots of simple stats such as count of approaches, count of interactions, chasings etc...
import matplotlib.pyplot as plt
import numpy as np
import igraph as ig
import networkx as nx
import pandas as pd
import os
import sys
import pandas as pd
import seaborn as sns
from scip... |
fe4f8261c13c57ad4b89a7819d2bc32801f3a117f463d6fc75979cbd18445ca2 | Python | 24,167 | 483 | import torch
import torch.nn as nn
import random
import warnings
import numpy as np
from .SlidingAttention import Intercoder
random.seed(1234)
warnings.filterwarnings("ignore")
def index2onehot(pep, hla, tcr, device):
acid = torch.tensor([14, 7, 0]).to(device)
alkali = torch.tensor([5, 8, 17, 0]).to(device)... |
b9d28a07f216cb0ff05276570269f4ccd0dd02d99411fbf1c797892b6f48b62d | Python | 24,174 | 661 | from os.path import join
from analysis.vis_utils import get_reactome_pathway_names
from config_path import BASE_PATH
module_path = join(BASE_PATH, 'analysis/figure_3')
import pandas as pd
import numpy as np
from os.path import join
import matplotlib.pyplot as plt
'''
first layer
'''
def get_first_layer_df(nlargest):... |
ba05ef959a55ef67107e84a6bcbb9bbdef23cd495963c86b1bbcd4b19eea4937 | Python | 24,187 | 634 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
import xml.etree.ElementTree as etree
from collections import defaultdict
class PomdpXReader:
"""
Initialize an instance of PomdpX reader class
Parameters
----------
path : file or str
Path of the file containing PomdpX information.
strin... |
dd148ec0d5603a0265b1b34c6e1bbfb3940b2b9b56f142558f8855cf00739705 | Python | 24,210 | 557 | def filter_labels(input_file, output_file, target_classes):
"""
过滤指定类别的目标并将结果写入新的文件中。
:param input_file: 输入文件的路径
:param output_file: 输出文件的路径
:param target_classes: 需要过滤的类别号集合
"""
with open(input_file, 'r') as infile, open(output_file, 'w') as outfile:
for line in infile:
... |
eba47206598a0e93e2f662d9c87343222556f236ac37373236e3970c43fb521d | Python | 24,211 | 578 | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
# Modified by Roshan Rao
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Licens... |
9d9257e2c3d0177a25529725c08968bec29a8a01830562e7a252949ce0d3f155 | Python | 24,217 | 520 | def trial_events(subject_id, task, direction):
# subject_id: e.g. 100307
# task: e.g. EMOTION. Must match one of the task conditions below
# directoin: LR|RL. determines which eprime and HCP block deisgn data to use for constructing the design
#
# this function returns single trials for all events ... |
3d237d10c9e3d485d8967661279e70a03fb0d19ae71b744852e79daa675af8cb | Python | 24,246 | 527 | from copy import deepcopy
import argparse
from time import time
import sys, os
import pickle
import scanpy as sc
import numpy as np
import torch
import torch.optim as optim
import torch.nn as nn
from torch.optim.lr_scheduler import StepLR
from .model import GEARS_Model
from .inference import evaluate, compute_metric... |
cbc09ba76361e074b3d1600a35324a43237efda6a3877e7d6a340b65c747e1f7 | Python | 24,268 | 622 | #!/usr/bin/env python3
"""
Fair Comparative Benchmark Analysis for RAG-GNN Framework
- Fair node classification (no information leakage)
- Publication-quality figures with Set2 colors
- Comprehensive evaluation across multiple tasks
"""
import numpy as np
import pandas as pd
import networkx as nx
import matplotlib.pyp... |
102dc0340eaed302b58b61ec30da64a9f86667caba6039bb41b3a7a81ec3c50b | Python | 24,277 | 614 | """Scoring a `Linker` against gold identifiers BRENDA did not produce.
A mention is judged when the outside authority's identifier pairs with exactly
one BRENDA entity of the types asked for, never because the linker returned
one candidate — selecting on the linker's side would make its own answer the
gold. See the ev... |
f38b9d27e983d2037c9e16810aef19fad854382fafe50857a74b7d5033f1a104 | Python | 24,306 | 727 | import argparse
import numpy as np
import tskit
import sys
import os
import io
import yaml
import torch
import moments
import stdpopsim
import ray
import numdifftools as nd
import matplotlib.pyplot as plt
import matplotlib.lines as lines
import seaborn as sns
import pickle
from torch import Tensor
from sbi.inference i... |
0eafe2ee04b35719cc0316a083bc10f1444b1d26530a8bb1910fb2f16f05c62e | Python | 24,346 | 601 | import os
import numpy as np
from matplotlib import pyplot as plt, patches
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.cm import get_cmap
from mdt import get_slice_in_dimension
from mdt.visualization.maps.base import Clipping, Scale, Point2d
from mdt.visualization.utils import MyColourBarTic... |
d87c3d50ba35f6e781844ab568965881d2c5caded37d54a648685cef4583f153 | Python | 24,348 | 561 | """
Pipeline 5: Formal Layer 2H Bulletproof Analysis on EIF2S1-PELO
Author: Drake H. Harbert (D.H.H.)
Affiliation: Inner Architecture LLC, Canton, OH
ORCID: 0009-0007-7740-3616
Date: 2026-04-29
Description:
Computes formal continuous Weighted Jaccard, all three sign-treatment
formulations, Type 1/2/6 dissociat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.