sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
eaba96b4e903b5275baf7364cb3caf602147b7cb0de00a2beb0a126da6f7e456 | Python | 1,614 | 52 | from io import StringIO
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
class TestInvalidConcat:
@pytest.mark.parametrize("obj", [1, {}, [1, 2], (1, 2)])
def test_concat_invalid(self, obj):
# trying to concat an ndframe with a non-ndframe
df1 = pd.DataFrame(... |
fca5c9d80bb7f85a833b870920fd5f96c77cec816fcd96ac933d3a9530f991ae | Python | 1,615 | 61 | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import sys
import matplotlib.ticker as ticker
import matplotlib.transforms as transforms
from pathlib import Path
import math
from statistics import mean, stdev
from plotting_functions import *
#create figure and set font
fig, ax = plt.subplots()
... |
7381ba21692f7307a0dfed19428bfaae5eafa10327dace66cc23efd6010aac1c | Python | 1,617 | 62 | # -*- coding: utf-8 -*-
# Add classes from directory #
from sdna.net.core.ae import *
from sdna.net.core.channel import *
from sdna.net.core.encoder import *
from sdna.net.core.decoder import *
from sdna.net.core.coder import *
from sdna.net.core.interleaver import *
from sdna.net.core.layers import *
# Add networks ... |
7f1309126849886531d70b39cd5ad8efdbd0072e35e41d64f96a2f13b1c8eae3 | Python | 1,618 | 54 | from torch import distributions as pyd
import math
import torch.nn.functional as F
import numpy as np
class TanhTransform(pyd.transforms.Transform):
domain = pyd.constraints.real
codomain = pyd.constraints.interval(-1.0, 1.0)
bijective = True
sign = +1
def __init__(self, cache_size=1):
su... |
a3fe424a84bf484b6d7c903796a740787d8a62b4bac7b698eea5343c968220f8 | Python | 1,618 | 53 | import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
import pandas._testing as tm
@pytest.mark.parametrize("dtype", ["int64", "float64"])
def test_to_numpy_na_value(dtype):
# GH#48951
ser = pd.Series([1, 2, pd.NA, 4])
result = ser.to_numpy(dtype=dtype, na_value=... |
1fc68ed1cb4c6d6453444148b48712848e86f6e7bf47d6c57d8de6d492df8b3b | Python | 1,619 | 61 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Created by Roberto Preste
from collections import namedtuple
from pkg_resources import resource_filename
import unittest
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from mtoolnote.human import HumanVariant
class TestHumanVariant(unitte... |
78815b22789031b679808feea301b65b807643ecfdce9bb555989053ae16667d | Python | 1,619 | 51 | import torch
from mrpro.operators import Jacobian
from mrpro.operators.functionals import L2NormSquared
from mrpro.utils import RandomGenerator
from tests.helper import dotproduct_adjointness_test
def test_jacobian_adjointness() -> None:
"""Test adjointness of Jacobian operator."""
rng = RandomGenerator(123)... |
0bd388f0b7f53c2dce479c1029b6c407f0d165491dda96c615e663f59cbe34d1 | Python | 1,620 | 79 | featuresets_dict = {
"numwords": [["numwords", {}]],
"BERT_all": [
["contextual_lm", {"model_name": "bert-base-uncased", "layer_num": -1}]
],
"BERT_10": [
[
"contextual_lm",
{
"model_name": "bert-base-uncased",
"layer_num": -1,
... |
3ac4c4a73c94635d58dbc5cc65e81f03b46f7d9e7e991d805ae2cc5b3c37eddb | Python | 1,621 | 48 | import numpy as np
import matplotlib.pyplot as plt
import sys
plt.rc("xtick",labelsize=18)
plt.rc("ytick",labelsize=18)
plt.rc("axes",labelsize=18)
to_paper = "--to-paper" in sys.argv
folder_z = "/projects/LEIFER/francesco/pumpprobe/instrument_characterization/tuningthickness/20220222/stepbystep_20220222_093056/"
z... |
83ab4b16fa2a0063999e563b1480944a554a69f703143d520711bc8dfb0b42f0 | Python | 1,621 | 45 | import numpy as np
import matplotlib.pyplot as plt
import itertools
import color_palette as cp
from matplotlib import rc
from pylab import rcParams
import sys
# the axes attributes need to be set before the call to subplot
rc('font',**{'family':'sans-serif','sans-serif':['Arial']}, size=10)
rc('text', usetex=True)
rc(... |
ba98b302aa2403794e4a89c4042fd7b5fb6e05c62e33cf9e00bfa54f5b41c44c | Python | 1,623 | 58 | # 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... |
d7843ac6b8f760c0b3d952c90e52b6b6147ee5a34946680f1fd9743141cee430 | Python | 1,623 | 59 | # ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.0
# kernelspec:
# display_name: ol-connectome
# language: python
# name: python3
# ---
# %% [markdown]
# Completeness is defined as th... |
a9cbae086eb41ad14debe7e87545d34debec0aa53f6e0f4022cd2093b70a20ec | Python | 1,626 | 56 | """
vegas example from the Basic Integrals section
of the Tutorial and Overview section of the
vegas documentation (slightly modified).
"""
from __future__ import print_function # makes this work for python2 and 3
import vegas
import numpy as np
import gvar as gv
import sys
if sys.argv[1:]:
SHOW_GRID = eval(s... |
b4cfd671171a6e36a96f1356641d103be2ebf7c980b866718a91e273089d6439 | Python | 1,626 | 47 | import os
from .DropDownMenu import DropDownMenu
class SelectSes(DropDownMenu):
"""
A dropdown menu widget specifically designed for selecting session directories.
"""
def __init__(self, default_msg):
"""
Initialize the SelectSes widget.
Args:
default_msg (str): T... |
be1e74f955c5e723cf84d4b0ff271fee778586ee288b11a3864b55f6b91d8786 | Python | 1,630 | 42 | # 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... |
e50cae8673535781da69e272a0cae8a5c4b872668f9a4aa30b085b7e29da4b17 | Python | 1,630 | 56 | import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import math
def ensembleData(X,y,idealSub):
groupData = [X[member] for member in idealSub]
groupData = np.concatenate([groupData[_] for _ in range(len(groupData))],axis=-1)
groupData = np.concatenate([groupData[:,:,:,_] for _ ... |
94a971973822304e5db95cc1ec2f0abd8a88259bfdbf8f4d9d2ce9a09219c31f | Python | 1,631 | 48 | # JN 2015-01-06 refactoring
from __future__ import print_function, division, absolute_import
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QListWidget, QVBoxLayout, QLabel, QSizePolicy
from .. import get_relevant_folders, get_time_files
class PickSessionDialog(QDialog):
"""
pick a session for sorti... |
418727c9ca608f580f9c79ca2423914a3222f74ceb4ba5845d680f915a00b32d | Python | 1,632 | 62 | from abc import ABC
from typing import List, Optional, Union
import pandas as pd
from pycaret.internal.display.display_backend import (
DisplayBackend,
SilentBackend,
detect_backend,
)
from pycaret.internal.logging import get_logger
class DisplayComponent(ABC):
def __init__(
self,
*,... |
e19600eecdafb799da7166c9c154de864df9eda58524dfa39b8c9b15fbaf4ca7 | Python | 1,632 | 43 | import torch
import torch.nn as nn
from sequence_models.losses import MaskedCrossEntropyLoss
if torch.cuda.is_available():
device = torch.device('cuda')
else:
device = torch.device('cpu')
def test_masked_cel():
n = 5
ell = 7
t = 11
scores = torch.randn(n, ell, t).to(device)
targets = tor... |
c79d1be60b9e7fa02d3a453aa8f0eb68921497be138d260a868bab43e40d179f | Python | 1,633 | 41 | # -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet):
# ----------------------------------------------------------------------------------------------... |
f8fc3f7746bf776dc755a4730298b7044dcf30ad2b1e132e36d534082e835f4e | Python | 1,633 | 49 | import sys, re
strip = False
if len(sys.argv) > 1:
strip = bool(int(sys.argv[1]))
splitter = re.compile(' *[-+|:] *')
spill = re.compile('(.+)S[0-9]+$')
pred_name = re.compile('[^(]+\((.+)\)')
#pred_name = re.compile('(.*\.\()?([^ ()]+)\)?')
def cleanParens(l):
for i, x in enumerate(l):
x_new = x
... |
1cc0b834a649a57a7e4f4cba76b195639772c7cc6ab0d0943f823c294a69ef7c | Python | 1,635 | 47 | import torch
import torch.nn as nn
from tnn.layers import LinearLayer, AntiSymmetricLayer, HamiltonianLayer
class ResidualLayer(nn.Module):
def __init__(self, width, h=1.0, activation=None, bias=True, device=None, dtype=None):
factory_kwargs = {'device': device, 'dtype': dtype}
super(ResidualLaye... |
d71c9739dd6a54c0ac41c8a1e32209963ffa360adae12c1c23d470d2f2f01534 | Python | 1,635 | 50 | import pytest
import pandas as pd
import pandas._testing as tm
class TestSeriesUnaryOps:
# __neg__, __pos__, __invert__
def test_neg(self):
ser = pd.Series(range(5), dtype="float64", name="series")
tm.assert_series_equal(-ser, -1 * ser)
def test_invert(self):
ser = pd.Series(ran... |
12c4e6c10db1ba16782105211f31854d5c7ec965739a38b3e9bc60c5c327c440 | Python | 1,636 | 61 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""The setup script."""
from setuptools import setup, find_packages
with open('README.rst') as readme_file:
readme = readme_file.read()
with open('HISTORY.rst') as history_file:
history = history_file.read()
requirements = [
"Click>=6.0",
"nipype>=1.2.2... |
ee785d5d2a17d81d6f2b2cb1bf941d319a783d016b9405603439205e42c3fda8 | Python | 1,636 | 57 | import pytest
from pandas._libs.tslibs import offsets
from pandas.tseries.frequencies import (
is_subperiod,
is_superperiod,
)
@pytest.mark.parametrize(
"p1,p2,expected",
[
# Input validation.
(offsets.MonthEnd(), None, False),
(offsets.YearEnd(), None, False),
(None,... |
43b0f1533314e1b6e6269ca526e8f5f57863dccccaff7a8fba2e522dcd6ae23f | Python | 1,637 | 67 | import numpy as np
from scipy.optimize import curve_fit
'''Weighted correlation coefficient, Wikipedia and [1].
[1] https://stackoverflow.com/questions/38641691/weighted-correlation-coefficient-with-pandas'''
def m(x, w):
"""Weighted Mean"""
return np.sum(x * w) / np.sum(w)
def cov(x, y, w):
"""Weighted ... |
fc92a8fed05b96155f445feb9dbae2c0e0089a86f7772874d2c5c8971fcf49f9 | Python | 1,637 | 59 | """Test plot export"""
import os
import pathlib
import shutil
import tempfile
from PyQt6 import QtWidgets
import pytest
from shapeout2.gui.main import ShapeOut2
from shapeout2.gui import export
from shapeout2 import session
datapath = pathlib.Path(__file__).parent / "data"
@pytest.fixture(autouse=True)
def run_aro... |
4453db6f68e58a0cb0f5da29c66364593455de026c21cf64082ef13599e15515 | Python | 1,638 | 61 | from AnalysisProcess.BasicAnalysisProcess import BasicAnalysisProcess
import numpy as np
from psychopy import core
import pickle
import os
class TestingProcess(BasicAnalysisProcess):
def __init__(self):
self.algorithm = None
self.cacheData = None
self.W = None
sup... |
8aea8a91abee6c98c0eed377a6b3144700ede6b927e2ddccc7fc011c55980d54 | Python | 1,638 | 49 | # Utils methods
from .config import DIMENSION
import numpy as np
from tensorflow.keras import backend as K
from tensorflow.keras.layers import Conv2D, Conv3D
def deprocess_image(img):
"""Same normalization as in:
https://github.com/fchollet/keras/blob/master/examples/conv_filter_visualization.py
"""
#... |
5450812fc4d94e3845b83b10356841a784db0ad0fed8e2ce36637c3803ebdbce | Python | 1,640 | 22 | """Contains miscellaneous information about the implemented indices
[index-name] : (ClassName, Abbreviation, (ways of calculating the index,))
"""
Indices = {"Austin-Colwell": ("AustinColwell", "AC", ("1sim_wdis", "1sim_dis")),
"Baroni-Urbani-Buser": ("BaroniUrbaniBuser", "BUB", ("1sim_wdis", "1sim_dis")),
... |
e0944a61562dfe51a6f41e137ff986aa538c79515f7ce1be76c530806df448d2 | Python | 1,643 | 60 | """Customizable model hyperparameter """
import tensorflow as tf
from .layers import (
dense_attention_layer, sequence_attention_layer,
contextual_attention_layer, learned_positional_encoding,
sinusoidal_positional_encoding
)
# Specifies types of RNN cells used for the SMILES encoder.
# Uses CUDA implemen... |
3292ac29e0d8fc79174fff9dbbc9b5fd3e32b0be235279ab8c7316242e67d129 | Python | 1,644 | 48 | import sys, re, argparse
argparser = argparse.ArgumentParser('''Computes accumulation, future, and spillover columns from a space-delimited input column list.''')
argparser.add_argument('-a', '--accumulate', dest='accumulate', action='store_true', help='Compute accumulation columns')
argparser.add_argument('-f', '--fu... |
905d37f780450f822956a775851c6efa64345ca904093c2476993294b9e52ba3 | Python | 1,644 | 50 | """
Supported Arguments for model variant:
* For GPT-Neo and OPT family, everything before the slash shown in the get_llm_vec.py
file (i.e., EleutherAI/ and facebook/) is not needed in any step after get_llm_vec.py
GPT-2 family:
"gpt2", "gpt2-medium", "gpt2-large", "gpt2-xl"
GPT-Neo family:
"gpt-neo-125M", "gpt-ne... |
a279af461de4e4c2c12fd29ac211d7fd8f3c7bb671b4bab7c1bb5e735c6a1708 | Python | 1,645 | 61 | import numpy as np
import torch
import re
def read_pfm(filename):
file = open(filename, 'rb')
color = None
width = None
height = None
scale = None
endian = None
header = file.readline().decode('utf-8').rstrip()
if header == 'PF':
color = True
elif header == 'Pf':
co... |
62c6b13ea10f7a40ebfcf7b8b6bf2287fe636356b930758440c527d0bb9d92cf | Python | 1,646 | 65 |
import sys
import re
import getopt
# python peval.py (-i) <goldfile> <hypothfile> (where -i ignores role label, just compares topology)
optlist,args = getopt.gnu_getopt(sys.argv,'rl')
gfile = open(args[1],'r')
hfile = open(args[2],'r')
labelIgnored = '-l' in sys.argv
def click(gprop, hypoths):
if not labelIgno... |
afa3d07cb5b36e35fb03303b89f4f8647b2a30b836c58bb4fe6f19fa38c66d2d | Python | 1,646 | 48 | # 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... |
ba01c873d0f9aa88c800bc56e77f6db950e47af4b161887baeaf0eea1baa9a8f | Python | 1,648 | 62 | """
Shared methods for Index subclasses backed by ExtensionArray.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
from pandas.util._decorators import cache_readonly
from pandas.core.indexes.base import Index
if TYPE_CHECKING:
import numpy as np
from pandas._typing import (
... |
d36c7b5f1b850563323824b78fff5785584db1d22d69aed9f190a9f8ea31e8e3 | Python | 1,650 | 54 | #!/usr/bin/env python
import os
from shutil import copyfile
try:
import pyproj
except ImportError:
print("'pyproj' is not installed. Use the command below to install it:")
print(" pip install pyproj")
exit()
def copy_with_check(src, dst):
if os.path.isfile(dst):
print('{0} file alrea... |
629fd05d6e84b812206d36e8f4fc2b2a6061850b04994b204e2b27ed9b8e3581 | Python | 1,652 | 50 | __all__ = ["PeptideMS2Trainer"]
import os
from logging import Logger
from typing import List, Optional, Union
from ....util.progress import ProgressFactoryProto
from ...common.training import TrainerBase
from ...util.writer import SummaryWriterProto
from .data import PeptideMS2Data, PeptideMS2DataBatch
from .loss imp... |
266dfacace631bb645b592b7d5615f5af152504cbe1bd2667e91a16c4b6cb30f | Python | 1,654 | 58 | import numpy as np
from pathlib import Path
import json
from model.utils import get_grid, get_griddata, get_energy_histogram
class Dataset(object):
"""
Dataset for Energy grid histogram
"""
griddata_format = '.griddata16'
grid_format = '.grid'
def __init__(self, path, downstream, split):
... |
f395c133914217b03cb203614585719f1cadbbb6488710ee84723233b3e7cd18 | Python | 1,654 | 52 | import numpy as np
import pytest
import emcee
from emcee.backends.hdf import TempHDFBackend, does_hdf5_support_longdouble
def test_longdouble_doesnt_crash_bug_312():
def log_prob(x, ivar):
return -0.5 * np.sum(ivar * x**2)
np.random.seed(0)
ndim, nwalkers = 5, 20
ivar = 1.0 / np.random.rand(... |
0d65ba51c1f90f7fd00263e3d1cda515f076b253d59dd8063026158b8353f8d7 | Python | 1,655 | 59 | from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
U_ref = np.array([10.0, 10.0])
Z_ref = np.array([10.0, 10.0])
z_0 = np.array([3e-4, 0.01])
z_ground = np.array([0.0, 0.0])
kappa = 0.41
C_mu = 0.09
z = np.linspace(0.1, 100.0, 100)
z = np.tile(z, (len(U_ref), 1)).T
U_star = ka... |
5e856092edd8031068b1269b483c9827b24740614dde4d0f58c38cf1c9d22264 | Python | 1,655 | 54 | """
_
.__(.)< (KWAK)
\___)
~~~~~~~~~~~~~~~~~~~~
"""
import time
import sys
sys.path.append("../")
from HandPoseStreamer.pose_streamer import Pose_Streamer
def working_example_1():
# Working example of a TCP stream of pose data from Python to Unity
# One pose is made of 17 triplets of ... |
072a0d09a288ed6cb08f8507ba916107fe9dcf2bc0379d4315bd9c6bc5abf75f | Python | 1,656 | 44 | import os
from unittest import TestCase
import pandas as pd
import dynast.preprocessing.aggregation as aggregation
import dynast.preprocessing.conversion as conversion
import dynast.utils as utils
from .. import mixins
class TestAggregation(mixins.TestMixin, TestCase):
def test_read_rates(self):
aggre... |
1be349b5686618621ab049e54e1ff5d57f917931ff51b38a659f0ce41610e23b | Python | 1,656 | 56 | """2D radial trajectory class."""
import torch
from mrpro.data.KTrajectory import KTrajectory
from mrpro.data.traj_calculators.KTrajectoryCalculator import KTrajectoryCalculator
from mrpro.utils.reshape import unsqueeze_tensors_left
class KTrajectoryRadial2D(KTrajectoryCalculator):
"""Radial 2D trajectory."""
... |
690de4e51dedd4b98aef1d9bc5a3b4e4cbf98f29105fef2e1b5d3cb1a66a4afe | Python | 1,657 | 46 | """
# Microbiome Analysis Powered By Recursive Quasi-species Networks:
Description:
Uncovering rules of organization, competition, succession and exploitation
---
Installation:
```
pip install qbiome
```
or
```
pip3 install qbiome --user
```
Notes:
Depends on the `quasinet` packa... |
122440cd9bcdb2ba85b5be8cb4967338f9df2d825994804672f8e4380dfebb31 | Python | 1,658 | 62 | import time
import logging
import torch
import numpy as np
import ismrmrd
import gadgetron
from modules.schemas.base_image_array import (
BaseImageArrayNormalisation,
BaseImageArrayTransformations,
)
from modules.schemas.mlc_tracking import (
MLCImageArrayParser,
MLCSocketmaker,
... |
41a1a884fbbf581a8a89056ad44660b9f44f8a86213a4e4e6b86c5a88b9d3704 | Python | 1,658 | 41 | from base import loggingUtils
import numpy
import optparse
import os
import shutil
import logging
from base import imageTimeSeries, imageTimeSeriesConfig
def loadData_for_async(fbase, t):
from tvtk.api import tvtk
r = tvtk.XMLStructuredGridReader(file_name="%s%d.vts" % (fbase, t))
r.update()
v = numpy.... |
8d5dec95b943bcd7d3ac4da10310b8d3ccce0ea4e38153a7a07a8092fb186a9b | Python | 1,658 | 38 | from tests.conftest import FIRST_LINE_MODEL_PATH
import pytest
@pytest.mark.assets_required
class TestBinaryModel:
# Pre-trained model (from Spectrum paper)
def test_predict(self, first_line_model_from_file, growth_image, no_growth_image):
output_prediction = first_line_model_from_file.predict(growth_... |
5c70c5a865ae3a49f5201bfc873678548b69f3b0ddec4d00bcf8bf28bb24f33d | Python | 1,661 | 29 | # SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of sourc... |
233b0eab49c4348eff60701523e4a265f1f2716ecb45767d6ba4ffb6ed0a1d97 | Python | 1,662 | 49 | from datetime import datetime
import numpy as np
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
def test_reindex_like(datetime_series):
other = datetime_series[::2]
tm.assert_series_equal(
datetime_series.reindex(other.index), datetime_series.reindex_like(... |
3dc90b269242c65673f1bf9918bf4beec5353a9f6889e5d6d4e08dcca0b8bc02 | Python | 1,662 | 49 | # Copyright 2018-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 ... |
466efd1985e16b00d6ec06c9040cc74acc1840d324db3697b4c86971167bb999 | Python | 1,662 | 57 | import numpy as np, sys, matplotlib.pyplot as plt
import pumpprobe as pp
head_only = "--head-only" in sys.argv
funa = pp.Funatlas(merge_bilateral=True,merge_dorsoventral=False,merge_AWC=True)
funa.load_aconnectome_from_file(chem_th=0,gap_th=0,exclude_white=False)
aconn_gap = funa.aconn_gap.copy()
aconn_chem = funa.... |
c4450b10a907c0bae1604db45e20423e94f9e38d6b846b85a01e940d86b95fb4 | Python | 1,662 | 37 | # Copyright 2019 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# 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://w... |
97d66207d33567b4470a24eaeac6fa8475230af206705a7e4093c228592759f7 | Python | 1,664 | 55 | """
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 ray import tune
def tune_reporter(
iters,
train_metrics,
val_metrics,
test_metrics=None,
metric_to_op... |
d1cec08566748cf13a9c82406fca2349c260c7a7d5a2e8ce01e736759007087d | Python | 1,664 | 59 | import dclab
import matplotlib.pylab as plt
# dataset
ds = dclab.new_dataset("fluorescence/fluorescence.rtdc")
# plot
fig = plt.figure(figsize=(7, 3))
ax1a = plt.subplot(121)
ax1a.scatter(ds["area_um"], ds["deform"], s=.2,
marker=".", color="#A51200", alpha=1)
ax1a.tick_params('x', colors='#A51200')
a... |
74042f632b1bfefe85b5eb21fd9ea93f8bf93f9a0b68318e002411a8e5b47f78 | Python | 1,666 | 51 | import time
from StimulationSystem.StimulationProcess.BasicStimulationProcess import BasicStimulationProcess
from psychopy import core, event
import datetime
class StimulateProcess(BasicStimulationProcess):
def __init__(self) -> None:
super().__init__()
def change(self, result):
... |
b2a860d9c70656c155873bf4a52245d759e52ed44572b193de31fc8ec85d91d2 | Python | 1,666 | 56 | from src import simulation
import numpy as np
from numpy.random import default_rng
def test_population_minmax():
""" test if population is between min and max """
min = 20
max = 60
N = 100
population = simulation.get_population(min,max,N)
assert np.all(population >= min)
assert np.all(popul... |
e31bebe686b925b9371599c58df802a79b806d42597822975993cbc6d4cb7fa0 | Python | 1,669 | 53 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def test_transpose(index_or_series_obj):
obj = index_or_series_obj
tm.assert_equal(obj.transpose(), obj)
def test_transpose_non_default_axes(index_or_series_obj):
msg = "the 'axes' parameter is not supported"
obj = in... |
7791ecf2781141276983b432a59f9216341a4007edd2e342d453af2de328dec5 | Python | 1,672 | 59 | #!/usr/bin/env python3
# coding: utf-8
"""Detect loops (and other patterns) in Hi-C contact maps."""
from setuptools import setup, find_packages
import codecs
CLASSIFIERS = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programm... |
254b8276224f9d877c949e80846cc89e7d1bb0c6026d12513ebad2d89f0485cb | Python | 1,673 | 62 | import os
import shutil
class models_genesis_config:
model = "Vnet"
suffix = "genesis_chest_ct"
exp_name = model + "-" + suffix
# data
data = "/mnt/dataset/shared/zongwei/LUNA16/Self_Learning_Cubes"
train_fold=[0,1,2,3,4]
valid_fold=[5,6]
test_fold=[7,8,9]
hu_min = -1000.0
... |
349d68e7f818f6d8abe8545073e138c6a3f6eec2f492eb339082e2e429f2cec5 | Python | 1,673 | 55 | import ast
import argparse
import configparser
from xgb.create_tree import Tree
from cnn.Pilot1.P1B3.cnn import CNN
def main(args):
tree_model = Tree(args)
tree_model.train()
tree_model.evaluate()
cnn = CNN(args)
print('\n############ FINAL RESULTS #############\n')
results = [
['X... |
c34408f527e88aca94621b804c324682c37f100c4f7d7f434c2b1e9a40e55daf | Python | 1,678 | 42 | # -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet):
# ----------------------------------------------------------------------------------------------... |
f75d1decb8edb5c50cfec77d1ee08dad5282a185bb14de0200afa009b712d5a8 | Python | 1,678 | 42 | # -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet):
# ----------------------------------------------------------------------------------------------... |
a9de4aa971d700927c3a0f78aaa7cce4621ae96dbd27f5c124250c37015e92b1 | Python | 1,679 | 55 | """Position feed-forward network from "Attention is All You Need"."""
import torch.nn as nn
import torch.nn.functional as F
class ActivationFunction(object):
relu = "relu"
gelu = "gelu"
ACTIVATION_FUNCTIONS = {
ActivationFunction.relu: F.relu,
ActivationFunction.gelu: F.gelu,
}
class Positionwise... |
998baf8e0e9cba93b7d25d9fdcfac901114d7e00df7667eb818a1121da33cdd9 | Python | 1,683 | 71 | import logging
class InsertError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return f"Insert Error: {self.value}!"
def __repr__(self):
return self.__str__()
class MitosisError(Exception):
def __init__(self, message=None):
self.messag... |
cdbaeb7a83bbe711aa42187eb20cb5236561354db5c1054a34561deaaf0900fe | Python | 1,683 | 43 | import torch
def get_optimizer(model, cfg):
if cfg.OPTIMIZER.OPTIMIZING_METHOD == 'sgd':
return torch.optim.SGD(
model.parameters(),
lr=cfg.OPTIMIZER.BASE_LR,
momentum=cfg.OPTIMIZER.MOMENTUM,
weight_decay=cfg.OPTIMIZER.WEIGHT_DECAY,
dampening=cfg... |
e3c987ccd1e98f3bc42e1ec7ee1b0b61404af76700be275dd2e83d5cd999ca70 | Python | 1,683 | 57 | import pytest
import pandas as pd
from pandas.tseries.offsets import (
BaseOffset,
BDay,
Day,
Hour,
)
class TestFreq:
def test_freq_setter_errors(self):
# GH#20678
idx = pd.DatetimeIndex(["20180101", "20180103", "20180105"])
# setting with an incompatible freq
ms... |
1ac87153c55a086f31f8dd749ab189df8686f9560de06ffb52240ce2a87c376c | Python | 1,685 | 49 | """
module docstring
"""
import os
from cptools2 import generate_scripts
CURRENT_PATH = os.path.dirname(__file__)
TEST_DIR_PATH = os.path.join(CURRENT_PATH, "example_commands")
def test_make_command_paths():
"""cptools2.generate_scripts.make_commands_paths(commands_location)"""
paths = generate_scripts.make_... |
de8480b6750c6a559c17b92b71f2c8259e43286ced4ed55c13591d4c269c8351 | Python | 1,685 | 47 | """Phase 11 statistical-computing package.
Each procedure is a typed module under this package exposing a single
``run(df, params) -> AnalysisResult`` function. The dispatcher
(:mod:`pycaret_server.analyses.factory`) resolves by ``Analysis.kind``;
adding a new procedure is one new module + one entry.
The result envel... |
a5f9abaac4f7a195bd09f0df6c80314e8d9e5f32a2760985d1762127bb2d8257 | Python | 1,687 | 99 | from __future__ import annotations
from pandas._libs.tslibs.offsets import (
FY5253,
BaseOffset,
BDay,
BHalfYearBegin,
BHalfYearEnd,
BMonthBegin,
BMonthEnd,
BQuarterBegin,
BQuarterEnd,
BusinessDay,
BusinessHour,
BusinessMonthBegin,
BusinessMonthEnd,
BYearBegin,
... |
b1e6c03ddfc3553886abd4fd6ac30a0022c2b98801574bd1482796d8fabf1245 | Python | 1,687 | 49 | import os
import sys
import numpy as np
import nibabel as nib
# Get the absolute path to the root directory of your project
project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
# Append the project root to sys.path
sys.path.append(project_root)
from src.nexi.pow... |
1dca76b761a69f7ed81982cf8f3c6e377b65af0e3fa2cbb520dc6b8b59508a45 | Python | 1,688 | 50 | import numpy as np
from abc import ABC
class MIcroSTructureParameters(ABC):
"""Microstructure parameters."""
def __init__(self, mist_model, param=None):
"""Initialize the microstructure parameters."""
# number of parameters
self.n_params = mist_model.n_params
# parameter names... |
57d94bc28ae89fb82d03290cf69955f27e9136d1dfacf03bc1a8435b3679e81c | Python | 1,689 | 58 | """Sanity check image sizes and svg viewboxes."""
from PIL import Image
from pathlib import Path
from lxml import etree
import sys
def _check_image(base_dir, image_dir):
assert image_dir.is_dir()
expected_size = (int(image_dir.name), int(image_dir.name))
num_bad = 0
num_good = 0
for image_file in image_dir.iter... |
a8a027d397e5de0b5026470509f1cdd705b6f862b9d58b0ec49c662a32652e9e | Python | 1,689 | 53 | import re
import numpy as np
import pandas as pd
from torch.utils.data import Dataset
def load_flip_data(data_fpath, dataset, split, max_len=2048):
"""returns dataframe of train, (val), test sets"""
datadir = data_fpath + dataset + '/splits/'
path = datadir + split + '.csv'
df = pd.read_csv(path)
... |
b4c617f8535f521496d62b4b057e6523a6d2f83520e3c0ce3a0c2ee0ef028b5c | Python | 1,690 | 31 | # SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of sourc... |
a19d35616302fe62cd73ba41dd08e0a0f3a337e440c8d686b450d36e1f74a032 | Python | 1,692 | 49 | # 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... |
df4ce5ca55c436143e6ba03b7d81b2cb8df74cadf373129f108c4874c88fbb59 | Python | 1,693 | 43 | import os, sys, glob
import vcf
from csv import DictWriter, DictReader
from Bio import SeqIO
FIELDS = ['locus', 'size', 'num_snp', 'num_hap_nopartial', 'num_hap_withpartial']
dirs = glob.glob('by_loci/*size*')
f = open('summarized.isophase_results.txt', 'w')
writer = DictWriter(f, FIELDS, delimiter='\t')
writer.writ... |
8f350e9efcda87e8267939f36b9fe3d2d460be7ec82cb6c8e39a0f62b1bda3a3 | Python | 1,694 | 51 | #####################################################################################################################
# Date created : 10/21/2022
# Date modified: 10/21/2022
# Purpose : This program is to crate features from pdb phi-psi-alpha (sin,cos) total 6
##############################################... |
93e8ac9e8fce1af5b87a4feeb51a43602417c62ac2de5fe8c4ca2924d3612100 | Python | 1,697 | 53 | # 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... |
610913eb050679ae21c9a79338f003d729161cdfec00244748c188d4c0f453be | Python | 1,698 | 54 | # 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... |
173dee899a9bc2081885f9ce336c01bd48f26127fd04d504a432da760364ba8e | Python | 1,699 | 34 | ###############################################################################
# This script This function extracts the pubmed id of the papers that are #
# selected based on abstracts reviews. #
# #
... |
45d3a36756ba3e119d2f7c197af2539e6a12ed1b61d73737fe9ffc8fde62e7b6 | Python | 1,701 | 59 | import numpy as np
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
import seaborn as sns
import myvariant
def mutation_ratio(id1, id2, df_sum, res):
tmp1 = df_sum.loc[(df_sum['SYMBOL'] == id1)]
tmp2 = df_sum.loc[(df_sum['SYMBOL'] == id2)]
tmp1.reset_index(inplace=True)
tmp2.... |
d8799870ed8f5a0744330878b9e49d3bac9d693534669394e1aa752f497093aa | Python | 1,701 | 38 | import numpy as np
import time
class CRF(object):
def __init__(self, testing_size, positive_unary_energy, co_exp_net, theta):
self.unary_potential = np.vstack((1 - positive_unary_energy, positive_unary_energy))
self.co_exp_net = co_exp_net
self.current_q = np.zeros((2, testing_size))
... |
b600b62aab1498cc2e45598e8ec2fd180e7bf417f90c84fbeebea92dac657710 | Python | 1,704 | 57 | #%%
from pathlib import Path
from src import fs_roi_lut
import nibabel as nib
import seaborn as sns
#%%
name = 'fs'
LOCATION = Path(__file__).parent
data_dir = LOCATION.parent.parent / 'data'
roi_file = Path(data_dir,f'rois_{name}.json')
location = Path(__file__).parent
subject_dir = location.parent.parent.parent / 'f... |
4a800e3d378b6bcc7ba7f1e5eaba66687e5faa2c44a0b222282cf78f5c44cfda | Python | 1,706 | 40 | ARGS_COL_MAP = {
'target': 'Target',
'pretrained_file': 'Pretrained Model',
'embed_dim': 'Embedding Dimension',
'words_dim': 'Word Dimension',
'epochs': 'Epochs',
'l2logreg_c': 'BoW LR C',
'rf_estimators': 'BoW RF Estimators',
'lr': 'Learning Rate',
'patience': 'Patience',
'mode'... |
2a53f17d021553d8b1332117fec3c14fda024337da4b200b36af58f67cc325ab | Python | 1,707 | 53 | # 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... |
1daddd69c26f5458ab3be7beeede974db8ff955eba7afc3a7f221759388de588 | Python | 1,708 | 61 | from __future__ import annotations
import pandas._testing as tm
from pandas.api import types
from pandas.tests.api.test_api import Base
class TestTypes(Base):
allowed = [
"is_any_real_numeric_dtype",
"is_bool",
"is_bool_dtype",
"is_categorical_dtype",
"is_complex",
... |
401fc9fcce23c2d733e8143d87fe1296f76d5f313fffdab9f96861a53f6b4e3d | Python | 1,708 | 47 | """ObjectStore protocol — every driver implements this.
The interface is intentionally narrow. Anything that's not implementable
across all back-ends (versioning, multipart upload, bucket creation)
lives on the driver itself, not the base. Application code targets only
``ObjectStore``.
"""
from __future__ import anno... |
1ed93294ba9f4514ca104a3620cf2297a21f19f783ab8f5a1dc69252f6a13d58 | Python | 1,711 | 57 | # Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master... |
3007e4d699d142d35915c76cdd6a9bd23cba768c4901fcb42cc214abc1114a62 | Python | 1,711 | 32 | # SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of sourc... |
b778860d35ed89a4b3d4dbb3bf764ffc0ad1bcecd760e235eaa7412a608239da | Python | 1,711 | 64 | # -*- coding: utf-8 -*-
"""
Created on Fri Mar 4 14:43:04 2022
@author: System 6
"""
import os
import sys
# Append paths to delta-dev and deep cell control before import:
sys.path.append('C:/DeepLearning/DeLTA_dev')
sys.path.append('C:/Users/System 6/Documents/deepcellcontrol')
sys.path.append('C:/Users/System 6/Docu... |
5b9808e6dd9691faa0eaf62f29f4fcfb6b841c76891d928a9f56b6da6a3b4e0d | Python | 1,712 | 62 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 8 11:19:58 2023
@author: tomas
"""
import pandas
import warnings
import cine
# mm between each marking on the tube
TENTH_DISTANCE = 5.5
# mL between each marking on the tube
TENTH_VOL = 0.1
def get_table():
table = pandas.read_csv("unit_co... |
531d9e58f67e4190ecd2c116ebca615f26d5dd20cfe89a43c9379e339ea422d2 | Python | 1,713 | 51 | import pytest
import pandas as pd
class TestTimestampToJulianDate:
def test_compare_1700(self):
ts = pd.Timestamp("1700-06-23")
res = ts.to_julian_date()
assert res == 2_342_145.5
def test_compare_2000(self):
ts = pd.Timestamp("2000-04-12")
res = ts.to_julian_date()
... |
3a2da2cbfe38f39d51decdbe73a9d6ad62edd53d279b9d22ce57a68c3274c3d1 | Python | 1,714 | 50 | import sys
sys.path.append('.')
import time
from CommonSystem.MessageReceiver.ExchangeMessageManagement import ExchangeMessageManagement
from CommonSystem.Config import Config
from OperationSystem.operationOperator import operationOperator
from OperationSystem.AnalysisProcess.AnalysisController import AnalysisC... |
78daa33bf8e5fdea170e9f39cbc77c1244e1af4f83c81373982e51294c8352ec | Python | 1,714 | 55 | from Common import loggingUtils
from Surfaces.surfaces import *
from Common.kernelFunctions import *
#import surfaceTimeSeries as match
from Surfaces import secondOrderMatching as match, surfaceMatching
def compute():
outputDir = '/Users/younes/Development/Results/threeBallsSplineAndMomentum'
#outputDir = '/... |
8c7891034e8f591e0bbb80c126dcb3e77c94ca39f14c1e3ca74c9a4e727d6490 | Python | 1,714 | 56 | # 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... |
ea31177366ccfa06c8dbcbd0b8ea3c1bd90016170d807ea2e97e23086a1f420f | Python | 1,715 | 62 | from src import config_handler
import json
import pytest
import os
import tempfile
import yaml
TEST_NAME_JSON = 'test_file.json'
TEST_NAME_YAML = 'test_file.yml'
TEST_DICT = {'PATHS':{'Test1':1, 'Test2':2}}
def setup_module():
with open(TEST_NAME_JSON, 'w') as f:
json.dump(TEST_DICT, f, indent=4)
wit... |
026c7809a84673010a0664d112aab0d8c80247f407afee4580ebac45c7eec518 | Python | 1,716 | 69 | import sys
import numpy as np
import pandas as pd
def filter_regressions(x):
subject = x.subject.values
docid = x.docid.values
trialid = x.trialid.values
trialpos = x.trialpos.values
key_prev = (None, None, None)
frontier = -1
sel = []
for s, d, t, ix in zip(subject, docid, trialid, tr... |
8aeea34db11d6420ceb9e3aa98823b67d47194a92690c525be939eb4729ebe9e | Python | 1,716 | 52 |
import json
import cine
from matplotlib import pyplot
import itertools
import random
import tube2
import re
DATE_EXPR = re.compile("\d{4}.\d{2}.\d{2}")
MOTH_EXPR = re.compile("moth\d{2}|mothM\d|mothDelta\d")
def draw_object(ax, entry):
row = entry[1]
col = entry[2]
maxrow = entry[10]
message = str(ro... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.