sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
b7c31256f6a0d1e19a96a162b44ffdc4c190ae3f222f674aff8e413a11d838fb
Python
6,950
236
from models.model import * from objective import * from models.losses import * import torch from scipy.optimize import minimize import numpy as np import os import matplotlib.pyplot as plt import matplotlib as mpl from objective import Objective import PyMieScatt as pms import argparse ### refractive index dictiona...
405c77687d854d0ea8235ee101b00d4f781f7cf95daf3820312decd40854653f
Python
6,951
204
from rdkit import Chem import torch from dgllife.utils import * from dgllife.utils.featurizers import CanonicalAtomFeaturizer, CanonicalBondFeaturizer from ocelotml_2d.mlp_features import * #from mlp_features import * import json from ocelotml_2d.MPNN_evidential import MPNNPredictor_evidential from ocelotml_2d...
eccdaf1fd4cf21ba6b8febaeb79449d887a353f3a4247258c54d151c66a9e384
Python
6,952
186
from pathlib import Path import numpy as np import pytest from learnMSA.config.config import Configuration from learnMSA.model.context import LearnMSAContext from learnMSA.model.tf.training import BatchGenerator, make_dataset from learnMSA.util import EmbeddingCache, EmbeddingDataset, SequenceDataset @pytest.fixtur...
cddfea70d7899e9d97e8c3bf6e6ba816cd67195b1b4a8e7ea73b0df2e6b7a08e
Python
6,953
183
import os import unittest import numpy as np from patch import p from arborize import define_model, neuron_build from arborize.exceptions import UnknownLocationError, UnknownSynapseError from ._shared import SchematicsFixture @unittest.skipIf( "NRN_SEGFAULT" in os.environ, "These tests are sk...
19e6c4df87e04e8c96c00b113e0ba1f2110f37a0aaa06fb985131746c8d50014
Python
6,954
186
import base64 import io import json import zlib from pip._vendor import msgpack from pip._vendor.requests.structures import CaseInsensitiveDict from .compat import HTTPResponse, pickle, text_type def _b64_decode_bytes(b): return base64.b64decode(b.encode("ascii")) def _b64_decode_str(s): return _b64_decod...
92be9d221e36ad2a9d5c4b42620f2a3949faaf1a163600dae45efd4980488809
Python
6,954
175
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pyre-strict from unittest.mock import patch import numpy as np import pandas as pd import torch from ax.benchmark...
0af4e3203033efc08a759876de8d798b0094fb0bfb915453ddb9a960dbaff45a
Python
6,955
181
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pyre-strict from copy import deepcopy from ax.adapter.base import DataLoaderConfig from ax.adapter.data_utils imp...
e3fd26974b03ed92c56259b8b49cc55a0ae58070f53a20b6fb5b3b7132cd8949
Python
6,955
227
""" Generators for the small graph atlas. """ import gzip import importlib.resources from itertools import islice import networkx as nx __all__ = ["graph_atlas", "graph_atlas_g"] #: The total number of graphs in the atlas. #: #: The graphs are labeled starting from 0 and extending to (but not #: including) this num...
2a6b183eb41b69dc183ed6c356685a5563e84dafd2c687559168bf66292607df
Python
6,956
178
import os import numpy as np from scipy import interpolate from types import SimpleNamespace from voluseg._tools.load_volume import load_volume from voluseg._tools.save_volume import save_volume from voluseg._tools.get_volume_name import get_volume_name from voluseg._tools.constants import ori, ali, nii, hdf from volu...
eea7222241d43e3c12c483f8c49e1963593754c25182550d7d80075e8bf3ecd3
Python
6,957
181
from spikingjelly.logger import logger import os from pathlib import Path from typing import Callable, Optional, Tuple from torchvision.datasets.utils import extract_archive from . import utils from .base import NeuromorphicDatasetFolder __all__ = ["DVSLip"] class DVSLip(NeuromorphicDatasetFolder): def __init...
53c5ee799bc97b04fdd26df2cd1e96e21d90f3913b3f23ebacb00563b3f01c97
Python
6,961
192
from matplotlib import pyplot as plt import matplotlib.patches as mpatches import pandas as pd import numpy as np import os from math import floor, ceil color_grey = '#B3B3B3' color_blue = 'cornflowerblue' color_red = '#D62728' color_green = '#60A917' # ================ =============================== # character ...
e8b472283043c5c8b02dc6e8ae6d5e81a299d8e93a4734f4257748edec4f4c38
Python
6,964
161
from datetime import datetime from functools import reduce from typing import Optional import tensorflow as tf from tensorflow.keras import layers from tensorflow.python.keras.losses import LossFunctionWrapper from tensorflow.python.keras.utils import losses_utils class PolicyWrapper(layers.Layer): def __init__(...
3cf892ab9f86b13d4bb1ff1fc2d1b018355fd6186fe592daae25ad7f39016c0c
Python
6,968
172
"""Functions for finding chains in a graph.""" import networkx as nx from networkx.utils import not_implemented_for __all__ = ["chain_decomposition"] @not_implemented_for("directed") @not_implemented_for("multigraph") @nx._dispatchable def chain_decomposition(G, root=None): """Returns the chain decomposition of...
8f567fff815a2582ec339b989fd1758b1e50dd05b3e911a78682f49e50f8c227
Python
6,968
185
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pyre-strict from typing import final import pandas as pd from ax.adapter.base import Adapter from ax.analysis.analysis import Analysis f...
2958e07a60db391d99326ba13f3fca3c7a116211721964e8f0cf16f3801c75e8
Python
6,970
176
# -*- coding: utf-8 -*- """ Created on Tue Feb 22 11:55:42 2022 @author: marcomau """ # GNN for displacement/stress field predictions import torch import torch_geometric from torch.nn import Sequential, Linear, ReLU, LayerNorm, LSTM, GRU from torch_geometric.nn import MessagePassing import functools impo...
18d9b10678f7fb84aeb7132c3f302526fa6bf1e68c0dcc7ad897d7cf764975ff
Python
6,973
176
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pyre-strict from __future__ import annotations from collections import defaultdict from copy import deepcopy imp...
860292f22a20bedbfd3519a0e20185ee0f88700f8e2a1fc2566ca1061a7dd1de
Python
6,974
167
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
a6e1c9e9392d0fa15854223858759978f69051c5fb78b1a024b77bb766d6649c
Python
6,974
211
from nl_expr.expression_walker import ( ExpressionWalker, PatternWalker, ResolveSymbolMixin, add_match, ) from nl_expr.expressions import Constant, Symbol from ..relational_algebra import ( ColumnStr, ExtendedProjection, FunctionApplicationListMember, NameColumns, NumberColumns, ...
35ed40b0fca344ee5585ee1e7b363cdb0f7e0be22fe352d5fe6d32feb3cea8b9
Python
6,979
213
import copy import math import random import numpy import torch from torch import nn from src.expressions_transfer import * USE_CUDA = torch.cuda.is_available() MAX_OUTPUT_LENGTH = 33 def time_since(s): # compute time m = math.floor(s / 60) s -= m * 60 h = math.floor(m / 60) m -=...
66a150c06c84c7faaa5351248b4c299413076cb37aa1051ce2780a7a2f22c7b6
Python
6,980
178
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
0f045703dddd4229a30c4e32e2e2685002abf8f50112db1432ba5dff2cc89385
Python
6,984
189
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pyre-strict from collections import defaultdict import numpy as np import numpy.typing as npt from ax.adapter.discrete import DiscreteAd...
3062b7336b0e45b6d6f5cd9e1f273f341d6d920ba65480df0ae158db4f817978
Python
6,986
272
import typing from .. import solver from .. import expressions from .. import logic from ..typed_symbol_table import TypedSymbolTable C_ = expressions.Constant S_ = expressions.Symbol def test_simple_symbol_query(): ds = solver.FirstOrderLogicSolver(TypedSymbolTable()) for s in range(5): sym = S_[i...
ffd716e4999f2183b1751e7f82de6fb9eeb6ceda1ae04e065966574597d87f24
Python
6,990
280
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pyre-strict from __future__ import annotations import traceback from abc import ABC, abstractmethod from collections.abc import Callable...
271ca69dbcb244c317a20b6154489b6565d6dddee195b4ba5dd888652b626136
Python
6,996
211
# Density and co-localisation of pre- and post-synaptic markers. # by Richard Butler, Gurdon Institute Imaging Facility, University of Cambridge # # Copyright 2021, 2022 Richard Butler # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as publ...
0a84547b1109b843c4565bac278c264acec3b21e7a7f0ade1dc16b5f135d87cb
Python
6,998
154
import os import argparse import sys import time from scripts.new_patient_pipeline.run_script_segmentation import run_script_segmentation from scripts.new_patient_pipeline.run_script_preprocessing import run_script_preprocessing from scripts.new_patient_pipeline.run_script_prediction import run_script_prediction from m...
f022fddf5562e1504d2a847a2fbd35d124d333a52596e47e8b5eee8cc1262bb6
Python
6,998
193
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pyre-strict import inspect from collections.abc import Callable, Iterable, Mapping from logging import Logger from...
662a7441c12ea757a1afacf3b57785cc6e501514f99fc39e1538688ed00f2ec7
Python
7,001
185
''' This code is borrowed from https://github.com/Namkyeong/BGRL_Pytorch ''' import numpy as np import torch import models import utils import data import os import sys import warnings from torch import optim from tensorboardX import SummaryWriter from sklearn import metrics from sklearn.linear_model import Logis...
b217630cd870c247f1c9625f48ebd2ef1eddcbdf781eab3a590d19383e5929af
Python
7,001
219
""" Algorithms for computing distance measures on trees. """ import networkx as nx __all__ = [ "center", "centroid", ] @nx.utils.not_implemented_for("directed") def center(G): """Returns the center of an undirected tree graph. The center of a tree consists of nodes that minimize the maximum eccentr...
3ef87432f4ca691b99bb058bfb0a49202d3394101c9d38aba522c98bef5ceea7
Python
7,006
195
import random import pytest import networkx as nx from networkx.utils import arbitrary_element, graphs_equal @pytest.mark.parametrize("prefix_tree_fn", (nx.prefix_tree, nx.prefix_tree_recursive)) def test_basic_prefix_tree(prefix_tree_fn): # This example is from the Wikipedia article "Trie" # <https://en.wi...
4713ed5339aa4ec8dc07c6fc8f627511598143d2df1e55e1a0f8de0d2903d4bb
Python
7,008
186
""" Created on 2020.05.19 @author: Jiahua Rao, Weiming Li, Hui Yang, Jiancong Xie Code based on: Shang et al "Edge Attention-based Multi-Relational Graph Convolutional Networks" -> https://github.com/Luckick/EAGCN Coley et al "Convolutional Embedding of Attributed Molecular Graphs for Physical Property Prediction" ->...
220388196efa391cc3fdb762196fa658cb8050baa43c363ff168e13cb0e00a13
Python
7,010
155
from src.models.wavelet_model import WaveletAI import tensorflow as tf import numpy as np from src.data import DataServing from src.custom_metrics import JaccardIndex from src.utility import bin_localisations_v2, get_reconstruct_coords,FRC_loss, timing from src.models.loss_functions import compute_loss_decode, compute_...
51bfab701bcb8a8fc468518f7b23a929033c05fc34faa2c4da5c3ebc6fb7b697
Python
7,010
190
import numpy as np import pandas as pd from sklearn.preprocessing import scale def _mvalue(da, scale_group=True, alpha=1): mc = da.sel(count_type="mc") cov = da.sel(count_type="cov") m = np.log2((mc + alpha) / (cov - mc + alpha)) if scale_group: group_axis = da.dims.index("group") m.va...
f49f50cc0fa09606d08d373c5ce60d944bf95bfe7ef1524954a80c7afa322640
Python
7,013
180
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
5a3da38535d9f0bc275e13c2cf88215647b41f62fcec46b0857950af0a20c6be
Python
7,014
228
from __future__ import print_function from itertools import repeat import collections import math import torch import torch.nn as nn from torch.nn import functional as F __all__ = ['Model'] WIDTH = [16,32,64,128,256,512] def _ntuple(n): """ Copied from the PyTorch source code (https://github.com/pytorch)...
e30ef62312e1a4511e686db36f688667ed81b791f3cc4a7e0e8df19c2a611e68
Python
7,018
197
import sys import time def _format_time(seconds): """Format seconds as hh:mm:ss. Parameters ---------- seconds : float Time in seconds. Returns ------- str Formatted time string in hh:mm:ss format. """ hours = int(seconds // 3600) minutes = int((second...
95b6adcaa5f3e7d79f4e3af6fec84d6dcf8764870e8bf5afa39ab04d4a9cf419
Python
7,019
233
""" Module for abstract classes interfacing matplotlib plots. """ import abc from typing import List, Tuple, Union import numpy as np from bsb import Scaffold from matplotlib import patches from matplotlib import pyplot as plt class Plot(abc.ABC): """ Matplotlib plot class interface. """ def __init...
d5b26b7cbdd6fffec3bc82707ed24f49f6a775ed9812d549f8119969ca8cb05e
Python
7,020
199
from dotmap import DotMap import torch import numpy as np from collections import deque from copy import deepcopy from loguru import logger from .losses.spectrum_loss import _spectrum_loss_fn from .losses.likelihood_regularization_loss import _likelihood_regularization_loss_fn from ..materials.material_collection imp...
d174f7e71bdfa4065426ba97142ecf179afb72eb00ef4e958543706698be36ac
Python
7,021
163
"""Mixin providing common wait methods that work across Selenium and Playwright.""" from typing import Any from galaxy.navigation.components import Target class WaitMethodsMixin: """ Mixin providing high-level wait methods. This mixin abstracts wait operations to work with both Selenium and Playwright ...
1ee4bc426a25be16138a3ce78d64ba448e0f1cfbf36b250a13c8994e36554ca0
Python
7,028
154
from collections import defaultdict import tensorflow.compat.v1 as tf from .layers import GraphConvolutionSparseMulti, \ DistMultDecoder, InnerProductDecoder, DEDICOMDecoder, BilinearDecoder, GraphAttentionMulti, GraphConvolutionMulti flags = tf.app.flags FLAGS = flags.FLAGS class Model(object): ...
b4f79939898a5b5bd023aeea0d2b8f8a83eaf69d85e92d2e131eab8062b30951
Python
7,030
205
""" Segment info DataFrame IO for processing tasks """ import os from sqlalchemy import select, text import pandas as pd from ... import io from .. import colnames as cn from . import filenames as fn SEG_INFO_COLUMNS = [cn.seg_id, cn.size, *cn.centroid_cols, *cn.bbox_cols] CHUNK_START_COLUMNS = [cn.chunk_tag, cn....
99868bca71f68a69f4982f97f57fd5a34023dad1fe50197d8c9d19287b36defe
Python
7,035
159
import tensorflow.compat.v1 as tf import numpy as np flags = tf.app.flags FLAGS = flags.FLAGS class DecagonOptimizer(object): def __init__(self, embeddings, latent_inters, latent_varies, degrees, edge_types, edge_type2dim, placeholders, margin=0.1, neg_sample_weights=1...
61b5dec57ac23e0b2fae5d069a9a75d9a24b752bd8b2e91f41a2149db0c5994d
Python
7,038
188
"""Typed description of Galaxy's app object.""" import abc import threading from typing import ( Any, Optional, TYPE_CHECKING, ) from kombu import Connection from typing_extensions import Protocol from galaxy.auth import AuthManager from galaxy.datatypes.registry import Registry from galaxy.di import Con...
f7d1c5f8af943331b905da83cd49e673e71db9ce05aa79cc41392f87b47a67fd
Python
7,039
179
import copy import pytest import torch from spikingjelly.activation_based.neuron.flexsn import FlexSN def _lif_core(x, v, threshold): h = v + (x - v) * 0.5 spike = torch.sigmoid(h - threshold) return spike, h * (1.0 - spike) def _reference(x_seq, v, threshold): outputs, states = [], [] for x i...
33a72a5477c26086bae62b18ebd8c5438f86bed56a2865790a1b9e05cb22600e
Python
7,040
207
import argparse import os import numpy as np import math import itertools import time import datetime import sys import torchvision.transforms as transforms from torchvision.utils import save_image from torch.utils.data import DataLoader from torchvision import datasets from torch.autograd import Variable from model...
8ee5a39bd4468872b70d996b5bbbd0dc91841e2b9a5dce43c7b1c6acf13a3168
Python
7,042
207
import random import torch import torch.nn as nn import torch.nn.functional as F from cogdl.data import Graph from cogdl.layers import SAGELayer from .. import BaseModel def sage_sampler(adjlist, edge_index, num_sample): if adjlist == {}: row, col = edge_index row = row.cpu().numpy() co...
5e03e683a6d6887005d6243be7faf636a53113139035945479850fce509ae7e1
Python
7,043
334
import pytest import networkx as nx def test_selfloops_raises(): G = nx.ladder_graph(3) G.add_edge(0, 0) with pytest.raises(nx.NetworkXError, match=".*not bipartite"): nx.bipartite.maximal_extendability(G) def test_disconnected_raises(): G = nx.ladder_graph(3) G.add_node("a") with p...
5f29a68ee3bc6fb5ab58d330a092c3cd86b9579ffe306b09605f24e562706892
Python
7,043
132
""" Workflow script to get fish dots in the given segmentation mask """ from helpers_and_sources.mainflow_helpers import * from helpers_and_sources import gaussian_plot import tifffile as tf import numpy as np import csv from os.path import split, splitext, join from os import makedirs # The following functions d...
92e20134cb265c99a5c988d39639f0116461058acd2d421528b1b1fb0b099df7
Python
7,043
198
import base64 import contextlib import hashlib import importlib.metadata import json import os import tempfile import time import typing from uuid import uuid4 from ...exceptions import MissingActiveConfigError from ..interfaces import FileStore as IFileStore def _id_to_path(url): return base64.urlsafe_b64encode...
2570be0325234c5dbef4edb791f89fbd42810818a1acf804d03632982a5b0e89
Python
7,046
200
import torch import torch.nn as nn from torch.nn.modules.normalization import LayerNorm import random from utilities.constants import * from utilities.device import get_device from .positional_encoding import PositionalEncoding from .rpr import TransformerEncoderRPR, TransformerEncoderLayerRPR # MusicTransformer cl...
e9baa25af5d8732119c43d87e30cdc5213dc47158c91d12953419e154a290990
Python
7,047
187
import pandas as pd from tensorflow.keras.models import Model import numpy as np from sklearn.model_selection import train_test_split, KFold from sklearn.metrics import accuracy_score from tensorflow.keras.optimizers import Adam, SGD import os import random from sklearn.model_selection import train_test_split...
2df71cba55ee5225b25bc33cd5621530bff327f3347bf14b3b041a02062fc3ea
Python
7,048
180
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
329dd2b59a1dd54db826d8207a5fd3ffea0b36903c0e582148f3357605c4a082
Python
7,048
176
""" Plot Supplemental Figure S5 """ import numpy as np import pylab as pl import strinf as si # # # PARAMETERS # # # ZOOM = 1.5 SAVE = True # Save figure file SHOW = True # The trials from all conditons datadir = "./data/" DSL = {"multy_0_surround_bi" : "2022-05-12-16-03-09-435421_107_direction_r...
ae04691eaa761417602dc5d42b639612aa6650d3363640c232018dc9d45ecd9b
Python
7,051
204
import argparse import os import numpy as np import math import torchvision.transforms as transforms from torchvision.utils import save_image from torch.utils.data import DataLoader from torchvision import datasets from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F import torch...
1b2b8a6f6406c305d6acfec212ee0b889c561994d44b9f05d27882b9878a7158
Python
7,055
169
# -*- coding: utf-8 -*- from figureflow import figure import seaborn as sb import numpy as np import os import importlib importlib.reload(figure) Figure = figure.Figure input_folder = os.path.dirname(os.path.abspath(__file__)) figure = Figure(input_folder,number=9, dpi=600, width=7.3) figure.creat...
e0e722377597b7a86874d9960434936d14b8200f313932a132c34f4c9eb29ea7
Python
7,063
211
# rmf 3.24.2020, last modified 5.18.2021 # cleaned up 3.1.2022 import sys import statsmodels.stats.multitest as multi # USAGE usage = 'python ' + sys.argv[0] + ' <test results file> <meme map file> <gene median expression file> <secondary FBID file> <secondary JASPAR ID file>' if len(sys.argv) != 6 or '-h' in sys.arg...
05777330df54574749b280d080277ad5c156a3ccd919a726f4d245a9cbbd7b3c
Python
7,067
196
import os import os.path as osp import numpy as np from collections import defaultdict import scipy.sparse as sp import torch from cogdl.data import Graph, Dataset from cogdl.utils import untar, download_url from cogdl.utils.grb_utils import adj_to_tensor class GRBDataset(Dataset): GRB_SUPPORTED_DATASETS = {"gr...
4dde154494d355e5b1d6ec29b679951c0e452efbc6d72ef946a77c11ae93586f
Python
7,068
166
# MIT License # # Copyright (c) 2019-2024 The PyQMC Developers # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, m...
a40cad9e5b98e2c2f1e52a53608bc2043285de59d9cc6fa76e7faaeb77d03b5d
Python
7,071
147
""" Plotting all experiments for the paper. """ import numpy as np import roblib import settings from pathlib import Path import pandas as pd from utils import load_config from plot_maker import plot_module def naming_unfolding(str_template, unfolding_specs): cur_strings = [str_template] for idx...
fa319c787c19721c33e80a4a4f17354deab944dad2dc8b54f9f1ad70b0c3c74c
Python
7,071
166
from brian2.core.preferences import prefs from brian2lava.utils.const import runtime_configs, HARDWARE from brian2lava.preset_mode.model_loader import ModelLoader from brian2lava.preset_mode.handler import PresetProcessHandler class SettingsParser: def __init__(self, device): self.device = device ...
87114b5f435c76d87b758edec5c21d168e94190ae3b99e8a21e20bde3aabfb7a
Python
7,081
200
from __future__ import absolute_import import logging import os import re from pip._internal.utils.logging import indent_log from pip._internal.utils.misc import ( display_path, make_vcs_requirement_url, rmtree, split_auth_from_netloc, ) from pip._internal.vcs import VersionControl, vcs _svn_xml_url_re = re.comp...
418de06947f84b22ca3a6296fe4a5bcb62c16bb4c1887cee0e924e0d2002b76b
Python
7,082
166
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
5deaaf15f4c3a50c3a3b3fabf96ec50681dff8ba342ad2ebbae80958637ac73c
Python
7,085
215
import argparse import os import numpy as np import math import torchvision.transforms as transforms from torchvision.utils import save_image from torch.utils.data import DataLoader from torchvision import datasets from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F import torch...
5c885999dd5562115947b054abdcff4860b2bcb660e3046ea00e0a4d6e1eff64
Python
7,087
166
import copy import os import tempfile import matplotlib.pyplot as plt import numpy as np import pandas as pd import pytest from sklearn.cluster import KMeans from test_utils import make_cell_table import ark.settings as settings import ark.spLDA.processing as pros import ark.utils.spatial_lda_utils as spu def test_...
653da3168c8ccf9c0e03612124024c062198479e58bbc788682d4e593671f98e
Python
7,092
176
#!/usr/bin/env python # Copyright 2020 The HuggingFace Team. 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...
2f251d4941649c8d7b96bb7941b371d0971ddf91c6bc2c97b89e49f464a88f54
Python
7,097
202
""" Copyright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer and Marius Pachitariu. """ import os import numpy as np import matplotlib.pyplot as plt from pathlib import Path from cellpose import models, io, metrics from cellpose.models import CellposeModel from tqdm import trange # uses tensorflow ...
0c5e9ff721c414a2c7a1689f17dd1df5ab58201d986a7978d27e74d242ad1e04
Python
7,098
185
from __future__ import annotations from contextlib import nullcontext from os import PathLike from pathlib import Path from typing import TYPE_CHECKING, cast import h5py import zarr from anndata._core.file_backing import AnnDataFileManager from anndata._io.specs.registry import read_elem, read_elem_lazy from anndata...
7f82554639e85b4ebbe4c79192ae9ff2df7af5d4525706b27411594f0f742ee3
Python
7,110
220
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import csv import json import os import random import sys from itertools import product NAME = "projects" def read_rules(name): rules = [] with open(os.path.join(sys.argv[1], f"{name}.csv")) as f: reader = csv.DictReader(f) ...
a569a6581a1e18bbea4b7da8a6f37e58e805cb7fee4bdf5107cf8961329ba6eb
Python
7,110
194
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pyre-strict from typing import Any, final import numpy as np import pandas as pd from ax.adapter.base import Adapter from ax.analysis.an...
9d24c5bceed38c53ab032f0733125f784a84bda77912fc8697dbda930bf210ca
Python
7,111
192
import abc import warnings import nest from bsb import AdapterError, DeviceModel, Targetting, config, refs, types from .distributions import nest_constant @config.node class NestRule: """ Interface to connect a device directly through the NEST interface. """ rule = config.attr(type=str, required=Tr...
9ff5431f0c9faafb3d5ea338c4d4a654e1b014a890e615f777f80d208c2e6a53
Python
7,114
223
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import csv import json import os import random import sys from itertools import product NAME = "annotationguides" def read_rules(name): rules = [] with open(os.path.join(sys.argv[1], f"{name}.csv")) as f: reader = csv.DictReader(f)...
43aea0ed05dbb4768c5a61af7a4d0d5b65c0915f7dc4fd28ebb3371be5d6d339
Python
7,116
155
from math import floor as floor from numpy import array as array from numpy import exp as exp from numpy import zeros as zeros from scipy.special import gammaincc as gammaincc from scipy.special import hyp1f1 as hyp1f1 class TemplateMatching: @staticmethod def non_overlapping_test(binary_data:str, verbose=Fa...
8f22d2c29f5a5acf4dab095ee1aca18da3546d45614c765a0e9290c83dc3c74f
Python
7,117
207
"""Calculate RDMs based on Mahalanobis distance. For a given subject: - load epochs for a stream (single or dual) - perform baseline correction - create a design matrix where each trial is predicted by the condition of that trial. For example, if there are conditions 1, 2, and 3, the design matrix has three column...
bb2891f0e390d4e78a8c4356b9c9b8145c2208030d66b34f04862112436ed6eb
Python
7,117
232
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
ed3cd25f0dfc2dc4d2db6fa8f0634a75e590c38b34a10b86c567b5ad665cf47e
Python
7,117
207
"""Calculate RDMs based on Mahalanobis distance. For a given subject: - load epochs for a stream (single or dual) - perform baseline correction - create a design matrix where each trial is predicted by the condition of that trial. For example, if there are conditions 1, 2, and 3, the design matrix has three column...
b821c7a3e61c73babefb216644a99c3cda86b468e8c7bf323fff3e60cbc6c5a2
Python
7,121
190
import tensorflow as tf # tf.enable_v2_behavior() import pandas as pd from tensorflow.keras.models import Model import numpy as np from sklearn.model_selection import train_test_split, KFold from sklearn.metrics import accuracy_score # from keras import optimizers import os import random from sklearn.model_se...
24586bc4e2a043f3f4ddb6e40a99d6baea8aa1aba4981f447c3bfa397c01adb2
Python
7,125
188
import pandas as pd from tensorflow.keras.models import Model import numpy as np from sklearn.model_selection import train_test_split, KFold from sklearn.metrics import accuracy_score from tensorflow.keras.optimizers import Adam, SGD import os import random from sklearn.model_selection import train_test_split...
90f3eb5ea104534432d88c60b3a6518ab6e44572b76f9f7edc76a486301fbdd0
Python
7,126
190
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Render a 2d video of the input locations; velocities # # # and of the filter's estimated velocities; and of the # # # inferred motion strengths. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # import numpy as np ...
8d77b886b61d274ae5d50697043ab32fe55a9a23d5377903d67f1328c21a1dac
Python
7,127
245
def load_dnn_data(args, cond_idx): """Load the DNN feature maps of the training and test images. Parameters ---------- args : Namespace Input arguments. cond_idx : int Indices of the used image conditions. Returns ------- X_train : dict of float Training images feature maps. X_test : dict of float Te...
079851483eea92014b9bbf3f8255a66101caf91d1e973ad16789b942cac9d721
Python
7,130
226
""" Provenance helpers shared by storage engines and the simulation result writer. Exposes ``new_storage_id``, ``iso_now``, ``collect_plugin_manifest``, ``collect_host_info``, and ``build_root_metadata`` (the canonical assembler of the root-level provenance bundle an engine writes on ``create()``), plus the ``encode_a...
86ffad60358e26c66d415c82bdfc9f3f86689704b4a4462812b9f8cb21535e84
Python
7,131
241
import math import numpy as np import scipy import scipy.sparse as sp from scipy.special import iv from sklearn import preprocessing class HeatKernel(object): def __init__(self, t=0.5, theta0=0.6, theta1=0.4): self.t = t self.theta0 = theta0 self.theta1 = theta1 def prop_adjacency(sel...
fd3af01117c38fab9c150e74f31cbac6ed1d43be427b0d07e4ef8197f4737f0e
Python
7,135
168
"""Reinhard (2001) colour transfer in Ruderman Lab space. Pure DataArray layer: every function takes and returns ``xr.DataArray`` (or numpy), stays lazy, touches no ``sdata``, and exposes no public surface. The thin ``sdata`` wrapper lives in :mod:`._normalize`. ``params`` arguments must already be resolved by :func:...
76c5fb5e2add93525c25454c37de23cbf5e72c707e8ca18ad7f9213dffb3e4ab
Python
7,137
150
""" Properties for the CamCoil implementation. These include: 1. ACCEPTED_RES_ONE 2. pH2_prop 3. pH7_prop 4. weights 5. weights_LFP """ import hashlib from functools import partial from numpy import nan as np_nan from collections import namedtuple # Add documentation to the NamedTuple. __pdoc__ =...
34433dd0598e5943708c7139702468727af0f76f35ecc46b402fef3ac36e3bf4
Python
7,138
138
import numpy as np import shutil import MDAnalysis as mda from MDAnalysis.analysis import pca, align from MDAnalysis.coordinates.memory import MemoryReader from MDAnalysis.analysis.base import AnalysisFromFunction import uuid import os from sklearn.decomposition import PCA import os import uuid print('imported mod...
8ab9f0ec09393a7229d746ded65d6bea30f1284e362aae51fc0cf3b6a71027c8
Python
7,140
193
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
6aff3a9a2a287a755885dd5ab7a7dd3241420959c67da42ef423b2fcd17316b8
Python
7,141
166
# -*- coding: utf-8 -*- from figureflow import figure import seaborn as sb import numpy as np import os import importlib importlib.reload(figure) Figure = figure.Figure input_folder = os.path.dirname(os.path.abspath(__file__)) figure = Figure(input_folder,number=10, dpi=600, width=5) figure.cr...
a7975b919a7fa8b6cd1b64319ff31c330dd60c663a734dfa00d802f994c3f2b8
Python
7,143
243
import tensorflow as tf from tensorflow import keras from keras import optimizers from tensorflow.keras import layers import numpy as np np.set_printoptions(precision=5) import matplotlib.pyplot as plt import pandas as pd pd.options.display.float_format = '{:,.5f}'.format import scipy as sp from scipy import stats imp...
0e051c1d0dbc7bed0f587da9f8c0d7e86bd6e4e244e10b5fec923c3da34a4e94
Python
7,144
162
# encoding: utf-8 # copyright: GeoDS Lab, University of Wisconsin-Madison # authors: Yuhao Kang, Song Gao, Jinmeng Rao import pandas as pd import numpy as np import os import geopandas as gpd import psycopg2 import argparse import datetime parser = argparse.ArgumentParser(description='Month, start day, end day') parse...
b290d4906ef3134904a528185a4bfeda77eabfbde77bb9b72597135bff00bb98
Python
7,144
185
from smile.experiment import Experiment from smile.state import Wait, Loop, Parallel, Meanwhile, UntilDone, Serial, \ Done, Debug from smile.video import ProgressBar, Image, RstDocument, ButtonPress, Button, \ Slider, Rectangle, TextInput, Label, Ellipse,\ ...
d19a7d98887e38dc0e413bd554447c623c44ef7172254d279ee16756f3fa06f2
Python
7,144
171
# TODO this script was adapted to the new data classes, but is not yet tested. # If you succesfully un it, remove this comment from meld_classifier.experiment import Experiment from meld_classifier.paths import EXPERIMENT_PATH from meld_classifier.network_tools import ensemble_models from meld_classifier.evaluation imp...
944dd3e819cbb61f29dae0088c534f0bf253c385913416f5ff46711a09d21f1f
Python
7,145
230
"""Function for computing walks in a graph.""" import networkx as nx from networkx.utils import not_implemented_for, py_random_state __all__ = ["number_of_walks", "random_walk"] @nx._dispatchable def number_of_walks(G, walk_length): """Returns the number of walks connecting each pair of nodes in `G` A *wal...
d9a15c5c731124757ba2cb691b37770a9c096d140ae9ae8985362b1b9c6b2237
Python
7,149
195
import numpy as np import synthetic_spatial_datagen def test_generate_test_dist_matrix(): # use default parameters sample_dist_mat = synthetic_spatial_datagen.generate_test_dist_matrix() # assert matrix symmetry assert np.allclose(sample_dist_mat.loc[np.arange(1, 301), np.arange(1, 301)].values, ...
fcbe53baa1f64639e3b4b1ad7fa63a7403f1ef2b10f6e02ff8df8b63a408a63b
Python
7,152
205
""" The sorts of the columns of a query's result, from the query itself. A column of a result holds the values of a variable of the head of the query. When the variable is an argument of a predicate declaring its ``arguments`` in the engine's configuration, in the body of the query, the column holds values of the sort...
131c62a8df593d7fc1ae182e2c47221bddcaff1e79df930198183aa8c7c7b15c
Python
7,155
234
import json import os.path as osp import time import numpy as np import scipy.sparse as sp import torch from sklearn.preprocessing import StandardScaler from cogdl.data import Graph, Dataset from cogdl.utils import download_url, Accuracy, MultiLabelMicroF1, BCEWithLogitsLoss, CrossEntropyLoss from .planetoid_data imp...
75d51c589e286758952dda2974d27704b2b41bf70cfb36b42fc21e0f38c954d0
Python
7,155
215
import copy import os import tempfile from datetime import timedelta import pytest import torch import torch.distributed as dist import torch.multiprocessing as mp from spikingjelly.activation_based import functional, layer, neuron from spikingjelly.activation_based.distributed.tensor_parallel import ( ChannelSha...
0da96ee8fdc99ccd0bd4cacc0507b2f608cfbed21171b50427fa90e9ac707661
Python
7,156
247
# ---------------------------------------------------------------------------- # build_sample_matrix.py # Author: Antoine Beauchamp # Created: June 22nd, 2022 """ Build a gene-by-sample expression matrix. Description ----------- This is a script to process the Allen Human Brain Atlas microarray gene expression data...
bca06551681c0c5daff8a56427ec53ddf3e1081e3b9d501211424fbc42a061f5
Python
7,159
225
# -*- coding: utf-8 -*- """Airy module Generates the Airy beam shape based on experimental or theoretical parameters """ # Created on Tue Apr 7 10:01:32 2020 # Contributions and Changelog accessed via a private git repository: # https://github.com/philipwijesinghe/deep-learning-lsm.git # philip.wijesinghe@gmail.com...
e8b893825b245775820b4a459892c8624094804424b9d9aae17a9cac4ae74b0b
Python
7,159
214
"""Tests for squidpy._validators.""" from __future__ import annotations from unittest.mock import MagicMock import pytest from squidpy._validators import ( assert_in_range, assert_isinstance, assert_key_in_adata, assert_key_in_sdata, assert_non_empty_sequence, assert_non_negative, assert...
367d0728bfd34d1bf86911fd12d4a0f44e2328cce7222b2a6b1ee5236167f718
Python
7,165
211
## To be continued.... import pandas as pd import numpy as np import glob import os import nilearn.signal import matplotlib.pyplot as plt from scipy import stats import pingouin as pg import statsmodels.api as sm import seaborn as sns def loadsnr(snrcoil, snrtrue): def reshapesnr(snr_all): mz=snr_all...
ecc34f66a2bd596c590b74e0cef3011fe44f4653852e9c2af76ee59335225232
Python
7,167
186
# -*- coding: utf-8 -*- from __future__ import absolute_import import logging import os from pip._internal.cache import WheelCache from pip._internal.cli import cmdoptions from pip._internal.cli.base_command import RequirementCommand from pip._internal.exceptions import CommandError, PreviousBuildDirError from pip._i...
acc4df9845f176e20dc308dbf03c90357c63d38ccd12771ade5b107555c30fed
Python
7,169
193
#!/usr/bin/env python3 import os import numpy as np from param_stamp import get_param_stamp_from_args from visual import visual_plt as my_plt import main_task_free from param_values import check_for_errors,set_default_values import options import utils ## Parameter-values to compare c_list = [0.001, 0.01, 0.1, 1., 10...