sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
ccfd6cc7f2ad0efb4f412aae3a74c24dbeb9f00c5a6f376e33a5004dbdebc9ed | Python | 4,057 | 146 | """Module contains 2D-specific plotting functions."""
from typing import Optional
from matplotlib import pyplot as plt
import numpy as np
from sklearn.metrics import confusion_matrix
from moseq2_lda.util import dict_merge
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import seaborn as sns
import matplotl... |
d31c5340a6614c586f1b2c73fb1175ad3d155ce452ba60c85fa112d46baf6b06 | Python | 4,058 | 114 | #!/usr/bin/env python
'''
Testcases for the neural network prediction
'''
import windseer.utils as utils
import windseer
import numpy as np
import os
import unittest
windseer_path = os.path.dirname(windseer.__file__)
testdata_folder = os.path.join(windseer_path, 'test', 'testdata')
test_file_data = os.path.join(test... |
dbe282eae272bf3d1d8d9e565d4177a3313ba43deffe267f181b3537e8f9a2d8 | Python | 4,058 | 114 | import os
import torch
import numpy as np
from AYN_Package.DataSet.ForObjectDetection.VOC_nwpu import *
from AYN_Package.BaseDev.cv2_ import CV2
from tqdm import tqdm
from AYN_Package.Task.ObjectDetection.D2.Dev.tools import DevTool
def cwloss(output : torch.Tensor,
target : torch.Tensor,
... |
2d6040998a3d8891166a7edfd8c715dd579be333f970fdbb83250309f5361769 | Python | 4,059 | 153 | """
Tests multithreading behaviour for reading and
parsing files for each parser defined in parsers.py
"""
from contextlib import ExitStack
from io import BytesIO
from multiprocessing.pool import ThreadPool
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
# We'll probably always ski... |
136d7fac50d5356c91789cca748378d99f9008dea2aec30abf969c41362d3a56 | Python | 4,061 | 96 | """Numerical coil simulations."""
import torch
from einops import repeat
from mrpro.data.SpatialDimension import SpatialDimension
def birdcage_2d(
n_coils: int,
image_dimensions: SpatialDimension[int],
relative_radius: float = 1.5,
normalize_with_rss: bool = True,
) -> torch.Tensor:
"""Numerical... |
896ebcab65040c1c03434a3251106fd331326583515431c0f7f0ec17ae9b25c5 | Python | 4,063 | 107 | #!/usr/bin/env python
"""Given rows from parse_gtime, generate a figure and a latex table of results.
"""
import argparse
from common import fileopen
import os
import sys
import pandas as pd
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--input", default="-")
parser.add_argument... |
e5184d2ae4c521b2c0650fc63b07c205584cc46ae71e40b7c55cbf267c3edf95 | Python | 4,064 | 108 | """Symmetric encryption for at-rest secrets (LLM API keys, future cloud creds).
Backed by ``cryptography.fernet.Fernet`` (AES-128-CBC + HMAC-SHA256). Keys
ride in env var ``PYCARET_SECRETS_KEY`` (base64-urlsafe-encoded 32 bytes —
the format ``Fernet.generate_key()`` produces).
Stored ciphertext is prefixed with ``ENC... |
dcf36ea8be06a4ef2e9d5cb53f0e5bd1feaaa4320cbd6356371aee9f15fe5909 | Python | 4,066 | 157 | from collections import Counter
from copy import deepcopy
import numpy as np
from sklearn.preprocessing import LabelBinarizer
from keras.models import model_from_yaml
def right_pad(sequences):
"""
Pads sequences with extra "*" characters.
"""
padded_sequences = deepcopy(sequences)
seq_lengths = ... |
2b7c0baecc48dd5d37f01beb26803e451ae27226d19fcc833b1b4810ab1ac908 | Python | 4,073 | 114 | """Run explainer — reads a completed Run's snapshot + leaderboard + events
and produces a plain-prose explanation of what happened + what to try next.
Intended UX: a collapsible card on `/runs/:id` that the user opens after a
run succeeds. Low-stakes, reads-only.
Prompt input: the Run row itself (status, duration, sn... |
45f749630c7502a534e7f85abf4cffcf06c91092f26a2f5f6aade29dd37236fe | Python | 4,074 | 130 | #!/usr/bin/env python
__author__ = 'etseng@pacb.com'
import sys
"""
Faithful copy of cupcake.io.BED.py
Misc APIs for reading BED format
UCSC BED format:
https://genome.ucsc.edu/FAQ/FAQformat#format1
SimpleBED --- chr, 0-based start, 1-based end
"""
class SimpleBED(object):
def __init__(self, chrom, start, end, n... |
cc685b1a521282a2e686a0a310854343cdd680dbba4b2bb46646a9cd7ce57304 | Python | 4,075 | 123 | """Model-registry equality tests — checks that every registered model's
equality predicate uniquely matches itself.
Rewritten for PyCaret 4.0 OOP API. The 3.x pattern of
``exp = ClassificationExperiment(); exp.setup(...)`` becomes
``exp = ClassificationExperiment(target=...).fit(...)`` — target is a
constructor parame... |
c233d083545cdea519e84cad3688bfc397394b0b94eccf1501ffd31bd84baa21 | Python | 4,076 | 117 | """Pure serialisers — ORM row → wire-friendly YAML/JSON dict.
These functions don't talk to Git or the filesystem. They're called by
both the live "publish to Git" service AND the standalone CLI export
(``pycaret-server export <project>``, a future cut), so keeping them
side-effect-free matters.
The on-disk layout ea... |
d453c4f6e9f043743218f740386d770f5c113450348021bcd33a79743d76406a | Python | 4,076 | 126 | #!/usr/bin/env python3
#
# Copyright 2016 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 requir... |
e8b32b23ec0bb84f9b7ee65b6e8d7bdc71793dffecf548a7c632dd8350c8f2b5 | Python | 4,077 | 112 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.util.version import Version
xarray = pytest.importorskip("xarray")
class TestDataFrameToXArray:
@pytest.fixture
def df(self):
return pd.DataFrame(
{
"a": list("abcd"),
... |
f42fecfa82745c27a08f0b1376569fc6fff72d1777c06ba5ac92a07e78a066eb | Python | 4,078 | 113 | import gymnasium as gym
import numpy as np
import yaml
from smacv2.env import StarCraft2Env
from smacv2.env import MultiAgentEnv
from smacv2.env.starcraft2.wrapper import StarCraftCapabilityEnvWrapper
class SMACEnvV2(gym.Env):
def __init__(self, name="3m", **kwargs):
gym.Env.__init__(self)
self._se... |
115fae9d0b04f811fe7aca3192f04a89cc89beac5c7617e4e6f14c802a98f38b | Python | 4,080 | 124 | # Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
20292e5fa450acaa6b67e81cb1a84382e9dc9e7993474b503d59589bc9d4f7e0 | Python | 4,081 | 126 | import numpy as np
import sys
sys.path.append('..')
from util import window_tools
def normBin(filtpos,staValue,freD):
freD_dropna = freD[~np.isnan(staValue)]
filtpos_dropna = np.asarray(filtpos)[~np.isnan(staValue)]
staValue_dropna = staValue[~np.isnan(staValue)]
dafBin,ihsBin,posBin = windo... |
a391c0d7d32ba0bd0e9a8eb828eef51cdbe0a12f47beaa35f4b576f48160f3bb | Python | 4,081 | 89 | from Surfaces.surfaces import *
from Common.kernelFunctions import *
from Surfaces.surfaceMatching import *
from Common import pointEvolution as evol, loggingUtils
def compute():
outputDir = '/Users/younes/Development/Results/biocardMultiLargeKernel'
#outputDir = '/cis/home/younes/MorphingData/twoBallsStitch... |
79febc0a341727d641a1fbf1ebd4fcaaa16632ea94759c79efb9890bc1918e09 | Python | 4,084 | 80 | import numpy as np
from scipy.interpolate import interp1d
import time as clocktime
################################################################
## Get phase densities from experimental data
#################################################################
ncells = 16
## Spike set contain spike times, we need to map... |
cb90bfa876cc64f9f3d249cf4888bbc2c7b0cd46d757ed3cef077a8442050723 | Python | 4,084 | 95 | # MIT License
#
# Copyright 2026 Broad Institute
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, ... |
563b077e051df60673b873b1c03b93ce0e1bd169c900f54c8306016ba8bf2202 | Python | 4,087 | 108 | import numpy as np, matplotlib.pyplot as plt, sys
import pumpprobe as pp
rise = "--rise" in sys.argv
ds_list = "/projects/LEIFER/francesco/funatlas_list.txt"
funa1 = pp.Funatlas.from_datasets(ds_list,ds_exclude_tags="unc-31 D20")
funa2 = pp.Funatlas.from_datasets(ds_list,ds_tags="unc-31")
funas = [funa1,funa2]
label... |
86b139580a9a3c218135269721c8edaaea965f550fccfad8f9d99886264de94c | Python | 4,091 | 130 | """
Linear regression script for fMRI data (Blank2014).
Note: This script expects the response data generated with the modelblocks pipeline
"""
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score, log_loss
from scipy.stats im... |
c4cf258902a0ebd1f3d6a9cf60cc21b709e11b519e000bc38add46317c92f386 | Python | 4,091 | 134 | import numpy as np
import scipy.sparse as ssp
import torch
import networkx as nx
import dgl
import pickle
import random
def serialize(data):
data_tuple = tuple(data.values())
return pickle.dumps(data_tuple)
def deserialize(data):
data_tuple = pickle.loads(data)
keys = ('nodes', 'r_label', 'g_label', ... |
673dc9e70439c4f80e5274e3c0ccdd5d8b4350399721e4bd9b4132a390321746 | Python | 4,092 | 116 | """Model specification based on selected genes and hand-engineered drug features."""
import tensorflow as tf
from ...hyperparams import ACTIVATION_FN_FACTORY
from ...layers import dense_attention_layer
def dnn_fn(features, labels, mode, params):
"""
Implement model for IC50 prediction based on selected genes ... |
824572f67ee21da6951d7fd1414897a5055eb6b433557c6487f3bd99af9976ee | Python | 4,092 | 136 | import argparse
import tqdm
import os
import pandas as pd
from deepglyco.chem.common.elements import ElementCollection
from deepglyco.chem.pep.aminoacids import AminoAcidCollection
from deepglyco.chem.pep.mods import ModificationCollection
from deepglyco.speclib.pep.hdf import PeptideSpectralLibraryHdf
from deepglyco.... |
dde77df73f2a0408d521175c535b86751e172edcdabb8dde20b7f77cf0c55fc9 | Python | 4,092 | 119 | """L2 Squared Norm."""
import torch
from mrpro.operators.Functional import ElementaryProximableFunctional, throw_if_negative_or_complex
class L2NormSquared(ElementaryProximableFunctional):
r"""Functional class for the squared L2 Norm.
This implements the functional given by
:math:`f: C^N \rightarrow [0... |
03cbd23b5e91db0ac2fa8d64cbd0766e94d1e30872175202af2a88082c72e320 | Python | 4,098 | 97 | # Copyright 2018-2025 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
cb0fc021c3fae0c06b300063d3dd33e5d2497723f752fb951483c2994dacc012 | Python | 4,098 | 122 | import numpy as np
import pandas as pd
from sklearn.inspection import permutation_importance
SUPPORTED_LIN_REG = ['LinearRegression','ARDRegression','BayesianRidge','LinearSVR']
SUPPORTED_TREE_REG = ['XGBRegressor']
SUPPORTED_DUMMY_REG = ['DummyRegressor', 'Pyment']
SUPPORTED_STACKING_REG = ['StackingRegressor']
SUPPO... |
e47a3efa2028019bddfcd91b2b59da99d38d0475a61fb0c863f27a1932585d8b | Python | 4,098 | 125 | # Copyright 2025 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... |
fa2d92afb5a0eead8082782079bd6467a6e567ec394d16319b90eadd393729fb | Python | 4,098 | 114 | from typing import Literal, cast
import pytest
import torch
from mrpro.operators import ElementaryFunctional, ElementaryProximableFunctional, ProximableFunctional
from mrpro.operators.Functional import ScaledProximableFunctional
from mrpro.utils import RandomGenerator
from tests.operators.functionals.conftest import ... |
23bd1ab216eb6947b55a200c3df81c4a32e416ecda3816bfc891b53bc093d702 | Python | 4,100 | 127 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
class SharedSetAxisTests:
@pytest.fixture
def obj(self):
raise NotImplementedError("Implemented by subclasses")
def test_set_axis(self, obj):
# GH14636; this tests setting index for both Series and DataFram... |
feaf14081c67214ca20c0c4940f7636c7b7498da00cf811f4f7e0b4a57fa6c54 | Python | 4,100 | 109 | """Deployment risk reviewer — checks a Pipeline before it goes live.
UX: modal on `/pipelines/:id` that opens when the user clicks "Review
before deploy" in the deploy sidebar. Takes no user input — the payload
is derived from the Pipeline + its origin Run.
Flags: missing preprocessing steps (imputer, encoder) in the... |
680b5adf979cac2b89338e6b6db51aa421fb00f0da2ce207aa20cadf09d023c3 | Python | 4,103 | 108 | # Copyright 2026 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... |
8e687654c845895b4867a53ebe3faeead9c37cdf42218ae86294c61681bb9387 | Python | 4,104 | 115 | import sys, argparse, pandas as pd, numpy as np
# Source: https://github.com/PyMVPA/PyMVPA/blob/master/mvpa2/misc/fx.py#L17
def single_gamma_hrf(t, A=5.4, W=5.2, K=1.0):
"""Hemodynamic response function model.
The version consists of a single gamma function (also see
double_gamma_hrf()).
Parameters
... |
6ae046acdaddf2230947e2c53d0b0cc8ce27b405b8b22d1121507a2a7b2d4dfa | Python | 4,105 | 109 | # Copyright 2024 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... |
bee954286df479f4a94cb10d632bbf6f9684cea9d4352d291b9ef25b56033dd6 | Python | 4,105 | 112 | # Copyright 2025 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... |
e96ab9322e74a844ed7482de1fa9e89f2f281e368e96515c1c17e3c7db1a0b89 | Python | 4,106 | 108 | """Thread-safe event broker — fans events from worker threads to WebSocket clients.
Design
------
Events are emitted synchronously from a `concurrent.futures` worker thread
inside the `DBEventLogger`. WebSocket handlers are async coroutines running on
the asyncio event loop. The broker bridges the two worlds with `as... |
ecda69352a2ee0104a571d3c81ce5df79b69e72282c50321676327f24fb36682 | Python | 4,107 | 136 | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 26 18:06:05 2023
@author: jeanbaptiste
"""
import os
import json
import sys
import glob
import time
import copy
import numpy as np
import matplotlib.pyplot as plt
# Make sure the proper path is used:
dcc_repo_path = './../'
sys.path.insert(0,dcc_repo_path)
import deepce... |
2b820b292e37d626bfd49762adf4d0ce568dcaaa679fff72d78ca981aeb9abdd | Python | 4,109 | 130 | __all__ = [
"ElementInfo",
"ElementCollection",
"ElementComposition",
]
import os
from typing import Dict, Mapping, NamedTuple, Optional, Union
from ...util.io.yaml import load_yaml
ElementComposition = Mapping[str, int]
class ElementInfo(NamedTuple):
name: str
mass: float
class ElementColle... |
97a399b78b130fe311bfc4024443c11351d054ee9b2ebe0f5412b2b62fac0255 | Python | 4,109 | 159 | # Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
c728be15a97c4933f3234d733d441e151705bc88ab450eed0e62eca81a2b944a | Python | 4,110 | 118 | import filecmp
import os
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT))
from tests.helpers.compare_newick_semantics import compare_tree_files
RUN_TREESHRINK = REPO_ROOT / "run_treeshrink.py"
IN... |
1d8d4bae0443a10b14225a4fd653a57f2268a4e6a27c9187c3f222ea304668b9 | Python | 4,114 | 122 | """Jacobian."""
from collections.abc import Callable
import torch
from mrpro.operators.LinearOperator import LinearOperator
from mrpro.operators.Operator import Operator
class Jacobian(LinearOperator):
"""Jacobian of an Operator.
This operator implements the Jacobian of a (non-linear) operator at a given ... |
8dabcc3c169c961bb45aca8cd2d41e6bbaa9980a670eb28bfc51979e2b4e3412 | Python | 4,114 | 143 | #python calcXtimetoks.py tokfixnFile textFile
import sys
import re
tokfixnfileix = 1
textfileix = 2
#########################
#
# Load TokFixns File
#
#########################
DEBUG = False
corpus = []
sys.stderr.write('Loading tokfixns\n')
firstLine = True
firstWord = True
header = []
accumulated = {'fdur':0... |
95e3704133cb2173ae8f39c61bc5088c09b1cb8e283fa8f3b2da24bc87aad816 | Python | 4,115 | 179 | #!/usr/bin/env python
"""
Copyright (c) 2014-2017 Alex Forencich
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify,... |
2826909c8c6731eaee664c93d61498eaf9bc11cf76bf3ad658059f5f8957a556 | Python | 4,122 | 107 | import datetime
class StimulationState:
def __init__(self):
self.status = None
self.result_id = None
class stimulationOperator:
def __init__(self):
self.messenager = None
self.state = StimulationState()
self.events = ['CTOK',
... |
c512d440809e45bc97ddcae206bda4b79c6728d0bb4465df49e1fb0678702cf6 | Python | 4,126 | 77 | import os, sys
import argparse
import apnet
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
parser = argparse.ArgumentParser(description='Single-model training of binding free energy neural networks')
parser.add_argument('--set', type=str, default='', help='Pre-programmed dataset name to train... |
8049e6d794381408446876e8dc3a959cb4f9f929e6abfd0828da8219d06f8cd0 | Python | 4,127 | 113 | from PyQt6 import QtCore, QtWidgets
import pyqtgraph as pg
from pyqtgraph import exporters
class SimplePlotItem(pg.PlotItem):
"""Custom class for data visualization in Shape-Out
Modifications include:
- right click menu only with "Export..."
- top and right axes
"""
def __init__(self, parent... |
ca732ef76866f309b2ad9fdad6baa62f9783864fa2d4f553507b247560c42271 | Python | 4,127 | 121 | import numpy as np
def xread_count(r, stream, count, startid=0, block=None) -> list:
"""
Block and read multiple entries from a single stream
Parameters
----------
r : redis.Redis
instance of the redis.Redis interface
stream : bytes
Name of the stream
count : int
N... |
6df5fd68d345840d3bb0dca6f3db9e45e5a0ad1686e9390693b9c027347dabc0 | Python | 4,128 | 144 | """Pydantic models for the LLM advisory surface.
All provider output is normalised to `LLMAdvice` before it hits the DB — this
is the envelope the UI consumes regardless of which provider ran.
"""
from __future__ import annotations
from datetime import datetime
from pydantic import BaseModel, Field
# Allowlisted p... |
74af05ba501b08909eca5e92d52d4b61d788e4047150377f750a82996615ea51 | Python | 4,128 | 138 | # %%
from pathlib import Path
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from scipy.stats import ttest_ind
from statannotations.Annotator import Annotator
# %%
results_dir = Path(__file__).parent.parent / "results" / "2_confounds"
data_df = pd.read_csv(results_dir / "used_data.csv", ind... |
593ce9440dfeaeffc64836d48cd9c215690a5673c126fbb21486866d0c94ba44 | Python | 4,130 | 118 | '''For collecting global values'''
# section A: general -----------------------------------------------------------
NUM_SNPS = 36 # number of seg sites, should be divisible by 4
L = 50000 # heuristic to get enough SNPs for simulations (50,000 or fifty-thousand)
BATCH_SIZE = 50
DEFAULT_SEED = 1833
DEFAU... |
66bac281a1f9cd24e94aaf4c96e2fae691e07e06dfae0c1a820b5a1083182a18 | Python | 4,130 | 141 | import os
import pysam
import numpy as np
def compare_csv_subcomponents(truvari_res_folder):
base_csv_list = []
call_csv_list = []
# # collect from base
for record in pysam.VariantFile(os.path.join(truvari_res_folder, "tp-base.vcf")):
csv_info = {}
csv_type = record.info["SVTYPE"]
... |
5d2a016476948318f6f8a1303720bee281fa87e5fcdf9c50cbc5b8d052cdd0f4 | Python | 4,131 | 110 | from Environment import *
from scipy import ndimage
from torch.utils.data import Dataset
from scipy import ndimage as ndi
from scipy import stats
def random_rot_flip(image, label):
k = np.random.randint(0, 4)
for zz in range(image.shape[0]):
image[zz,:,:] = np.rot90(image[zz,:,:], k)
label[zz,:... |
be2d8ecd533f973e69ce95b80738834db49caec272caa651cb88c19438e311c0 | Python | 4,132 | 119 | #!/usr/bin/env python
import os
def docker_help(ImgName):
query = """=============================%s helper=============================
--------------------------
Performing Skullstripping
+ With GPU:
docker run --gpus all -v (your work directory):/data \
%s \
muSkullSt... |
ab267190a39baa30b840eb201dee90a185e9bce2fe1ff74a43ffe86a316939bb | Python | 4,136 | 120 | from scipy.optimize.linesearch import scalar_search_wolfe2, scalar_search_wolfe1
def line_search_wolfe(opt, pk, gfk=None, old_fval=None,
old_old_fval=None, c1=0.001, c2=0.9, amax=None,
maxiter=100, euclidean = True):
"""Find alpha that satisfies strong Wolfe conditio... |
e8e1fc34d76d3eaa74474723286db6e31a1d58783d11c80aeae7d6b6c6e4d92e | Python | 4,136 | 126 | # -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet):
# ----------------------------------------------------------------------------------------------... |
e9338a8086171613d13e2920e1ca9ea71fe427555725b69a67d954649c696f59 | Python | 4,136 | 127 | # Copyright 2018-2023 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
6a13d12fcada3a9055f9693193b4e0945e4a16a29a633be12d71d08b8547e4c9 | Python | 4,137 | 108 | import numpy as np, matplotlib.pyplot as plt, sys
import pumpprobe as pp
from scipy.optimize import curve_fit
plt.rc("xtick",labelsize=18)
plt.rc("ytick",labelsize=18)
plt.rc("axes",labelsize=18)
to_paper = "--to-paper" in sys.argv
cumulative = "--cumulative" in sys.argv
exclude_white = "--exclude-white" in sys.argv
... |
56f0856275f2548b880afa43a1ba9a283976c93c14628ac30fd12019d6cf85f9 | Python | 4,139 | 117 | #!/usr/bin/env python
"""Training on a single process."""
import torch
from onmt.inputters.inputter import IterOnDevice
from onmt.model_builder import build_model
from onmt.utils.optimizers import Optimizer
from onmt.utils.misc import set_random_seed
from onmt.trainer import build_trainer
from onmt.models import build... |
e01a8960b637c84e2be73e522d7a1143182eca30be4e3fb19ed5d2f80b27e3b3 | Python | 4,139 | 96 | import torch
import numpy as np
# Typing
from torch import Tensor
from typing import List, Tuple, Optional
####################### Model #######################
from torch import nn
from graphite.nn import MLP
class Encoder(nn.Module):
def __init__(self, init_node_dim: int, init_edge_dim: int, node_dim: int, ed... |
6f4041e634f1e52ef9ce178ead83d4784505a48000cf4aeb06f84baf67560c54 | Python | 4,141 | 92 | # MOFTransformer version 2.1.1
from itertools import chain
from moftransformer.test import test
str_kwargs_names = {
'loss_names': "One or more of the following loss : 'regression', 'classification', 'mpt', 'moc', and 'vfp'"
}
int_kwargs_names = {
'n_classes': "Number of classes when your loss is 'cl... |
fb065cfff923030f3814705d2e8d7707ea463a305509de091359264a0d50bf6a | Python | 4,141 | 104 | """Tests for non-linear optimization algorithms."""
import pytest
import torch
from mrpro.algorithms.optimizers import OptimizerStatus, adam, lbfgs
from mrpro.operators import ConstraintsOp
from tests.operators import Rosenbrock
@pytest.mark.parametrize('enforce_bounds_on_x1', [True, False])
@pytest.mark.parametrize... |
0c7c14efde911de5a8899da59f665fcd3776960e1da58443d1c55e8a32a22c29 | Python | 4,144 | 90 |
# TODO: Parallelize by chromosome.
# Spawn a pheweb process to do each chromosome. Each one must do:
# + For every `pheno_gz/*.gz` and `sites/sites.tsv`, find the byte offset to the block that begins our chromosome.
# + Now cffi down into a function just like our normal one, but which starts at that offset, discar... |
52e5a35bc8cf50d089e70d9a1065b96b2bc8cfc1ff9b5d01ce79f82fb0185397 | Python | 4,147 | 103 | # Copyright 2025 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... |
185f1805ad1e516572e8d83864ecf4289aa656cbd8be3b4291251a2e0fb785ef | Python | 4,151 | 131 | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 25 16:04:54 2022
@author: fm02
"""
### Author: federica.magnabosco@mrc-cbu.cam.ac.uk
### Plot results from LDvsSD individual ROIs accuracy
import numpy as np
import pandas as pd
import pickle
import seaborn as sns
import matplotlib.pyplot as plt
from scipy.stats import ... |
a8fb619ef54795b0ec33de0a2e073990162066d2a3c75891befd81717080067b | Python | 4,152 | 125 | #! /bioinfo/local/build/python/python-2.7.9/bin/python
################################################################################
# convert_xlsx2txt.py 1.0.1 #
# Authors: P. Poullet (Institut Curie) #
# Contact: myproms@cu... |
c96de001f323a2a3cd998400521e5e95d919bf9337e0589c35eee029f77b6c76 | Python | 4,153 | 69 | """General-purpose test script for image-to-image translation.
Once you have trained your model with train.py, you can use this script to test the model.
It will load a saved model from '--checkpoints_dir' and save the results to '--results_dir'.
It first creates model and dataset given the option. It will hard-code ... |
2764f10381c4837c09507d3ec13b3aebcd375a3b74adb29ceea9319c112c4f23 | Python | 4,154 | 117 | """Train command for the lightning-pose CLI."""
from __future__ import annotations
import argparse
import datetime
import logging
import os
from pathlib import Path
from typing import TYPE_CHECKING, Any
from lightning_pose.cli import types
logger = logging.getLogger(__name__)
if TYPE_CHECKING:
from lightning_p... |
375d335223518ed2563fc5718ae87d698fe8558ac240bc77cf38a789c48b0e0c | Python | 4,154 | 125 | from torch import nn
class Vgg16_Net(nn.Module):
def __init__(self):
super(Vgg16_Net, self).__init__()
self.layer1 = nn.Sequential(
nn.Conv2d(in_channels=3, out_channels=64, kernel_size=3, stride=1, padding=1),
# 224*224*3 -> 224*224*64
nn.BatchNorm2d(6... |
d06585c20033b15e22395a4564333f92878545a934993b990ac91bd89a6c8f4d | Python | 4,154 | 97 | import os
import pandas as pd
from tables.table_globals import METHOD_TABLES_DIR, LABEL_DIR, PT_DATA_FILE
"""
Table generation. Adapted from thesis but to output Google doc compliant tables, not LaTeX
"""
def generate_pt_demo_table():
filename = PT_DATA_FILE
df = pd.read_csv(filename)
total_n = len(df.i... |
d2174f97c25c6d240e26483c356aff165767429b9f901112fb2dd388e9bdb285 | Python | 4,154 | 159 | """
Methods used by Block.replace and related methods.
"""
from __future__ import annotations
import operator
import re
from re import Pattern
from typing import (
TYPE_CHECKING,
Any,
)
import numpy as np
from pandas.core.dtypes.common import (
is_bool,
is_re,
is_re_compilable,
)
from pandas.cor... |
3bcac83d101950de4996d80e0e34dfc54e4ea8fc84cb1e93a29a7f83e1919d2f | Python | 4,157 | 106 | """Total Variation (TV) Denoising using PDHG."""
from __future__ import annotations
from collections.abc import Sequence
from typing import overload
import torch
from mrpro.algorithms.optimizers.pdhg import pdhg
from mrpro.data.IData import IData
from mrpro.operators import LinearOperatorMatrix, ProximableFunctiona... |
dbd3df36278241646b30d7fc7b0c20d7d10f2e5813be226d1e71c3071d791256 | Python | 4,157 | 141 | # Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
1e828b7526cd583cabf6a692172e15a29d319cd62d767f584d6984056c675f26 | Python | 4,159 | 88 | import os
import pandas as pd
import sys
from botocore.client import Config
import ibm_boto3
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
from load_db.NKIRS import get_baseline_visit, open_subject_meta... |
aa3fe3b2b53dc0fd7ea89b0145c7dd8e29baed7b9ac0a2a53993c5a924a00b9b | Python | 4,160 | 136 | import numpy as np
import pandas as pd
import pandas._testing as tm
from pandas.tests.copy_view.util import get_array
# -----------------------------------------------------------------------------
# Copy/view behaviour for the values that are set in a DataFrame
def test_set_column_with_array():
# Case: setting... |
28ed4a1c86b7ef2d42b7a99f5c16b722d0d780042539254ee0e570fbe4a7af4b | Python | 4,161 | 144 | #python calcXtimetoks.py tokfixnFile textFile
import sys
import re
tokfixnfileix = 1
textfileix = 2
#########################
#
# Load TokFixns File
#
#########################
DEBUG = False
corpus = []
sys.stderr.write('Loading tokfixns\n')
firstLine = True
firstWord = True
header = []
accumulated = {'fdur':0... |
bb8add729b1a2fda62ee477f347bfec5f545c18746f366b35dd1fc11e7bbade0 | Python | 4,163 | 110 | # emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
# ex: set sts=4 ts=4 sw=4 et:
"""
.. _datasets_databases:
=========================
Neurosynth and NeuroQuery
=========================
Neurosynth and NeuroQuery are the two largest publicly-available coordinate-based databa... |
e5790b9188d4f21f50bced5743bc1a34900c561a2e4fb71c5a021d2a7886bfb9 | Python | 4,163 | 72 | import os
import single_cell_parser as scp
from model_data_base.mdbopen import create_mdb_path, resolve_mdb_path
from model_data_base.IO.LoaderDumper import pandas_to_msgpack
def get_confile_form_network_param(n):
confile = set([n.network[k].synapses.connectionFile for k in list(n.network.keys())])
synfi... |
b5720bcc0c3436c681bf3256d89ce4debf7fdb9688230c4e4f728ab1b2f4c80b | Python | 4,164 | 112 | import pickle
import argparse
import numpy as np
from scipy.integrate import ode
from numpy.random import random
###################################################################
# definition of the system equations
def coupled_rossler_systems(t, xy, omega_1, omega_2, epsilon):
"""
Unidirectionally couple... |
1d93dd5c3a8026005a535bc4de37cc47e2ce7713a9b46ed610daf9a5a0f2ba58 | Python | 4,165 | 137 | from __future__ import annotations
import functools
from typing import TYPE_CHECKING
import numpy as np
from pandas.compat._optional import import_optional_dependency
if TYPE_CHECKING:
from collections.abc import Callable
@functools.cache
def generate_online_numba_ewma_func(
nogil: bool,
parallel: boo... |
1dbf7e70241948b01acf4fbaa852ff1d3769e5099d66e361be0ce5560c6115a4 | Python | 4,165 | 113 | # MIT License
#
# Copyright (c) 2020 Gabriel Nogueira (Talendar)
# Copyright (c) 2023 Martin Kubovcik
#
# 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 ... |
23822953d89d4314cfac710c7da37ad1a260b8180383a2c94375db8d00923e4a | Python | 4,165 | 138 | import numpy as np
import pandas as pd
import json
PDBFS = {
'ATOM': [0, 4],
'atype': [13, 16],
'resName': [17, 20],
'CHAIN': 21,
'resSeq': [22, 26],
'X': [30, 38],
'Y': [38, 46],
'Z': [46, 54],
'plddt': [61, 66],
'ELEMENT': 77
}
def extractPDB(row, target):
if target in ... |
0b037e3c7ca078075af1ef64e9fb6d06ae2ef65c7e3a441dc3aa0f66b941e2a6 | Python | 4,168 | 114 | from functools import partial
import sys
import numpy as np
import pytest
import pandas._libs.window.aggregations as window_aggregations
import pandas as pd
import pandas._testing as tm
def _get_rolling_aggregations():
# list pairs of name and function
# each function has this signature:
# (const float... |
33eec32f48466d8732d84add8ddd4190975c34a9e95da495d2c7243a82c771d6 | Python | 4,169 | 110 | # Copyright 2024 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... |
88bf65ff0b7a37d884b16c592ef2aa9c281f69f9df75e2c59229f6a708dbbd4a | Python | 4,169 | 78 | import argparse
import textwrap
from pgen.esm_sampler import ESM_sampler
from pgen import models
from pgen.utils import write_sequential_fasta, RawAndDefaultsFormatter
from pathlib import Path
import sys
model_map = {"esm1b":models.ESM1b, "esm6":models.ESM6, "esm12":models.ESM12, "esm34":models.ESM34, "esm1v... |
ddb64d34b23b7bc1680f6eb9a84ffd46bf47d357204e8e390295b5f03281a1ce | Python | 4,169 | 116 | # Copyright 2026 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... |
e2743f520548d90f507860fb22d0265bea81f10460a5f8ef26ae046a8dd48dbf | Python | 4,169 | 120 | """Recommend command for the lightning-pose CLI."""
from __future__ import annotations
import argparse
import logging
import sys
from datetime import datetime
from pathlib import Path
from typing import Any
logger = logging.getLogger(__name__)
def register_parser(subparsers: Any) -> argparse.ArgumentParser:
""... |
4761a249625711af58e262a123bc32a8c99ce9cd3d58f16380b598cc9d538705 | Python | 4,174 | 125 | import numpy as np
import pytest
from pandas.compat import is_platform_arm
import pandas.util._test_decorators as td
import pandas as pd
import pandas._testing as tm
from pandas.util.version import Version
pytestmark = [td.skip_if_no("numba"), pytest.mark.single_cpu, pytest.mark.skipif()]
numba = pytest.importorski... |
51f5c081578d822c580c354ed2fe8fe8cf9f98061d36d87d6fdbdd8eb1652cc9 | Python | 4,174 | 153 | import sys
import torch
import networkx as nx
import networkx.algorithms.components.connected as nxacc
import networkx.algorithms.dag as nxadag
import numpy as np
def pearson_corr(x, y):
xx = x - torch.mean(x)
yy = y - torch.mean(y)
return torch.sum(xx*yy) / (torch.norm(xx, 2)*torch.norm(yy,2))
def load_ontology(... |
b747ae4d52a3b2847f816d627a89e18c8b3fcd8cd282ce7d64fc9011724c4b89 | Python | 4,176 | 115 |
import pathlib
import meniscus_rate2
from loess import loess_1d
import real_unit_convert as ruc
import numpy as np
import pandas
from matplotlib import pyplot
import statistics
def list_filenames():
p_folder = pathlib.Path("./proboscis_measurements")
m_folder = pathlib.Path("./meniscusTrackNN")
p_sheets... |
1f3eb84b198aa09f8459d59ad01e39e9e847ae72a06718f9112746786296d029 | Python | 4,182 | 111 | """Public-API and CLI regressions for #800, part of #757."""
import gzip
from pathlib import Path
import random
import subprocess
import sys
import MACS3
import pytest
from conftest import macs3_env, no_core_dumps
HEADER = "@SQ\tSN:chr1\tLN:1000000\n"
def record(name="rev", flag=16, cigar="50M", pos=5000):
r... |
531e48a3f19748859414d592ed57ada2db98ae5eef2eade3bcda69e70f80c05d | Python | 4,184 | 126 | import tensorflow as tf
from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping, ReduceLROnPlateau
from tensorflow.keras.optimizers import Adam
import numpy as np
import os
import random
from sklearn.utils import class_weight
import h5py
def generator(data_folder, files, batch_size):
"""
Generato... |
b6cb1e17ebe27a718817c7214ac2c8a4c44f0b94c42439ed3b2b0ed08b8e4926 | Python | 4,186 | 116 | # Copyright 2018-2024 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or... |
6158ae246e6811d4c2d43fc4688ab67cdc34f972b3d3a54bc065d94680860957 | Python | 4,191 | 134 | import argparse
import os
import pandas as pd
import tqdm
from deepglyco.chem.common.elements import ElementCollection
from deepglyco.chem.pep.aminoacids import AminoAcidCollection
from deepglyco.chem.pep.fragments import PeptideFragmentTypeCollection
from deepglyco.chem.pep.losses import NeutralLossTypeCollection
fr... |
b6dcc89a6201ec447283ca0fe4a224bfa7cac5ba431aa4ddd4990bb339f635a7 | Python | 4,191 | 170 | # -*- coding: utf-8 -*-
"""Untitled0.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1rZw4-xrAPpxQHSKuADlvWTu_ufljzgmD
##DRIVE MOUNT
"""
from google.colab import drive
drive.mount('/content/drive/', force_remount=True)
import os
my_drive_path =... |
b1079e7460f8dccba222fc2f93aa9ce7346e86b10c139fa35cd6b5746cf2721e | Python | 4,192 | 182 | #!/usr/bin/env python
"""
Copyright (c) 2014-2017 Alex Forencich
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify,... |
fb83a37c789d0c544459e4db18def426d18c0fdf89a24afb1897584c1118e122 | Python | 4,194 | 100 | import math
import os
import random
import argparse
from datetime import datetime
import numpy as np
import tensorflow as tf
from tensorflow import keras
from utils.structure import getModel
from utils.dataset import gen, get_dataset_from_csv
from utils.record import saveConfig, drawFig
print(tf.test.gpu_device_nam... |
6ca3d62ef312b5f515d3314ced388fc0b2d801a2d8b4f317c306303089f9478f | Python | 4,195 | 123 | import ctypes
import zoneinfo
import pytest
import pandas.util._test_decorators as td
import pandas as pd
import pandas._testing as tm
pa = pytest.importorskip("pyarrow")
@td.skip_if_no("pyarrow")
def test_dataframe_arrow_interface(using_infer_string):
df = pd.DataFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]})... |
8b9d49858a8b859d4fe649e1e69f6d2e997638a589559ada06949664a4f44631 | Python | 4,196 | 120 | import pathlib
import importlib.resources
import dclab
import numpy as np
from PyQt6 import uic, QtCore, QtGui, QtWidgets
class Rlme4ResultsDialog(QtWidgets.QDialog):
def __init__(self, parent, rlme4_results, *args, **kwargs):
super(Rlme4ResultsDialog, self).__init__(parent, *args, **kwargs)
ref ... |
1810c5fd61c99e1cfe005836331a265dd4b55aa0d611df9f8165d644e96dd578 | Python | 4,202 | 150 | """define generic base classes for pandas objects"""
from __future__ import annotations
from typing import (
TYPE_CHECKING,
Any,
cast,
)
if TYPE_CHECKING:
from pandas import (
Categorical,
CategoricalIndex,
DataFrame,
DatetimeIndex,
Index,
IntervalIndex... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.