body
stringlengths
26
98.2k
body_hash
int64
-9,222,864,604,528,158,000
9,221,803,474B
docstring
stringlengths
1
16.8k
path
stringlengths
5
230
name
stringlengths
1
96
repository_name
stringlengths
7
89
lang
stringclasses
1 value
body_without_docstring
stringlengths
20
98.2k
def stop(self): 'stop thread' print('stop tcp_sync uhd message tcp thread') self.q_quit.put('end')
-3,887,549,335,389,106,700
stop thread
src/tcp_sync.py
stop
Opendigitalradio/ODR-StaticPrecorrection
python
def stop(self): print('stop tcp_sync uhd message tcp thread') self.q_quit.put('end')
def stop(self): 'stop tcp thread' self.tcpa.stop()
3,942,472,123,918,109,000
stop tcp thread
src/tcp_sync.py
stop
Opendigitalradio/ODR-StaticPrecorrection
python
def stop(self): self.tcpa.stop()
def get_msgs(self, num): 'get received messages as string of integer' out = [] while (len(out) < num): out.append(self.tcpa.queue.get()) return out
7,122,424,559,509,667,000
get received messages as string of integer
src/tcp_sync.py
get_msgs
Opendigitalradio/ODR-StaticPrecorrection
python
def get_msgs(self, num): out = [] while (len(out) < num): out.append(self.tcpa.queue.get()) return out
def get_msgs_fft(self, num): '\n get received messages as string of integer\n apply fftshift to message\n ' out = [] while (len(out) < num): out.append(self.tcpa.queue.get()) return [np.fft.fftshift(np.array(o)) for o in out]
3,706,248,970,104,361,500
get received messages as string of integer apply fftshift to message
src/tcp_sync.py
get_msgs_fft
Opendigitalradio/ODR-StaticPrecorrection
python
def get_msgs_fft(self, num): '\n get received messages as string of integer\n apply fftshift to message\n ' out = [] while (len(out) < num): out.append(self.tcpa.queue.get()) return [np.fft.fftshift(np.array(o)) for o in out]
def get_res(self): 'get received messages as string of integer' out = [] while (not self.tcpa.queue.empty()): out.append(self.tcpa.queue.get()) return out
8,593,142,558,867,377,000
get received messages as string of integer
src/tcp_sync.py
get_res
Opendigitalradio/ODR-StaticPrecorrection
python
def get_res(self): out = [] while (not self.tcpa.queue.empty()): out.append(self.tcpa.queue.get()) return out
def has_msg(self): 'Checks if one or more messages were received and empties the message queue' return (self.get_res() != '')
-6,734,502,277,231,435,000
Checks if one or more messages were received and empties the message queue
src/tcp_sync.py
has_msg
Opendigitalradio/ODR-StaticPrecorrection
python
def has_msg(self): return (self.get_res() != )
def SparseSoftmaxCrossEntropyWithLogits(features, labels, is_grad=False, sens=1.0): 'sparse softmax cross entropy with logits' if is_grad: return loss_ad.sparse_softmax_cross_entropy_with_logits_ad(labels, features, reduction='mean', grad_scale=sens) return loss.sparse_softmax_cross_entropy_with_log...
7,726,223,615,983,516,000
sparse softmax cross entropy with logits
python/akg/ms/cce/sparse_softmax_cross_entropy_with_logits.py
SparseSoftmaxCrossEntropyWithLogits
Kiike5/akg
python
def SparseSoftmaxCrossEntropyWithLogits(features, labels, is_grad=False, sens=1.0): if is_grad: return loss_ad.sparse_softmax_cross_entropy_with_logits_ad(labels, features, reduction='mean', grad_scale=sens) return loss.sparse_softmax_cross_entropy_with_logits(labels, features, reduction='mean')
@requires_version('scipy', '0.14') def test_savgol_filter(): 'Test savgol filtering\n ' h_freq = 10.0 evoked = read_evokeds(fname, 0) freqs = fftpack.fftfreq(len(evoked.times), (1.0 / evoked.info['sfreq'])) data = np.abs(fftpack.fft(evoked.data)) match_mask = np.logical_and((freqs >= 0), (fre...
1,003,566,939,427,207,700
Test savgol filtering
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_savgol_filter
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
@requires_version('scipy', '0.14') def test_savgol_filter(): '\n ' h_freq = 10.0 evoked = read_evokeds(fname, 0) freqs = fftpack.fftfreq(len(evoked.times), (1.0 / evoked.info['sfreq'])) data = np.abs(fftpack.fft(evoked.data)) match_mask = np.logical_and((freqs >= 0), (freqs <= (h_freq / 2.0))...
def test_hash_evoked(): 'Test evoked hashing\n ' ave = read_evokeds(fname, 0) ave_2 = read_evokeds(fname, 0) assert_equal(hash(ave), hash(ave_2)) assert_true((pickle.dumps(ave) == pickle.dumps(ave_2))) ave_2.data[(0, 0)] -= 1 assert_not_equal(hash(ave), hash(ave_2))
4,966,346,371,525,945,000
Test evoked hashing
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_hash_evoked
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_hash_evoked(): '\n ' ave = read_evokeds(fname, 0) ave_2 = read_evokeds(fname, 0) assert_equal(hash(ave), hash(ave_2)) assert_true((pickle.dumps(ave) == pickle.dumps(ave_2))) ave_2.data[(0, 0)] -= 1 assert_not_equal(hash(ave), hash(ave_2))
@slow_test def test_io_evoked(): 'Test IO for evoked data (fif + gz) with integer and str args\n ' tempdir = _TempDir() ave = read_evokeds(fname, 0) write_evokeds(op.join(tempdir, 'evoked-ave.fif'), ave) ave2 = read_evokeds(op.join(tempdir, 'evoked-ave.fif'))[0] assert_true(np.allclose(ave.da...
6,766,221,181,861,603,000
Test IO for evoked data (fif + gz) with integer and str args
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_io_evoked
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
@slow_test def test_io_evoked(): '\n ' tempdir = _TempDir() ave = read_evokeds(fname, 0) write_evokeds(op.join(tempdir, 'evoked-ave.fif'), ave) ave2 = read_evokeds(op.join(tempdir, 'evoked-ave.fif'))[0] assert_true(np.allclose(ave.data, ave2.data, atol=1e-16, rtol=0.001)) assert_array_alm...
def test_shift_time_evoked(): ' Test for shifting of time scale\n ' tempdir = _TempDir() ave = read_evokeds(fname, 0) ave.shift_time((- 0.1), relative=True) write_evokeds(op.join(tempdir, 'evoked-ave.fif'), ave) ave_bshift = read_evokeds(op.join(tempdir, 'evoked-ave.fif'), 0) ave_bshift.s...
8,973,585,115,289,390,000
Test for shifting of time scale
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_shift_time_evoked
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_shift_time_evoked(): ' \n ' tempdir = _TempDir() ave = read_evokeds(fname, 0) ave.shift_time((- 0.1), relative=True) write_evokeds(op.join(tempdir, 'evoked-ave.fif'), ave) ave_bshift = read_evokeds(op.join(tempdir, 'evoked-ave.fif'), 0) ave_bshift.shift_time(0.2, relative=True) ...
def test_evoked_resample(): 'Test for resampling of evoked data\n ' tempdir = _TempDir() ave = read_evokeds(fname, 0) sfreq_normal = ave.info['sfreq'] ave.resample((2 * sfreq_normal)) write_evokeds(op.join(tempdir, 'evoked-ave.fif'), ave) ave_up = read_evokeds(op.join(tempdir, 'evoked-ave...
341,372,984,005,174,200
Test for resampling of evoked data
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_evoked_resample
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_evoked_resample(): '\n ' tempdir = _TempDir() ave = read_evokeds(fname, 0) sfreq_normal = ave.info['sfreq'] ave.resample((2 * sfreq_normal)) write_evokeds(op.join(tempdir, 'evoked-ave.fif'), ave) ave_up = read_evokeds(op.join(tempdir, 'evoked-ave.fif'), 0) ave_normal = read_e...
def test_evoked_detrend(): 'Test for detrending evoked data\n ' ave = read_evokeds(fname, 0) ave_normal = read_evokeds(fname, 0) ave.detrend(0) ave_normal.data -= np.mean(ave_normal.data, axis=1)[:, np.newaxis] picks = pick_types(ave.info, meg=True, eeg=True, exclude='bads') assert_true(n...
-6,973,230,050,582,125,000
Test for detrending evoked data
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_evoked_detrend
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_evoked_detrend(): '\n ' ave = read_evokeds(fname, 0) ave_normal = read_evokeds(fname, 0) ave.detrend(0) ave_normal.data -= np.mean(ave_normal.data, axis=1)[:, np.newaxis] picks = pick_types(ave.info, meg=True, eeg=True, exclude='bads') assert_true(np.allclose(ave.data[picks], ave...
@requires_pandas def test_to_data_frame(): 'Test evoked Pandas exporter' ave = read_evokeds(fname, 0) assert_raises(ValueError, ave.to_data_frame, picks=np.arange(400)) df = ave.to_data_frame() assert_true((df.columns == ave.ch_names).all()) df = ave.to_data_frame(index=None).reset_index('time')...
8,547,556,037,848,418,000
Test evoked Pandas exporter
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_to_data_frame
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
@requires_pandas def test_to_data_frame(): ave = read_evokeds(fname, 0) assert_raises(ValueError, ave.to_data_frame, picks=np.arange(400)) df = ave.to_data_frame() assert_true((df.columns == ave.ch_names).all()) df = ave.to_data_frame(index=None).reset_index('time') assert_true(('time' in d...
def test_evoked_proj(): 'Test SSP proj operations\n ' for proj in [True, False]: ave = read_evokeds(fname, condition=0, proj=proj) assert_true(all(((p['active'] == proj) for p in ave.info['projs']))) if proj: assert_raises(ValueError, ave.add_proj, [], {'remove_existing': ...
-3,701,147,736,561,590,300
Test SSP proj operations
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_evoked_proj
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_evoked_proj(): '\n ' for proj in [True, False]: ave = read_evokeds(fname, condition=0, proj=proj) assert_true(all(((p['active'] == proj) for p in ave.info['projs']))) if proj: assert_raises(ValueError, ave.add_proj, [], {'remove_existing': True}) asser...
def test_get_peak(): 'Test peak getter\n ' evoked = read_evokeds(fname, condition=0, proj=True) assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmin=1) assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmax=0.9) assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmin=0.02...
8,836,964,148,858,811,000
Test peak getter
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_get_peak
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_get_peak(): '\n ' evoked = read_evokeds(fname, condition=0, proj=True) assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmin=1) assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmax=0.9) assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmin=0.02, tmax=0.01) ...
def test_drop_channels_mixin(): 'Test channels-dropping functionality\n ' evoked = read_evokeds(fname, condition=0, proj=True) drop_ch = evoked.ch_names[:3] ch_names = evoked.ch_names[3:] ch_names_orig = evoked.ch_names dummy = evoked.drop_channels(drop_ch, copy=True) assert_equal(ch_name...
-6,536,372,745,575,585,000
Test channels-dropping functionality
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_drop_channels_mixin
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_drop_channels_mixin(): '\n ' evoked = read_evokeds(fname, condition=0, proj=True) drop_ch = evoked.ch_names[:3] ch_names = evoked.ch_names[3:] ch_names_orig = evoked.ch_names dummy = evoked.drop_channels(drop_ch, copy=True) assert_equal(ch_names, dummy.ch_names) assert_equal(...
def test_pick_channels_mixin(): 'Test channel-picking functionality\n ' evoked = read_evokeds(fname, condition=0, proj=True) ch_names = evoked.ch_names[:3] ch_names_orig = evoked.ch_names dummy = evoked.pick_channels(ch_names, copy=True) assert_equal(ch_names, dummy.ch_names) assert_equal...
3,259,110,269,856,583,700
Test channel-picking functionality
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_pick_channels_mixin
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_pick_channels_mixin(): '\n ' evoked = read_evokeds(fname, condition=0, proj=True) ch_names = evoked.ch_names[:3] ch_names_orig = evoked.ch_names dummy = evoked.pick_channels(ch_names, copy=True) assert_equal(ch_names, dummy.ch_names) assert_equal(ch_names_orig, evoked.ch_names) ...
def test_equalize_channels(): 'Test equalization of channels\n ' evoked1 = read_evokeds(fname, condition=0, proj=True) evoked2 = evoked1.copy() ch_names = evoked1.ch_names[2:] evoked1.drop_channels(evoked1.ch_names[:1]) evoked2.drop_channels(evoked2.ch_names[1:2]) my_comparison = [evoked1...
-7,844,826,099,472,365,000
Test equalization of channels
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_equalize_channels
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_equalize_channels(): '\n ' evoked1 = read_evokeds(fname, condition=0, proj=True) evoked2 = evoked1.copy() ch_names = evoked1.ch_names[2:] evoked1.drop_channels(evoked1.ch_names[:1]) evoked2.drop_channels(evoked2.ch_names[1:2]) my_comparison = [evoked1, evoked2] equalize_chann...
def test_evoked_arithmetic(): 'Test evoked arithmetic\n ' ev = read_evokeds(fname, condition=0) ev1 = EvokedArray(np.ones_like(ev.data), ev.info, ev.times[0], nave=20) ev2 = EvokedArray((- np.ones_like(ev.data)), ev.info, ev.times[0], nave=10) ev = (ev1 + ev2) assert_equal(ev.nave, (ev1.nave ...
4,783,975,814,896,653,000
Test evoked arithmetic
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_evoked_arithmetic
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_evoked_arithmetic(): '\n ' ev = read_evokeds(fname, condition=0) ev1 = EvokedArray(np.ones_like(ev.data), ev.info, ev.times[0], nave=20) ev2 = EvokedArray((- np.ones_like(ev.data)), ev.info, ev.times[0], nave=10) ev = (ev1 + ev2) assert_equal(ev.nave, (ev1.nave + ev2.nave)) asser...
def test_array_epochs(): 'Test creating evoked from array\n ' tempdir = _TempDir() rng = np.random.RandomState(42) data1 = rng.randn(20, 60) sfreq = 1000.0 ch_names = [('EEG %03d' % (i + 1)) for i in range(20)] types = (['eeg'] * 20) info = create_info(ch_names, sfreq, types) evok...
1,354,860,884,603,699,000
Test creating evoked from array
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_array_epochs
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_array_epochs(): '\n ' tempdir = _TempDir() rng = np.random.RandomState(42) data1 = rng.randn(20, 60) sfreq = 1000.0 ch_names = [('EEG %03d' % (i + 1)) for i in range(20)] types = (['eeg'] * 20) info = create_info(ch_names, sfreq, types) evoked1 = EvokedArray(data1, info, ...
def test_add_channels(): 'Test evoked splitting / re-appending channel types\n ' evoked = read_evokeds(fname, condition=0) evoked.info['buffer_size_sec'] = None evoked_eeg = evoked.pick_types(meg=False, eeg=True, copy=True) evoked_meg = evoked.pick_types(meg=True, copy=True) evoked_stim = evo...
8,884,444,190,310,556,000
Test evoked splitting / re-appending channel types
python-packages/mne-python-0.10/mne/tests/test_evoked.py
test_add_channels
rajegannathan/grasp-lift-eeg-cat-dog-solution-updated
python
def test_add_channels(): '\n ' evoked = read_evokeds(fname, condition=0) evoked.info['buffer_size_sec'] = None evoked_eeg = evoked.pick_types(meg=False, eeg=True, copy=True) evoked_meg = evoked.pick_types(meg=True, copy=True) evoked_stim = evoked.pick_types(meg=False, stim=True, copy=True) ...
def prob_mac_given_loc(self, mac, val, loc, positive): '\n Determine the P(mac=val | loc) (positive)\n Determine the P(mac=val | ~loc) (not positive)\n ' name = '{}{}{}{}'.format(mac, val, loc, positive) cached = cache.get(name) if (cached != None): return cached P = 0.0...
6,535,456,042,018,533,000
Determine the P(mac=val | loc) (positive) Determine the P(mac=val | ~loc) (not positive)
server/ai/src/naive_bayes.py
prob_mac_given_loc
ChuVal/Respaldo2
python
def prob_mac_given_loc(self, mac, val, loc, positive): '\n Determine the P(mac=val | loc) (positive)\n Determine the P(mac=val | ~loc) (not positive)\n ' name = '{}{}{}{}'.format(mac, val, loc, positive) cached = cache.get(name) if (cached != None): return cached P = 0.0...
def tune_model(mod, params, tune_settings, target, model_name): '\n Tune a model for a specified number of trials along with other tune settings.\n Tune settings are specified using a json configuration, as per the TVM tools readme.\n ' early_stopping = tune_settings['early_stopping'] number = tune...
9,174,764,952,180,181,000
Tune a model for a specified number of trials along with other tune settings. Tune settings are specified using a json configuration, as per the TVM tools readme.
tools/tune_model.py
tune_model
lhutton1/benchmark-tvm
python
def tune_model(mod, params, tune_settings, target, model_name): '\n Tune a model for a specified number of trials along with other tune settings.\n Tune settings are specified using a json configuration, as per the TVM tools readme.\n ' early_stopping = tune_settings['early_stopping'] number = tune...
def tune_models(data): '\n Auto tune all models referenced in the json configuration.\n ' target_string = data['target'] tune_settings = data['autotuner_settings'] for model in data['models']: (trace, input_shapes) = get_model(model['name'], model['type']) (mod, params) = relay.fro...
860,469,008,408,997,100
Auto tune all models referenced in the json configuration.
tools/tune_model.py
tune_models
lhutton1/benchmark-tvm
python
def tune_models(data): '\n \n ' target_string = data['target'] tune_settings = data['autotuner_settings'] for model in data['models']: (trace, input_shapes) = get_model(model['name'], model['type']) (mod, params) = relay.frontend.from_pytorch(trace, input_shapes) print(f"Tu...
def example_1(): '\n THIS IS A LONG COMMENT AND should be wrapped to fit within a 72 \n character limit\n ' long_1 = 'LONG CODE LINES should be wrapped within 79 character to \n prevent page cutoff stuff' long_2 = 'This IS a long string that looks gross and goes beyond \n what...
5,549,236,925,018,196,000
THIS IS A LONG COMMENT AND should be wrapped to fit within a 72 character limit
lambdata/code_review.py
example_1
DevinJMantz/lambdata-25
python
def example_1(): '\n THIS IS A LONG COMMENT AND should be wrapped to fit within a 72 \n character limit\n ' long_1 = 'LONG CODE LINES should be wrapped within 79 character to \n prevent page cutoff stuff' long_2 = 'This IS a long string that looks gross and goes beyond \n what...
def test_api_root_should_reply_200(self): ' GET /api/v1/ should return an hyperlink to the users view and return a successful status 200 OK.\n ' request = APIRequestFactory().get('/api/v1/') user_list_view = UserViewSet.as_view({'get': 'list'}) response = user_list_view(request) self.assertEq...
7,714,308,681,116,089,000
GET /api/v1/ should return an hyperlink to the users view and return a successful status 200 OK.
users_django/users/tests/test_views.py
test_api_root_should_reply_200
r-o-main/users-exercise
python
def test_api_root_should_reply_200(self): ' \n ' request = APIRequestFactory().get('/api/v1/') user_list_view = UserViewSet.as_view({'get': 'list'}) response = user_list_view(request) self.assertEqual(status.HTTP_200_OK, response.status_code)
def test_list_all_users_should_retrieve_all_users_and_reply_200(self): ' GET /api/v1/users should return all the users (or empty if no users found)\n and return a successful status 200 OK.\n ' users = User.objects.all().order_by('id') request = self.factory.get(reverse('v1:user-list')) ...
-6,177,446,604,823,195,000
GET /api/v1/users should return all the users (or empty if no users found) and return a successful status 200 OK.
users_django/users/tests/test_views.py
test_list_all_users_should_retrieve_all_users_and_reply_200
r-o-main/users-exercise
python
def test_list_all_users_should_retrieve_all_users_and_reply_200(self): ' GET /api/v1/users should return all the users (or empty if no users found)\n and return a successful status 200 OK.\n ' users = User.objects.all().order_by('id') request = self.factory.get(reverse('v1:user-list')) ...
@staticmethod def _min_norm_element_from2(v1v1, v1v2, v2v2): '\n Analytical solution for min_{c} |cx_1 + (1-c)x_2|_2^2\n d is the distance (objective) optimzed\n v1v1 = <x1,x1>\n v1v2 = <x1,x2>\n v2v2 = <x2,x2>\n ' if (v1v2 >= v1v1): gamma = 0.999 cost =...
-4,625,356,207,219,539,000
Analytical solution for min_{c} |cx_1 + (1-c)x_2|_2^2 d is the distance (objective) optimzed v1v1 = <x1,x1> v1v2 = <x1,x2> v2v2 = <x2,x2>
utils/min_norm_solvers.py
_min_norm_element_from2
DavidHidde/backdoors101
python
@staticmethod def _min_norm_element_from2(v1v1, v1v2, v2v2): '\n Analytical solution for min_{c} |cx_1 + (1-c)x_2|_2^2\n d is the distance (objective) optimzed\n v1v1 = <x1,x1>\n v1v2 = <x1,x2>\n v2v2 = <x2,x2>\n ' if (v1v2 >= v1v1): gamma = 0.999 cost =...
@staticmethod def _min_norm_2d(vecs: list, dps): '\n Find the minimum norm solution as combination of two points\n This is correct only in 2D\n ie. min_c |\\sum c_i x_i|_2^2 st. \\sum c_i = 1 , 1 >= c_1 >= 0\n for all i, c_i + c_j = 1.0 for some i, j\n ' dmin = 100000000.0 ...
2,761,131,809,362,592,300
Find the minimum norm solution as combination of two points This is correct only in 2D ie. min_c |\sum c_i x_i|_2^2 st. \sum c_i = 1 , 1 >= c_1 >= 0 for all i, c_i + c_j = 1.0 for some i, j
utils/min_norm_solvers.py
_min_norm_2d
DavidHidde/backdoors101
python
@staticmethod def _min_norm_2d(vecs: list, dps): '\n Find the minimum norm solution as combination of two points\n This is correct only in 2D\n ie. min_c |\\sum c_i x_i|_2^2 st. \\sum c_i = 1 , 1 >= c_1 >= 0\n for all i, c_i + c_j = 1.0 for some i, j\n ' dmin = 100000000.0 ...
@staticmethod def _projection2simplex(y): '\n Given y, it solves argmin_z |y-z|_2 st \\sum z = 1 , 1 >= z_i >= 0 for all i\n ' m = len(y) sorted_y = np.flip(np.sort(y), axis=0) tmpsum = 0.0 tmax_f = ((np.sum(y) - 1.0) / m) for i in range((m - 1)): tmpsum += sorted_y[i] ...
-384,395,269,440,826,900
Given y, it solves argmin_z |y-z|_2 st \sum z = 1 , 1 >= z_i >= 0 for all i
utils/min_norm_solvers.py
_projection2simplex
DavidHidde/backdoors101
python
@staticmethod def _projection2simplex(y): '\n Given y, it solves argmin_z |y-z|_2 st \\sum z = 1 , 1 >= z_i >= 0 for all i\n ' m = len(y) sorted_y = np.flip(np.sort(y), axis=0) tmpsum = 0.0 tmax_f = ((np.sum(y) - 1.0) / m) for i in range((m - 1)): tmpsum += sorted_y[i] ...
@staticmethod def find_min_norm_element(vecs: list): '\n Given a list of vectors (vecs), this method finds the minimum norm\n element in the convex hull as min |u|_2 st. u = \\sum c_i vecs[i]\n and \\sum c_i = 1. It is quite geometric, and the main idea is the\n fact that if d_{ij} = min...
-7,322,903,186,992,737,000
Given a list of vectors (vecs), this method finds the minimum norm element in the convex hull as min |u|_2 st. u = \sum c_i vecs[i] and \sum c_i = 1. It is quite geometric, and the main idea is the fact that if d_{ij} = min |u|_2 st u = c x_i + (1-c) x_j; the solution lies in (0, d_{i,j})Hence, we find the best 2-task ...
utils/min_norm_solvers.py
find_min_norm_element
DavidHidde/backdoors101
python
@staticmethod def find_min_norm_element(vecs: list): '\n Given a list of vectors (vecs), this method finds the minimum norm\n element in the convex hull as min |u|_2 st. u = \\sum c_i vecs[i]\n and \\sum c_i = 1. It is quite geometric, and the main idea is the\n fact that if d_{ij} = min...
@staticmethod def find_min_norm_element_FW(vecs): '\n Given a list of vectors (vecs), this method finds the minimum norm\n element in the convex hull\n as min |u|_2 st. u = \\sum c_i vecs[i] and \\sum c_i = 1.\n It is quite geometric, and the main idea is the fact that if\n d_{ij}...
6,128,836,268,395,524,000
Given a list of vectors (vecs), this method finds the minimum norm element in the convex hull as min |u|_2 st. u = \sum c_i vecs[i] and \sum c_i = 1. It is quite geometric, and the main idea is the fact that if d_{ij} = min |u|_2 st u = c x_i + (1-c) x_j; the solution lies in (0, d_{i,j})Hence, we find the best 2-task ...
utils/min_norm_solvers.py
find_min_norm_element_FW
DavidHidde/backdoors101
python
@staticmethod def find_min_norm_element_FW(vecs): '\n Given a list of vectors (vecs), this method finds the minimum norm\n element in the convex hull\n as min |u|_2 st. u = \\sum c_i vecs[i] and \\sum c_i = 1.\n It is quite geometric, and the main idea is the fact that if\n d_{ij}...
def __init__(self, cfg): 'Create configuration settings that may not already be set.\n\n The user can either define the relevant namespaces specifically for the\n mat_views plugin, or the mat_views plugin can draw on the settings in the\n bucardo section of the config. If neither exists, the s...
6,242,808,382,029,592,000
Create configuration settings that may not already be set. The user can either define the relevant namespaces specifically for the mat_views plugin, or the mat_views plugin can draw on the settings in the bucardo section of the config. If neither exists, the script will throw an error. Keyword arguments: cfg: conten...
plugins/mat_views/__init__.py
__init__
emmadev/bucardo_wrapper
python
def __init__(self, cfg): 'Create configuration settings that may not already be set.\n\n The user can either define the relevant namespaces specifically for the\n mat_views plugin, or the mat_views plugin can draw on the settings in the\n bucardo section of the config. If neither exists, the s...
def refresh(self): 'Refresh materialized views.\n\n First, this method finds the namespaces being replicated, by referring to the\n config for schemas and tables.\n\n Then it finds any materialized views in the namespaces.\n\n Then it refreshes the materialized views.\n ' prin...
4,562,420,599,338,210,000
Refresh materialized views. First, this method finds the namespaces being replicated, by referring to the config for schemas and tables. Then it finds any materialized views in the namespaces. Then it refreshes the materialized views.
plugins/mat_views/__init__.py
refresh
emmadev/bucardo_wrapper
python
def refresh(self): 'Refresh materialized views.\n\n First, this method finds the namespaces being replicated, by referring to the\n config for schemas and tables.\n\n Then it finds any materialized views in the namespaces.\n\n Then it refreshes the materialized views.\n ' prin...
def step(self): 'In this function the robot will return to default pose, to\n be ready for the new command.\n ' origin = [0.4] self.observation = torch.tensor(origin, dtype=self.precision, device=self.device)
-4,679,040,297,958,044,000
In this function the robot will return to default pose, to be ready for the new command.
environments/nao/pose_assumption.py
step
AroMorin/DNNOP
python
def step(self): 'In this function the robot will return to default pose, to\n be ready for the new command.\n ' origin = [0.4] self.observation = torch.tensor(origin, dtype=self.precision, device=self.device)
def evaluate(self, inference): 'Evaluates the predicted pose.' self.reset_state() values = self.process_inference(inference) self.apply(values) angles = self.get_joints() self.calc_error(angles) return self.error
-2,085,172,381,588,377,600
Evaluates the predicted pose.
environments/nao/pose_assumption.py
evaluate
AroMorin/DNNOP
python
def evaluate(self, inference): self.reset_state() values = self.process_inference(inference) self.apply(values) angles = self.get_joints() self.calc_error(angles) return self.error
def process_inference(self, inference): 'Ensures safety of the predicted angles.' values = [a.item() for a in inference] for (idx, value) in enumerate(values): name = self.joints[idx] limits = self.motion.getLimits(name) min_angle = limits[0][0] max_angle = limits[0][1] ...
3,344,582,118,635,586,600
Ensures safety of the predicted angles.
environments/nao/pose_assumption.py
process_inference
AroMorin/DNNOP
python
def process_inference(self, inference): values = [a.item() for a in inference] for (idx, value) in enumerate(values): name = self.joints[idx] limits = self.motion.getLimits(name) min_angle = limits[0][0] max_angle = limits[0][1] max_vel = limits[0][2] max_tor...
def apply(self, angles): 'Applies the pose to the robot.' self.set_joints(angles)
-8,043,274,140,901,361,000
Applies the pose to the robot.
environments/nao/pose_assumption.py
apply
AroMorin/DNNOP
python
def apply(self, angles): self.set_joints(angles)
def calc_error(self, angles): 'Calculate the error between predicted and target angles, and\n add the safety penalties.\n ' errors = [abs((x - y)) for (x, y) in zip(angles, self.target_angles)] error = sum(errors) error += self.penalty self.error = torch.tensor(error)
-1,805,989,592,975,838,000
Calculate the error between predicted and target angles, and add the safety penalties.
environments/nao/pose_assumption.py
calc_error
AroMorin/DNNOP
python
def calc_error(self, angles): 'Calculate the error between predicted and target angles, and\n add the safety penalties.\n ' errors = [abs((x - y)) for (x, y) in zip(angles, self.target_angles)] error = sum(errors) error += self.penalty self.error = torch.tensor(error)
def parse_args(args=[], doc=False): '\n Handle parsing of arguments and flags. Generates docs using help from `ArgParser`\n\n Args:\n args (list): argv passed to the binary\n doc (bool): If the function should generate and return manpage\n\n Returns:\n Processed args and a copy of the ...
6,631,359,889,158,821,000
Handle parsing of arguments and flags. Generates docs using help from `ArgParser` Args: args (list): argv passed to the binary doc (bool): If the function should generate and return manpage Returns: Processed args and a copy of the `ArgParser` object if not `doc` else a `string` containing the generated m...
client/blackhat/bin/installable/ifconfig.py
parse_args
stautonico/blackhat-simulator
python
def parse_args(args=[], doc=False): '\n Handle parsing of arguments and flags. Generates docs using help from `ArgParser`\n\n Args:\n args (list): argv passed to the binary\n doc (bool): If the function should generate and return manpage\n\n Returns:\n Processed args and a copy of the ...
def main(args: list, pipe: bool) -> Result: '\n # TODO: Add docstring for manpage\n ' (args, parser) = parse_args(args) if parser.error_message: if (not args.version): return output(f'{__COMMAND__}: {parser.error_message}', pipe, success=False) if args.version: return o...
-6,250,299,901,454,325,000
# TODO: Add docstring for manpage
client/blackhat/bin/installable/ifconfig.py
main
stautonico/blackhat-simulator
python
def main(args: list, pipe: bool) -> Result: '\n \n ' (args, parser) = parse_args(args) if parser.error_message: if (not args.version): return output(f'{__COMMAND__}: {parser.error_message}', pipe, success=False) if args.version: return output(f'ifconfig (blackhat netuti...
def __init__(self, tau_V, geometry='dusty', dust_type='mw', dust_distribution='clumpy'): "\n Load the attenuation curves for a given geometry, dust type and\n dust distribution.\n\n Parameters\n ----------\n tau_V: float\n optical depth in V band\n\n geometry: str...
1,800,130,098,260,879,000
Load the attenuation curves for a given geometry, dust type and dust distribution. Parameters ---------- tau_V: float optical depth in V band geometry: string 'shell', 'cloudy' or 'dusty' dust_type: string 'mw' or 'smc' dust_distribution: string 'homogeneous' or 'clumpy' Returns ------- Attx: np array ...
dust_attenuation/radiative_transfer.py
__init__
gbrammer/dust_attenuation
python
def __init__(self, tau_V, geometry='dusty', dust_type='mw', dust_distribution='clumpy'): "\n Load the attenuation curves for a given geometry, dust type and\n dust distribution.\n\n Parameters\n ----------\n tau_V: float\n optical depth in V band\n\n geometry: str...
def evaluate(self, x, tau_V): '\n WG00 function\n\n Parameters\n ----------\n x: float\n expects either x in units of wavelengths or frequency\n or assumes wavelengths in [micron]\n\n internally microns are used\n\n tau_V: float\n optical de...
5,917,144,303,742,886,000
WG00 function Parameters ---------- x: float expects either x in units of wavelengths or frequency or assumes wavelengths in [micron] internally microns are used tau_V: float optical depth in V band Returns ------- Attx: np array (float) Att(x) attenuation curve [mag] Raises ------ ValueError In...
dust_attenuation/radiative_transfer.py
evaluate
gbrammer/dust_attenuation
python
def evaluate(self, x, tau_V): '\n WG00 function\n\n Parameters\n ----------\n x: float\n expects either x in units of wavelengths or frequency\n or assumes wavelengths in [micron]\n\n internally microns are used\n\n tau_V: float\n optical de...
def get_extinction(self, x, tau_V): '\n Return the extinction at a given wavelength and\n V-band optical depth.\n\n Parameters\n ----------\n x: float\n expects either x in units of wavelengths or frequency\n or assumes wavelengths in [micron]\n\n int...
8,449,185,508,644,122,000
Return the extinction at a given wavelength and V-band optical depth. Parameters ---------- x: float expects either x in units of wavelengths or frequency or assumes wavelengths in [micron] internally microns are used tau_V: float optical depth in V band Returns ------- ext: np array (float) ext(x) ...
dust_attenuation/radiative_transfer.py
get_extinction
gbrammer/dust_attenuation
python
def get_extinction(self, x, tau_V): '\n Return the extinction at a given wavelength and\n V-band optical depth.\n\n Parameters\n ----------\n x: float\n expects either x in units of wavelengths or frequency\n or assumes wavelengths in [micron]\n\n int...
def get_fsca(self, x, tau_V): '\n Return the scattered flux fraction at a given wavelength and\n V-band optical depth.\n\n Parameters\n ----------\n x: float\n expects either x in units of wavelengths or frequency\n or assumes wavelengths in [micron]\n\n ...
5,405,936,841,851,005,000
Return the scattered flux fraction at a given wavelength and V-band optical depth. Parameters ---------- x: float expects either x in units of wavelengths or frequency or assumes wavelengths in [micron] internally microns are used tau_V: float optical depth in V band Returns ------- fsca: np array (flo...
dust_attenuation/radiative_transfer.py
get_fsca
gbrammer/dust_attenuation
python
def get_fsca(self, x, tau_V): '\n Return the scattered flux fraction at a given wavelength and\n V-band optical depth.\n\n Parameters\n ----------\n x: float\n expects either x in units of wavelengths or frequency\n or assumes wavelengths in [micron]\n\n ...
def get_fdir(self, x, tau_V): '\n Return the direct attenuated stellar flux fraction at a given\n wavelength and V-band optical depth.\n\n Parameters\n ----------\n x: float\n expects either x in units of wavelengths or frequency\n or assumes wavelengths in [m...
-6,710,853,848,865,956,000
Return the direct attenuated stellar flux fraction at a given wavelength and V-band optical depth. Parameters ---------- x: float expects either x in units of wavelengths or frequency or assumes wavelengths in [micron] internally microns are used tau_V: float optical depth in V band Returns ------- fsc...
dust_attenuation/radiative_transfer.py
get_fdir
gbrammer/dust_attenuation
python
def get_fdir(self, x, tau_V): '\n Return the direct attenuated stellar flux fraction at a given\n wavelength and V-band optical depth.\n\n Parameters\n ----------\n x: float\n expects either x in units of wavelengths or frequency\n or assumes wavelengths in [m...
def get_fesc(self, x, tau_V): '\n Return the total escaping flux fraction at a given wavelength and\n V-band optical depth.\n\n Parameters\n ----------\n x: float\n expects either x in units of wavelengths or frequency\n or assumes wavelengths in [micron]\n\n ...
6,972,523,913,694,243,000
Return the total escaping flux fraction at a given wavelength and V-band optical depth. Parameters ---------- x: float expects either x in units of wavelengths or frequency or assumes wavelengths in [micron] internally microns are used tau_V: float optical depth in V band Returns ------- fsca: np array...
dust_attenuation/radiative_transfer.py
get_fesc
gbrammer/dust_attenuation
python
def get_fesc(self, x, tau_V): '\n Return the total escaping flux fraction at a given wavelength and\n V-band optical depth.\n\n Parameters\n ----------\n x: float\n expects either x in units of wavelengths or frequency\n or assumes wavelengths in [micron]\n\n ...
def get_albedo(self, x): '\n Return the albedo in function of wavelength for the corresponding\n dust type (SMC or MW). The albedo gives the probability a photon\n is scattered from a dust grain.\n\n Parameters\n ----------\n x: float\n expects either x in units o...
263,105,765,852,705,340
Return the albedo in function of wavelength for the corresponding dust type (SMC or MW). The albedo gives the probability a photon is scattered from a dust grain. Parameters ---------- x: float expects either x in units of wavelengths or frequency or assumes wavelengths in [micron] internally microns are use...
dust_attenuation/radiative_transfer.py
get_albedo
gbrammer/dust_attenuation
python
def get_albedo(self, x): '\n Return the albedo in function of wavelength for the corresponding\n dust type (SMC or MW). The albedo gives the probability a photon\n is scattered from a dust grain.\n\n Parameters\n ----------\n x: float\n expects either x in units o...
def get_scattering_phase_function(self, x): '\n Return the scattering phase function in function of wavelength for the\n corresponding dust type (SMC or MW). The scattering phase\n function gives the angle at which the photon scatters.\n\n Parameters\n ----------\n x: float...
-1,038,028,975,065,373,800
Return the scattering phase function in function of wavelength for the corresponding dust type (SMC or MW). The scattering phase function gives the angle at which the photon scatters. Parameters ---------- x: float expects either x in units of wavelengths or frequency or assumes wavelengths in [micron] inter...
dust_attenuation/radiative_transfer.py
get_scattering_phase_function
gbrammer/dust_attenuation
python
def get_scattering_phase_function(self, x): '\n Return the scattering phase function in function of wavelength for the\n corresponding dust type (SMC or MW). The scattering phase\n function gives the angle at which the photon scatters.\n\n Parameters\n ----------\n x: float...
def load_raster_tile_lookup(iso3): '\n Load in the preprocessed raster tile lookup.\n\n Parameters\n ----------\n iso3 : string\n Country iso3 code.\n\n Returns\n -------\n lookup : dict\n A lookup table containing raster tile boundary coordinates\n as the keys, and the fil...
3,739,566,521,185,524,700
Load in the preprocessed raster tile lookup. Parameters ---------- iso3 : string Country iso3 code. Returns ------- lookup : dict A lookup table containing raster tile boundary coordinates as the keys, and the file paths as the values.
scripts/los.py
load_raster_tile_lookup
edwardoughton/e3nb
python
def load_raster_tile_lookup(iso3): '\n Load in the preprocessed raster tile lookup.\n\n Parameters\n ----------\n iso3 : string\n Country iso3 code.\n\n Returns\n -------\n lookup : dict\n A lookup table containing raster tile boundary coordinates\n as the keys, and the fil...
def generate_grid(iso3, side_length): '\n Generate a spatial grid for the chosen country.\n ' directory = os.path.join(DATA_INTERMEDIATE, iso3, 'grid') if (not os.path.exists(directory)): os.makedirs(directory) filename = 'grid_{}_{}_km.shp'.format(side_length, side_length) path_output...
-6,030,022,322,096,739,000
Generate a spatial grid for the chosen country.
scripts/los.py
generate_grid
edwardoughton/e3nb
python
def generate_grid(iso3, side_length): '\n \n ' directory = os.path.join(DATA_INTERMEDIATE, iso3, 'grid') if (not os.path.exists(directory)): os.makedirs(directory) filename = 'grid_{}_{}_km.shp'.format(side_length, side_length) path_output = os.path.join(directory, filename) if os....
def find_tile(polygon, tile_lookup): '\n\n Parameters\n ----------\n polygon : tuple\n The bounds of the modeling region.\n tile_lookup : dict\n A lookup table containing raster tile boundary coordinates\n as the keys, and the file paths as the values.\n\n Return\n ------\n ...
-5,881,771,837,956,214,000
Parameters ---------- polygon : tuple The bounds of the modeling region. tile_lookup : dict A lookup table containing raster tile boundary coordinates as the keys, and the file paths as the values. Return ------ output : list Contains the file path to the correct raster tile. Note: only the first e...
scripts/los.py
find_tile
edwardoughton/e3nb
python
def find_tile(polygon, tile_lookup): '\n\n Parameters\n ----------\n polygon : tuple\n The bounds of the modeling region.\n tile_lookup : dict\n A lookup table containing raster tile boundary coordinates\n as the keys, and the file paths as the values.\n\n Return\n ------\n ...
def add_id_range_data_to_grid(iso3, tile_lookup, side_length): '\n Query the Digital Elevation Model to get an estimated interdecile\n range for each grid square.\n\n ' directory = os.path.join(DATA_INTERMEDIATE, iso3, 'grid') filename = 'grid_final.shp' path_output = os.path.join(directory, fi...
8,463,154,447,399,699,000
Query the Digital Elevation Model to get an estimated interdecile range for each grid square.
scripts/los.py
add_id_range_data_to_grid
edwardoughton/e3nb
python
def add_id_range_data_to_grid(iso3, tile_lookup, side_length): '\n Query the Digital Elevation Model to get an estimated interdecile\n range for each grid square.\n\n ' directory = os.path.join(DATA_INTERMEDIATE, iso3, 'grid') filename = 'grid_final.shp' path_output = os.path.join(directory, fi...
def interdecile_range(x): '\n Get range between bottom 10% and top 10% of values.\n\n This is from the Longley-Rice Irregular Terrain Model.\n\n Code here: https://github.com/edwardoughton/itmlogic\n Paper here: https://joss.theoj.org/papers/10.21105/joss.02266.pdf\n\n Parameters\n ----------\n ...
-8,710,541,322,283,852,000
Get range between bottom 10% and top 10% of values. This is from the Longley-Rice Irregular Terrain Model. Code here: https://github.com/edwardoughton/itmlogic Paper here: https://joss.theoj.org/papers/10.21105/joss.02266.pdf Parameters ---------- x : list Terrain profile values. Returns ------- interdecile_ran...
scripts/los.py
interdecile_range
edwardoughton/e3nb
python
def interdecile_range(x): '\n Get range between bottom 10% and top 10% of values.\n\n This is from the Longley-Rice Irregular Terrain Model.\n\n Code here: https://github.com/edwardoughton/itmlogic\n Paper here: https://joss.theoj.org/papers/10.21105/joss.02266.pdf\n\n Parameters\n ----------\n ...
def viewshed(point, path_input, path_output, tile_name, max_distance, crs): '\n Perform a viewshed using GRASS.\n\n Parameters\n ---------\n point : tuple\n The point being queried.\n tile_lookup : dict\n A lookup table containing raster tile boundary coordinates\n as the keys, a...
-3,419,314,850,477,786,600
Perform a viewshed using GRASS. Parameters --------- point : tuple The point being queried. tile_lookup : dict A lookup table containing raster tile boundary coordinates as the keys, and the file paths as the values. path_output : string The directory path for the output folder. tile_name : string ...
scripts/los.py
viewshed
edwardoughton/e3nb
python
def viewshed(point, path_input, path_output, tile_name, max_distance, crs): '\n Perform a viewshed using GRASS.\n\n Parameters\n ---------\n point : tuple\n The point being queried.\n tile_lookup : dict\n A lookup table containing raster tile boundary coordinates\n as the keys, a...
def check_los(path_input, point): '\n Find potential LOS high points.\n\n Parameters\n ----------\n path_input : string\n File path for the digital elevation raster tile.\n point : tuple\n Coordinate point being queried.\n\n Returns\n -------\n los : string\n The Line of...
3,052,230,217,628,284,400
Find potential LOS high points. Parameters ---------- path_input : string File path for the digital elevation raster tile. point : tuple Coordinate point being queried. Returns ------- los : string The Line of Sight (los) of the path queried.
scripts/los.py
check_los
edwardoughton/e3nb
python
def check_los(path_input, point): '\n Find potential LOS high points.\n\n Parameters\n ----------\n path_input : string\n File path for the digital elevation raster tile.\n point : tuple\n Coordinate point being queried.\n\n Returns\n -------\n los : string\n The Line of...
def setUp(self): 'Called before each test.\n\n Performs setup.\n\n Args:\n self (TestJLock): the ``TestJLock`` instance\n\n Returns:\n ``None``\n ' assertRaisesRegexp = getattr(self, 'assertRaisesRegexp', None) self.assertRaisesRegexp = getattr(self, 'assertRais...
-659,573,350,972,982,100
Called before each test. Performs setup. Args: self (TestJLock): the ``TestJLock`` instance Returns: ``None``
tests/unit/test_jlock.py
setUp
Bhav97/pylink
python
def setUp(self): 'Called before each test.\n\n Performs setup.\n\n Args:\n self (TestJLock): the ``TestJLock`` instance\n\n Returns:\n ``None``\n ' assertRaisesRegexp = getattr(self, 'assertRaisesRegexp', None) self.assertRaisesRegexp = getattr(self, 'assertRais...
def tearDown(self): 'Called after each test.\n\n Performs teardown.\n\n Args:\n self (TestJLock): the ``TestJLock`` instance\n\n Returns:\n ``None``\n ' pass
-903,176,742,624,613,600
Called after each test. Performs teardown. Args: self (TestJLock): the ``TestJLock`` instance Returns: ``None``
tests/unit/test_jlock.py
tearDown
Bhav97/pylink
python
def tearDown(self): 'Called after each test.\n\n Performs teardown.\n\n Args:\n self (TestJLock): the ``TestJLock`` instance\n\n Returns:\n ``None``\n ' pass
@mock.patch('tempfile.tempdir', new='tmp') def test_jlock_init_and_delete(self): 'Tests initialization and deleting a ``JLock``.\n\n Args:\n self (TestJLock): the ``TestJLock`` instance\n\n Returns:\n ``None``\n ' serial_no = 3735928559 lock = jlock.JLock(serial_no) ...
4,304,005,466,927,635,500
Tests initialization and deleting a ``JLock``. Args: self (TestJLock): the ``TestJLock`` instance Returns: ``None``
tests/unit/test_jlock.py
test_jlock_init_and_delete
Bhav97/pylink
python
@mock.patch('tempfile.tempdir', new='tmp') def test_jlock_init_and_delete(self): 'Tests initialization and deleting a ``JLock``.\n\n Args:\n self (TestJLock): the ``TestJLock`` instance\n\n Returns:\n ``None``\n ' serial_no = 3735928559 lock = jlock.JLock(serial_no) ...
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.close') @mock.patch('os.path.exists') @mock.patch('os.open') @mock.patch('os.write') @mock.patch('os.remove') @mock.patch('pylink.jlock.psutil') @mock.patch('pylink.jlock.open') def test_jlock_acquire_exists(self, mock_open, mock_util, mock_rm, mock_wr, mock_op...
-2,859,460,508,332,200,000
Tests trying to acquire when the lock exists for an active process. Args: self (TestJLock): the ``TestJLock`` instance mock_open (Mock): mocked built-in open method mock_util (Mock): mocked ``psutil`` module mock_rm (Mock): mocked os remove method mock_wr (Mock): mocked os write method mock_op (Mock): mock...
tests/unit/test_jlock.py
test_jlock_acquire_exists
Bhav97/pylink
python
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.close') @mock.patch('os.path.exists') @mock.patch('os.open') @mock.patch('os.write') @mock.patch('os.remove') @mock.patch('pylink.jlock.psutil') @mock.patch('pylink.jlock.open') def test_jlock_acquire_exists(self, mock_open, mock_util, mock_rm, mock_wr, mock_op...
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.close') @mock.patch('os.path.exists') @mock.patch('os.open') @mock.patch('os.write') @mock.patch('os.remove') @mock.patch('pylink.jlock.psutil') @mock.patch('pylink.jlock.open') def test_jlock_acquire_os_error(self, mock_open, mock_util, mock_rm, mock_wr, mock_...
8,056,188,146,607,140,000
Tests trying to acquire the lock but generating an os-level error. Args: self (TestJLock): the ``TestJLock`` instance mock_open (Mock): mocked built-in open method mock_util (Mock): mocked ``psutil`` module mock_rm (Mock): mocked os remove method mock_wr (Mock): mocked os write method mock_op (Mock): mocke...
tests/unit/test_jlock.py
test_jlock_acquire_os_error
Bhav97/pylink
python
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.close') @mock.patch('os.path.exists') @mock.patch('os.open') @mock.patch('os.write') @mock.patch('os.remove') @mock.patch('pylink.jlock.psutil') @mock.patch('pylink.jlock.open') def test_jlock_acquire_os_error(self, mock_open, mock_util, mock_rm, mock_wr, mock_...
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.close') @mock.patch('os.path.exists') @mock.patch('os.open') @mock.patch('os.write') @mock.patch('os.remove') @mock.patch('pylink.jlock.psutil') @mock.patch('pylink.jlock.open') def test_jlock_acquire_bad_file(self, mock_open, mock_util, mock_rm, mock_wr, mock_...
-4,963,035,849,834,785,000
Tests acquiring the lockfile when the current lockfile is invallid. Args: self (TestJLock): the ``TestJLock`` instance mock_open (Mock): mocked built-in open method mock_util (Mock): mocked ``psutil`` module mock_rm (Mock): mocked os remove method mock_wr (Mock): mocked os write method mock_op (Mock): mock...
tests/unit/test_jlock.py
test_jlock_acquire_bad_file
Bhav97/pylink
python
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.close') @mock.patch('os.path.exists') @mock.patch('os.open') @mock.patch('os.write') @mock.patch('os.remove') @mock.patch('pylink.jlock.psutil') @mock.patch('pylink.jlock.open') def test_jlock_acquire_bad_file(self, mock_open, mock_util, mock_rm, mock_wr, mock_...
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.close') @mock.patch('os.path.exists') @mock.patch('os.open') @mock.patch('os.write') @mock.patch('os.remove') @mock.patch('pylink.jlock.psutil') @mock.patch('pylink.jlock.open') def test_jlock_acquire_invalid_pid(self, mock_open, mock_util, mock_rm, mock_wr, mo...
3,479,992,910,060,522,500
Tests acquiring the lockfile when the pid in the lockfile is invalid. Args: self (TestJLock): the ``TestJLock`` instance mock_open (Mock): mocked built-in open method mock_util (Mock): mocked ``psutil`` module mock_rm (Mock): mocked os remove method mock_wr (Mock): mocked os write method mock_op (Mock): mo...
tests/unit/test_jlock.py
test_jlock_acquire_invalid_pid
Bhav97/pylink
python
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.close') @mock.patch('os.path.exists') @mock.patch('os.open') @mock.patch('os.write') @mock.patch('os.remove') @mock.patch('pylink.jlock.psutil') @mock.patch('pylink.jlock.open') def test_jlock_acquire_invalid_pid(self, mock_open, mock_util, mock_rm, mock_wr, mo...
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.close') @mock.patch('os.path.exists') @mock.patch('os.open') @mock.patch('os.write') @mock.patch('os.remove') @mock.patch('pylink.jlock.psutil') @mock.patch('pylink.jlock.open') def test_jlock_acquire_old_pid(self, mock_open, mock_util, mock_rm, mock_wr, mock_o...
5,418,935,793,553,427,000
Tests acquiring when the PID in the lockfile does not exist. Args: self (TestJLock): the ``TestJLock`` instance mock_open (Mock): mocked built-in open method mock_util (Mock): mocked ``psutil`` module mock_rm (Mock): mocked os remove method mock_wr (Mock): mocked os write method mock_op (Mock): mocked os o...
tests/unit/test_jlock.py
test_jlock_acquire_old_pid
Bhav97/pylink
python
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.close') @mock.patch('os.path.exists') @mock.patch('os.open') @mock.patch('os.write') @mock.patch('os.remove') @mock.patch('pylink.jlock.psutil') @mock.patch('pylink.jlock.open') def test_jlock_acquire_old_pid(self, mock_open, mock_util, mock_rm, mock_wr, mock_o...
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.path.exists') @mock.patch('os.close') @mock.patch('os.remove') def test_jlock_release_acquired(self, mock_remove, mock_close, mock_exists): 'Tests releasing a held lock.\n\n Args:\n self (TestJLock): the ``TestJLock`` instance\n moc...
-1,303,112,917,660,697,900
Tests releasing a held lock. Args: self (TestJLock): the ``TestJLock`` instance mock_remove (Mock): mock file removal method mock_close (Mock): mocked close method mock_exists (Mock): mocked path exist method Returns: ``None``
tests/unit/test_jlock.py
test_jlock_release_acquired
Bhav97/pylink
python
@mock.patch('tempfile.tempdir', new='tmp') @mock.patch('os.path.exists') @mock.patch('os.close') @mock.patch('os.remove') def test_jlock_release_acquired(self, mock_remove, mock_close, mock_exists): 'Tests releasing a held lock.\n\n Args:\n self (TestJLock): the ``TestJLock`` instance\n moc...
@mock.patch('tempfile.tempdir', new='tmp') def test_jlock_release_not_held(self): 'Tests calling release when lock not held.\n\n Args:\n self (TestJLock): the ``TestJLock`` instance\n\n Returns:\n ``None``\n ' lock = jlock.JLock(3735928559) self.assertFalse(lock.releas...
-6,036,109,378,423,207,000
Tests calling release when lock not held. Args: self (TestJLock): the ``TestJLock`` instance Returns: ``None``
tests/unit/test_jlock.py
test_jlock_release_not_held
Bhav97/pylink
python
@mock.patch('tempfile.tempdir', new='tmp') def test_jlock_release_not_held(self): 'Tests calling release when lock not held.\n\n Args:\n self (TestJLock): the ``TestJLock`` instance\n\n Returns:\n ``None``\n ' lock = jlock.JLock(3735928559) self.assertFalse(lock.releas...
def calculate_mypypath() -> List[str]: 'Return MYPYPATH so that stubs have precedence over local sources.' typeshed_root = None count = 0 started = time.time() for parent in itertools.chain(Path(__file__).parents, Path(mypy.api.__file__).parents, Path(os.__file__).parents): count += 1 ...
-3,410,128,251,006,485,000
Return MYPYPATH so that stubs have precedence over local sources.
flake8_mypy.py
calculate_mypypath
ambv/flake8-mypy
python
def calculate_mypypath() -> List[str]: typeshed_root = None count = 0 started = time.time() for parent in itertools.chain(Path(__file__).parents, Path(mypy.api.__file__).parents, Path(os.__file__).parents): count += 1 candidate = (((parent / 'lib') / 'mypy') / 'typeshed') if...
@classmethod def adapt_error(cls, e: Any) -> _Flake8Error: 'Adapts the extended error namedtuple to be compatible with Flake8.' return e._replace(message=e.message.format(*e.vars))[:4]
8,806,283,538,528,994,000
Adapts the extended error namedtuple to be compatible with Flake8.
flake8_mypy.py
adapt_error
ambv/flake8-mypy
python
@classmethod def adapt_error(cls, e: Any) -> _Flake8Error: return e._replace(message=e.message.format(*e.vars))[:4]
def omit_error(self, e: Error) -> bool: 'Returns True if error should be ignored.' if (e.vars and (e.vars[0] == 'No parent module -- cannot perform relative import')): return True return bool(noqa(self.lines[(e.lineno - 1)]))
50,287,199,794,713,950
Returns True if error should be ignored.
flake8_mypy.py
omit_error
ambv/flake8-mypy
python
def omit_error(self, e: Error) -> bool: if (e.vars and (e.vars[0] == 'No parent module -- cannot perform relative import')): return True return bool(noqa(self.lines[(e.lineno - 1)]))
def generic_visit(self, node: ast.AST) -> None: 'Called if no explicit visitor function exists for a node.' for (_field, value) in ast.iter_fields(node): if self.should_type_check: break if isinstance(value, list): for item in value: if self.should_type_ch...
8,189,229,941,107,114,000
Called if no explicit visitor function exists for a node.
flake8_mypy.py
generic_visit
ambv/flake8-mypy
python
def generic_visit(self, node: ast.AST) -> None: for (_field, value) in ast.iter_fields(node): if self.should_type_check: break if isinstance(value, list): for item in value: if self.should_type_check: break if isinstanc...
def send_lineage(self, operator=None, inlets=None, outlets=None, context=None): '\n Sends lineage metadata to a backend\n :param operator: the operator executing a transformation on the inlets and outlets\n :param inlets: the inlets to this operator\n :param outlets: the outlets from thi...
-4,835,420,171,956,280,000
Sends lineage metadata to a backend :param operator: the operator executing a transformation on the inlets and outlets :param inlets: the inlets to this operator :param outlets: the outlets from this operator :param context: the current context of the task instance
airflow/lineage/backend/__init__.py
send_lineage
1010data/incubator-airflow
python
def send_lineage(self, operator=None, inlets=None, outlets=None, context=None): '\n Sends lineage metadata to a backend\n :param operator: the operator executing a transformation on the inlets and outlets\n :param inlets: the inlets to this operator\n :param outlets: the outlets from thi...
def distance_p2p(points_src, normals_src, points_tgt, normals_tgt): ' Computes minimal distances of each point in points_src to points_tgt.\n\n Args:\n points_src (numpy array): source points\n normals_src (numpy array): source normals\n points_tgt (numpy array): target points\n norma...
6,655,076,472,768,128,000
Computes minimal distances of each point in points_src to points_tgt. Args: points_src (numpy array): source points normals_src (numpy array): source normals points_tgt (numpy array): target points normals_tgt (numpy array): target normals
src/eval.py
distance_p2p
hummat/convolutional_occupancy_networks
python
def distance_p2p(points_src, normals_src, points_tgt, normals_tgt): ' Computes minimal distances of each point in points_src to points_tgt.\n\n Args:\n points_src (numpy array): source points\n normals_src (numpy array): source normals\n points_tgt (numpy array): target points\n norma...
def distance_p2m(points, mesh): ' Compute minimal distances of each point in points to mesh.\n\n Args:\n points (numpy array): points array\n mesh (trimesh): mesh\n\n ' (_, dist, _) = trimesh.proximity.closest_point(mesh, points) return dist
5,079,051,146,742,759,000
Compute minimal distances of each point in points to mesh. Args: points (numpy array): points array mesh (trimesh): mesh
src/eval.py
distance_p2m
hummat/convolutional_occupancy_networks
python
def distance_p2m(points, mesh): ' Compute minimal distances of each point in points to mesh.\n\n Args:\n points (numpy array): points array\n mesh (trimesh): mesh\n\n ' (_, dist, _) = trimesh.proximity.closest_point(mesh, points) return dist
def get_threshold_percentage(dist, thresholds): ' Evaluates a point cloud.\n\n Args:\n dist (numpy array): calculated distance\n thresholds (numpy array): threshold values for the F-score calculation\n ' in_threshold = [(dist <= t).mean() for t in thresholds] return in_threshold
-5,807,954,387,139,640,000
Evaluates a point cloud. Args: dist (numpy array): calculated distance thresholds (numpy array): threshold values for the F-score calculation
src/eval.py
get_threshold_percentage
hummat/convolutional_occupancy_networks
python
def get_threshold_percentage(dist, thresholds): ' Evaluates a point cloud.\n\n Args:\n dist (numpy array): calculated distance\n thresholds (numpy array): threshold values for the F-score calculation\n ' in_threshold = [(dist <= t).mean() for t in thresholds] return in_threshold
def eval_mesh(self, mesh, pointcloud_tgt, normals_tgt, points_iou, occ_tgt, remove_wall=False): ' Evaluates a mesh.\n\n Args:\n mesh (trimesh): mesh which should be evaluated\n pointcloud_tgt (numpy array): target point cloud\n normals_tgt (numpy array): target normals\n ...
6,281,606,503,414,471,000
Evaluates a mesh. Args: mesh (trimesh): mesh which should be evaluated pointcloud_tgt (numpy array): target point cloud normals_tgt (numpy array): target normals points_iou (numpy_array): points tensor for IoU evaluation occ_tgt (numpy_array): GT occupancy values for IoU points
src/eval.py
eval_mesh
hummat/convolutional_occupancy_networks
python
def eval_mesh(self, mesh, pointcloud_tgt, normals_tgt, points_iou, occ_tgt, remove_wall=False): ' Evaluates a mesh.\n\n Args:\n mesh (trimesh): mesh which should be evaluated\n pointcloud_tgt (numpy array): target point cloud\n normals_tgt (numpy array): target normals\n ...
@staticmethod def eval_pointcloud(pointcloud, pointcloud_tgt, normals=None, normals_tgt=None, thresholds=np.linspace((1.0 / 1000), 1, 1000)): ' Evaluates a point cloud.\n\n Args:\n pointcloud (numpy array): predicted point cloud\n pointcloud_tgt (numpy array): target point cloud\n ...
1,854,094,332,186,122,500
Evaluates a point cloud. Args: pointcloud (numpy array): predicted point cloud pointcloud_tgt (numpy array): target point cloud normals (numpy array): predicted normals normals_tgt (numpy array): target normals thresholds (numpy array): threshold values for the F-score calculation
src/eval.py
eval_pointcloud
hummat/convolutional_occupancy_networks
python
@staticmethod def eval_pointcloud(pointcloud, pointcloud_tgt, normals=None, normals_tgt=None, thresholds=np.linspace((1.0 / 1000), 1, 1000)): ' Evaluates a point cloud.\n\n Args:\n pointcloud (numpy array): predicted point cloud\n pointcloud_tgt (numpy array): target point cloud\n ...
def test_assert_json(self): 'Expecting json response but content type is not valid.' self.headers.append(('content-type', 'text/html; charset=UTF-8')) self.client.get('auth/token') self.assertRaises(AssertionError, (lambda : self.client.json))
-6,025,931,481,044,628,000
Expecting json response but content type is not valid.
src/wheezy/core/tests/test_httpclient.py
test_assert_json
akornatskyy/wheezy.core
python
def test_assert_json(self): self.headers.append(('content-type', 'text/html; charset=UTF-8')) self.client.get('auth/token') self.assertRaises(AssertionError, (lambda : self.client.json))
def test_json(self): 'json response.' patcher = patch.object(httpclient, 'json_loads') mock_json_loads = patcher.start() mock_json_loads.return_value = {} self.headers.append(('content-type', 'application/json; charset=UTF-8')) self.mock_response.read.return_value = '{}'.encode('utf-8') self...
-6,126,482,337,211,894,000
json response.
src/wheezy/core/tests/test_httpclient.py
test_json
akornatskyy/wheezy.core
python
def test_json(self): patcher = patch.object(httpclient, 'json_loads') mock_json_loads = patcher.start() mock_json_loads.return_value = {} self.headers.append(('content-type', 'application/json; charset=UTF-8')) self.mock_response.read.return_value = '{}'.encode('utf-8') self.client.get('aut...
def test_gzip(self): 'Ensure gzip decompression.' self.headers.append(('content-encoding', 'gzip')) self.mock_response.read.return_value = compress('test'.encode('utf-8')) self.client.get('auth/token') assert ('test' == self.client.content)
-4,188,835,249,121,999,000
Ensure gzip decompression.
src/wheezy/core/tests/test_httpclient.py
test_gzip
akornatskyy/wheezy.core
python
def test_gzip(self): self.headers.append(('content-encoding', 'gzip')) self.mock_response.read.return_value = compress('test'.encode('utf-8')) self.client.get('auth/token') assert ('test' == self.client.content)
def test_etag(self): 'ETag processing.' self.headers.append(('etag', '"ca231fbc"')) self.client.get('auth/token') (method, path, body, headers) = self.mock_c.request.call_args[0] assert ('If-None-Match' not in headers) assert ('"ca231fbc"' == self.client.etags['/api/v1/auth/token']) self.cli...
1,679,836,737,837,823,700
ETag processing.
src/wheezy/core/tests/test_httpclient.py
test_etag
akornatskyy/wheezy.core
python
def test_etag(self): self.headers.append(('etag', '"ca231fbc"')) self.client.get('auth/token') (method, path, body, headers) = self.mock_c.request.call_args[0] assert ('If-None-Match' not in headers) assert ('"ca231fbc"' == self.client.etags['/api/v1/auth/token']) self.client.get('auth/toke...
@classmethod def is_usable(cls): '\n Check whether this class is available for use.\n\n :return: Boolean determination of whether this implementation is usable.\n :rtype: bool\n\n ' return True
-7,418,314,823,100,840,000
Check whether this class is available for use. :return: Boolean determination of whether this implementation is usable. :rtype: bool
python/smqtk/representation/descriptor_index/memory.py
is_usable
cdeepakroy/SMQTK
python
@classmethod def is_usable(cls): '\n Check whether this class is available for use.\n\n :return: Boolean determination of whether this implementation is usable.\n :rtype: bool\n\n ' return True
@classmethod def get_default_config(cls): "\n Generate and return a default configuration dictionary for this class.\n This will be primarily used for generating what the configuration\n dictionary would look like for this class without instantiating it.\n\n By default, we observe what t...
-460,871,247,947,447,100
Generate and return a default configuration dictionary for this class. This will be primarily used for generating what the configuration dictionary would look like for this class without instantiating it. By default, we observe what this class's constructor takes as arguments, turning those argument names into configu...
python/smqtk/representation/descriptor_index/memory.py
get_default_config
cdeepakroy/SMQTK
python
@classmethod def get_default_config(cls): "\n Generate and return a default configuration dictionary for this class.\n This will be primarily used for generating what the configuration\n dictionary would look like for this class without instantiating it.\n\n By default, we observe what t...
@classmethod def from_config(cls, config_dict, merge_default=True): '\n Instantiate a new instance of this class given the configuration\n JSON-compliant dictionary encapsulating initialization arguments.\n\n :param config_dict: JSON compliant dictionary encapsulating\n a configurati...
8,910,833,205,713,397,000
Instantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments. :param config_dict: JSON compliant dictionary encapsulating a configuration. :type config_dict: dict :param merge_default: Merge the given configuration on top of the default prov...
python/smqtk/representation/descriptor_index/memory.py
from_config
cdeepakroy/SMQTK
python
@classmethod def from_config(cls, config_dict, merge_default=True): '\n Instantiate a new instance of this class given the configuration\n JSON-compliant dictionary encapsulating initialization arguments.\n\n :param config_dict: JSON compliant dictionary encapsulating\n a configurati...
def __init__(self, cache_element=None, pickle_protocol=(- 1)): '\n Initialize a new in-memory descriptor index, or reload one from a\n cache.\n\n :param cache_element: Optional data element cache, loading an existing\n index if the element has bytes. If the given element is writable,...
9,142,104,922,851,511,000
Initialize a new in-memory descriptor index, or reload one from a cache. :param cache_element: Optional data element cache, loading an existing index if the element has bytes. If the given element is writable, new descriptors added to this index are cached to the element. :type cache_element: None | smqtk.rep...
python/smqtk/representation/descriptor_index/memory.py
__init__
cdeepakroy/SMQTK
python
def __init__(self, cache_element=None, pickle_protocol=(- 1)): '\n Initialize a new in-memory descriptor index, or reload one from a\n cache.\n\n :param cache_element: Optional data element cache, loading an existing\n index if the element has bytes. If the given element is writable,...
def clear(self): "\n Clear this descriptor index's entries.\n " self._table = {} self.cache_table()
8,491,712,948,916,743,000
Clear this descriptor index's entries.
python/smqtk/representation/descriptor_index/memory.py
clear
cdeepakroy/SMQTK
python
def clear(self): "\n \n " self._table = {} self.cache_table()
def has_descriptor(self, uuid): '\n Check if a DescriptorElement with the given UUID exists in this index.\n\n :param uuid: UUID to query for\n :type uuid: collections.Hashable\n\n :return: True if a DescriptorElement with the given UUID exists in this\n index, or False if not...
-5,014,531,050,288,331,000
Check if a DescriptorElement with the given UUID exists in this index. :param uuid: UUID to query for :type uuid: collections.Hashable :return: True if a DescriptorElement with the given UUID exists in this index, or False if not. :rtype: bool
python/smqtk/representation/descriptor_index/memory.py
has_descriptor
cdeepakroy/SMQTK
python
def has_descriptor(self, uuid): '\n Check if a DescriptorElement with the given UUID exists in this index.\n\n :param uuid: UUID to query for\n :type uuid: collections.Hashable\n\n :return: True if a DescriptorElement with the given UUID exists in this\n index, or False if not...
def add_descriptor(self, descriptor, no_cache=False): '\n Add a descriptor to this index.\n\n Adding the same descriptor multiple times should not add multiple\n copies of the descriptor in the index.\n\n :param descriptor: Descriptor to index.\n :type descriptor: smqtk.representa...
2,048,474,242,797,334,000
Add a descriptor to this index. Adding the same descriptor multiple times should not add multiple copies of the descriptor in the index. :param descriptor: Descriptor to index. :type descriptor: smqtk.representation.DescriptorElement :param no_cache: Do not cache the internal table if a file cache was provided. ...
python/smqtk/representation/descriptor_index/memory.py
add_descriptor
cdeepakroy/SMQTK
python
def add_descriptor(self, descriptor, no_cache=False): '\n Add a descriptor to this index.\n\n Adding the same descriptor multiple times should not add multiple\n copies of the descriptor in the index.\n\n :param descriptor: Descriptor to index.\n :type descriptor: smqtk.representa...
def add_many_descriptors(self, descriptors): '\n Add multiple descriptors at one time.\n\n :param descriptors: Iterable of descriptor instances to add to this\n index.\n :type descriptors:\n collections.Iterable[smqtk.representation.DescriptorElement]\n\n ' adde...
6,443,921,287,025,161,000
Add multiple descriptors at one time. :param descriptors: Iterable of descriptor instances to add to this index. :type descriptors: collections.Iterable[smqtk.representation.DescriptorElement]
python/smqtk/representation/descriptor_index/memory.py
add_many_descriptors
cdeepakroy/SMQTK
python
def add_many_descriptors(self, descriptors): '\n Add multiple descriptors at one time.\n\n :param descriptors: Iterable of descriptor instances to add to this\n index.\n :type descriptors:\n collections.Iterable[smqtk.representation.DescriptorElement]\n\n ' adde...
def get_descriptor(self, uuid): "\n Get the descriptor in this index that is associated with the given UUID.\n\n :param uuid: UUID of the DescriptorElement to get.\n :type uuid: collections.Hashable\n\n :raises KeyError: The given UUID doesn't associate to a\n DescriptorElemen...
1,490,188,453,307,830,000
Get the descriptor in this index that is associated with the given UUID. :param uuid: UUID of the DescriptorElement to get. :type uuid: collections.Hashable :raises KeyError: The given UUID doesn't associate to a DescriptorElement in this index. :return: DescriptorElement associated with the queried UUID. :rtype...
python/smqtk/representation/descriptor_index/memory.py
get_descriptor
cdeepakroy/SMQTK
python
def get_descriptor(self, uuid): "\n Get the descriptor in this index that is associated with the given UUID.\n\n :param uuid: UUID of the DescriptorElement to get.\n :type uuid: collections.Hashable\n\n :raises KeyError: The given UUID doesn't associate to a\n DescriptorElemen...
def get_many_descriptors(self, uuids): "\n Get an iterator over descriptors associated to given descriptor UUIDs.\n\n :param uuids: Iterable of descriptor UUIDs to query for.\n :type uuids: collections.Iterable[collections.Hashable]\n\n :raises KeyError: A given UUID doesn't associate wi...
-8,884,322,907,515,492,000
Get an iterator over descriptors associated to given descriptor UUIDs. :param uuids: Iterable of descriptor UUIDs to query for. :type uuids: collections.Iterable[collections.Hashable] :raises KeyError: A given UUID doesn't associate with a DescriptorElement in this index. :return: Iterator of descriptors associa...
python/smqtk/representation/descriptor_index/memory.py
get_many_descriptors
cdeepakroy/SMQTK
python
def get_many_descriptors(self, uuids): "\n Get an iterator over descriptors associated to given descriptor UUIDs.\n\n :param uuids: Iterable of descriptor UUIDs to query for.\n :type uuids: collections.Iterable[collections.Hashable]\n\n :raises KeyError: A given UUID doesn't associate wi...
def remove_descriptor(self, uuid, no_cache=False): "\n Remove a descriptor from this index by the given UUID.\n\n :param uuid: UUID of the DescriptorElement to remove.\n :type uuid: collections.Hashable\n\n :raises KeyError: The given UUID doesn't associate to a\n DescriptorEl...
1,289,530,611,836,269,300
Remove a descriptor from this index by the given UUID. :param uuid: UUID of the DescriptorElement to remove. :type uuid: collections.Hashable :raises KeyError: The given UUID doesn't associate to a DescriptorElement in this index. :param no_cache: Do not cache the internal table if a file cache was provided....
python/smqtk/representation/descriptor_index/memory.py
remove_descriptor
cdeepakroy/SMQTK
python
def remove_descriptor(self, uuid, no_cache=False): "\n Remove a descriptor from this index by the given UUID.\n\n :param uuid: UUID of the DescriptorElement to remove.\n :type uuid: collections.Hashable\n\n :raises KeyError: The given UUID doesn't associate to a\n DescriptorEl...
def remove_many_descriptors(self, uuids): "\n Remove descriptors associated to given descriptor UUIDs from this\n index.\n\n :param uuids: Iterable of descriptor UUIDs to remove.\n :type uuids: collections.Iterable[collections.Hashable]\n\n :raises KeyError: A given UUID doesn't a...
-6,591,105,128,639,121,000
Remove descriptors associated to given descriptor UUIDs from this index. :param uuids: Iterable of descriptor UUIDs to remove. :type uuids: collections.Iterable[collections.Hashable] :raises KeyError: A given UUID doesn't associate with a DescriptorElement in this index.
python/smqtk/representation/descriptor_index/memory.py
remove_many_descriptors
cdeepakroy/SMQTK
python
def remove_many_descriptors(self, uuids): "\n Remove descriptors associated to given descriptor UUIDs from this\n index.\n\n :param uuids: Iterable of descriptor UUIDs to remove.\n :type uuids: collections.Iterable[collections.Hashable]\n\n :raises KeyError: A given UUID doesn't a...
def instructions(type_library: PushTypeLibrary): 'Return all core text instructions.' i = [] for push_type in ['str', 'char']: i.append(SimpleInstruction('{t}_concat'.format(t=push_type), _concat, input_stacks=[push_type, push_type], output_stacks=['str'], code_blocks=0, docstring='Concatenates the ...
4,267,998,663,476,276,700
Return all core text instructions.
pyshgp/push/instructions/text.py
instructions
RedBeansAndRice/pyshgp
python
def instructions(type_library: PushTypeLibrary): i = [] for push_type in ['str', 'char']: i.append(SimpleInstruction('{t}_concat'.format(t=push_type), _concat, input_stacks=[push_type, push_type], output_stacks=['str'], code_blocks=0, docstring='Concatenates the top two {t}s and pushes the resultin...
@pytest.fixture(params=['proxy', 'layered', 'memory', 'file', 'serialised']) def cache(request): 'Return cache.' if (request.param == 'proxy'): cache = ftrack_api.cache.ProxyCache(ftrack_api.cache.MemoryCache()) elif (request.param == 'layered'): cache = ftrack_api.cache.LayeredCache([ftrack...
5,505,313,335,095,566,000
Return cache.
openpype/modules/ftrack/python2_vendor/ftrack-python-api/test/unit/test_cache.py
cache
Mikfr83/OpenPype
python
@pytest.fixture(params=['proxy', 'layered', 'memory', 'file', 'serialised']) def cache(request): if (request.param == 'proxy'): cache = ftrack_api.cache.ProxyCache(ftrack_api.cache.MemoryCache()) elif (request.param == 'layered'): cache = ftrack_api.cache.LayeredCache([ftrack_api.cache.Memo...
def function(mutable, x, y=2): 'Function for testing.' mutable['called'] = True return {'result': (x + y)}
7,300,508,250,387,626,000
Function for testing.
openpype/modules/ftrack/python2_vendor/ftrack-python-api/test/unit/test_cache.py
function
Mikfr83/OpenPype
python
def function(mutable, x, y=2): mutable['called'] = True return {'result': (x + y)}
def assert_memoised_call(memoiser, function, expected, args=None, kw=None, memoised=True): 'Assert *function* call via *memoiser* was *memoised*.' mapping = {'called': False} if (args is not None): args = ((mapping,) + args) else: args = (mapping,) result = memoiser.call(function, ar...
-5,157,968,186,569,180,000
Assert *function* call via *memoiser* was *memoised*.
openpype/modules/ftrack/python2_vendor/ftrack-python-api/test/unit/test_cache.py
assert_memoised_call
Mikfr83/OpenPype
python
def assert_memoised_call(memoiser, function, expected, args=None, kw=None, memoised=True): mapping = {'called': False} if (args is not None): args = ((mapping,) + args) else: args = (mapping,) result = memoiser.call(function, args, kw) assert (result == expected) assert (map...
def test_get(cache): 'Retrieve item from cache.' cache.set('key', 'value') assert (cache.get('key') == 'value')
-4,670,795,253,040,756,000
Retrieve item from cache.
openpype/modules/ftrack/python2_vendor/ftrack-python-api/test/unit/test_cache.py
test_get
Mikfr83/OpenPype
python
def test_get(cache): cache.set('key', 'value') assert (cache.get('key') == 'value')
def test_get_missing_key(cache): 'Fail to retrieve missing item from cache.' with pytest.raises(KeyError): cache.get('key')
-7,415,425,646,362,388,000
Fail to retrieve missing item from cache.
openpype/modules/ftrack/python2_vendor/ftrack-python-api/test/unit/test_cache.py
test_get_missing_key
Mikfr83/OpenPype
python
def test_get_missing_key(cache): with pytest.raises(KeyError): cache.get('key')
def test_set(cache): 'Set item in cache.' with pytest.raises(KeyError): cache.get('key') cache.set('key', 'value') assert (cache.get('key') == 'value')
5,439,127,552,633,369,000
Set item in cache.
openpype/modules/ftrack/python2_vendor/ftrack-python-api/test/unit/test_cache.py
test_set
Mikfr83/OpenPype
python
def test_set(cache): with pytest.raises(KeyError): cache.get('key') cache.set('key', 'value') assert (cache.get('key') == 'value')