uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
c4b5fa219403882ab3a3b41d
train
class
class ReliabilityLayer: def __init__(self, transport, address): self.stop = False self.last_ack_time = 0 self._split_packet_id = 0 self._remote_system_time = 0 self._transport = transport self._address = address self._acks = rangelist.RangeList() self._send_message_number_index = 0 self._se...
class ReliabilityLayer:
def __init__(self, transport, address): self.stop = False self.last_ack_time = 0 self._split_packet_id = 0 self._remote_system_time = 0 self._transport = transport self._address = address self._acks = rangelist.RangeList() self._send_message_number_index = 0 self._sequenced_write_index = 0 ...
# Todo: combine packets in datagrams if possible import asyncio import logging import math import time from collections import OrderedDict from pyraknet import rangelist from pyraknet.bitstream import BitStream, c_bit, c_uint, c_ushort log = logging.getLogger(__name__) class PacketReliability: Unreliab...
118
256
1,916
4
113
cmarshall108/pyraknet
pyraknet/reliability.py
Python
ReliabilityLayer
ReliabilityLayer
20
216
20
20
1f22a32b38276ab1a611c7c32860ab723708847a
bigcode/the-stack
train
c208207a162bb3d8d2ff660d
train
class
class PacketReliability: Unreliable = 0 UnreliableSequenced = 1 Reliable = 2 ReliableOrdered = 3 ReliableSequenced = 4
class PacketReliability:
Unreliable = 0 UnreliableSequenced = 1 Reliable = 2 ReliableOrdered = 3 ReliableSequenced = 4
if possible import asyncio import logging import math import time from collections import OrderedDict from pyraknet import rangelist from pyraknet.bitstream import BitStream, c_bit, c_uint, c_ushort log = logging.getLogger(__name__) class PacketReliability:
63
64
47
5
58
cmarshall108/pyraknet
pyraknet/reliability.py
Python
PacketReliability
PacketReliability
13
18
13
13
cb41661d7194b0339fc84de9ded2abce5d16970b
bigcode/the-stack
train
c00e52263e95bdfe9f200aa9
train
class
class YahooFinEngine(AbstractEngine): AnalyseEarningsEstimateDf: pd.DataFrame AnalyseRevenueEstimateDf: pd.DataFrame AnalyseEarningsHistoryDf: pd.DataFrame AnalyseEPSRevisionsDf: pd.DataFrame AnalyseGrowthEstimateDf: pd.DataFrame __analysisDictionary: dict CashFlowDf: Optional[DataFrame] ...
class YahooFinEngine(AbstractEngine):
AnalyseEarningsEstimateDf: pd.DataFrame AnalyseRevenueEstimateDf: pd.DataFrame AnalyseEarningsHistoryDf: pd.DataFrame AnalyseEPSRevisionsDf: pd.DataFrame AnalyseGrowthEstimateDf: pd.DataFrame __analysisDictionary: dict CashFlowDf: Optional[DataFrame] BalanceSheetDf: Optional[DataFrame] ...
from typing import Optional from pandas import DataFrame from yahoo_fin.stock_info import * from Common.Readers.Engine.AbstractEngine import AbstractEngine class YahooFinEngine(AbstractEngine):
36
104
348
7
28
enriqueescobar-askida/Kinito.Finance
Common/Readers/Engine/YahooFinEngine.py
Python
YahooFinEngine
YahooFinEngine
9
45
9
9
cd61191c8f4a3f23759d05cd7554078638e71d1d
bigcode/the-stack
train
7f334dda878ddc643f5292dc
train
function
@view_config(route_name="login", renderer="login.mako") def response(request): if request.method == "POST": username = request.params.get("username") password = request.params.get("password") matched = checkpw(username, password) if matched: request.session["identity"] = ...
@view_config(route_name="login", renderer="login.mako") def response(request):
if request.method == "POST": username = request.params.get("username") password = request.params.get("password") matched = checkpw(username, password) if matched: request.session["identity"] = whois(username) url = request.route_url("home") return ...
from pyramid.httpexceptions import HTTPFound from pyramid.view import view_config from bulbs.components.auth import checkpw, whois @view_config(route_name="login", renderer="login.mako") def response(request):
46
64
110
18
27
CrystallineEntity/bulbs
bulbs/views/login.py
Python
response
response
6
20
6
7
7538a9f4484e73fbf788e0d6ec9cfc31c5f7fbde
bigcode/the-stack
train
debc1bc40ed8cb07f3585291
train
class
class _PLIEst(_EpochMeanConEstBase): """PLI Estimator.""" name = 'PLI' def __init__(self, n_cons, n_freqs, n_times): super(_PLIEst, self).__init__(n_cons, n_freqs, n_times) # allocate accumulator self._acc = np.zeros(self.csd_shape) def accumulate(self, con_idx, csd_xy): ...
class _PLIEst(_EpochMeanConEstBase):
"""PLI Estimator.""" name = 'PLI' def __init__(self, n_cons, n_freqs, n_times): super(_PLIEst, self).__init__(n_cons, n_freqs, n_times) # allocate accumulator self._acc = np.zeros(self.csd_shape) def accumulate(self, con_idx, csd_xy): """Accumulate some connections.""...
con. score for some connections.""" if self.con_scores is None: self.con_scores = np.zeros(self.csd_shape) plv = np.abs(self._acc / n_epochs) self.con_scores[con_idx] = plv class _PLIEst(_EpochMeanConEstBase):
64
64
188
12
51
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_PLIEst
_PLIEst
145
165
145
145
937059c32773ae08cb9b974b047b932b677ef31c
bigcode/the-stack
train
11a4b185817799ad9643ad59
train
class
class _EpochMeanConEstBase(_AbstractConEstBase): """Base class for methods that estimate connectivity as mean epoch-wise.""" def __init__(self, n_cons, n_freqs, n_times): self.n_cons = n_cons self.n_freqs = n_freqs self.n_times = n_times if n_times == 0: self.csd_sh...
class _EpochMeanConEstBase(_AbstractConEstBase):
"""Base class for methods that estimate connectivity as mean epoch-wise.""" def __init__(self, n_cons, n_freqs, n_times): self.n_cons = n_cons self.n_freqs = n_freqs self.n_times = n_times if n_times == 0: self.csd_shape = (n_cons, n_freqs) else: ...
ImplementedError('accumulate method not implemented') def combine(self, other): raise NotImplementedError('combine method not implemented') def compute_con(self, con_idx, n_epochs): raise NotImplementedError('compute_con method not implemented') class _EpochMeanConEstBase(_AbstractConEstBase):...
64
64
188
13
51
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_EpochMeanConEstBase
_EpochMeanConEstBase
44
65
44
44
4ec8fdbca10eb1076103485cd3d441c3d231cede
bigcode/the-stack
train
346fc7eca559b01664f5d831
train
function
def _prepare_connectivity(epoch_block, tmin, tmax, fmin, fmax, sfreq, indices, mode, fskip, n_bands, cwt_frequencies, faverage): """Check and precompute dimensions of results data.""" first_epoch = epoch_block[0] # get the data size and time scale n_s...
def _prepare_connectivity(epoch_block, tmin, tmax, fmin, fmax, sfreq, indices, mode, fskip, n_bands, cwt_frequencies, faverage):
"""Check and precompute dimensions of results data.""" first_epoch = epoch_block[0] # get the data size and time scale n_signals, n_times_in, times_in = _get_and_verify_data_sizes(first_epoch) if times_in is None: # we are not using Epochs or SourceEstimate(s) as input times_in = n...
_con[:, freq_idx_bands[band_idx]], axis=1) this_con = this_con_bands con.append(this_con) if indices is None: # return all-to-all connectivity matrices logger.info(' assembling connectivity matrix ' '(filling the upper triangular region of the matrix)') ...
256
256
1,220
44
211
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_prepare_connectivity
_prepare_connectivity
941
1,052
941
943
668a231a66e1a62d21bd3c4be403986674c558aa
bigcode/the-stack
train
a8998c28001dff18c4efc063
train
class
class _PLIUnbiasedEst(_PLIEst): """Unbiased PLI Square Estimator.""" name = 'Unbiased PLI Square' def compute_con(self, con_idx, n_epochs): """Compute final con. score for some connections.""" if self.con_scores is None: self.con_scores = np.zeros(self.csd_shape) pli_me...
class _PLIUnbiasedEst(_PLIEst):
"""Unbiased PLI Square Estimator.""" name = 'Unbiased PLI Square' def compute_con(self, con_idx, n_epochs): """Compute final con. score for some connections.""" if self.con_scores is None: self.con_scores = np.zeros(self.csd_shape) pli_mean = self._acc[con_idx] / n_epoc...
some connections.""" if self.con_scores is None: self.con_scores = np.zeros(self.csd_shape) pli_mean = self._acc[con_idx] / n_epochs self.con_scores[con_idx] = np.abs(pli_mean) class _PLIUnbiasedEst(_PLIEst):
64
64
135
11
53
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_PLIUnbiasedEst
_PLIUnbiasedEst
168
182
168
168
a6f59f86e4c0fa87ab3bc4ab44c959663eda07cf
bigcode/the-stack
train
07d32dddc6643651f7936d9e
train
class
class _WPLIDebiasedEst(_EpochMeanConEstBase): """Debiased WPLI Square Estimator.""" name = 'Debiased WPLI Square' def __init__(self, n_cons, n_freqs, n_times): super(_WPLIDebiasedEst, self).__init__(n_cons, n_freqs, n_times) # store imag(csd), abs(imag(csd)), imag(csd)^2 acc_shape ...
class _WPLIDebiasedEst(_EpochMeanConEstBase):
"""Debiased WPLI Square Estimator.""" name = 'Debiased WPLI Square' def __init__(self, n_cons, n_freqs, n_times): super(_WPLIDebiasedEst, self).__init__(n_cons, n_freqs, n_times) # store imag(csd), abs(imag(csd)), imag(csd)^2 acc_shape = (3,) + self.csd_shape self._acc = np...
self.con_scores = np.zeros(self.csd_shape) num = np.abs(self._acc[0, con_idx]) denom = self._acc[1, con_idx] # handle zeros in denominator z_denom = np.where(denom == 0.) denom[z_denom] = 1. con = num / denom # where we had zeros in denominator, we set con to...
126
126
422
15
110
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_WPLIDebiasedEst
_WPLIDebiasedEst
223
263
223
223
535ffa044044e2682fd82b79aabc06bd9b9b955d
bigcode/the-stack
train
148f255e118fec30d72caa6b
train
class
class _CohyEst(_CohEstBase): """Coherency Estimator.""" name = 'Coherency' def compute_con(self, con_idx, n_epochs, psd_xx, psd_yy): """Compute final con. score for some connections.""" if self.con_scores is None: self.con_scores = np.zeros(self.csd_shape, ...
class _CohyEst(_CohEstBase):
"""Coherency Estimator.""" name = 'Coherency' def compute_con(self, con_idx, n_epochs, psd_xx, psd_yy): """Compute final con. score for some connections.""" if self.con_scores is None: self.con_scores = np.zeros(self.csd_shape, dtype=np.co...
_scores = np.zeros(self.csd_shape) csd_mean = self._acc[con_idx] / n_epochs self.con_scores[con_idx] = np.abs(csd_mean) / np.sqrt(psd_xx * psd_yy) class _CohyEst(_CohEstBase):
64
64
128
11
53
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_CohyEst
_CohyEst
95
106
95
95
bfa23108d50e80ba1367e54efeb34f0c70e47f0f
bigcode/the-stack
train
d6e7418da6544c6aca5f0bcf
train
function
def _assemble_spectral_params(mode, n_times, mt_adaptive, mt_bandwidth, sfreq, mt_low_bias, cwt_n_cycles, cwt_frequencies, freqs, freq_mask): """Prepare time-frequency decomposition.""" spectral_params = dict( eigvals=None, window_fun=None, wav...
def _assemble_spectral_params(mode, n_times, mt_adaptive, mt_bandwidth, sfreq, mt_low_bias, cwt_n_cycles, cwt_frequencies, freqs, freq_mask):
"""Prepare time-frequency decomposition.""" spectral_params = dict( eigvals=None, window_fun=None, wavelets=None) n_tapers = None n_times_spectrum = 0 if mode == 'multitaper': # compute standardized half-bandwidth if mt_bandwidth is not None: half_nbw = float(mt_b...
%d: %0.1fHz..%0.1fHz ' '(%d points)' % (i + 1, bfreqs[0], bfreqs[-1], len(bfreqs))) if faverage: logger.info(' connectivity scores will be averaged for ' 'each band') return (n_cons, times, n_times, times_in, n_tim...
169
169
565
44
125
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_assemble_spectral_params
_assemble_spectral_params
1,055
1,109
1,055
1,057
3d8b2a5fedfa237262fd210be8de6e48fdf170db
bigcode/the-stack
train
f2726c5440b909d8f09a945b
train
function
@verbose def spectral_connectivity(data, method='coh', indices=None, sfreq=2 * np.pi, mode='multitaper', fmin=None, fmax=np.inf, fskip=0, faverage=False, tmin=None, tmax=None, mt_bandwidth=None, mt_adaptive=False, mt...
@verbose def spectral_connectivity(data, method='coh', indices=None, sfreq=2 * np.pi, mode='multitaper', fmin=None, fmax=np.inf, fskip=0, faverage=False, tmin=None, tmax=None, mt_bandwidth=None, mt_adaptive=False, mt...
"""Compute frequency- and time-frequency-domain connectivity measures. The connectivity method(s) are specified using the "method" parameter. All methods are based on estimates of the cross- and power spectral densities (CSD/PSD) Sxy and Sxx, Syy. The spectral densities can be estimated using a mu...
% msg) con_method_types.append(this_method) # determine how many arguments the compute_con_function needs n_comp_args = [len(_get_args(mtype.compute_con)) for mtype in con_method_types] # we currently only support 3 arguments if any(n not in (3, 5) for n in n_comp_args)...
256
256
3,897
105
150
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
spectral_connectivity
spectral_connectivity
559
938
559
566
bbb42b21aee47404dcb314b1c73686e153b9d9c1
bigcode/the-stack
train
b7f511d5a403bd9846668a55
train
function
def _check_estimators(method, mode): """Check constrution of connectivity estimators.""" n_methods = len(method) con_method_types = list() for this_method in method: if this_method in _CON_METHOD_MAP: con_method_types.append(_CON_METHOD_MAP[this_method]) elif isinstance(this_...
def _check_estimators(method, mode):
"""Check constrution of connectivity estimators.""" n_methods = len(method) con_method_types = list() for this_method in method: if this_method in _CON_METHOD_MAP: con_method_types.append(_CON_METHOD_MAP[this_method]) elif isinstance(this_method, string_types): ra...
'imcoh': _ImCohEst, 'plv': _PLVEst, 'ppc': _PPCEst, 'pli': _PLIEst, 'pli2_unbiased': _PLIUnbiasedEst, 'wpli': _WPLIEst, 'wpli2_debiased': _WPLIDebiasedEst} def _check_estimators(method, mode):
86
86
288
9
77
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_check_estimators
_check_estimators
528
556
528
528
4428ae0f4f24877b5df5c7a14e491003b4b46b88
bigcode/the-stack
train
ed8eca02b6a72b28dd537422
train
class
class _ImCohEst(_CohEstBase): """Imaginary Coherence Estimator.""" name = 'Imaginary Coherence' def compute_con(self, con_idx, n_epochs, psd_xx, psd_yy): """Compute final con. score for some connections.""" if self.con_scores is None: self.con_scores = np.zeros(self.csd_shape) ...
class _ImCohEst(_CohEstBase):
"""Imaginary Coherence Estimator.""" name = 'Imaginary Coherence' def compute_con(self, con_idx, n_epochs, psd_xx, psd_yy): """Compute final con. score for some connections.""" if self.con_scores is None: self.con_scores = np.zeros(self.csd_shape) csd_mean = self._acc[c...
.csd_shape, dtype=np.complex128) csd_mean = self._acc[con_idx] / n_epochs self.con_scores[con_idx] = csd_mean / np.sqrt(psd_xx * psd_yy) class _ImCohEst(_CohEstBase):
64
64
127
12
52
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_ImCohEst
_ImCohEst
109
119
109
109
3f5c069bd0bf47562ca8e7b988634515f85c5903
bigcode/the-stack
train
1274f8e68c2800f8b1632aba
train
class
class _AbstractConEstBase(object): """ABC for connectivity estimators.""" def start_epoch(self): raise NotImplementedError('start_epoch method not implemented') def accumulate(self, con_idx, csd_xy): raise NotImplementedError('accumulate method not implemented') def combine(self, othe...
class _AbstractConEstBase(object):
"""ABC for connectivity estimators.""" def start_epoch(self): raise NotImplementedError('start_epoch method not implemented') def accumulate(self, con_idx, csd_xy): raise NotImplementedError('accumulate method not implemented') def combine(self, other): raise NotImplementedErr...
_mt, _psd_from_mt_adaptive) from ..time_frequency.tfr import morlet, cwt from ..utils import logger, verbose, _time_mask, warn from ..externals.six import string_types ######################################################################## # Various connectivity estimators cla...
64
64
100
8
55
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_AbstractConEstBase
_AbstractConEstBase
28
41
28
28
c9f936d3783009fa9259f2922a9d44614e27a3e0
bigcode/the-stack
train
e0c40ac0474db34b9c425775
train
class
class _WPLIEst(_EpochMeanConEstBase): """WPLI Estimator.""" name = 'WPLI' def __init__(self, n_cons, n_freqs, n_times): super(_WPLIEst, self).__init__(n_cons, n_freqs, n_times) # store both imag(csd) and abs(imag(csd)) acc_shape = (2,) + self.csd_shape self._acc = np.zero...
class _WPLIEst(_EpochMeanConEstBase):
"""WPLI Estimator.""" name = 'WPLI' def __init__(self, n_cons, n_freqs, n_times): super(_WPLIEst, self).__init__(n_cons, n_freqs, n_times) # store both imag(csd) and abs(imag(csd)) acc_shape = (2,) + self.csd_shape self._acc = np.zeros(acc_shape) def accumulate(self,...
if self.con_scores is None: self.con_scores = np.zeros(self.csd_shape) pli_mean = self._acc[con_idx] / n_epochs # See Vinck paper Eq. (30) con = (n_epochs * pli_mean ** 2 - 1) / (n_epochs - 1) self.con_scores[con_idx] = con class _WPLIEst(_EpochMeanConEstBase):
93
93
310
13
79
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_WPLIEst
_WPLIEst
185
220
185
185
30e3ce0c5c8aa0bfffed9dfde76b28fac09ebb4f
bigcode/the-stack
train
9d96248a843e0a09b73788a8
train
function
def _check_method(method): """Test if a method implements the required interface.""" interface_members = [m[0] for m in getmembers(_AbstractConEstBase) if not m[0].startswith('_')] method_members = [m[0] for m in getmembers(method) if not m[0].startswith('_')] ...
def _check_method(method):
"""Test if a method implements the required interface.""" interface_members = [m[0] for m in getmembers(_AbstractConEstBase) if not m[0].startswith('_')] method_members = [m[0] for m in getmembers(method) if not m[0].startswith('_')] for member in interfac...
(epoch, (list, tuple)): epoch = (epoch,) epochs_out.append(epoch) if len(epochs_out) >= n: yield epochs_out epochs_out = list() if 0 < len(epochs_out) < n: yield epochs_out def _check_method(method):
64
64
101
6
57
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_check_method
_check_method
476
486
476
476
cff3334cf4fa63a97035e508be75dd1973f46750
bigcode/the-stack
train
b080b63344a12831e8eb17d6
train
function
def _get_and_verify_data_sizes(data, n_signals=None, n_times=None, times=None): """Get and/or verify the data sizes and time scales.""" if not isinstance(data, (list, tuple)): raise ValueError('data has to be a list or tuple') n_signals_tot = 0 for this_data in data: this_n_signals, this...
def _get_and_verify_data_sizes(data, n_signals=None, n_times=None, times=None):
"""Get and/or verify the data sizes and time scales.""" if not isinstance(data, (list, tuple)): raise ValueError('data has to be a list or tuple') n_signals_tot = 0 for this_data in data: this_n_signals, this_n_times = this_data.shape if n_times is not None: if this_n...
0].startswith('_')] method_members = [m[0] for m in getmembers(method) if not m[0].startswith('_')] for member in interface_members: if member not in method_members: return False, member return True, None def _get_and_verify_data_sizes(data, n_signals=None, n_times...
80
80
267
21
58
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_get_and_verify_data_sizes
_get_and_verify_data_sizes
489
518
489
489
005e69b4ff54bda32bccb3bfe6fafd2f4efccbc5
bigcode/the-stack
train
26eb576a97a6228e8fee814c
train
class
class _PLVEst(_EpochMeanConEstBase): """PLV Estimator.""" name = 'PLV' def __init__(self, n_cons, n_freqs, n_times): super(_PLVEst, self).__init__(n_cons, n_freqs, n_times) # allocate accumulator self._acc = np.zeros(self.csd_shape, dtype=np.complex128) def accumulate(self, c...
class _PLVEst(_EpochMeanConEstBase):
"""PLV Estimator.""" name = 'PLV' def __init__(self, n_cons, n_freqs, n_times): super(_PLVEst, self).__init__(n_cons, n_freqs, n_times) # allocate accumulator self._acc = np.zeros(self.csd_shape, dtype=np.complex128) def accumulate(self, con_idx, csd_xy): """Accumulat...
= np.zeros(self.csd_shape) csd_mean = self._acc[con_idx] / n_epochs self.con_scores[con_idx] = np.imag(csd_mean) / np.sqrt(psd_xx * psd_yy) class _PLVEst(_EpochMeanConEstBase):
64
64
193
12
52
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_PLVEst
_PLVEst
122
142
122
122
2e8eeb0c17c3e555a2bd5c17a3ba9a4b82690b28
bigcode/the-stack
train
8a73f5cca03a5b22637e0c12
train
function
def _epoch_spectral_connectivity(data, sig_idx, tmin_idx, tmax_idx, sfreq, mode, window_fun, eigvals, wavelets, freq_mask, mt_adaptive, idx_map, block_size, psd, accumulate_psd, con_method_types, ...
def _epoch_spectral_connectivity(data, sig_idx, tmin_idx, tmax_idx, sfreq, mode, window_fun, eigvals, wavelets, freq_mask, mt_adaptive, idx_map, block_size, psd, accumulate_psd, con_method_types, ...
"""Estimate connectivity for one epoch (see spectral_connectivity).""" n_cons = len(idx_map[0]) if wavelets is not None: n_times_spectrum = n_times n_freqs = len(wavelets) else: n_times_spectrum = 0 n_freqs = np.sum(freq_mask) if not accumulate_inplace: # in...
== 0.) denom[z_denom] = 1. this_acc = csd_xy / denom this_acc[z_denom] = 0. # handle division by zero self._acc[con_idx] += this_acc def compute_con(self, con_idx, n_epochs): """Compute final con. score for some connections.""" if self.con_scores is None: ...
256
256
1,408
78
178
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_epoch_spectral_connectivity
_epoch_spectral_connectivity
301
459
301
306
628659f30795b4f0ea246d28e1636a3f3be1fea8
bigcode/the-stack
train
c91f6322c3d8b06ea3dedd06
train
function
def _get_n_epochs(epochs, n): """Generate lists with at most n epochs.""" epochs_out = list() for epoch in epochs: if not isinstance(epoch, (list, tuple)): epoch = (epoch,) epochs_out.append(epoch) if len(epochs_out) >= n: yield epochs_out epochs_o...
def _get_n_epochs(epochs, n):
"""Generate lists with at most n epochs.""" epochs_out = list() for epoch in epochs: if not isinstance(epoch, (list, tuple)): epoch = (epoch,) epochs_out.append(epoch) if len(epochs_out) >= n: yield epochs_out epochs_out = list() if 0 < len(epo...
conjugate()) for method in con_methods: method.accumulate(con_idx, csd) # future estimator types need to be explicitly handled here else: raise RuntimeError('This should never happen') return con_methods, psd def _get_n_epochs(epochs, n):
64
64
94
10
53
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_get_n_epochs
_get_n_epochs
462
473
462
462
fad56b0c3919a0131a5f0412d6deeaa9d3af783d
bigcode/the-stack
train
1893f5ab07fe9305a141b25d
train
class
class _PPCEst(_EpochMeanConEstBase): """Pairwise Phase Consistency (PPC) Estimator.""" name = 'PPC' def __init__(self, n_cons, n_freqs, n_times): super(_PPCEst, self).__init__(n_cons, n_freqs, n_times) # store csd / abs(csd) self._acc = np.zeros(self.csd_shape, dtype=np.complex128...
class _PPCEst(_EpochMeanConEstBase):
"""Pairwise Phase Consistency (PPC) Estimator.""" name = 'PPC' def __init__(self, n_cons, n_freqs, n_times): super(_PPCEst, self).__init__(n_cons, n_freqs, n_times) # store csd / abs(csd) self._acc = np.zeros(self.csd_shape, dtype=np.complex128) def accumulate(self, con_idx, ...
z_denom = np.where(denom == 0.) denom[z_denom] = 1. con = (sum_im_csd ** 2 - sum_sq_im_csd) / denom # where we had zeros in denominator, we set con to zero con[z_denom] = 0. self.con_scores[con_idx] = con class _PPCEst(_EpochMeanConEstBase):
93
93
313
12
80
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_PPCEst
_PPCEst
266
297
266
266
c9a26b4eeb788d9b5cee6d803370da5ad18b17c3
bigcode/the-stack
train
2c6e35e9b67d25dbe8fb6131
train
class
class _CohEst(_CohEstBase): """Coherence Estimator.""" name = 'Coherence' def compute_con(self, con_idx, n_epochs, psd_xx, psd_yy): """Compute final con. score for some connections.""" if self.con_scores is None: self.con_scores = np.zeros(self.csd_shape) csd_mean = sel...
class _CohEst(_CohEstBase):
"""Coherence Estimator.""" name = 'Coherence' def compute_con(self, con_idx, n_epochs, psd_xx, psd_yy): """Compute final con. score for some connections.""" if self.con_scores is None: self.con_scores = np.zeros(self.csd_shape) csd_mean = self._acc[con_idx] / n_epochs ...
self._acc = np.zeros(self.csd_shape, dtype=np.complex128) def accumulate(self, con_idx, csd_xy): """Accumulate CSD for some connections.""" self._acc[con_idx] += csd_xy class _CohEst(_CohEstBase):
64
64
122
11
52
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_CohEst
_CohEst
82
92
82
82
861670f7929eb42d8a87308ff166a9b75b16d59f
bigcode/the-stack
train
572df53a4021c84976b203dc
train
class
class _CohEstBase(_EpochMeanConEstBase): """Base Estimator for Coherence, Coherency, Imag. Coherence.""" def __init__(self, n_cons, n_freqs, n_times): super(_CohEstBase, self).__init__(n_cons, n_freqs, n_times) # allocate space for accumulation of CSD self._acc = np.zeros(self.csd_shap...
class _CohEstBase(_EpochMeanConEstBase):
"""Base Estimator for Coherence, Coherency, Imag. Coherence.""" def __init__(self, n_cons, n_freqs, n_times): super(_CohEstBase, self).__init__(n_cons, n_freqs, n_times) # allocate space for accumulation of CSD self._acc = np.zeros(self.csd_shape, dtype=np.complex128) def accumula...
start of each epoch.""" pass # for this type of con. method we don't do anything def combine(self, other): """Include con. accumated for some epochs in this estimate.""" self._acc += other._acc class _CohEstBase(_EpochMeanConEstBase):
64
64
133
13
50
britta-wstnr/mne-python
mne/connectivity/spectral.py
Python
_CohEstBase
_CohEstBase
68
79
68
68
514bd7403cd8e9419884117b8158da87c845aaca
bigcode/the-stack
train
ec96d4911a56977692ce68ee
train
function
@login_manager.user_loader def load_user(user_id): return User.query.get(int(user_id))
@login_manager.user_loader def load_user(user_id):
return User.query.get(int(user_id))
in ('http', 'https') and ref_url.netloc == test_url.netloc # class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(30), unique=True) @login_manager.user_loader def load_user(user_id):
64
64
20
11
53
python-pro/FlaskProjectsRepo
UltimateNewFlask/Login-Flask/app.py
Python
load_user
load_user
39
41
39
40
813f748a41cbba65f94c5485911443e40039eee8
bigcode/the-stack
train
c2ba76faf14534c743f9bf5f
train
function
@app.route('/fresh') @fresh_login_required def fresh(): return '<h1>You have a fresh session!</h1>'
@app.route('/fresh') @fresh_login_required def fresh():
return '<h1>You have a fresh session!</h1>'
return '<h1>You are in the protected area, {}!</h1>'.format(current_user.username) @app.route('/logout') @login_required def logout(): logout_user() return '<h1>You are now logged out</h1>' @app.route('/fresh') @fresh_login_required def fresh():
63
64
27
13
50
python-pro/FlaskProjectsRepo
UltimateNewFlask/Login-Flask/app.py
Python
fresh
fresh
79
82
79
81
7fb95ae3a591c6a2d9dcab46fbff60bc2c02f69d
bigcode/the-stack
train
3d26175d50f684083dae0e1f
train
function
@app.route('/home') @login_required def home(): return '<h1>You are in the protected area, {}!</h1>'.format(current_user.username)
@app.route('/home') @login_required def home():
return '<h1>You are in the protected area, {}!</h1>'.format(current_user.username)
if is_safe_url(next): return redirect(next) return '<h1>You have successfully logged in {} Olima!</h1>'.format(current_user.username) # session["next"]=request.args.get('next') return render_template("login.html") @app.route('/home') @login_required def home():
64
64
33
11
53
python-pro/FlaskProjectsRepo
UltimateNewFlask/Login-Flask/app.py
Python
home
home
65
68
65
67
5afb7e86dadfe0610c215494bcc13a99f4228a26
bigcode/the-stack
train
08f271ebe51e72676013b9d3
train
function
@app.route('/logout') @login_required def logout(): logout_user() return '<h1>You are now logged out</h1>'
@app.route('/logout') @login_required def logout():
logout_user() return '<h1>You are now logged out</h1>'
) # session["next"]=request.args.get('next') return render_template("login.html") @app.route('/home') @login_required def home(): return '<h1>You are in the protected area, {}!</h1>'.format(current_user.username) @app.route('/logout') @login_required def logout():
64
64
28
11
53
python-pro/FlaskProjectsRepo
UltimateNewFlask/Login-Flask/app.py
Python
logout
logout
71
75
71
73
9451a208ae13113b8dbaf9dcc11eb34d06eda25d
bigcode/the-stack
train
77406bafb776c8642e8c09c8
train
function
def is_safe_url(target): ref_url = urlparse(request.host_url) test_url = urlparse(urljoin(request.host_url, target)) return test_url.scheme in ('http', 'https') and ref_url.netloc == test_url.netloc
def is_safe_url(target):
ref_url = urlparse(request.host_url) test_url = urlparse(urljoin(request.host_url, target)) return test_url.scheme in ('http', 'https') and ref_url.netloc == test_url.netloc
login_manager.login_view='login' login_manager.login_message='Unless you login, I do not see any point for you to stay here .' login_manager.refresh_view = 'login' login_manager.needs_refresh_message = 'You need to login again!' db = SQLAlchemy(app) def is_safe_url(target):
64
64
53
6
58
python-pro/FlaskProjectsRepo
UltimateNewFlask/Login-Flask/app.py
Python
is_safe_url
is_safe_url
29
33
29
29
c36176fc4d919e51cda3df84e2fd275f21d90563
bigcode/the-stack
train
e62a6f45300259966e88e068
train
function
@app.route('/login',methods=["GET","POST"]) def login(): if request.method=="POST": username=request.form['username'] user = User.query.filter_by(username=username).first() if not user: return '<h1>User does not exist</h1>' login_user(user,remember=True) if 'next' in session: next=session['next'] ...
@app.route('/login',methods=["GET","POST"]) def login():
if request.method=="POST": username=request.form['username'] user = User.query.filter_by(username=username).first() if not user: return '<h1>User does not exist</h1>' login_user(user,remember=True) if 'next' in session: next=session['next'] if is_safe_url(next): return redirect(next) r...
Mixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(30), unique=True) @login_manager.user_loader def load_user(user_id): return User.query.get(int(user_id)) @app.route('/login',methods=["GET","POST"]) def login():
64
64
134
14
50
python-pro/FlaskProjectsRepo
UltimateNewFlask/Login-Flask/app.py
Python
login
login
43
63
43
44
d002e9593f62fd98ee640d88c280d17aa663842f
bigcode/the-stack
train
65284e0308ae59bcf8c28b11
train
class
class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(30), unique=True)
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(30), unique=True)
) def is_safe_url(target): ref_url = urlparse(request.host_url) test_url = urlparse(urljoin(request.host_url, target)) return test_url.scheme in ('http', 'https') and ref_url.netloc == test_url.netloc # class User(UserMixin, db.Model):
63
64
33
8
55
python-pro/FlaskProjectsRepo
UltimateNewFlask/Login-Flask/app.py
Python
User
User
35
37
35
35
3f8b4e28cc2e0ce6fa6f739e4c1d9726833e8df0
bigcode/the-stack
train
102f6d3c83bec3e7ee319af9
train
class
class GenerativeQueryTest(fixtures.MappedTest): run_inserts = 'once' run_deletes = None @classmethod def define_tables(cls, metadata): Table('foo', metadata, Column('id', Integer, sa.Sequence('foo_id_seq'), primary_key=True), Column('bar', Integer), Col...
class GenerativeQueryTest(fixtures.MappedTest):
run_inserts = 'once' run_deletes = None @classmethod def define_tables(cls, metadata): Table('foo', metadata, Column('id', Integer, sa.Sequence('foo_id_seq'), primary_key=True), Column('bar', Integer), Column('range', Integer)) @classmethod def...
from test.lib.testing import eq_ import sqlalchemy as sa from test.lib import testing from sqlalchemy import Integer, String, ForeignKey, MetaData, func from test.lib.schema import Table from test.lib.schema import Column from sqlalchemy.orm import mapper, relationship, create_session from test.lib.testing import eq_ f...
89
256
1,365
11
77
ContextLogic/sqlalchemy
test/orm/test_generative.py
Python
GenerativeQueryTest
GenerativeQueryTest
13
154
13
13
95ac533d866cb3c0b2d442e166aeda1051449ed3
bigcode/the-stack
train
77a96b8584afa01cd4dc34d2
train
class
class CaseSensitiveTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('Table1', metadata, Column('ID', Integer, primary_key=True)) Table('Table2', metadata, Column('T1ID', Integer, ForeignKey("Table1.ID"), primary_key=T...
class CaseSensitiveTest(fixtures.MappedTest): @classmethod
def define_tables(cls, metadata): Table('Table1', metadata, Column('ID', Integer, primary_key=True)) Table('Table2', metadata, Column('T1ID', Integer, ForeignKey("Table1.ID"), primary_key=True), Column('NUM', Integer, primary_key=True)) ...
.classes.Address, self.tables.orders, self.tables.addresses) session = create_session() sel = users.outerjoin(orders).outerjoin( addresses, orders.c.address_id == addresses.c.id) q = (session.query(User).select_from(se...
112
113
377
14
98
ContextLogic/sqlalchemy
test/orm/test_generative.py
Python
CaseSensitiveTest
CaseSensitiveTest
288
337
288
290
295f020b4d86137faa6ef23c16a91617bd8350a1
bigcode/the-stack
train
8788476d2af4b64e1047f8ad
train
class
class GenerativeTest2(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('table1', metadata, Column('id', Integer, primary_key=True)) Table('table2', metadata, Column('t1id', Integer, ForeignKey("table1.id"), primary_key=T...
class GenerativeTest2(fixtures.MappedTest): @classmethod
def define_tables(cls, metadata): Table('table1', metadata, Column('id', Integer, primary_key=True)) Table('table2', metadata, Column('t1id', Integer, ForeignKey("table1.id"), primary_key=True), Column('num', Integer, primary_key=True)) ...
query.order_by(sa.desc(Foo.bar))[0].bar == 99 def test_offset(self): Foo = self.classes.Foo query = create_session().query(Foo) assert list(query.order_by(Foo.bar).offset(10))[0].bar == 10 def test_offset(self): Foo = self.classes.Foo query = create_session().query(F...
113
113
378
15
97
ContextLogic/sqlalchemy
test/orm/test_generative.py
Python
GenerativeTest2
GenerativeTest2
157
209
157
159
43c1e05110806d269c8e8aace8bd9ed3149c9b92
bigcode/the-stack
train
87e15848434a8747acf0b6bf
train
class
class RelationshipsTest(_fixtures.FixtureTest): run_setup_mappers = 'once' run_inserts = 'once' run_deletes = None @classmethod def setup_mappers(cls): addresses, Order, User, Address, orders, users = (cls.tables.addresses, cls.classes.Order, ...
class RelationshipsTest(_fixtures.FixtureTest):
run_setup_mappers = 'once' run_inserts = 'once' run_deletes = None @classmethod def setup_mappers(cls): addresses, Order, User, Address, orders, users = (cls.tables.addresses, cls.classes.Order, cls.classes.User, ...
6, 3))) def test_distinct_count(self): table2, Obj1, table1 = (self.tables.table2, self.classes.Obj1, self.tables.table1) query = create_session().query(Obj1) eq_(query.count(), 4) res = query.filter(sa.and_(table1.c....
152
152
509
9
143
ContextLogic/sqlalchemy
test/orm/test_generative.py
Python
RelationshipsTest
RelationshipsTest
212
285
212
212
d662e4c53bc7b63050496962c11b95f0f02b334f
bigcode/the-stack
train
f8406911eadbb634fd976255
train
class
class Webnews(models.Model): text = models.CharField(max_length=150) date = models.CharField(max_length=50,null=True) link = models.CharField(max_length=300,null=True)
class Webnews(models.Model):
text = models.CharField(max_length=150) date = models.CharField(max_length=50,null=True) link = models.CharField(max_length=300,null=True)
from django.db import models class Webnews(models.Model):
12
64
43
6
5
hanjak/news_notificator
sender/news_updater/models.py
Python
Webnews
Webnews
3
6
3
3
e5a8c99c7ba22a7225a3846d90883108edf7eb4b
bigcode/the-stack
train
ce6d67e4a461da471541f643
train
class
class TestMD: @pytest.fixture(autouse=True, scope='class') def _class_scope(self, env): conf = TlsTestConf(env=env, extras={ 'base': "LogLevel md:trace4" }) conf.add_md_vhosts(domains=[env.domain_a, env.domain_b]) conf.install() assert env.apache_restart() ==...
class TestMD: @pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env): conf = TlsTestConf(env=env, extras={ 'base': "LogLevel md:trace4" }) conf.add_md_vhosts(domains=[env.domain_a, env.domain_b]) conf.install() assert env.apache_restart() == 0 def test_11_get_a(self, env): # do we see the co...
import time from datetime import timedelta import pytest from .conf import TlsTestConf class TestMD: @pytest.fixture(autouse=True, scope='class')
37
81
273
17
19
tititiou36/httpd
test/modules/tls/test_11_md.py
Python
TestMD
TestMD
9
37
9
11
681ddc1b419a232b6783a6b16e179c04b76c60f5
bigcode/the-stack
train
b9509ba796c08d70dfdef1c6
train
function
def traffic(request): if request.is_ajax and request.method == 'POST': request_file = models.Image_data( image=request.FILES.get('file')) request_file.save() result = utils.predict_traffic_sign(request_file.image.name) os.remove(request_file.image.name) response =...
def traffic(request):
if request.is_ajax and request.method == 'POST': request_file = models.Image_data( image=request.FILES.get('file')) request_file.save() result = utils.predict_traffic_sign(request_file.image.name) os.remove(request_file.image.name) response = {'sign': result} ...
') result = utils.generate_question(context=context, answer=answer) response = {'question': result} return JsonResponse(response) # return render(request,'projects/qgen.html', {'upload':True, 'result':result}) return render(request, 'projects/qgen.html') def traffic(request):
64
64
84
4
60
saichandrapandraju/saichandra
projects/views.py
Python
traffic
traffic
27
37
27
27
a280b5de25d52e4160ee7d800a8ca398b3c7f6ed
bigcode/the-stack
train
ed802e3ca3fb558c7416f192
train
function
def ai4code(request): if request.is_ajax and request.method == 'POST': data = request.POST.dict() code = data.get('code') language = data.get('language') # print(code, language) result = utils.ai4code(code, language) # print(result) response = {'output': resul...
def ai4code(request):
if request.is_ajax and request.method == 'POST': data = request.POST.dict() code = data.get('code') language = data.get('language') # print(code, language) result = utils.ai4code(code, language) # print(result) response = {'output': result} return Json...
result = utils.sketch(request_file.image.name) # print(request_file.image.name) os.remove(request_file.image.name) return render(request, 'projects/sketch.html', {'upload': True, 'result': result}) return render(request, 'projects/sketch.html') def ai4code(request):
64
64
91
6
58
saichandrapandraju/saichandra
projects/views.py
Python
ai4code
ai4code
75
86
75
75
b86f635643ad99db4dd11f7b400a6ea493b0448b
bigcode/the-stack
train
0eef2fa8c74b6fcf69f8c550
train
function
def sketch(request): if request.method == 'POST': request_file = models.Image_data(image=request.FILES['file_upload']) request_file.save() result = utils.sketch(request_file.image.name) # print(request_file.image.name) os.remove(request_file.image.name) return render(...
def sketch(request):
if request.method == 'POST': request_file = models.Image_data(image=request.FILES['file_upload']) request_file.save() result = utils.sketch(request_file.image.name) # print(request_file.image.name) os.remove(request_file.image.name) return render(request, 'projects/sk...
if request.is_ajax and request.method == 'POST': data = request.POST.dict() en_txt = data.get('english') response = {'output': utils.en_2_in(en_txt)} return JsonResponse(response) return render(request, 'projects/en_2_in.html') def sketch(request):
64
64
91
4
60
saichandrapandraju/saichandra
projects/views.py
Python
sketch
sketch
63
72
63
63
b70c3bf359c291251b0ddb7146063b71352c76fe
bigcode/the-stack
train
e4d95c20b9ba793f55f53b9a
train
function
def agender(request): result = {'age': 33, 'gender': 'MALE'} if request.method == 'POST': print(request.FILES) # request_file = models.Image_data(image=request.FILES['file_upload']) # request_file.save() # print(request_file.image.name) # result = utils.predict_agender(re...
def agender(request):
result = {'age': 33, 'gender': 'MALE'} if request.method == 'POST': print(request.FILES) # request_file = models.Image_data(image=request.FILES['file_upload']) # request_file.save() # print(request_file.image.name) # result = utils.predict_agender(request_file.image.name)...
image=request.FILES.get('file')) request_file.save() result = utils.predict_traffic_sign(request_file.image.name) os.remove(request_file.image.name) response = {'sign': result} return JsonResponse(response) return render(request, 'projects/traffic.html') def agender(request...
64
64
126
5
59
saichandrapandraju/saichandra
projects/views.py
Python
agender
agender
40
51
40
40
8785de41e1a03cb96b40a6f934a53436b840760d
bigcode/the-stack
train
87a441f4923631c2157c2e66
train
function
def en_2_in(request): if request.is_ajax and request.method == 'POST': data = request.POST.dict() en_txt = data.get('english') response = {'output': utils.en_2_in(en_txt)} return JsonResponse(response) return render(request, 'projects/en_2_in.html')
def en_2_in(request):
if request.is_ajax and request.method == 'POST': data = request.POST.dict() en_txt = data.get('english') response = {'output': utils.en_2_in(en_txt)} return JsonResponse(response) return render(request, 'projects/en_2_in.html')
utils.predict_agender(request_file.image.name) # os.remove(request_file.image.name) return render(request, 'projects/age_gender.html', {'upload': True, 'result': result}) return render(request, 'projects/age_gender.html', {'upload': False}) def en_2_in(request):
64
64
68
7
57
saichandrapandraju/saichandra
projects/views.py
Python
en_2_in
en_2_in
54
60
54
54
e590f577f508a90844eae0b99f9e8bc656165758
bigcode/the-stack
train
a7e48bb0c41f2f7729ed1640
train
function
def qgen(request): if request.is_ajax and request.method == 'POST': data = request.POST.dict() context = data.get('context') answer = data.get('answer') result = utils.generate_question(context=context, answer=answer) response = {'question': result} return JsonRespons...
def qgen(request):
if request.is_ajax and request.method == 'POST': data = request.POST.dict() context = data.get('context') answer = data.get('answer') result = utils.generate_question(context=context, answer=answer) response = {'question': result} return JsonResponse(response) ...
from django.shortcuts import render from django.http import JsonResponse from . import utils from . import models import os # Create your views here. def index(request): return render(request, 'projects/index.html') def qgen(request):
51
64
99
5
46
saichandrapandraju/saichandra
projects/views.py
Python
qgen
qgen
14
24
14
14
b16460aa19ab76a889dc625e86b0babb47ccc9bf
bigcode/the-stack
train
c002277236f6f1a969169b70
train
function
def index(request): return render(request, 'projects/index.html')
def index(request):
return render(request, 'projects/index.html')
from django.shortcuts import render from django.http import JsonResponse from . import utils from . import models import os # Create your views here. def index(request):
36
64
14
4
32
saichandrapandraju/saichandra
projects/views.py
Python
index
index
10
11
10
10
77dba1cbf6d55db149eea809b23d359ce7579a9f
bigcode/the-stack
train
bf4d34b8fbca674a1971d89f
train
function
@pytest.fixture def none_in_gt_fourth_2d_3ch(): s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.zeros((10, 1, 224, 224)) s_batch[:, :, 0:112, 0:112] = 1.0 a_batch[:, :, 112:224, 112:224] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10...
@pytest.fixture def none_in_gt_fourth_2d_3ch():
s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.zeros((10, 1, 224, 224)) s_batch[:, :, 0:112, 0:112] = 1.0 a_batch[:, :, 112:224, 112:224] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, ...
np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def none_in_gt_fourth_2d_3ch():
64
64
153
16
48
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
none_in_gt_fourth_2d_3ch
none_in_gt_fourth_2d_3ch
221
232
221
222
bc2ddb6ec78b2e2140a4b1ed99c4e34f17384ae1
bigcode/the-stack
train
a953ce5a0ca684b6bc34eeb1
train
function
@pytest.fixture def half_in_gt_zeros_2d_3ch(): s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.zeros((10, 1, 224, 224)) s_batch[:, :, 50:100, 50:100] = 1.0 a_batch[:, :, 0:100, 75:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, ...
@pytest.fixture def half_in_gt_zeros_2d_3ch():
s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.zeros((10, 1, 224, 224)) s_batch[:, :, 50:100, 50:100] = 1.0 a_batch[:, :, 0:100, 75:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "...
np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def half_in_gt_zeros_2d_3ch():
64
64
153
16
48
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
half_in_gt_zeros_2d_3ch
half_in_gt_zeros_2d_3ch
249
260
249
250
03864ba3f48798d60f31812ba49dece6a791b141
bigcode/the-stack
train
f2721b2a1c75af8d0ba2d6cc
train
function
@pytest.fixture def all_in_gt_zeros_1d_3ch(): s_batch = np.zeros((10, 1, 224)) a_batch = np.zeros((10, 1, 224)) s_batch[:, :, 50:150] = 1.0 a_batch[:, :, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_...
@pytest.fixture def all_in_gt_zeros_1d_3ch():
s_batch = np.zeros((10, 1, 224)) a_batch = np.zeros((10, 1, 224)) s_batch[:, :, 50:150] = 1.0 a_batch[:, :, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, }
.randn(10, 1, 28, 28), "y_batch": np.random.randint(0, 10, size=10), "a_batch": None, "s_batch": s_batch, } @pytest.fixture def all_in_gt_zeros_1d_3ch():
64
64
134
16
48
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
all_in_gt_zeros_1d_3ch
all_in_gt_zeros_1d_3ch
67
78
67
68
6c3d6fbaec5416885840cf5c0123271309b08caa
bigcode/the-stack
train
6498bcb560e0775e26764d25
train
function
@pytest.fixture def half_in_gt_zeros_bigger_1d_3ch(): s_batch = np.zeros((10, 1, 224)) a_batch = np.zeros((10, 1, 224)) s_batch[:, :, 0:100] = 1.0 a_batch[:, :, 0:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batc...
@pytest.fixture def half_in_gt_zeros_bigger_1d_3ch():
s_batch = np.zeros((10, 1, 224)) a_batch = np.zeros((10, 1, 224)) s_batch[:, :, 0:100] = 1.0 a_batch[:, :, 0:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, }
, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } # TODO: unused fixture @pytest.fixture def half_in_gt_zeros_bigger_1d_3ch():
64
64
136
18
45
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
half_in_gt_zeros_bigger_1d_3ch
half_in_gt_zeros_bigger_1d_3ch
292
303
292
293
ca0510c1113bf701fccfcd109436a83d1b206f93
bigcode/the-stack
train
7d30c647bf954555ef723449
train
function
@pytest.fixture def all_in_gt_seg_bigger_2d_3ch(): s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224, 224)) s_batch[:, :, 0:150, 0:150] = 1.0 a_batch[:, :, 50:150, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": ...
@pytest.fixture def all_in_gt_seg_bigger_2d_3ch():
s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224, 224)) s_batch[:, :, 0:150, 0:150] = 1.0 a_batch[:, :, 50:150, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch...
.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def all_in_gt_seg_bigger_2d_3ch():
64
64
164
17
47
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
all_in_gt_seg_bigger_2d_3ch
all_in_gt_seg_bigger_2d_3ch
137
148
137
138
3be8491eeb900a5331d01a925de696aa2beeae24
bigcode/the-stack
train
e05aff6c0bf8e823cadc04a1
train
function
@pytest.fixture def all_in_gt_1d_3ch(): s_batch = np.zeros((10, 1, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224)) s_batch[:, :, 50:150] = 1.0 a_batch[:, :, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), ...
@pytest.fixture def all_in_gt_1d_3ch():
s_batch = np.zeros((10, 1, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224)) s_batch[:, :, 50:150] = 1.0 a_batch[:, :, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch"...
typing import Union import numpy as np import pytest from pytest_lazyfixture import lazy_fixture from ..fixtures import * from ...quantus.metrics import * from ...quantus.helpers import * from ...quantus.helpers.explanation_func import explain @pytest.fixture def all_in_gt_1d_3ch():
64
64
142
14
49
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
all_in_gt_1d_3ch
all_in_gt_1d_3ch
13
24
13
14
1cd6cf4333ccba4f55b9d9618c47354627360c47
bigcode/the-stack
train
84e0a21b03e1e9200690cadb
train
function
@pytest.fixture def all_in_gt_non_normalised_2d(): s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.random.uniform(0, 20, size=(10, 1, 224, 224)) s_batch[:, :, 50:150, 50:150] = 1.0 a_batch[:, :, 50:150, 50:150] = 25 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": ...
@pytest.fixture def all_in_gt_non_normalised_2d():
s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.random.uniform(0, 20, size=(10, 1, 224, 224)) s_batch[:, :, 50:150, 50:150] = 1.0 a_batch[:, :, 50:150, 50:150] = 25 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch...
_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def all_in_gt_non_normalised_2d():
64
64
157
14
50
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
all_in_gt_non_normalised_2d
all_in_gt_non_normalised_2d
109
120
109
110
ad6e6be9d9f30b07748fa02ab6b423dee95e1b84
bigcode/the-stack
train
b5f102244b5f5c324d64fb36
train
function
@pytest.fixture def none_in_gt_1d_3ch(): s_batch = np.zeros((10, 1, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224)) s_batch[:, :, 0:100] = 1.0 a_batch[:, :, 100:200] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), ...
@pytest.fixture def none_in_gt_1d_3ch():
s_batch = np.zeros((10, 1, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224)) s_batch[:, :, 0:100] = 1.0 a_batch[:, :, 100:200] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch"...
.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def none_in_gt_1d_3ch():
64
64
142
14
50
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
none_in_gt_1d_3ch
none_in_gt_1d_3ch
151
162
151
152
8d0f8a9fb37c489a26ae1d7e1dd8db1d37285a24
bigcode/the-stack
train
46fa588ef595562ee2a6abfd
train
function
@pytest.fixture def half_in_gt_2d_3ch(): s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224, 224)) s_batch[:, :, 50:100, 50:100] = 1.0 a_batch[:, :, 0:100, 75:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random...
@pytest.fixture def half_in_gt_2d_3ch():
s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224, 224)) s_batch[:, :, 50:100, 50:100] = 1.0 a_batch[:, :, 0:100, 75:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batc...
_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def half_in_gt_2d_3ch():
64
64
161
14
50
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
half_in_gt_2d_3ch
half_in_gt_2d_3ch
277
288
277
278
92ac8c731100f07a8077186fd3f3d49496e48739
bigcode/the-stack
train
319cbfca8a06ad19cbcea91b
train
function
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_zeros_1d_3ch"), { "weighted": False, "disable_warnings": False, "displ...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_zeros_1d_3ch"), { "weighted": False, "disable_warnings": False, "displ...
scores = AttributionLocalisation(**params)( model=model, x_batch=data["x_batch"], y_batch=data["y_batch"], a_batch=data["a_batch"], s_batch=data["s_batch"], **params ) if isinstance(expected, float): assert all(s == expected for s in scores), "Test fai...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_zeros_1d_3ch"), { "weighted": False, "disable_warnings": False, "displ...
869
256
1,006
869
0
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
test_attribution_localisation
test_attribution_localisation
1,062
1,213
1,062
1,197
fca6a3d13c90f9e6b31d81561b4e1804a9bb24de
bigcode/the-stack
train
b72fa6877e228ec28c07ab30
train
function
@pytest.fixture def none_in_gt_fourth_1d(): s_batch = np.zeros((10, 1, 224)) a_batch = np.zeros((10, 1, 224)) s_batch[:, :, 0:112] = 1.0 a_batch[:, :, 112:224] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_ba...
@pytest.fixture def none_in_gt_fourth_1d():
s_batch = np.zeros((10, 1, 224)) a_batch = np.zeros((10, 1, 224)) s_batch[:, :, 0:112] = 1.0 a_batch[:, :, 112:224] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, }
np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def none_in_gt_fourth_1d():
64
64
131
13
51
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
none_in_gt_fourth_1d
none_in_gt_fourth_1d
207
218
207
208
17ebe02023e56691099288369421669b1d03c52b
bigcode/the-stack
train
e14693d3f3d455c4cd4e5401
train
function
@pytest.fixture def none_in_gt_zeros_2d_3ch(): s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.zeros((10, 1, 224, 224)) s_batch[:, :, 0:100, 0:100] = 1.0 a_batch[:, :, 100:200, 100:200] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10,...
@pytest.fixture def none_in_gt_zeros_2d_3ch():
s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.zeros((10, 1, 224, 224)) s_batch[:, :, 0:100, 0:100] = 1.0 a_batch[:, :, 100:200, 100:200] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, ...
np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def none_in_gt_zeros_2d_3ch():
64
64
153
16
48
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
none_in_gt_zeros_2d_3ch
none_in_gt_zeros_2d_3ch
193
204
193
194
c610b5dd80a7f20e90941e5cbe69c8c526fbfce9
bigcode/the-stack
train
4049d547cb4935a8f622b394
train
function
@pytest.fixture def all_in_gt_non_normalised_1d_3ch(): s_batch = np.zeros((10, 1, 224)) a_batch = np.random.uniform(0, 20, size=(10, 1, 224)) s_batch[:, :, 50:150] = 1.0 a_batch[:, :, 50:150] = 25 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, si...
@pytest.fixture def all_in_gt_non_normalised_1d_3ch():
s_batch = np.zeros((10, 1, 224)) a_batch = np.random.uniform(0, 20, size=(10, 1, 224)) s_batch[:, :, 50:150] = 1.0 a_batch[:, :, 50:150] = 25 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": ...
10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def all_in_gt_non_normalised_1d_3ch():
64
64
141
17
47
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
all_in_gt_non_normalised_1d_3ch
all_in_gt_non_normalised_1d_3ch
95
106
95
96
1856a990e0d86dd839ea6145de2e5fa02061a659
bigcode/the-stack
train
0495715b3c3308640c7e3f07
train
function
@pytest.fixture def none_in_gt_zeros_1d_3ch(): s_batch = np.zeros((10, 1, 224)) a_batch = np.zeros((10, 1, 224)) s_batch[:, :, 0:100] = 1.0 a_batch[:, :, 100:200] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a...
@pytest.fixture def none_in_gt_zeros_1d_3ch():
s_batch = np.zeros((10, 1, 224)) a_batch = np.zeros((10, 1, 224)) s_batch[:, :, 0:100] = 1.0 a_batch[:, :, 100:200] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, }
(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def none_in_gt_zeros_1d_3ch():
64
64
134
16
48
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
none_in_gt_zeros_1d_3ch
none_in_gt_zeros_1d_3ch
179
190
179
180
6259713f14acf22db356409837eb7ba258aad3b6
bigcode/the-stack
train
c6e530bf2b130b4380b5e458
train
function
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, }, ...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, }, ...
scores = RelevanceRankAccuracy(**params)( model=model, x_batch=data["x_batch"], y_batch=data["y_batch"], a_batch=data["a_batch"], s_batch=data["s_batch"], **params ) if isinstance(expected, float): print(scores) assert all(s == expected for s i...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, }, ...
798
256
936
798
0
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
test_relevance_rank_accuracy
test_relevance_rank_accuracy
658
797
658
781
e4a00ad1f6c7c7d51912913f00f705d131b4cfa0
bigcode/the-stack
train
7cd781070681800f3cb0773a
train
function
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_zeros_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, ...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_zeros_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, ...
scores = RelevanceMassAccuracy(**params)( model=model, x_batch=data["x_batch"], y_batch=data["y_batch"], a_batch=data["a_batch"], s_batch=data["s_batch"], **params ) if isinstance(expected, float): assert all(s == expected for s in scores), "Test faile...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_zeros_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, ...
785
256
919
785
0
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
test_relevance_mass_accuracy
test_relevance_mass_accuracy
800
936
800
921
0c11d04322646001360e14bd4c4b839abd13a9b5
bigcode/the-stack
train
ccd2befe52f5efb650ae97b1
train
function
@pytest.fixture def all_in_gt_zeros_2d_3ch(): s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.zeros((10, 1, 224, 224)) s_batch[:, :, 50:150, 50:150] = 1.0 a_batch[:, :, 50:150, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, ...
@pytest.fixture def all_in_gt_zeros_2d_3ch():
s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.zeros((10, 1, 224, 224)) s_batch[:, :, 50:150, 50:150] = 1.0 a_batch[:, :, 50:150, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, ...
np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def all_in_gt_zeros_2d_3ch():
64
64
153
16
48
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
all_in_gt_zeros_2d_3ch
all_in_gt_zeros_2d_3ch
81
92
81
82
2e8094ef9ae7bfd6058b7d874e9288b060ac8747
bigcode/the-stack
train
836733b55b0c9d7173b1e2c5
train
function
@pytest.fixture def all_in_gt_no_abatch_1d_1ch(): s_batch = np.zeros((10, 1, 28)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 28)) s_batch[:, :, 0:15] = 1.0 return { "x_batch": np.random.randn(10, 1, 28), "y_batch": np.random.randint(0, 10, size=10), "a_batch": None, ...
@pytest.fixture def all_in_gt_no_abatch_1d_1ch():
s_batch = np.zeros((10, 1, 28)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 28)) s_batch[:, :, 0:15] = 1.0 return { "x_batch": np.random.randn(10, 1, 28), "y_batch": np.random.randint(0, 10, size=10), "a_batch": None, "s_batch": s_batch, }
10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def all_in_gt_no_abatch_1d_1ch():
64
64
128
17
47
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
all_in_gt_no_abatch_1d_1ch
all_in_gt_no_abatch_1d_1ch
41
51
41
42
8ef01a8b82be6fc970ab1108ab5c62dce2bb0176
bigcode/the-stack
train
1bc8354f0ed7820bbf840440
train
function
@pytest.fixture def half_in_gt_zeros_1d_3ch(): s_batch = np.zeros((10, 1, 224)) a_batch = np.zeros((10, 1, 224)) s_batch[:, :, 50:100] = 1.0 a_batch[:, :, 0:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_...
@pytest.fixture def half_in_gt_zeros_1d_3ch():
s_batch = np.zeros((10, 1, 224)) a_batch = np.zeros((10, 1, 224)) s_batch[:, :, 50:100] = 1.0 a_batch[:, :, 0:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, }
(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def half_in_gt_zeros_1d_3ch():
64
64
134
16
48
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
half_in_gt_zeros_1d_3ch
half_in_gt_zeros_1d_3ch
235
246
235
236
9ae9b8812e718ae2971ca3e8e84a2d611fcd3fd4
bigcode/the-stack
train
e962515b941a80d863e2035d
train
function
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, }, ...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, }, ...
scores = AUC(**params)( model=model, x_batch=data["x_batch"], y_batch=data["y_batch"], a_batch=data["a_batch"], s_batch=data["s_batch"], **params ) if isinstance(expected, float): assert all(s == expected for s in scores), f"Test failed. {scores[0]}" ...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, }, ...
662
240
800
662
0
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
test_auc
test_auc
939
1,059
939
1,044
cec25ff1bc5db39b2c8013f96446e8246e4193db
bigcode/the-stack
train
27e11f2007ac3345eb1c511a
train
function
@pytest.fixture def all_in_gt_seg_bigger_1d_3ch(): s_batch = np.zeros((10, 1, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224)) s_batch[:, :, 0:150] = 1.0 a_batch[:, :, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=...
@pytest.fixture def all_in_gt_seg_bigger_1d_3ch():
s_batch = np.zeros((10, 1, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224)) s_batch[:, :, 0:150] = 1.0 a_batch[:, :, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch":...
10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def all_in_gt_seg_bigger_1d_3ch():
64
64
145
17
47
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
all_in_gt_seg_bigger_1d_3ch
all_in_gt_seg_bigger_1d_3ch
123
134
123
124
6242bbed05a4c8fd5b1aa720e4ae283e2d8c1872
bigcode/the-stack
train
10e3efd5c82440fc30ee63ed
train
function
@pytest.fixture def all_in_gt_no_abatch_2d_1ch(): s_batch = np.zeros((10, 1, 28, 28)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 28, 28)) s_batch[:, :, 0:15, 0:15] = 1.0 return { "x_batch": np.random.randn(10, 1, 28, 28), "y_batch": np.random.randint(0, 10, size=10), "a_bat...
@pytest.fixture def all_in_gt_no_abatch_2d_1ch():
s_batch = np.zeros((10, 1, 28, 28)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 28, 28)) s_batch[:, :, 0:15, 0:15] = 1.0 return { "x_batch": np.random.randn(10, 1, 28, 28), "y_batch": np.random.randint(0, 10, size=10), "a_batch": None, "s_batch": s_batch, }
np.random.randn(10, 1, 28), "y_batch": np.random.randint(0, 10, size=10), "a_batch": None, "s_batch": s_batch, } @pytest.fixture def all_in_gt_no_abatch_2d_1ch():
64
64
142
17
47
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
all_in_gt_no_abatch_2d_1ch
all_in_gt_no_abatch_2d_1ch
54
64
54
55
fade9c185c857e5099c707e3248943b7e18dfefa
bigcode/the-stack
train
7d79670a11d2d765c6bfe3b3
train
function
@pytest.fixture def half_in_gt_1d_3ch(): s_batch = np.zeros((10, 1, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224)) s_batch[:, :, 50:100] = 1.0 a_batch[:, :, 0:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), ...
@pytest.fixture def half_in_gt_1d_3ch():
s_batch = np.zeros((10, 1, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224)) s_batch[:, :, 50:100] = 1.0 a_batch[:, :, 0:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch":...
.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def half_in_gt_1d_3ch():
64
64
142
14
50
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
half_in_gt_1d_3ch
half_in_gt_1d_3ch
263
274
263
264
04221e4a37a07ae2830328fa66840e47f8fc6ff0
bigcode/the-stack
train
182e78c14018a9c1353239dc
train
function
@pytest.fixture def all_in_gt_2d_3ch(): s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224, 224)) s_batch[:, :, 50:150, 50:150] = 1.0 a_batch[:, :, 50:150, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random...
@pytest.fixture def all_in_gt_2d_3ch():
s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224, 224)) s_batch[:, :, 50:150, 50:150] = 1.0 a_batch[:, :, 50:150, 50:150] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_bat...
_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def all_in_gt_2d_3ch():
64
64
161
14
50
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
all_in_gt_2d_3ch
all_in_gt_2d_3ch
27
38
27
28
bc84e8c240071df1a35dc4555fd457e676dea9b3
bigcode/the-stack
train
34cbe128f02af709abb6865e
train
function
@pytest.fixture def half_in_gt_zeros_bigger_2d_3ch(): s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.zeros((10, 1, 224, 224)) s_batch[:, :, 0:100, 0:100] = 1.0 a_batch[:, :, 0:100, 75:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0,...
@pytest.fixture def half_in_gt_zeros_bigger_2d_3ch():
s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.zeros((10, 1, 224, 224)) s_batch[:, :, 0:100, 0:100] = 1.0 a_batch[:, :, 0:100, 75:100] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_...
, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } # TODO: unused fixture @pytest.fixture def half_in_gt_zeros_bigger_2d_3ch():
64
64
155
18
45
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
half_in_gt_zeros_bigger_2d_3ch
half_in_gt_zeros_bigger_2d_3ch
307
318
307
308
bc16571752abf3b508087e6513d332ab7ed63a28
bigcode/the-stack
train
fa86a87b854ddc1fb6750e35
train
function
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "k": 100, "disable_warnings": False, "display_progressbar"...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "k": 100, "disable_warnings": False, "display_progressbar"...
scores = TopKIntersection(**params)( model=model, x_batch=data["x_batch"], y_batch=data["y_batch"], a_batch=data["a_batch"], s_batch=data["s_batch"], **params ) print(scores, expected) if isinstance(expected, float): assert all(s == expected for s ...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "k": 100, "disable_warnings": False, "display_progressbar"...
1,289
256
1,428
1,289
0
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
test_top_k_intersection
test_top_k_intersection
444
655
444
639
5159b2577aeb135eef75487c1088eb8b7ba7dd15
bigcode/the-stack
train
c0786a363fe4d31a3b337a66
train
function
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, }, ...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, }, ...
scores = PointingGame(**params)( model=model, x_batch=data["x_batch"], y_batch=data["y_batch"], a_batch=data["a_batch"], s_batch=data["s_batch"], **params ) if isinstance(expected, bool): assert all(s == expected for s in scores), "Test failed." el...
@pytest.mark.localisation @pytest.mark.parametrize( "model,data,params,expected", [ ( lazy_fixture("load_1d_1ch_conv_model"), lazy_fixture("all_in_gt_1d_3ch"), { "disable_warnings": False, "display_progressbar": False, }, ...
605
229
764
605
0
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
test_pointing_game
test_pointing_game
321
441
321
424
b503fe4e2006df171ee650a3f546c1eb466cecbe
bigcode/the-stack
train
8fa2e19ef7fc80091ec03bac
train
function
@pytest.fixture def none_in_gt_2d_3ch(): s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224, 224)) s_batch[:, :, 0:100, 0:100] = 1.0 a_batch[:, :, 100:200, 100:200] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.rando...
@pytest.fixture def none_in_gt_2d_3ch():
s_batch = np.zeros((10, 1, 224, 224)) a_batch = np.random.uniform(0, 0.1, size=(10, 1, 224, 224)) s_batch[:, :, 0:100, 0:100] = 1.0 a_batch[:, :, 100:200, 100:200] = 1.0 return { "x_batch": np.random.randn(10, 3, 224, 224), "y_batch": np.random.randint(0, 10, size=10), "a_bat...
_batch": np.random.randn(10, 3, 224), "y_batch": np.random.randint(0, 10, size=10), "a_batch": a_batch, "s_batch": s_batch, } @pytest.fixture def none_in_gt_2d_3ch():
64
64
161
14
50
sebastian-lapuschkin/Quantus
tests/metrics/test_localisation_metrics.py
Python
none_in_gt_2d_3ch
none_in_gt_2d_3ch
165
176
165
166
9ea27b12ccd2645093beac06398f68eb7c8f7672
bigcode/the-stack
train
ff7f220f41b1c9219d92b450
train
class
class Edge(Element): CLASS = 'uk.gov.gchq.gaffer.data.element.Edge' def __init__(self, group, source, destination, directed, properties=None, matched_vertex=None): super().__init__(self.CLASS, group, properties) # Validate the arguments if not i...
class Edge(Element):
CLASS = 'uk.gov.gchq.gaffer.data.element.Edge' def __init__(self, group, source, destination, directed, properties=None, matched_vertex=None): super().__init__(self.CLASS, group, properties) # Validate the arguments if not isinstance(directed, b...
def __init__(self, group, vertex, properties=None): super().__init__(self.CLASS, group, properties) self.vertex = vertex def to_json(self): entity = super().to_json() entity['vertex'] = self.vertex return entity class Edge(Element):
64
64
178
4
59
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
Edge
Edge
267
290
267
267
79c586e1d3c11c5bfd46285f702d469707dfe1d4
bigcode/the-stack
train
bcc0523a7e6267ba9b1c1d0f
train
class
class EdgeVertices: NONE = 'NONE' SOURCE = 'SOURCE' DESTINATION = 'DESTINATION' BOTH = 'BOTH'
class EdgeVertices:
NONE = 'NONE' SOURCE = 'SOURCE' DESTINATION = 'DESTINATION' BOTH = 'BOTH'
DIRECTED' UNDIRECTED = 'UNDIRECTED' class InOutType: EITHER = 'EITHER' IN = 'INCOMING' OUT = 'OUTGOING' class SeedMatchingType: RELATED = 'RELATED' EQUAL = 'EQUAL' class EdgeVertices:
64
64
31
4
60
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
EdgeVertices
EdgeVertices
54
58
54
54
132ac9917baa48d860b19c68bafdf0b07b59382e
bigcode/the-stack
train
1d12ea6938a31f1bd7ab591d
train
class
class EdgeSeed(ElementSeed): CLASS = 'uk.gov.gchq.gaffer.operation.data.EdgeSeed' def __init__(self, source, destination, directed_type, matched_vertex=None): super().__init__() self.source = source self.destination = destination if isinstance(directed_type, str): se...
class EdgeSeed(ElementSeed):
CLASS = 'uk.gov.gchq.gaffer.operation.data.EdgeSeed' def __init__(self, source, destination, directed_type, matched_vertex=None): super().__init__() self.source = source self.destination = destination if isinstance(directed_type, str): self.directed_type = directed_t...
__init__(self, vertex): super().__init__() self.vertex = vertex def to_json(self): return {'class': self.CLASS, 'vertex': self.vertex} def to_json_wrapped(self): return { self.CLASS: { 'vertex': self.vertex, 'class': ...
79
79
266
6
73
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
EdgeSeed
EdgeSeed
135
176
135
135
8d8ce16fde4b9929ef3a24ab796d47cbddc7b48f
bigcode/the-stack
train
b6b1144a8ca7d931fb65b536
train
class
class EntitySeed(ElementSeed): CLASS = 'uk.gov.gchq.gaffer.operation.data.EntitySeed' def __init__(self, vertex): super().__init__() self.vertex = vertex def to_json(self): return {'class': self.CLASS, 'vertex': self.vertex} def to_json_wrapped(self): r...
class EntitySeed(ElementSeed):
CLASS = 'uk.gov.gchq.gaffer.operation.data.EntitySeed' def __init__(self, vertex): super().__init__() self.vertex = vertex def to_json(self): return {'class': self.CLASS, 'vertex': self.vertex} def to_json_wrapped(self): return { self.CLASS:...
): def __repr__(self): return json.dumps(self.to_json()) def to_json(self): raise NotImplementedError('Use either EntitySeed or EdgeSeed') def to_json_wrapped(self): raise NotImplementedError('Use either EntitySeed or EdgeSeed') class EntitySeed(ElementSeed):
64
64
97
6
58
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
EntitySeed
EntitySeed
115
132
115
115
079f4c1608b7458c3593cbde953fae24d7c49d87
bigcode/the-stack
train
6e259e5679018e2f80d43374
train
class
class SeedMatchingType: RELATED = 'RELATED' EQUAL = 'EQUAL'
class SeedMatchingType:
RELATED = 'RELATED' EQUAL = 'EQUAL'
class DirectedType: EITHER = 'EITHER' DIRECTED = 'DIRECTED' UNDIRECTED = 'UNDIRECTED' class InOutType: EITHER = 'EITHER' IN = 'INCOMING' OUT = 'OUTGOING' class SeedMatchingType:
64
64
19
5
59
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
SeedMatchingType
SeedMatchingType
49
51
49
49
b349aaf62d305c6ca332064d360ca3de6ed895e0
bigcode/the-stack
train
30cec5998d82533e060fe495
train
class
class Element(ToJson): def __init__(self, _class_name, group, properties=None): super().__init__() if not isinstance(_class_name, str): raise TypeError('ClassName must be a class name string') if not isinstance(group, str): raise TypeError('Group must be a string') ...
class Element(ToJson):
def __init__(self, _class_name, group, properties=None): super().__init__() if not isinstance(_class_name, str): raise TypeError('ClassName must be a class name string') if not isinstance(group, str): raise TypeError('Group must be a string') if not isinstance...
second): super().__init__() self.first = first self.second = second def to_json(self): return { 'class': self.CLASS, 'first': self.first.to_json_wrapped(), 'second': self.second.to_json_wrapped() } class Element(ToJson):
64
64
162
5
59
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
Element
Element
233
250
233
233
d8f9ecd8a6a390508a35cbcb02a86e278d4e9112
bigcode/the-stack
train
d4e1d87545c71e393951879d
train
class
class JoinType: FULL = 'FULL' OUTER = 'OUTER' INNER = 'INNER'
class JoinType:
FULL = 'FULL' OUTER = 'OUTER' INNER = 'INNER'
INATION = 'DESTINATION' BOTH = 'BOTH' class UseMatchedVertex: IGNORE = 'IGNORE' EQUAL = 'EQUAL' OPPOSITE = 'OPPOSITE' class MatchKey: LEFT = 'LEFT' RIGHT = 'RIGHT' class JoinType:
64
64
24
4
60
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
JoinType
JoinType
72
75
72
72
5580b02918b757aa0982b01803b714fbd8ee7400
bigcode/the-stack
train
403c188a3ab8e301d899b1ca
train
class
class MatchKey: LEFT = 'LEFT' RIGHT = 'RIGHT'
class MatchKey:
LEFT = 'LEFT' RIGHT = 'RIGHT'
Vertices: NONE = 'NONE' SOURCE = 'SOURCE' DESTINATION = 'DESTINATION' BOTH = 'BOTH' class UseMatchedVertex: IGNORE = 'IGNORE' EQUAL = 'EQUAL' OPPOSITE = 'OPPOSITE' class MatchKey:
64
64
16
4
60
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
MatchKey
MatchKey
67
69
67
67
4e263b01ea885e8a4fd9d1aed7ee767e1de143bb
bigcode/the-stack
train
796c7e970b8887bdbbd6f54a
train
class
class Base(ToJson): def __init__(self, _class_name=None): self._class_name = _class_name def to_json(self): obj = {} if self._class_name is not None: obj["class"] = self._class_name return obj
class Base(ToJson):
def __init__(self, _class_name=None): self._class_name = _class_name def to_json(self): obj = {} if self._class_name is not None: obj["class"] = self._class_name return obj
MatchKey: LEFT = 'LEFT' RIGHT = 'RIGHT' class JoinType: FULL = 'FULL' OUTER = 'OUTER' INNER = 'INNER' # Base class to be used by all Gaffer objects (Operations/ Functions / Predicates etc) class Base(ToJson):
64
64
62
5
59
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
Base
Base
79
89
79
79
1c2fdd5e46a7c503009b91df84255ae1ff65853c
bigcode/the-stack
train
32e59a6aa6815d6122face10
train
class
class Entity(Element): CLASS = 'uk.gov.gchq.gaffer.data.element.Entity' def __init__(self, group, vertex, properties=None): super().__init__(self.CLASS, group, properties) self.vertex = vertex def to_json(self): entity = super().to_json() entity['ve...
class Entity(Element):
CLASS = 'uk.gov.gchq.gaffer.data.element.Entity' def __init__(self, group, vertex, properties=None): super().__init__(self.CLASS, group, properties) self.vertex = vertex def to_json(self): entity = super().to_json() entity['vertex'] = self.vertex ...
_class_name self.group = group self.properties = properties def to_json(self): element = {'class': self._class_name, 'group': self.group} if self.properties is not None: element['properties'] = self.properties return element class Entity(Element):
64
64
79
4
59
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
Entity
Entity
253
264
253
253
20fa6ec176ee3c22b827a08cc81008ffad237843
bigcode/the-stack
train
25863ec383ffd1f8d84e77b6
train
class
class ToJson: """ Enables implementations to be converted to json via a to_json method """ def __repr__(self): return json.dumps(self.to_json()) def to_json(self): """ Converts an object to a simple json dictionary """ raise NotImplementedError('Use an imple...
class ToJson:
""" Enables implementations to be converted to json via a to_json method """ def __repr__(self): return json.dumps(self.to_json()) def to_json(self): """ Converts an object to a simple json dictionary """ raise NotImplementedError('Use an implementation') ...
import json class ToJson:
7
64
180
4
2
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
ToJson
ToJson
4
34
4
4
4c14a4b65a1d4133c7801ad4492fab7a9c3b1ebc
bigcode/the-stack
train
d34e6843ef3e94edc5ad483b
train
class
class DirectedType: EITHER = 'EITHER' DIRECTED = 'DIRECTED' UNDIRECTED = 'UNDIRECTED'
class DirectedType:
EITHER = 'EITHER' DIRECTED = 'DIRECTED' UNDIRECTED = 'UNDIRECTED'
_pretty_str()) def __str__(self): return str(self.to_json()) def __eq__(self, other): other_json = other if isinstance(other_json, ToJson): other_json = other.to_json() return self.to_json() == other_json class DirectedType:
64
64
30
4
59
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
DirectedType
DirectedType
37
40
37
37
8f5e2e69058a96c2ece87c95cbc47cc46592dfc1
bigcode/the-stack
train
4e91f9d2da5c5c0d8819df27
train
class
class ElementSeed(ToJson): def __repr__(self): return json.dumps(self.to_json()) def to_json(self): raise NotImplementedError('Use either EntitySeed or EdgeSeed') def to_json_wrapped(self): raise NotImplementedError('Use either EntitySeed or EdgeSeed')
class ElementSeed(ToJson):
def __repr__(self): return json.dumps(self.to_json()) def to_json(self): raise NotImplementedError('Use either EntitySeed or EdgeSeed') def to_json_wrapped(self): raise NotImplementedError('Use either EntitySeed or EdgeSeed')
=None): super().__init__(_class_name=_class_name) self.options = options def to_json(self): operation_json = super().to_json() if self.options is not None: operation_json["options"] = self.options return operation_json class ElementSeed(ToJson):
64
64
63
6
57
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
ElementSeed
ElementSeed
104
112
104
104
9c5efa950a9090a641bc0193472c24f707036725
bigcode/the-stack
train
150f80bafbb7a26b8522570a
train
class
class Operation(Base): def __init__(self, _class_name, options=None): super().__init__(_class_name=_class_name) self.options = options def to_json(self): operation_json = super().to_json() if self.options is not None: operation_json["options"] = self.options ...
class Operation(Base):
def __init__(self, _class_name, options=None): super().__init__(_class_name=_class_name) self.options = options def to_json(self): operation_json = super().to_json() if self.options is not None: operation_json["options"] = self.options return operation_json
(ToJson): def __init__(self, _class_name=None): self._class_name = _class_name def to_json(self): obj = {} if self._class_name is not None: obj["class"] = self._class_name return obj class Operation(Base):
64
64
74
4
59
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
Operation
Operation
92
101
92
92
3c1296c0a0a4e3552d0610afdda543ecdaff7f53
bigcode/the-stack
train
da9e996fff4c6b3c830a330c
train
class
class ElementPropertyComparator(Comparator): CLASS = 'uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator' def __init__(self, groups, property, reversed=False): super().__init__(class_name=None) self.groups = groups self.property = property self.reversed = rever...
class ElementPropertyComparator(Comparator):
CLASS = 'uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator' def __init__(self, groups, property, reversed=False): super().__init__(class_name=None) self.groups = groups self.property = property self.reversed = reversed def to_json(self): tmp_json ...
self.fields = fields def to_json(self): tmp_json = { 'class': self.class_name } if self.fields is not None: for key in self.fields: tmp_json[key] = self.fields[key] return tmp_json class ElementPropertyComparator(Comparator):
64
64
130
7
56
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
ElementPropertyComparator
ElementPropertyComparator
198
213
198
198
7f98e7d593253e47fd4162962fd3c0682ac6bce7
bigcode/the-stack
train
825ee97dbf8152004b195a30
train
class
class SeedPair(ToJson): CLASS = 'uk.gov.gchq.gaffer.commonutil.pair.Pair' def __init__(self, first, second): super().__init__() self.first = first self.second = second def to_json(self): return { 'class': self.CLASS, 'first': self.first.to_json_wrap...
class SeedPair(ToJson):
CLASS = 'uk.gov.gchq.gaffer.commonutil.pair.Pair' def __init__(self, first, second): super().__init__() self.first = first self.second = second def to_json(self): return { 'class': self.CLASS, 'first': self.first.to_json_wrapped(), 'seco...
(self): tmp_json = super().to_json() tmp_json["class"] = self.CLASS tmp_json['groups'] = self.groups tmp_json['property'] = self.property tmp_json['reversed'] = self.reversed return tmp_json class SeedPair(ToJson):
64
64
91
6
57
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
SeedPair
SeedPair
216
230
216
216
7692a55426e8fa8dcf429cb7bc4844406d1dad04
bigcode/the-stack
train
8fe95fa7305d47352e2a1772
train
class
class Comparator(ToJson): def __init__(self, class_name, fields=None): super().__init__() self.class_name = class_name self.fields = fields def to_json(self): tmp_json = { 'class': self.class_name } if self.fields is not None: for key in...
class Comparator(ToJson):
def __init__(self, class_name, fields=None): super().__init__() self.class_name = class_name self.fields = fields def to_json(self): tmp_json = { 'class': self.class_name } if self.fields is not None: for key in self.fields: ...
'destination': self.destination, 'directedType': self.directed_type, 'class': self.CLASS } if self.matched_vertex is not None: seed['matchedVertex'] = self.matched_vertex return { self.CLASS: seed } class Comparator(ToJson):
64
64
88
5
59
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
Comparator
Comparator
179
195
179
179
1a8d3e4675f5e55ec9d6230d7fff2c8c40c6b46b
bigcode/the-stack
train
6d820ffb3c034128058f0841
train
class
class UseMatchedVertex: IGNORE = 'IGNORE' EQUAL = 'EQUAL' OPPOSITE = 'OPPOSITE'
class UseMatchedVertex:
IGNORE = 'IGNORE' EQUAL = 'EQUAL' OPPOSITE = 'OPPOSITE'
' OUT = 'OUTGOING' class SeedMatchingType: RELATED = 'RELATED' EQUAL = 'EQUAL' class EdgeVertices: NONE = 'NONE' SOURCE = 'SOURCE' DESTINATION = 'DESTINATION' BOTH = 'BOTH' class UseMatchedVertex:
64
64
31
5
59
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
UseMatchedVertex
UseMatchedVertex
61
64
61
61
2ac08d5786e3e76594d35b949d2a430179d4459f
bigcode/the-stack
train
16a787216b318602fe08de2e
train
class
class InOutType: EITHER = 'EITHER' IN = 'INCOMING' OUT = 'OUTGOING'
class InOutType:
EITHER = 'EITHER' IN = 'INCOMING' OUT = 'OUTGOING'
other if isinstance(other_json, ToJson): other_json = other.to_json() return self.to_json() == other_json class DirectedType: EITHER = 'EITHER' DIRECTED = 'DIRECTED' UNDIRECTED = 'UNDIRECTED' class InOutType:
64
64
28
5
59
sw96411/gaffer-tools
fish-bowl/fishbowl/core.py
Python
InOutType
InOutType
43
46
43
43
39e58482f4949d45734676eb7e54a3315a52bdaa
bigcode/the-stack
train
4ca9388cd9fff17c7e340d9a
train
class
class Migration(migrations.Migration): dependencies = [ ('YtManagerApp', '0012_auto_20190819_1615'), ] operations = [ migrations.AddField( model_name='subscription', name='last_synchronised', field=models.DateTimeField(blank=True, null=True), ), ...
class Migration(migrations.Migration):
dependencies = [ ('YtManagerApp', '0012_auto_20190819_1615'), ] operations = [ migrations.AddField( model_name='subscription', name='last_synchronised', field=models.DateTimeField(blank=True, null=True), ), ]
# Generated by Django 2.2.5 on 2019-11-14 20:54 from django.db import migrations, models class Migration(migrations.Migration):
38
64
71
7
30
cyberjacob/ytsm
app/YtManagerApp/migrations/subscription_last_synchronised.py
Python
Migration
Migration
6
18
6
7
1b1f36e00fee71da3323cd6f9243e0382b9f685e
bigcode/the-stack
train
310e77f3d88a71091ac91406
train
function
def func(fn): """Marks a function as callable in Taichi-scope. This decorator transforms a Python function into a Taichi one. Taichi will JIT compile it into native instructions. Args: fn (Callable): The Python function to be decorated Returns: Callable: The decorated function ...
def func(fn):
"""Marks a function as callable in Taichi-scope. This decorator transforms a Python function into a Taichi one. Taichi will JIT compile it into native instructions. Args: fn (Callable): The Python function to be decorated Returns: Callable: The decorated function Example:: ...
taichi.lang.util import to_taichi_type from taichi.linalg.sparse_matrix import sparse_matrix_builder from taichi.tools.util import obsolete from taichi.types import any_arr, primitive_types, template import taichi as ti if util.has_pytorch(): import torch def func(fn):
64
64
210
4
59
somyasharmapuresoftware/taichi
python/taichi/lang/kernel_impl.py
Python
func
func
28
61
28
28
5a966b37a71ff0b4d93ee384108bed16c95306f7
bigcode/the-stack
train
6e794a8fb6c431f18cf4215f
train
class
class KernelDefError(Exception): pass
class KernelDefError(Exception):
pass
f'{self.num_args} argument(s) needed but {len(args)} provided.' ) key = self.extract(args) if key not in self.mapping: count = len(self.mapping) self.mapping[key] = count return self.mapping[key], key class KernelDefError(Exception):
64
64
9
6
57
somyasharmapuresoftware/taichi
python/taichi/lang/kernel_impl.py
Python
KernelDefError
KernelDefError
318
319
318
318
cd974f9bc1aee18136972e9e04cc1f3c981ce665
bigcode/the-stack
train
51b5defd316820de3745e82b
train
function
def _inside_class(level_of_class_stackframe): try: maybe_class_frame = sys._getframe(level_of_class_stackframe) statement_list = inspect.getframeinfo(maybe_class_frame)[3] first_statment = statement_list[0].strip() for pat in _KERNEL_CLASS_STACKFRAME_STMT_RES: if pat.matc...
def _inside_class(level_of_class_stackframe):
try: maybe_class_frame = sys._getframe(level_of_class_stackframe) statement_list = inspect.getframeinfo(maybe_class_frame)[3] first_statment = statement_list[0].strip() for pat in _KERNEL_CLASS_STACKFRAME_STMT_RES: if pat.match(first_statment): return True...
(object):, then in both versions, |code_context| is # 'class X(object):'... _KERNEL_CLASS_STACKFRAME_STMT_RES = [ re.compile(r'@(\w+\.)?data_oriented'), re.compile(r'class '), ] def _inside_class(level_of_class_stackframe):
64
64
91
10
54
somyasharmapuresoftware/taichi
python/taichi/lang/kernel_impl.py
Python
_inside_class
_inside_class
654
664
654
654
f22aee77d07238b2f54e045fd9d462ef788cc4ad
bigcode/the-stack
train
4fec4223207c6261ea1ddd6a
train
class
class KernelArgError(Exception): def __init__(self, pos, needed, provided): message = f'Argument {pos} (type={provided}) cannot be converted into required type {needed}' super().__init__(message) self.pos = pos self.needed = needed self.provided = provided
class KernelArgError(Exception):
def __init__(self, pos, needed, provided): message = f'Argument {pos} (type={provided}) cannot be converted into required type {needed}' super().__init__(message) self.pos = pos self.needed = needed self.provided = provided
) needed but {len(args)} provided.' ) key = self.extract(args) if key not in self.mapping: count = len(self.mapping) self.mapping[key] = count return self.mapping[key], key class KernelDefError(Exception): pass class KernelArgError(Exception):
64
64
69
6
57
somyasharmapuresoftware/taichi
python/taichi/lang/kernel_impl.py
Python
KernelArgError
KernelArgError
322
328
322
322
f5a3a0275afda498294f4877f31126091e243b6f
bigcode/the-stack
train
ff55e2dfe1d27b225a60ce54
train
function
def _kernel_impl(_func, level_of_class_stackframe, verbose=False): # Can decorators determine if a function is being defined inside a class? # https://stackoverflow.com/a/8793684/12003165 is_classkernel = _inside_class(level_of_class_stackframe + 1) _taichi_skip_traceback = 1 if verbose: pr...
def _kernel_impl(_func, level_of_class_stackframe, verbose=False): # Can decorators determine if a function is being defined inside a class? # https://stackoverflow.com/a/8793684/12003165
is_classkernel = _inside_class(level_of_class_stackframe + 1) _taichi_skip_traceback = 1 if verbose: print(f'kernel={_func.__name__} is_classkernel={is_classkernel}') primal = Kernel(_func, is_grad=False, _classkernel=is_classkernel) adjoint = Kernel(_func, is_grad=True, _classkernel=is_cla...
def _inside_class(level_of_class_stackframe): try: maybe_class_frame = sys._getframe(level_of_class_stackframe) statement_list = inspect.getframeinfo(maybe_class_frame)[3] first_statment = statement_list[0].strip() for pat in _KERNEL_CLASS_STACKFRAME_STMT_RES: if pat.matc...
138
138
463
47
90
somyasharmapuresoftware/taichi
python/taichi/lang/kernel_impl.py
Python
_kernel_impl
_kernel_impl
667
711
667
669
2f387f5d9ebd17d49046d63d58d7674ffe840c9d
bigcode/the-stack
train
622594cc7bd651c60f771196
train
function
def kernel(fn): """Marks a function as a Taichi kernel. A Taichi kernel is a function written in Python, and gets JIT compiled by Taichi into native CPU/GPU instructions (e.g. a series of CUDA kernels). The top-level ``for`` loops are automatically parallelized, and distributed to either a CPU thre...
def kernel(fn):
"""Marks a function as a Taichi kernel. A Taichi kernel is a function written in Python, and gets JIT compiled by Taichi into native CPU/GPU instructions (e.g. a series of CUDA kernels). The top-level ``for`` loops are automatically parallelized, and distributed to either a CPU thread pool or massi...
ichi_skip_traceback = 1 return primal(*args, **kwargs) wrapped.grad = adjoint wrapped._is_wrapped_kernel = True wrapped._is_classkernel = is_classkernel wrapped._primal = primal wrapped._adjoint = adjoint return wrapped def kernel(fn):
70
70
235
4
65
somyasharmapuresoftware/taichi
python/taichi/lang/kernel_impl.py
Python
kernel
kernel
714
743
714
714
f3a349ef64fe8fb5abe97828476478876a53b645
bigcode/the-stack
train
383d43f97c49495a26694655
train
function
def data_oriented(cls): """Marks a class as Taichi compatible. To allow for modularized code, Taichi provides this decorator so that Taichi kernels can be defined inside a class. See also https://docs.taichi.graphics/lang/articles/advanced/odop Example:: >>> @ti.data_oriented >>>...
def data_oriented(cls):
"""Marks a class as Taichi compatible. To allow for modularized code, Taichi provides this decorator so that Taichi kernels can be defined inside a class. See also https://docs.taichi.graphics/lang/articles/advanced/odop Example:: >>> @ti.data_oriented >>> class TiArray: ...
_kernel_func._is_staticmethod self.__name__ = None def __call__(self, *args, **kwargs): _taichi_skip_traceback = 1 if self._is_staticmethod: return self._primal(*args, **kwargs) return self._primal(self._kernel_owner, *args, **kwargs) def grad(self, *args, **kwargs)...
121
121
404
6
115
somyasharmapuresoftware/taichi
python/taichi/lang/kernel_impl.py
Python
data_oriented
data_oriented
774
832
774
774
1fd22b3efd209623941b97d7f9fbb7f8badf42b3
bigcode/the-stack
train
6341110fb7e17eed45b6ff5a
train
class
class TaichiCallableTemplateMapper: def __init__(self, annotations, template_slot_locations): self.annotations = annotations self.num_args = len(annotations) self.template_slot_locations = template_slot_locations self.mapping = {} @staticmethod def extract_arg(arg, anno): ...
class TaichiCallableTemplateMapper:
def __init__(self, annotations, template_slot_locations): self.annotations = annotations self.num_args = len(annotations) self.template_slot_locations = template_slot_locations self.mapping = {} @staticmethod def extract_arg(arg, anno): if isinstance(anno, template):...
or keyword" parameters' ) annotation = param.annotation if annotation is inspect.Parameter.empty: if i == 0 and self.classfunc: annotation = template() # TODO: pyfunc also need type annotation check when real function is enable...
195
195
650
7
188
somyasharmapuresoftware/taichi
python/taichi/lang/kernel_impl.py
Python
TaichiCallableTemplateMapper
TaichiCallableTemplateMapper
243
315
243
243
1930df5d9b995aab8bee884b6aae9deaa7de0860
bigcode/the-stack
train