body_hash stringlengths 64 64 | body stringlengths 23 109k | docstring stringlengths 1 57k | path stringlengths 4 198 | name stringlengths 1 115 | repository_name stringlengths 7 111 | repository_stars float64 0 191k | lang stringclasses 1
value | body_without_docstring stringlengths 14 108k | unified stringlengths 45 133k |
|---|---|---|---|---|---|---|---|---|---|
2acb15398f8b1bd3305034733a67f059d741c841d9050ac68087fbe7720dcde9 | def get_dataset_labels(self, dataset_obj):
u'\n Use creator-*, admin-* labels for proposed datasets\n '
if dataset_obj.notes.startswith(u'Proposed:'):
labels = [(u'creator-%s' % dataset_obj.creator_user_id)]
if dataset_obj.owner_org:
return (labels + [(u'admin-%s' % dat... | Use creator-*, admin-* labels for proposed datasets | ckanext/example_ipermissionlabels/plugin.py | get_dataset_labels | larrycameron80/ckan | 2,805 | python | def get_dataset_labels(self, dataset_obj):
u'\n \n '
if dataset_obj.notes.startswith(u'Proposed:'):
labels = [(u'creator-%s' % dataset_obj.creator_user_id)]
if dataset_obj.owner_org:
return (labels + [(u'admin-%s' % dataset_obj.owner_org)])
return labels
ret... | def get_dataset_labels(self, dataset_obj):
u'\n \n '
if dataset_obj.notes.startswith(u'Proposed:'):
labels = [(u'creator-%s' % dataset_obj.creator_user_id)]
if dataset_obj.owner_org:
return (labels + [(u'admin-%s' % dataset_obj.owner_org)])
return labels
ret... |
aa4801b10b7a333c99dbe711ba67663255ed7cd5c697d2a4aacf3c50c8750f60 | def get_user_dataset_labels(self, user_obj):
u'\n Include admin-* labels for users in addition to default labels\n creator-*, member-* and public\n '
labels = super(ExampleIPermissionLabelsPlugin, self).get_user_dataset_labels(user_obj)
if user_obj:
orgs = get_action(u'organizat... | Include admin-* labels for users in addition to default labels
creator-*, member-* and public | ckanext/example_ipermissionlabels/plugin.py | get_user_dataset_labels | larrycameron80/ckan | 2,805 | python | def get_user_dataset_labels(self, user_obj):
u'\n Include admin-* labels for users in addition to default labels\n creator-*, member-* and public\n '
labels = super(ExampleIPermissionLabelsPlugin, self).get_user_dataset_labels(user_obj)
if user_obj:
orgs = get_action(u'organizat... | def get_user_dataset_labels(self, user_obj):
u'\n Include admin-* labels for users in addition to default labels\n creator-*, member-* and public\n '
labels = super(ExampleIPermissionLabelsPlugin, self).get_user_dataset_labels(user_obj)
if user_obj:
orgs = get_action(u'organizat... |
8a8c107df9f01c4460765658bb45ae20aed4d1e20028860f51b1f292f7f54286 | def _test_array_like_same(self, like_func, array):
'\n Tests of *_array_like where shape, strides, dtype, and flags should\n all be equal.\n '
array_like = like_func(array)
self.assertEqual(array.shape, array_like.shape)
self.assertEqual(array.strides, array_like.strides)
self.a... | Tests of *_array_like where shape, strides, dtype, and flags should
all be equal. | numba/cuda/tests/cudapy/test_array.py | _test_array_like_same | castarco/numba | 6,620 | python | def _test_array_like_same(self, like_func, array):
'\n Tests of *_array_like where shape, strides, dtype, and flags should\n all be equal.\n '
array_like = like_func(array)
self.assertEqual(array.shape, array_like.shape)
self.assertEqual(array.strides, array_like.strides)
self.a... | def _test_array_like_same(self, like_func, array):
'\n Tests of *_array_like where shape, strides, dtype, and flags should\n all be equal.\n '
array_like = like_func(array)
self.assertEqual(array.shape, array_like.shape)
self.assertEqual(array.strides, array_like.strides)
self.a... |
6e47cb77af3de8e78b7f29ac5352064b8cddae935d042f2a1d92488c665a78a0 | def _test_array_like_view(self, like_func, view, d_view):
'\n Tests of device_array_like where the original array is a view - the\n strides should not be equal because a contiguous array is expected.\n '
nb_like = like_func(d_view)
self.assertEqual(d_view.shape, nb_like.shape)
self.... | Tests of device_array_like where the original array is a view - the
strides should not be equal because a contiguous array is expected. | numba/cuda/tests/cudapy/test_array.py | _test_array_like_view | castarco/numba | 6,620 | python | def _test_array_like_view(self, like_func, view, d_view):
'\n Tests of device_array_like where the original array is a view - the\n strides should not be equal because a contiguous array is expected.\n '
nb_like = like_func(d_view)
self.assertEqual(d_view.shape, nb_like.shape)
self.... | def _test_array_like_view(self, like_func, view, d_view):
'\n Tests of device_array_like where the original array is a view - the\n strides should not be equal because a contiguous array is expected.\n '
nb_like = like_func(d_view)
self.assertEqual(d_view.shape, nb_like.shape)
self.... |
3722d300d16e64ecf373aa2a84436c91f13b7abf10e368a973ed17a7944732bc | @staticmethod
def connectionDB(fileDB):
'\n Create a database connection to the SQLite database specified by fileDB\n\n :param fileDB: Database SQLite file\n :type fileDB: str\n :return: Connection object and cursor object or None\n '
try:
dbName = (fileDB + '.db')
... | Create a database connection to the SQLite database specified by fileDB
:param fileDB: Database SQLite file
:type fileDB: str
:return: Connection object and cursor object or None | src/final/Data.py | connectionDB | lrodrin/TFG | 2 | python | @staticmethod
def connectionDB(fileDB):
'\n Create a database connection to the SQLite database specified by fileDB\n\n :param fileDB: Database SQLite file\n :type fileDB: str\n :return: Connection object and cursor object or None\n '
try:
dbName = (fileDB + '.db')
... | @staticmethod
def connectionDB(fileDB):
'\n Create a database connection to the SQLite database specified by fileDB\n\n :param fileDB: Database SQLite file\n :type fileDB: str\n :return: Connection object and cursor object or None\n '
try:
dbName = (fileDB + '.db')
... |
261b6dc20015e9335bd8ecf8b739db98f35e5fb5a7ff94a5e7855bbf33f6a6eb | @staticmethod
def openFile(dataFile):
'\n Open data file specified by dataFile\n\n :param dataFile: Data file\n :type dataFile: str\n :return: File object or None\n :rtype: file\n '
try:
file = open(dataFile, 'r')
print(('File %s opened' % dataFile))
... | Open data file specified by dataFile
:param dataFile: Data file
:type dataFile: str
:return: File object or None
:rtype: file | src/final/Data.py | openFile | lrodrin/TFG | 2 | python | @staticmethod
def openFile(dataFile):
'\n Open data file specified by dataFile\n\n :param dataFile: Data file\n :type dataFile: str\n :return: File object or None\n :rtype: file\n '
try:
file = open(dataFile, 'r')
print(('File %s opened' % dataFile))
... | @staticmethod
def openFile(dataFile):
'\n Open data file specified by dataFile\n\n :param dataFile: Data file\n :type dataFile: str\n :return: File object or None\n :rtype: file\n '
try:
file = open(dataFile, 'r')
print(('File %s opened' % dataFile))
... |
5aae7f6b1d2c5da9e148158944225631143edd7c2724fdc5ddc0d8bdaa8c3028 | @staticmethod
def getDataFile(dataFile, fileType):
'\n Get data from data file specified by dataFile\n\n :param dataFile: Data file\n :param fileType: File type\n :type dataFile: file\n :type fileType: str\n :return: Column names and lines from dataFile\n '
colum... | Get data from data file specified by dataFile
:param dataFile: Data file
:param fileType: File type
:type dataFile: file
:type fileType: str
:return: Column names and lines from dataFile | src/final/Data.py | getDataFile | lrodrin/TFG | 2 | python | @staticmethod
def getDataFile(dataFile, fileType):
'\n Get data from data file specified by dataFile\n\n :param dataFile: Data file\n :param fileType: File type\n :type dataFile: file\n :type fileType: str\n :return: Column names and lines from dataFile\n '
colum... | @staticmethod
def getDataFile(dataFile, fileType):
'\n Get data from data file specified by dataFile\n\n :param dataFile: Data file\n :param fileType: File type\n :type dataFile: file\n :type fileType: str\n :return: Column names and lines from dataFile\n '
colum... |
2932c305549949e265a52ee82f975acc4fcd5abfdce1c335ea073167c6113b73 | @staticmethod
def createTable(cursor, tableName, columnNames):
'\n Create a table specified by tableName in a SQLite database\n\n :param cursor: Connection cursor\n :param tableName: Table name\n :param columnNames: Column names\n :type tableName: str\n :type columnNames: s... | Create a table specified by tableName in a SQLite database
:param cursor: Connection cursor
:param tableName: Table name
:param columnNames: Column names
:type tableName: str
:type columnNames: str | src/final/Data.py | createTable | lrodrin/TFG | 2 | python | @staticmethod
def createTable(cursor, tableName, columnNames):
'\n Create a table specified by tableName in a SQLite database\n\n :param cursor: Connection cursor\n :param tableName: Table name\n :param columnNames: Column names\n :type tableName: str\n :type columnNames: s... | @staticmethod
def createTable(cursor, tableName, columnNames):
'\n Create a table specified by tableName in a SQLite database\n\n :param cursor: Connection cursor\n :param tableName: Table name\n :param columnNames: Column names\n :type tableName: str\n :type columnNames: s... |
c4925c6932113f63bc0bbbb38ac5f2b5c89c00e91e9e5ff5d884523043e00da5 | @staticmethod
def insertDataTXT(tableName, columnNames, lines, cursor, connection):
'\n Insert values to a table specified by tableName in a SQLite database from a TXT file\n\n :param tableName: Table name\n :param columnNames: Column names\n :param lines: Lines from a data file\n ... | Insert values to a table specified by tableName in a SQLite database from a TXT file
:param tableName: Table name
:param columnNames: Column names
:param lines: Lines from a data file
:param cursor: Cursor object
:param connection: Connection object
:type tableName: str
:type columnNames: str | src/final/Data.py | insertDataTXT | lrodrin/TFG | 2 | python | @staticmethod
def insertDataTXT(tableName, columnNames, lines, cursor, connection):
'\n Insert values to a table specified by tableName in a SQLite database from a TXT file\n\n :param tableName: Table name\n :param columnNames: Column names\n :param lines: Lines from a data file\n ... | @staticmethod
def insertDataTXT(tableName, columnNames, lines, cursor, connection):
'\n Insert values to a table specified by tableName in a SQLite database from a TXT file\n\n :param tableName: Table name\n :param columnNames: Column names\n :param lines: Lines from a data file\n ... |
6fd31fa8a32ad178b5fc1f3e814e914efa91d8a8e7216b43bb5c5feade0f7137 | @staticmethod
def insertDataARFF(tableName, columnNames, lines, cursor, connection):
'\n Insert values to a table specified by tableName in SQLite database from an ARFF file\n\n :param tableName: Table name\n :param columnNames: Column names\n :param lines: Lines from a data file\n ... | Insert values to a table specified by tableName in SQLite database from an ARFF file
:param tableName: Table name
:param columnNames: Column names
:param lines: Lines from a data file
:param cursor: Cursor object
:param connection: Connection object
:type tableName: str
:type columnNames: str | src/final/Data.py | insertDataARFF | lrodrin/TFG | 2 | python | @staticmethod
def insertDataARFF(tableName, columnNames, lines, cursor, connection):
'\n Insert values to a table specified by tableName in SQLite database from an ARFF file\n\n :param tableName: Table name\n :param columnNames: Column names\n :param lines: Lines from a data file\n ... | @staticmethod
def insertDataARFF(tableName, columnNames, lines, cursor, connection):
'\n Insert values to a table specified by tableName in SQLite database from an ARFF file\n\n :param tableName: Table name\n :param columnNames: Column names\n :param lines: Lines from a data file\n ... |
1241e5b11bceb7f33139b8d1838c19b67353ae4cbe596086b1748b2cc69a2473 | @staticmethod
def selectData(tableName, cursor):
'\n Select all the rows from a table specified by tableName\n\n :param tableName: Table name\n :param cursor: Cursor object\n :type tableName: str\n :return: Column names and all rows from tableName or None\n '
try:
... | Select all the rows from a table specified by tableName
:param tableName: Table name
:param cursor: Cursor object
:type tableName: str
:return: Column names and all rows from tableName or None | src/final/Data.py | selectData | lrodrin/TFG | 2 | python | @staticmethod
def selectData(tableName, cursor):
'\n Select all the rows from a table specified by tableName\n\n :param tableName: Table name\n :param cursor: Cursor object\n :type tableName: str\n :return: Column names and all rows from tableName or None\n '
try:
... | @staticmethod
def selectData(tableName, cursor):
'\n Select all the rows from a table specified by tableName\n\n :param tableName: Table name\n :param cursor: Cursor object\n :type tableName: str\n :return: Column names and all rows from tableName or None\n '
try:
... |
1808583751df7de08512003f55c3bf8fcadfbea19cefa6664dd3f6cc2c60ac41 | @staticmethod
def getTableNamesDB(cursor):
'\n Return a list of all the table names from a SQLite database\n \n :param cursor: Cursor object\n :return: List of table names\n :rtype: list\n '
tablesNameList = list()
query = "SELECT name FROM sqlite_master WHERE type=... | Return a list of all the table names from a SQLite database
:param cursor: Cursor object
:return: List of table names
:rtype: list | src/final/Data.py | getTableNamesDB | lrodrin/TFG | 2 | python | @staticmethod
def getTableNamesDB(cursor):
'\n Return a list of all the table names from a SQLite database\n \n :param cursor: Cursor object\n :return: List of table names\n :rtype: list\n '
tablesNameList = list()
query = "SELECT name FROM sqlite_master WHERE type=... | @staticmethod
def getTableNamesDB(cursor):
'\n Return a list of all the table names from a SQLite database\n \n :param cursor: Cursor object\n :return: List of table names\n :rtype: list\n '
tablesNameList = list()
query = "SELECT name FROM sqlite_master WHERE type=... |
09fcfd6532d81f9e80f15568a62fb60863f895b933184aef94f4e60f22e9d52b | @staticmethod
def convertDataToSet(dataFile):
'\n Convert lines from data file specified by dataFile to sets\n\n :param dataFile: Data file\n :type dataFile: file\n :return: List of all the lines converted to sets\n :rtype: list\n '
subset = set()
moreFrequentSubset... | Convert lines from data file specified by dataFile to sets
:param dataFile: Data file
:type dataFile: file
:return: List of all the lines converted to sets
:rtype: list | src/final/Data.py | convertDataToSet | lrodrin/TFG | 2 | python | @staticmethod
def convertDataToSet(dataFile):
'\n Convert lines from data file specified by dataFile to sets\n\n :param dataFile: Data file\n :type dataFile: file\n :return: List of all the lines converted to sets\n :rtype: list\n '
subset = set()
moreFrequentSubset... | @staticmethod
def convertDataToSet(dataFile):
'\n Convert lines from data file specified by dataFile to sets\n\n :param dataFile: Data file\n :type dataFile: file\n :return: List of all the lines converted to sets\n :rtype: list\n '
subset = set()
moreFrequentSubset... |
c2aebeff4815415fb076a63a2e173877c66e19b8171169e481afd81d0ea8f655 | def test_fix_stim():
'Test fixing stim STI016 for Neuromag.'
raw = read_raw_fif(raw_fname, preload=True)
raw._data[(raw.ch_names.index('STI 014'), :3)] = [0, (- 32765), 0]
with pytest.warns(RuntimeWarning, match='STI016'):
events = find_events(raw, 'STI 014')
assert_array_equal(events[0], [(... | Test fixing stim STI016 for Neuromag. | mne/tests/test_event.py | test_fix_stim | hofaflo/mne-python | 1,953 | python | def test_fix_stim():
raw = read_raw_fif(raw_fname, preload=True)
raw._data[(raw.ch_names.index('STI 014'), :3)] = [0, (- 32765), 0]
with pytest.warns(RuntimeWarning, match='STI016'):
events = find_events(raw, 'STI 014')
assert_array_equal(events[0], [(raw.first_samp + 1), 0, 32765])
eve... | def test_fix_stim():
raw = read_raw_fif(raw_fname, preload=True)
raw._data[(raw.ch_names.index('STI 014'), :3)] = [0, (- 32765), 0]
with pytest.warns(RuntimeWarning, match='STI016'):
events = find_events(raw, 'STI 014')
assert_array_equal(events[0], [(raw.first_samp + 1), 0, 32765])
eve... |
581fad2ab8327776459c51c6b967f05d928dc073887d12ca63f7add30afb827f | def test_add_events():
'Test adding events to a Raw file.'
raw = read_raw_fif(raw_fname)
events = np.array([[raw.first_samp, 0, 1]])
pytest.raises(RuntimeError, raw.add_events, events, 'STI 014')
raw = read_raw_fif(raw_fname, preload=True)
orig_events = find_events(raw, 'STI 014')
events = n... | Test adding events to a Raw file. | mne/tests/test_event.py | test_add_events | hofaflo/mne-python | 1,953 | python | def test_add_events():
raw = read_raw_fif(raw_fname)
events = np.array([[raw.first_samp, 0, 1]])
pytest.raises(RuntimeError, raw.add_events, events, 'STI 014')
raw = read_raw_fif(raw_fname, preload=True)
orig_events = find_events(raw, 'STI 014')
events = np.array([raw.first_samp, 0, 1])
... | def test_add_events():
raw = read_raw_fif(raw_fname)
events = np.array([[raw.first_samp, 0, 1]])
pytest.raises(RuntimeError, raw.add_events, events, 'STI 014')
raw = read_raw_fif(raw_fname, preload=True)
orig_events = find_events(raw, 'STI 014')
events = np.array([raw.first_samp, 0, 1])
... |
b6d1a59ab183296154edd2d88d681cdbec9a6f2a896069e1c4dd2be002e5f189 | def test_merge_events():
'Test event merging.'
events_orig = [[1, 0, 1], [3, 0, 2], [10, 0, 3], [20, 0, 4]]
events_replacement = [[1, 0, 12], [3, 0, 12], [10, 0, 34], [20, 0, 34]]
events_no_replacement = [[1, 0, 1], [1, 0, 12], [1, 0, 1234], [3, 0, 2], [3, 0, 12], [3, 0, 1234], [10, 0, 3], [10, 0, 34], ... | Test event merging. | mne/tests/test_event.py | test_merge_events | hofaflo/mne-python | 1,953 | python | def test_merge_events():
events_orig = [[1, 0, 1], [3, 0, 2], [10, 0, 3], [20, 0, 4]]
events_replacement = [[1, 0, 12], [3, 0, 12], [10, 0, 34], [20, 0, 34]]
events_no_replacement = [[1, 0, 1], [1, 0, 12], [1, 0, 1234], [3, 0, 2], [3, 0, 12], [3, 0, 1234], [10, 0, 3], [10, 0, 34], [10, 0, 1234], [20, 0... | def test_merge_events():
events_orig = [[1, 0, 1], [3, 0, 2], [10, 0, 3], [20, 0, 4]]
events_replacement = [[1, 0, 12], [3, 0, 12], [10, 0, 34], [20, 0, 34]]
events_no_replacement = [[1, 0, 1], [1, 0, 12], [1, 0, 1234], [3, 0, 2], [3, 0, 12], [3, 0, 1234], [10, 0, 3], [10, 0, 34], [10, 0, 1234], [20, 0... |
a6db8d14edea04bea76c9ed89f9f1b0091ba7806402b1598b9386f1a0d3e3b0e | def test_io_events(tmpdir):
'Test IO for events.'
events = read_events(fname)
fname_temp = tmpdir.join('events-eve.fif')
write_events(fname_temp, events)
events2 = read_events(fname_temp)
assert_array_almost_equal(events, events2)
events2 = read_events(fname_gz)
assert_array_almost_equal... | Test IO for events. | mne/tests/test_event.py | test_io_events | hofaflo/mne-python | 1,953 | python | def test_io_events(tmpdir):
events = read_events(fname)
fname_temp = tmpdir.join('events-eve.fif')
write_events(fname_temp, events)
events2 = read_events(fname_temp)
assert_array_almost_equal(events, events2)
events2 = read_events(fname_gz)
assert_array_almost_equal(events, events2)
... | def test_io_events(tmpdir):
events = read_events(fname)
fname_temp = tmpdir.join('events-eve.fif')
write_events(fname_temp, events)
events2 = read_events(fname_temp)
assert_array_almost_equal(events, events2)
events2 = read_events(fname_gz)
assert_array_almost_equal(events, events2)
... |
c80f6e5efca0d082789ae0b9d6e937f99301b9912782a3a8a87648ba82e99a0d | def test_io_c_annot():
'Test I/O of MNE-C -annot.fif files.'
raw = read_raw_fif(fname_raw)
(sfreq, first_samp) = (raw.info['sfreq'], raw.first_samp)
events = read_events(fname_c_annot)
(events_2, event_id) = read_events(fname_c_annot, return_event_id=True)
assert_array_equal(events_2, events)
... | Test I/O of MNE-C -annot.fif files. | mne/tests/test_event.py | test_io_c_annot | hofaflo/mne-python | 1,953 | python | def test_io_c_annot():
raw = read_raw_fif(fname_raw)
(sfreq, first_samp) = (raw.info['sfreq'], raw.first_samp)
events = read_events(fname_c_annot)
(events_2, event_id) = read_events(fname_c_annot, return_event_id=True)
assert_array_equal(events_2, events)
expected = ((np.arange(2, 5) * sfre... | def test_io_c_annot():
raw = read_raw_fif(fname_raw)
(sfreq, first_samp) = (raw.info['sfreq'], raw.first_samp)
events = read_events(fname_c_annot)
(events_2, event_id) = read_events(fname_c_annot, return_event_id=True)
assert_array_equal(events_2, events)
expected = ((np.arange(2, 5) * sfre... |
4a3e4734069ffb7fcf0003b5b0f39fc10ef5befb60b3450ba173eb5ffa004eac | def test_find_events():
'Test find events in raw file.'
events = read_events(fname)
raw = read_raw_fif(raw_fname, preload=True)
extra_ends = ['', '_1']
orig_envs = [os.getenv(('MNE_STIM_CHANNEL%s' % s)) for s in extra_ends]
os.environ['MNE_STIM_CHANNEL'] = 'STI 014'
if ('MNE_STIM_CHANNEL_1' ... | Test find events in raw file. | mne/tests/test_event.py | test_find_events | hofaflo/mne-python | 1,953 | python | def test_find_events():
events = read_events(fname)
raw = read_raw_fif(raw_fname, preload=True)
extra_ends = [, '_1']
orig_envs = [os.getenv(('MNE_STIM_CHANNEL%s' % s)) for s in extra_ends]
os.environ['MNE_STIM_CHANNEL'] = 'STI 014'
if ('MNE_STIM_CHANNEL_1' in os.environ):
del os.en... | def test_find_events():
events = read_events(fname)
raw = read_raw_fif(raw_fname, preload=True)
extra_ends = [, '_1']
orig_envs = [os.getenv(('MNE_STIM_CHANNEL%s' % s)) for s in extra_ends]
os.environ['MNE_STIM_CHANNEL'] = 'STI 014'
if ('MNE_STIM_CHANNEL_1' in os.environ):
del os.en... |
f84e4f729fbecd069ffc11909c9ddc5c42044e23c87c00baf23c6ec1cf2a8254 | def test_pick_events():
'Test pick events in a events ndarray.'
events = np.array([[1, 0, 1], [2, 1, 0], [3, 0, 4], [4, 4, 2], [5, 2, 0]])
assert_array_equal(pick_events(events, include=[1, 4], exclude=4), [[1, 0, 1], [3, 0, 4]])
assert_array_equal(pick_events(events, exclude=[0, 2]), [[1, 0, 1], [3, 0,... | Test pick events in a events ndarray. | mne/tests/test_event.py | test_pick_events | hofaflo/mne-python | 1,953 | python | def test_pick_events():
events = np.array([[1, 0, 1], [2, 1, 0], [3, 0, 4], [4, 4, 2], [5, 2, 0]])
assert_array_equal(pick_events(events, include=[1, 4], exclude=4), [[1, 0, 1], [3, 0, 4]])
assert_array_equal(pick_events(events, exclude=[0, 2]), [[1, 0, 1], [3, 0, 4]])
assert_array_equal(pick_event... | def test_pick_events():
events = np.array([[1, 0, 1], [2, 1, 0], [3, 0, 4], [4, 4, 2], [5, 2, 0]])
assert_array_equal(pick_events(events, include=[1, 4], exclude=4), [[1, 0, 1], [3, 0, 4]])
assert_array_equal(pick_events(events, exclude=[0, 2]), [[1, 0, 1], [3, 0, 4]])
assert_array_equal(pick_event... |
276e28e8b276a87c60e2e67574881edc104834460192b8fda310befe901aae6f | def test_make_fixed_length_events():
'Test making events of a fixed length.'
raw = read_raw_fif(raw_fname)
events = make_fixed_length_events(raw, id=1)
assert (events.shape[1] == 3)
events_zero = make_fixed_length_events(raw, 1, first_samp=False)
assert_equal(events_zero[(0, 0)], 0)
assert_a... | Test making events of a fixed length. | mne/tests/test_event.py | test_make_fixed_length_events | hofaflo/mne-python | 1,953 | python | def test_make_fixed_length_events():
raw = read_raw_fif(raw_fname)
events = make_fixed_length_events(raw, id=1)
assert (events.shape[1] == 3)
events_zero = make_fixed_length_events(raw, 1, first_samp=False)
assert_equal(events_zero[(0, 0)], 0)
assert_array_equal(events_zero[(:, 0)], (events... | def test_make_fixed_length_events():
raw = read_raw_fif(raw_fname)
events = make_fixed_length_events(raw, id=1)
assert (events.shape[1] == 3)
events_zero = make_fixed_length_events(raw, 1, first_samp=False)
assert_equal(events_zero[(0, 0)], 0)
assert_array_equal(events_zero[(:, 0)], (events... |
149178ea2fd98a3d4dd4a90f774fc6d360e311334cab08a5e7fdfb036a70784b | def test_define_events():
'Test defining response events.'
events = read_events(fname)
raw = read_raw_fif(raw_fname)
(events_, _) = define_target_events(events, 5, 32, raw.info['sfreq'], 0.2, 0.7, 42, 99)
n_target = events[(events[(:, 2)] == 5)].shape[0]
n_miss = events_[(events_[(:, 2)] == 99)]... | Test defining response events. | mne/tests/test_event.py | test_define_events | hofaflo/mne-python | 1,953 | python | def test_define_events():
events = read_events(fname)
raw = read_raw_fif(raw_fname)
(events_, _) = define_target_events(events, 5, 32, raw.info['sfreq'], 0.2, 0.7, 42, 99)
n_target = events[(events[(:, 2)] == 5)].shape[0]
n_miss = events_[(events_[(:, 2)] == 99)].shape[0]
n_target_ = events... | def test_define_events():
events = read_events(fname)
raw = read_raw_fif(raw_fname)
(events_, _) = define_target_events(events, 5, 32, raw.info['sfreq'], 0.2, 0.7, 42, 99)
n_target = events[(events[(:, 2)] == 5)].shape[0]
n_miss = events_[(events_[(:, 2)] == 99)].shape[0]
n_target_ = events... |
31b2af251e188e37f26ea2937abb57cefd55aeab6dc5ab5055517559b232b865 | @testing.requires_testing_data
def test_acqparser():
'Test AcqParserFIF.'
pytest.raises(ValueError, AcqParserFIF, {'acq_pars': ''})
pytest.raises(ValueError, AcqParserFIF, {'acq_pars': 'baaa'})
pytest.raises(ValueError, AcqParserFIF, {'acq_pars': 'ERFVersion\n1'})
raw = read_raw_fif(raw_fname, prelo... | Test AcqParserFIF. | mne/tests/test_event.py | test_acqparser | hofaflo/mne-python | 1,953 | python | @testing.requires_testing_data
def test_acqparser():
pytest.raises(ValueError, AcqParserFIF, {'acq_pars': })
pytest.raises(ValueError, AcqParserFIF, {'acq_pars': 'baaa'})
pytest.raises(ValueError, AcqParserFIF, {'acq_pars': 'ERFVersion\n1'})
raw = read_raw_fif(raw_fname, preload=False)
acqp = A... | @testing.requires_testing_data
def test_acqparser():
pytest.raises(ValueError, AcqParserFIF, {'acq_pars': })
pytest.raises(ValueError, AcqParserFIF, {'acq_pars': 'baaa'})
pytest.raises(ValueError, AcqParserFIF, {'acq_pars': 'ERFVersion\n1'})
raw = read_raw_fif(raw_fname, preload=False)
acqp = A... |
0b9328d18a21f4163f29390bdd8f362fbe73496918170711d534806f79cabbb1 | @testing.requires_testing_data
def test_acqparser_averaging():
'Test averaging with AcqParserFIF vs. Elekta software.'
raw = read_raw_fif(fname_raw_elekta, preload=True)
acqp = AcqParserFIF(raw.info)
for cat in acqp.categories:
cond = acqp.get_condition(raw, cat)
eps = Epochs(raw, baseli... | Test averaging with AcqParserFIF vs. Elekta software. | mne/tests/test_event.py | test_acqparser_averaging | hofaflo/mne-python | 1,953 | python | @testing.requires_testing_data
def test_acqparser_averaging():
raw = read_raw_fif(fname_raw_elekta, preload=True)
acqp = AcqParserFIF(raw.info)
for cat in acqp.categories:
cond = acqp.get_condition(raw, cat)
eps = Epochs(raw, baseline=((- 0.05), 0), **cond)
ev = eps.average()
... | @testing.requires_testing_data
def test_acqparser_averaging():
raw = read_raw_fif(fname_raw_elekta, preload=True)
acqp = AcqParserFIF(raw.info)
for cat in acqp.categories:
cond = acqp.get_condition(raw, cat)
eps = Epochs(raw, baseline=((- 0.05), 0), **cond)
ev = eps.average()
... |
68a3b02f24af8184aedfa7d6b59031b7c1e9c52b228c51d72a52091a2c719253 | def test_shift_time_events():
'Test events latency shift by a given amount.'
events = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2]])
EXPECTED = [1, 2, 3]
new_events = shift_time_events(events, ids=None, tshift=1, sfreq=1)
assert all((new_events[(:, 0)] == EXPECTED))
events = np.array([[0, 0, 0], [1... | Test events latency shift by a given amount. | mne/tests/test_event.py | test_shift_time_events | hofaflo/mne-python | 1,953 | python | def test_shift_time_events():
events = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2]])
EXPECTED = [1, 2, 3]
new_events = shift_time_events(events, ids=None, tshift=1, sfreq=1)
assert all((new_events[(:, 0)] == EXPECTED))
events = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2]])
EXPECTED = [0, 2, 3]
... | def test_shift_time_events():
events = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2]])
EXPECTED = [1, 2, 3]
new_events = shift_time_events(events, ids=None, tshift=1, sfreq=1)
assert all((new_events[(:, 0)] == EXPECTED))
events = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2]])
EXPECTED = [0, 2, 3]
... |
07869b7ecb45753484082eb64f48e6c78f9d9b7e197c07236cc844647d33dc37 | def display(self, string, direction=None):
'Outputs the given string to the UI.'
if (direction is None):
cursor = ''
elif (direction == 'in'):
cursor = '<<< '
elif (direction == 'out'):
cursor = '>>> '
output = (((self.output.text + u'\n') + cursor) + string)
self.output.... | Outputs the given string to the UI. | wsh/connection.py | display | pinntech/wsh | 0 | python | def display(self, string, direction=None):
if (direction is None):
cursor =
elif (direction == 'in'):
cursor = '<<< '
elif (direction == 'out'):
cursor = '>>> '
output = (((self.output.text + u'\n') + cursor) + string)
self.output.document = Document(text=output, cursor... | def display(self, string, direction=None):
if (direction is None):
cursor =
elif (direction == 'in'):
cursor = '<<< '
elif (direction == 'out'):
cursor = '>>> '
output = (((self.output.text + u'\n') + cursor) + string)
self.output.document = Document(text=output, cursor... |
ecfccf6b998ba4002e3ec8cfbf5719700912aefacdb6f20a79c8018a5634e3f2 | def info(self, string):
'Output given string as info, which is a right justified text element.'
width = click.get_terminal_size()[0]
output = string.rjust(width)
output = ((self.output.text + '\n') + output)
self.output.document = Document(text=output, cursor_position=len(output)) | Output given string as info, which is a right justified text element. | wsh/connection.py | info | pinntech/wsh | 0 | python | def info(self, string):
width = click.get_terminal_size()[0]
output = string.rjust(width)
output = ((self.output.text + '\n') + output)
self.output.document = Document(text=output, cursor_position=len(output)) | def info(self, string):
width = click.get_terminal_size()[0]
output = string.rjust(width)
output = ((self.output.text + '\n') + output)
self.output.document = Document(text=output, cursor_position=len(output))<|docstring|>Output given string as info, which is a right justified text element.<|endoft... |
2f1c39e737357af03e58e30ce6b6ad82865bb89bdfabe050b35e21cecb82b11d | def send(self, sender, **kw):
'Send a data payload to the server.'
data = kw['data']
self.ws.send(data)
try:
json_data = json.loads(data)
self.display('sent', direction='out')
self.display(json.dumps(json_data, indent=2))
except Exception:
self.display('sent', directi... | Send a data payload to the server. | wsh/connection.py | send | pinntech/wsh | 0 | python | def send(self, sender, **kw):
data = kw['data']
self.ws.send(data)
try:
json_data = json.loads(data)
self.display('sent', direction='out')
self.display(json.dumps(json_data, indent=2))
except Exception:
self.display('sent', direction='out')
self.display(data) | def send(self, sender, **kw):
data = kw['data']
self.ws.send(data)
try:
json_data = json.loads(data)
self.display('sent', direction='out')
self.display(json.dumps(json_data, indent=2))
except Exception:
self.display('sent', direction='out')
self.display(data)... |
271baa7f9a01bbdf1c31bc44df3182b13259d29c28393fd52373f9a5335b335a | def close(self, sender, **kw):
'Close connection to the server.'
self.ws.close() | Close connection to the server. | wsh/connection.py | close | pinntech/wsh | 0 | python | def close(self, sender, **kw):
self.ws.close() | def close(self, sender, **kw):
self.ws.close()<|docstring|>Close connection to the server.<|endoftext|> |
02203531afcc8324063a03fbd36d5df5b9d7e31b8a76855547b83f54b064760b | def die(message):
'\n Print error and dies\n '
logger.error(message)
sys.exit(errno.EAGAIN) | Print error and dies | core/utils.py | die | brezerk/book_analyzer | 0 | python | def die(message):
'\n \n '
logger.error(message)
sys.exit(errno.EAGAIN) | def die(message):
'\n \n '
logger.error(message)
sys.exit(errno.EAGAIN)<|docstring|>Print error and dies<|endoftext|> |
87aeef36a75f5b7df6970de5f5c977fb61f73cb87ed7cd5d77fedc2ccf632fda | @distributed_trace
def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterable['_models.PrivateLinkResourceListResult']:
'Returns the list of private link resources.\n\n :param resource_group_name: The name of the resource group containing the Kusto cluster.\n :type resource... | Returns the list of private link resources.
:param resource_group_name: The name of the resource group containing the Kusto cluster.
:type resource_group_name: str
:param cluster_name: The name of the Kusto cluster.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct... | sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_private_link_resources_operations.py | list | automagically/azure-sdk-for-python | 1 | python | @distributed_trace
def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterable['_models.PrivateLinkResourceListResult']:
'Returns the list of private link resources.\n\n :param resource_group_name: The name of the resource group containing the Kusto cluster.\n :type resource... | @distributed_trace
def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterable['_models.PrivateLinkResourceListResult']:
'Returns the list of private link resources.\n\n :param resource_group_name: The name of the resource group containing the Kusto cluster.\n :type resource... |
96d5998ac13934e877068652dff18529ce3d7d2f9096d663a208b0ff8e891a86 | @distributed_trace
def get(self, resource_group_name: str, cluster_name: str, private_link_resource_name: str, **kwargs: Any) -> '_models.PrivateLinkResource':
'Gets a private link resource.\n\n :param resource_group_name: The name of the resource group containing the Kusto cluster.\n :type resource_g... | Gets a private link resource.
:param resource_group_name: The name of the resource group containing the Kusto cluster.
:type resource_group_name: str
:param cluster_name: The name of the Kusto cluster.
:type cluster_name: str
:param private_link_resource_name: The name of the private link resource.
:type private_link_... | sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_private_link_resources_operations.py | get | automagically/azure-sdk-for-python | 1 | python | @distributed_trace
def get(self, resource_group_name: str, cluster_name: str, private_link_resource_name: str, **kwargs: Any) -> '_models.PrivateLinkResource':
'Gets a private link resource.\n\n :param resource_group_name: The name of the resource group containing the Kusto cluster.\n :type resource_g... | @distributed_trace
def get(self, resource_group_name: str, cluster_name: str, private_link_resource_name: str, **kwargs: Any) -> '_models.PrivateLinkResource':
'Gets a private link resource.\n\n :param resource_group_name: The name of the resource group containing the Kusto cluster.\n :type resource_g... |
6c9012aec192b863e7c3ecd6da41011dde28b228981969629663fb003bdd54ad | def __init__(self, principalId):
' Constructor. '
self.principal = principal.Principal(principalId)
self.grantedPrivileges = list()
self.deniedPrivileges = list() | Constructor. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | __init__ | schlauch/DataFinder | 9 | python | def __init__(self, principalId):
' '
self.principal = principal.Principal(principalId)
self.grantedPrivileges = list()
self.deniedPrivileges = list() | def __init__(self, principalId):
' '
self.principal = principal.Principal(principalId)
self.grantedPrivileges = list()
self.deniedPrivileges = list()<|docstring|>Constructor.<|endoftext|> |
9c9e290fbddc2b9e9f25bf60355c2209b930a3b792bf88ab371cb5348c882142 | def setUp(self):
' Creates the required test environment. '
self._principalMock = SimpleMock(identifier='id')
self._acl = acl.AccessControlList() | Creates the required test environment. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | setUp | schlauch/DataFinder | 9 | python | def setUp(self):
' '
self._principalMock = SimpleMock(identifier='id')
self._acl = acl.AccessControlList() | def setUp(self):
' '
self._principalMock = SimpleMock(identifier='id')
self._acl = acl.AccessControlList()<|docstring|>Creates the required test environment.<|endoftext|> |
f6e70d2e1ff2cc5fae7edb2150d96d769f96c1a8aa1a9c311d6da70c5beaa8ea | def testPrincipalsAttribute(self):
' Tests the principals attribute. '
self.assertEquals(self._acl.principals, list())
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals(self._acl.principals, [self._principalMock])
principals = self._acl.principals
princip... | Tests the principals attribute. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testPrincipalsAttribute | schlauch/DataFinder | 9 | python | def testPrincipalsAttribute(self):
' '
self.assertEquals(self._acl.principals, list())
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals(self._acl.principals, [self._principalMock])
principals = self._acl.principals
principals.remove(self._principalMock)... | def testPrincipalsAttribute(self):
' '
self.assertEquals(self._acl.principals, list())
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals(self._acl.principals, [self._principalMock])
principals = self._acl.principals
principals.remove(self._principalMock)... |
c5f7b8d64bdb26c49dd6859b47ad66e2da48aadff6f385e4d70e68c1becf0dc5 | def testGrantPrivilege(self):
' Tests granting of privileges. '
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals... | Tests granting of privileges. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testGrantPrivilege | schlauch/DataFinder | 9 | python | def testGrantPrivilege(self):
' '
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals(self._acl.getGrantedPrivileg... | def testGrantPrivilege(self):
' '
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals(self._acl.getGrantedPrivileg... |
b18116a6e8c841cde9ba3882039c84b35c62a99d16f1a1b3fcba735107f09580 | def testDenyPrivilege(self):
' Tests denying of privileges. '
self._acl.denyPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.denyPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.denyPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals(self... | Tests denying of privileges. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testDenyPrivilege | schlauch/DataFinder | 9 | python | def testDenyPrivilege(self):
' '
self._acl.denyPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.denyPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.denyPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals(self._acl.getDeniedPrivileges(se... | def testDenyPrivilege(self):
' '
self._acl.denyPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.denyPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self._acl.denyPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals(self._acl.getDeniedPrivileges(se... |
14c37fa2b631364a02eef0d1cf4672fe727b24416054b2cdd22e4f612bf497fc | def testToPersistenceFormat(self):
' Tests the mapping into the persistence format. '
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals(self._acl.getGrantedPrivileges(self._principalMock), set([self._SUPPORTED_PRIVILEGE]))
self.assertEquals(len(self._acl.toPersis... | Tests the mapping into the persistence format. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testToPersistenceFormat | schlauch/DataFinder | 9 | python | def testToPersistenceFormat(self):
' '
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals(self._acl.getGrantedPrivileges(self._principalMock), set([self._SUPPORTED_PRIVILEGE]))
self.assertEquals(len(self._acl.toPersistenceFormat()), 1) | def testToPersistenceFormat(self):
' '
self._acl.grantPrivilege(self._principalMock, self._SUPPORTED_PRIVILEGE)
self.assertEquals(self._acl.getGrantedPrivileges(self._principalMock), set([self._SUPPORTED_PRIVILEGE]))
self.assertEquals(len(self._acl.toPersistenceFormat()), 1)<|docstring|>Tests the mappi... |
9c12517aed1c3397d76b2494bbcabe7cbfe82e19942e9e6e90ec742b95fd06f6 | def testCreate(self):
' Tests the creation of ACL. '
newAcl = self._acl.create([_PersistenceAceMock('a'), _PersistenceAceMock('b'), _PersistenceAceMock('c')])
self.assertEquals(len(newAcl.principals), 3)
invalidPrivAce = _PersistenceAceMock('a')
invalidPrivAce.grantedPrivileges = [self._UNSUPPORTED_... | Tests the creation of ACL. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testCreate | schlauch/DataFinder | 9 | python | def testCreate(self):
' '
newAcl = self._acl.create([_PersistenceAceMock('a'), _PersistenceAceMock('b'), _PersistenceAceMock('c')])
self.assertEquals(len(newAcl.principals), 3)
invalidPrivAce = _PersistenceAceMock('a')
invalidPrivAce.grantedPrivileges = [self._UNSUPPORTED_PRIVILEGE]
self.assert... | def testCreate(self):
' '
newAcl = self._acl.create([_PersistenceAceMock('a'), _PersistenceAceMock('b'), _PersistenceAceMock('c')])
self.assertEquals(len(newAcl.principals), 3)
invalidPrivAce = _PersistenceAceMock('a')
invalidPrivAce.grantedPrivileges = [self._UNSUPPORTED_PRIVILEGE]
self.assert... |
002a896ed6f9db1fae85a2930a39fa24e051eed6990ef6339a971218959e56e9 | def testComparison(self):
' Tests the comparison of two instances. '
self.assertEquals(self._acl, self._acl)
anotherAcl = acl.AccessControlList()
self.assertEquals(self._acl, anotherAcl)
aPrincipal = SimpleMock(identifier='aPrincipal')
anotherAcl.grantPrivilege(aPrincipal, self._SUPPORTED_PRIVIL... | Tests the comparison of two instances. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testComparison | schlauch/DataFinder | 9 | python | def testComparison(self):
' '
self.assertEquals(self._acl, self._acl)
anotherAcl = acl.AccessControlList()
self.assertEquals(self._acl, anotherAcl)
aPrincipal = SimpleMock(identifier='aPrincipal')
anotherAcl.grantPrivilege(aPrincipal, self._SUPPORTED_PRIVILEGE)
self.assertNotEquals(self._ac... | def testComparison(self):
' '
self.assertEquals(self._acl, self._acl)
anotherAcl = acl.AccessControlList()
self.assertEquals(self._acl, anotherAcl)
aPrincipal = SimpleMock(identifier='aPrincipal')
anotherAcl.grantPrivilege(aPrincipal, self._SUPPORTED_PRIVILEGE)
self.assertNotEquals(self._ac... |
3650daee8045826de993190a9c83e3f86138b64d866ecc45fcf1232ca2cdeaa9 | def testContentAccessLevel(self):
' Checks content access level handling. '
self._acl.setContentAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLevel(self._principalMoc... | Checks content access level handling. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testContentAccessLevel | schlauch/DataFinder | 9 | python | def testContentAccessLevel(self):
' '
self._acl.setContentAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self.asser... | def testContentAccessLevel(self):
' '
self._acl.setContentAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self.asser... |
05e80fe250d22f36772eee5143dd5eb6d58fa89f439a9429e3bbaaa13e73bc52 | def testPropertiesAccessLevel(self):
' Checks properties access level handling. '
self._acl.setPropertiesAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLevel(self._pri... | Checks properties access level handling. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testPropertiesAccessLevel | schlauch/DataFinder | 9 | python | def testPropertiesAccessLevel(self):
' '
self._acl.setPropertiesAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self... | def testPropertiesAccessLevel(self):
' '
self._acl.setPropertiesAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self... |
2c58fe73c2c66cead5b164d0f301f3a62f6a9f363146e840924faddc99b15fb6 | def testAdministrationAccessLevel(self):
' Checks administration access level handling. '
self._acl.setAdministrationAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLev... | Checks administration access level handling. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testAdministrationAccessLevel | schlauch/DataFinder | 9 | python | def testAdministrationAccessLevel(self):
' '
self._acl.setAdministrationAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
... | def testAdministrationAccessLevel(self):
' '
self._acl.setAdministrationAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLevel(self._principalMock), NONE_ACCESS_LEVEL)
... |
bfd5b30f23f0a40452d5464db5e40e2af0732ec21e64e9d7be409548289cce80 | def testClearPrivileges(self):
' Tests clearing of privileges. '
self._acl.setAdministrationAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(len(self._acl.principals), 1)
self._acl.clearPrivileges(self._principalMock)
self.assertEquals(len(self._acl.principals), 0) | Tests clearing of privileges. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testClearPrivileges | schlauch/DataFinder | 9 | python | def testClearPrivileges(self):
' '
self._acl.setAdministrationAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(len(self._acl.principals), 1)
self._acl.clearPrivileges(self._principalMock)
self.assertEquals(len(self._acl.principals), 0) | def testClearPrivileges(self):
' '
self._acl.setAdministrationAccessLevel(self._principalMock, NONE_ACCESS_LEVEL)
self.assertEquals(len(self._acl.principals), 1)
self._acl.clearPrivileges(self._principalMock)
self.assertEquals(len(self._acl.principals), 0)<|docstring|>Tests clearing of privileges.<... |
b6fd088778c7cc4b75eee714bffabab2774733fcfb3edd75aad93b7e6e72ac57 | def testIndex(self):
' Tests the index handling. '
self._acl.setContentAccessLevel(self._principalMock, FULL_ACCESS_LEVEL)
self.assertEquals(self._acl.getIndex(self._principalMock), 0)
anotherPrincipal = SimpleMock(identifier='anotherPrincipal')
self._acl.setContentAccessLevel(anotherPrincipal, FULL... | Tests the index handling. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testIndex | schlauch/DataFinder | 9 | python | def testIndex(self):
' '
self._acl.setContentAccessLevel(self._principalMock, FULL_ACCESS_LEVEL)
self.assertEquals(self._acl.getIndex(self._principalMock), 0)
anotherPrincipal = SimpleMock(identifier='anotherPrincipal')
self._acl.setContentAccessLevel(anotherPrincipal, FULL_ACCESS_LEVEL)
self.a... | def testIndex(self):
' '
self._acl.setContentAccessLevel(self._principalMock, FULL_ACCESS_LEVEL)
self.assertEquals(self._acl.getIndex(self._principalMock), 0)
anotherPrincipal = SimpleMock(identifier='anotherPrincipal')
self._acl.setContentAccessLevel(anotherPrincipal, FULL_ACCESS_LEVEL)
self.a... |
a0569816ee175bbd9a284a1b1a8d7cc28c7f09f2c6d14def537860a920f62b0f | def testAddDefaultPrincipal(self):
' Tests the default principal adding method. '
self._acl.addDefaultPrincipal(self._principalMock)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), READ_ONLY_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLevel(self._principalMock), READ_O... | Tests the default principal adding method. | test/unittest/datafinder_test/core/item/privileges/acl_test.py | testAddDefaultPrincipal | schlauch/DataFinder | 9 | python | def testAddDefaultPrincipal(self):
' '
self._acl.addDefaultPrincipal(self._principalMock)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), READ_ONLY_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLevel(self._principalMock), READ_ONLY_ACCESS_LEVEL)
self.assertEquals(se... | def testAddDefaultPrincipal(self):
' '
self._acl.addDefaultPrincipal(self._principalMock)
self.assertEquals(self._acl.contentAccessLevel(self._principalMock), READ_ONLY_ACCESS_LEVEL)
self.assertEquals(self._acl.propertiesAccessLevel(self._principalMock), READ_ONLY_ACCESS_LEVEL)
self.assertEquals(se... |
82d5d3feed478510698b73a7b907acd41acb424c758a8eea6e11a53c0334d57e | def setup(bot: tbb.TravusBotBase):
'Setup function ran when module is loaded.'
bot.add_cog(CoreFunctionalityCog(bot))
bot.add_command_help(CoreFunctionalityCog.botconfig_prefix, 'Core', None, ['$', 'bot!', 'bot ?', 'remove'])
bot.add_command_help(CoreFunctionalityCog.botconfig_deletemessages, 'Core', No... | Setup function ran when module is loaded. | core_commands.py | setup | Travus/Travus_Bot_Base | 2 | python | def setup(bot: tbb.TravusBotBase):
bot.add_cog(CoreFunctionalityCog(bot))
bot.add_command_help(CoreFunctionalityCog.botconfig_prefix, 'Core', None, ['$', 'bot!', 'bot ?', 'remove'])
bot.add_command_help(CoreFunctionalityCog.botconfig_deletemessages, 'Core', None, ['enable', 'y', 'disable', 'n'])
bo... | def setup(bot: tbb.TravusBotBase):
bot.add_cog(CoreFunctionalityCog(bot))
bot.add_command_help(CoreFunctionalityCog.botconfig_prefix, 'Core', None, ['$', 'bot!', 'bot ?', 'remove'])
bot.add_command_help(CoreFunctionalityCog.botconfig_deletemessages, 'Core', None, ['enable', 'y', 'disable', 'n'])
bo... |
cd8cf89e7e4a08859d6ea7f08f8567e02b7aa7530a8ce1f3a9ea129efe4034ae | def teardown(bot: tbb.TravusBotBase):
'Teardown function ran when module is unloaded.'
bot.remove_cog('CoreFunctionalityCog')
bot.remove_command_help(CoreFunctionalityCog) | Teardown function ran when module is unloaded. | core_commands.py | teardown | Travus/Travus_Bot_Base | 2 | python | def teardown(bot: tbb.TravusBotBase):
bot.remove_cog('CoreFunctionalityCog')
bot.remove_command_help(CoreFunctionalityCog) | def teardown(bot: tbb.TravusBotBase):
bot.remove_cog('CoreFunctionalityCog')
bot.remove_command_help(CoreFunctionalityCog)<|docstring|>Teardown function ran when module is unloaded.<|endoftext|> |
f894926d6e4b862691f7681484a0c8dc81f498ac7479f248b678b9dea85feb4c | def __init__(self, bot: tbb.TravusBotBase):
'Initialization function loading bot object for cog.'
self.bot = bot
self.log = logging.getLogger('core_commands')
self.log.setLevel(logging.INFO) | Initialization function loading bot object for cog. | core_commands.py | __init__ | Travus/Travus_Bot_Base | 2 | python | def __init__(self, bot: tbb.TravusBotBase):
self.bot = bot
self.log = logging.getLogger('core_commands')
self.log.setLevel(logging.INFO) | def __init__(self, bot: tbb.TravusBotBase):
self.bot = bot
self.log = logging.getLogger('core_commands')
self.log.setLevel(logging.INFO)<|docstring|>Initialization function loading bot object for cog.<|endoftext|> |
f88bcc80936b05349605d62937ca9cfaa751e6bb66f7958a6c824f898ba57cd6 | async def _module_operation(self, ctx: commands.Context, operation: str, mod: str):
'To avoid code duplication in the except blocks all module command functionality is grouped together.'
async def load():
'Contains the logic for loading a module.'
if (f'{mod}.py' in listdir('modules')):
... | To avoid code duplication in the except blocks all module command functionality is grouped together. | core_commands.py | _module_operation | Travus/Travus_Bot_Base | 2 | python | async def _module_operation(self, ctx: commands.Context, operation: str, mod: str):
async def load():
'Contains the logic for loading a module.'
if (f'{mod}.py' in listdir('modules')):
self.bot.load_extension(f'modules.{mod}')
(await self.bot.update_command_states())
... | async def _module_operation(self, ctx: commands.Context, operation: str, mod: str):
async def load():
'Contains the logic for loading a module.'
if (f'{mod}.py' in listdir('modules')):
self.bot.load_extension(f'modules.{mod}')
(await self.bot.update_command_states())
... |
dabcdec04110d9adb85bc35d0051ec46ef628e11fe6fbdc482a84a5ce731945d | @commands.is_owner()
@commands.group(invoke_without_command=True, name='botconfig', usage='<prefix/deletemessages/description/credits>')
async def botconfig(self, ctx: commands.Context):
"This command sets the bot's prefix, command trigger deletion behaviour, description and additional credits\n section. For... | This command sets the bot's prefix, command trigger deletion behaviour, description and additional credits
section. Fore more information check the help entry of one of these subcommands; `prefix`, `deletemessages`,
`description`, `credits`. | core_commands.py | botconfig | Travus/Travus_Bot_Base | 2 | python | @commands.is_owner()
@commands.group(invoke_without_command=True, name='botconfig', usage='<prefix/deletemessages/description/credits>')
async def botconfig(self, ctx: commands.Context):
"This command sets the bot's prefix, command trigger deletion behaviour, description and additional credits\n section. For... | @commands.is_owner()
@commands.group(invoke_without_command=True, name='botconfig', usage='<prefix/deletemessages/description/credits>')
async def botconfig(self, ctx: commands.Context):
"This command sets the bot's prefix, command trigger deletion behaviour, description and additional credits\n section. For... |
0df5c65e7f8ff4580f67443fb1e4c6081f57e8a52f4a30d3aaa0d8434b1c616a | @commands.is_owner()
@botconfig.command(name='prefix', usage='<NEW PREFIX/remove>')
async def botconfig_prefix(self, ctx: commands.Context, *, new_prefix: str):
'This command changes the bot prefix. The default prefix is `!`. Prefixes can be everything from symbols to\n words or a combination of the two, and... | This command changes the bot prefix. The default prefix is `!`. Prefixes can be everything from symbols to
words or a combination of the two, and can even include spaces, though they cannot start or end with spaces
since Discord removes empty space at the start and end of messages. The prefix is saved across reboots. S... | core_commands.py | botconfig_prefix | Travus/Travus_Bot_Base | 2 | python | @commands.is_owner()
@botconfig.command(name='prefix', usage='<NEW PREFIX/remove>')
async def botconfig_prefix(self, ctx: commands.Context, *, new_prefix: str):
'This command changes the bot prefix. The default prefix is `!`. Prefixes can be everything from symbols to\n words or a combination of the two, and... | @commands.is_owner()
@botconfig.command(name='prefix', usage='<NEW PREFIX/remove>')
async def botconfig_prefix(self, ctx: commands.Context, *, new_prefix: str):
'This command changes the bot prefix. The default prefix is `!`. Prefixes can be everything from symbols to\n words or a combination of the two, and... |
3295dc49f9b0dd71e8c35bbaeb54e586f2ff814bacf8528da7f3a1448b1d4d66 | @commands.is_owner()
@botconfig.command(name='deletemessages', aliases=['deletemsgs', 'deletecommands', 'deletecmds', 'delmessages', 'delmsgs', 'delcommands', 'delcmds'], usage='<enable/disable>')
async def botconfig_deletemessages(self, ctx: commands.Context, operation: str):
'This command sets the behaviour for d... | This command sets the behaviour for deletion of command triggers. If this is enabled then messages that
trigger commands will be deleted. Is this is disabled then the bot will not delete messages that trigger
commands. Per default this is enabled. This setting is saved across restarts. | core_commands.py | botconfig_deletemessages | Travus/Travus_Bot_Base | 2 | python | @commands.is_owner()
@botconfig.command(name='deletemessages', aliases=['deletemsgs', 'deletecommands', 'deletecmds', 'delmessages', 'delmsgs', 'delcommands', 'delcmds'], usage='<enable/disable>')
async def botconfig_deletemessages(self, ctx: commands.Context, operation: str):
'This command sets the behaviour for d... | @commands.is_owner()
@botconfig.command(name='deletemessages', aliases=['deletemsgs', 'deletecommands', 'deletecmds', 'delmessages', 'delmsgs', 'delcommands', 'delcmds'], usage='<enable/disable>')
async def botconfig_deletemessages(self, ctx: commands.Context, operation: str):
'This command sets the behaviour for d... |
bf6e20ddd7f2dcc6fe6211099cac6b5bc9735040cb34d08472284f00b8240fb0 | @commands.is_owner()
@botconfig.command(name='description', aliases=['desc'], usage='<DESCRIPTION/remove>')
async def botconfig_description(self, ctx: commands.Context, *, description: str):
'This command sets the bot description that is used by the about command. The description can technically be\n up to 4... | This command sets the bot description that is used by the about command. The description can technically be
up to 4096 characters long, keep however in mind that Discord messages have a maximum length of 4000 characters
(2000 without Nitro). If `remove` is sent along then the description will be removed. The special ke... | core_commands.py | botconfig_description | Travus/Travus_Bot_Base | 2 | python | @commands.is_owner()
@botconfig.command(name='description', aliases=['desc'], usage='<DESCRIPTION/remove>')
async def botconfig_description(self, ctx: commands.Context, *, description: str):
'This command sets the bot description that is used by the about command. The description can technically be\n up to 4... | @commands.is_owner()
@botconfig.command(name='description', aliases=['desc'], usage='<DESCRIPTION/remove>')
async def botconfig_description(self, ctx: commands.Context, *, description: str):
'This command sets the bot description that is used by the about command. The description can technically be\n up to 4... |
ffdc4bfb0be93fb43d55d91b9bb12c515632182b38f77e0818cf01b1a69cb6ef | @commands.is_owner()
@botconfig.command(name='credits', usage='<CREDITS/remove> *OBS: See help command entry!*')
async def botconfig_credits(self, ctx: commands.Context, *, description: str):
'This command sets the additional credits section of the about command. The additional credits section can be\n at ... | This command sets the additional credits section of the about command. The additional credits section can be
at most 1024 characters long, and supports both new lines, indents and embedded links. Indents of 5 spaces are
recommended. Embedded links should look like so; `[displayed text](URL)`. The credits should be pass... | core_commands.py | botconfig_credits | Travus/Travus_Bot_Base | 2 | python | @commands.is_owner()
@botconfig.command(name='credits', usage='<CREDITS/remove> *OBS: See help command entry!*')
async def botconfig_credits(self, ctx: commands.Context, *, description: str):
'This command sets the additional credits section of the about command. The additional credits section can be\n at ... | @commands.is_owner()
@botconfig.command(name='credits', usage='<CREDITS/remove> *OBS: See help command entry!*')
async def botconfig_credits(self, ctx: commands.Context, *, description: str):
'This command sets the additional credits section of the about command. The additional credits section can be\n at ... |
972700dfe638ab9fe0ee78e462d347cb2ee1e56bc91ca29da099d5d3611497fc | @commands.has_permissions(administrator=True)
@commands.group(invoke_without_command=True, name='module', aliases=['modules'], usage='<list/load/unload/reload/error>')
async def module(self, ctx: commands.Context):
"This command can load, unload, reload and list available modules. It can also show any errors that o... | This command can load, unload, reload and list available modules. It can also show any errors that occur
during the loading process. Modules contain added functionality, such as commands. The intended purpose for
modules is to extend the bot's functionality in semi-independent packages so that parts of the bot's
functi... | core_commands.py | module | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@commands.group(invoke_without_command=True, name='module', aliases=['modules'], usage='<list/load/unload/reload/error>')
async def module(self, ctx: commands.Context):
"This command can load, unload, reload and list available modules. It can also show any errors that o... | @commands.has_permissions(administrator=True)
@commands.group(invoke_without_command=True, name='module', aliases=['modules'], usage='<list/load/unload/reload/error>')
async def module(self, ctx: commands.Context):
"This command can load, unload, reload and list available modules. It can also show any errors that o... |
deb8a9c9bdd0cd010ee94990d9a0c2a6eb3d90282a2fb31c8fe145cecaacdbe1 | @commands.has_permissions(administrator=True)
@module.command(name='list')
async def module_list(self, ctx: commands.Context):
'This command lists all currently loaded and available modules. For the bot to find new modules they need to\n be placed inside the modules folder inside the bot directory. Modules l... | This command lists all currently loaded and available modules. For the bot to find new modules they need to
be placed inside the modules folder inside the bot directory. Modules listed by this command can be loaded,
unloaded and reloaded by the respective commands for this. See help text for `module load`, `module unlo... | core_commands.py | module_list | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@module.command(name='list')
async def module_list(self, ctx: commands.Context):
'This command lists all currently loaded and available modules. For the bot to find new modules they need to\n be placed inside the modules folder inside the bot directory. Modules l... | @commands.has_permissions(administrator=True)
@module.command(name='list')
async def module_list(self, ctx: commands.Context):
'This command lists all currently loaded and available modules. For the bot to find new modules they need to\n be placed inside the modules folder inside the bot directory. Modules l... |
18bf0e97961217e51506a177596dffcdbaf9b05a00b664d44ed57ab41763f255 | @commands.has_permissions(administrator=True)
@module.command(name='load', aliases=['l'], usage='<MODULE NAME>')
async def module_load(self, ctx: commands.Context, *, mod: str):
'This command loads modules. Modules should be located inside the module folder in the bot directory. The\n `module list` command c... | This command loads modules. Modules should be located inside the module folder in the bot directory. The
`module list` command can be used to show all modules available for loading. Once a module is loaded the
functionality defined in the module file will be added to the bot. If an error is encountered during the
loadi... | core_commands.py | module_load | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@module.command(name='load', aliases=['l'], usage='<MODULE NAME>')
async def module_load(self, ctx: commands.Context, *, mod: str):
'This command loads modules. Modules should be located inside the module folder in the bot directory. The\n `module list` command c... | @commands.has_permissions(administrator=True)
@module.command(name='load', aliases=['l'], usage='<MODULE NAME>')
async def module_load(self, ctx: commands.Context, *, mod: str):
'This command loads modules. Modules should be located inside the module folder in the bot directory. The\n `module list` command c... |
f6a499d0bdad6bde405a737bd9abfcd31d2be8b6f7c139c6348d3a8f605e5802 | @commands.has_permissions(administrator=True)
@module.command(name='unload', aliases=['ul'], usage='<MODULE NAME>')
async def module_unload(self, ctx: commands.Context, *, mod: str):
"This command unloads modules. When a loaded module is unloaded it's functionality will be removed. You can\n use the `module ... | This command unloads modules. When a loaded module is unloaded it's functionality will be removed. You can
use the `module list` command to see all currently loaded modules. This will not prevent default modules from
being loaded when the bot starts. See the `default` command for removing modules starting with the bot. | core_commands.py | module_unload | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@module.command(name='unload', aliases=['ul'], usage='<MODULE NAME>')
async def module_unload(self, ctx: commands.Context, *, mod: str):
"This command unloads modules. When a loaded module is unloaded it's functionality will be removed. You can\n use the `module ... | @commands.has_permissions(administrator=True)
@module.command(name='unload', aliases=['ul'], usage='<MODULE NAME>')
async def module_unload(self, ctx: commands.Context, *, mod: str):
"This command unloads modules. When a loaded module is unloaded it's functionality will be removed. You can\n use the `module ... |
acd570db99fae8b8defe85e0d35781ac643862727992c78e01f8ab6a01cfbf0a | @commands.has_permissions(administrator=True)
@module.command(name='reload', aliases=['rl'], usage='<MODULE NAME>')
async def module_reload(self, ctx: commands.Context, *, mod: str):
'This command reloads a module that is currently loaded. This will unload and load the module in one command.\n If the module ... | This command reloads a module that is currently loaded. This will unload and load the module in one command.
If the module is no longer present or the loading process encounters an error the module will not be reloaded
and the functionality from before the reload will be retained and the user informed, the `module erro... | core_commands.py | module_reload | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@module.command(name='reload', aliases=['rl'], usage='<MODULE NAME>')
async def module_reload(self, ctx: commands.Context, *, mod: str):
'This command reloads a module that is currently loaded. This will unload and load the module in one command.\n If the module ... | @commands.has_permissions(administrator=True)
@module.command(name='reload', aliases=['rl'], usage='<MODULE NAME>')
async def module_reload(self, ctx: commands.Context, *, mod: str):
'This command reloads a module that is currently loaded. This will unload and load the module in one command.\n If the module ... |
5ab7e66dd4e7764c10ebd380ff9f36e81e7956c3ce4fa1d5a66e77c23d344822 | @commands.has_permissions(administrator=True)
@module.command(name='error')
async def module_error(self, ctx: commands.Context):
'This command will show the last error that was encountered during the module load or reloading process. This\n information will also be logged to the console when the error first ... | This command will show the last error that was encountered during the module load or reloading process. This
information will also be logged to the console when the error first is encountered. This command retains this
information until another error replaces it, or the bot shuts down. | core_commands.py | module_error | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@module.command(name='error')
async def module_error(self, ctx: commands.Context):
'This command will show the last error that was encountered during the module load or reloading process. This\n information will also be logged to the console when the error first ... | @commands.has_permissions(administrator=True)
@module.command(name='error')
async def module_error(self, ctx: commands.Context):
'This command will show the last error that was encountered during the module load or reloading process. This\n information will also be logged to the console when the error first ... |
acc2103e2f842a19dd93cda6e2f82ad8f0c75b065a9d5d71e0fa47007cc67152 | @commands.is_owner()
@commands.group(invoke_without_command=True, name='default', aliases=['defaults'], usage='<add/remove/list>')
async def default(self, ctx: commands.Context):
'This command is used to add, remove or list default modules. Modules contain added functionality, such as\n commands. Default mod... | This command is used to add, remove or list default modules. Modules contain added functionality, such as
commands. Default modules are loaded automatically when the bot starts and as such any functionality in them
will be available as soon as the bot is online. For more info see the help text of the subcommands. | core_commands.py | default | Travus/Travus_Bot_Base | 2 | python | @commands.is_owner()
@commands.group(invoke_without_command=True, name='default', aliases=['defaults'], usage='<add/remove/list>')
async def default(self, ctx: commands.Context):
'This command is used to add, remove or list default modules. Modules contain added functionality, such as\n commands. Default mod... | @commands.is_owner()
@commands.group(invoke_without_command=True, name='default', aliases=['defaults'], usage='<add/remove/list>')
async def default(self, ctx: commands.Context):
'This command is used to add, remove or list default modules. Modules contain added functionality, such as\n commands. Default mod... |
88af6c2d6e3ce57521d9966117bd61399067f2e9250973e4c971369074592bcf | @commands.is_owner()
@default.command(name='list')
async def default_list(self, ctx: commands.Context):
'This command lists all current default modules. For more information on modules see the help text for the\n `module` command. All modules in this list start as soon as the bot is launched. For a list of a... | This command lists all current default modules. For more information on modules see the help text for the
`module` command. All modules in this list start as soon as the bot is launched. For a list of all available or
loaded modules see the `module list` command. | core_commands.py | default_list | Travus/Travus_Bot_Base | 2 | python | @commands.is_owner()
@default.command(name='list')
async def default_list(self, ctx: commands.Context):
'This command lists all current default modules. For more information on modules see the help text for the\n `module` command. All modules in this list start as soon as the bot is launched. For a list of a... | @commands.is_owner()
@default.command(name='list')
async def default_list(self, ctx: commands.Context):
'This command lists all current default modules. For more information on modules see the help text for the\n `module` command. All modules in this list start as soon as the bot is launched. For a list of a... |
7c8530b046f0145e0efaa0519105e1cb51b633ee658b26252cd3eda061c73e12 | @commands.is_owner()
@default.command(name='add', usage='<MODULE NAME>')
async def default_add(self, ctx: commands.Context, *, mod: str):
'This command adds a module to the list of default modules. Modules in this list are loaded automatically\n once the bot starts. This command does not load modules if they... | This command adds a module to the list of default modules. Modules in this list are loaded automatically
once the bot starts. This command does not load modules if they are not already loaded until the bot is started
the next time. For that, see the `module load` command. For a list of existing default modules, see the... | core_commands.py | default_add | Travus/Travus_Bot_Base | 2 | python | @commands.is_owner()
@default.command(name='add', usage='<MODULE NAME>')
async def default_add(self, ctx: commands.Context, *, mod: str):
'This command adds a module to the list of default modules. Modules in this list are loaded automatically\n once the bot starts. This command does not load modules if they... | @commands.is_owner()
@default.command(name='add', usage='<MODULE NAME>')
async def default_add(self, ctx: commands.Context, *, mod: str):
'This command adds a module to the list of default modules. Modules in this list are loaded automatically\n once the bot starts. This command does not load modules if they... |
d9b1fe8c1f79c66df987eafe241d1049d781b4d3d7f3a0b6628af8b4617363ba | @commands.is_owner()
@default.command(name='remove', usage='<MODULE NAME>')
async def default_remove(self, ctx: commands.Context, *, mod: str):
'This command removes a module from the list of default modules. Once removed from this list the module will\n no longer automatically be loaded when the bot starts.... | This command removes a module from the list of default modules. Once removed from this list the module will
no longer automatically be loaded when the bot starts. This command will not unload commands that are already
loaded. For that, see the `module unload` command. For a list of existing default modules, see the
`de... | core_commands.py | default_remove | Travus/Travus_Bot_Base | 2 | python | @commands.is_owner()
@default.command(name='remove', usage='<MODULE NAME>')
async def default_remove(self, ctx: commands.Context, *, mod: str):
'This command removes a module from the list of default modules. Once removed from this list the module will\n no longer automatically be loaded when the bot starts.... | @commands.is_owner()
@default.command(name='remove', usage='<MODULE NAME>')
async def default_remove(self, ctx: commands.Context, *, mod: str):
'This command removes a module from the list of default modules. Once removed from this list the module will\n no longer automatically be loaded when the bot starts.... |
3aa6fb795bba83a9a02b7dad3ce72a7abcdc2241a40e3e7c54a257c79e661bbb | @commands.has_permissions(administrator=True)
@commands.group(invoke_without_command=True, name='command', aliases=['commands'], usage='<enable/disable/show/hide>')
async def command(self, ctx: commands.Context):
"This command disables, enables, hides and shows other commands. Hiding commands means they don't show ... | This command disables, enables, hides and shows other commands. Hiding commands means they don't show up in
the overall help command list. Disabling a command means it can't be used. Disabled commands also do not show
up in the overall help command list and the specific help text for the command will not be viewable. C... | core_commands.py | command | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@commands.group(invoke_without_command=True, name='command', aliases=['commands'], usage='<enable/disable/show/hide>')
async def command(self, ctx: commands.Context):
"This command disables, enables, hides and shows other commands. Hiding commands means they don't show ... | @commands.has_permissions(administrator=True)
@commands.group(invoke_without_command=True, name='command', aliases=['commands'], usage='<enable/disable/show/hide>')
async def command(self, ctx: commands.Context):
"This command disables, enables, hides and shows other commands. Hiding commands means they don't show ... |
865afcde0e262e495ef119ac0ee327c16b6d11834ee4740d8e389bb2d6413895 | async def _command_get_state(self, command: commands.Command) -> int:
'Helper function for command command that gets the state of the command.'
async with self.bot.db.acquire() as conn:
cog_com_name = f"{((command.cog.__class__.__name__ + '.') if command.cog else '')}{command.name}"
response = (... | Helper function for command command that gets the state of the command. | core_commands.py | _command_get_state | Travus/Travus_Bot_Base | 2 | python | async def _command_get_state(self, command: commands.Command) -> int:
async with self.bot.db.acquire() as conn:
cog_com_name = f"{((command.cog.__class__.__name__ + '.') if command.cog else )}{command.name}"
response = (await conn.fetchval('SELECT state FROM command_states WHERE command = $1', ... | async def _command_get_state(self, command: commands.Command) -> int:
async with self.bot.db.acquire() as conn:
cog_com_name = f"{((command.cog.__class__.__name__ + '.') if command.cog else )}{command.name}"
response = (await conn.fetchval('SELECT state FROM command_states WHERE command = $1', ... |
e649cda2d347d13ea208c852285b509793100ba37721094bc0861770ac67914d | async def _command_set_state(self, command: commands.Command, state: int):
'Helper function for command command that sets the state of the command.'
async with self.bot.db.acquire() as conn:
(await conn.execute('UPDATE command_states SET state = $1 WHERE command = $2', state, f"{((command.cog.__class__.... | Helper function for command command that sets the state of the command. | core_commands.py | _command_set_state | Travus/Travus_Bot_Base | 2 | python | async def _command_set_state(self, command: commands.Command, state: int):
async with self.bot.db.acquire() as conn:
(await conn.execute('UPDATE command_states SET state = $1 WHERE command = $2', state, f"{((command.cog.__class__.__name__ + '.') if command.cog else )}{command.name}")) | async def _command_set_state(self, command: commands.Command, state: int):
async with self.bot.db.acquire() as conn:
(await conn.execute('UPDATE command_states SET state = $1 WHERE command = $2', state, f"{((command.cog.__class__.__name__ + '.') if command.cog else )}{command.name}"))<|docstring|>Helpe... |
790f8f80182c639a45200b7add207bbde45c44ecd6d54b476e57dc89a311c03a | @commands.has_permissions(administrator=True)
@command.command(name='enable', usage='<COMMAND NAME>')
async def command_enable(self, ctx: commands.Context, *, command_name: str):
"This command enables commands which have previously been disabled. This will allow them to be used again.\n It will also add the ... | This command enables commands which have previously been disabled. This will allow them to be used again.
It will also add the command back into the list of commands shown by the help command and re-enable the
viewing of it's help text given the command has help text and it has not otherwise been hidden. | core_commands.py | command_enable | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@command.command(name='enable', usage='<COMMAND NAME>')
async def command_enable(self, ctx: commands.Context, *, command_name: str):
"This command enables commands which have previously been disabled. This will allow them to be used again.\n It will also add the ... | @commands.has_permissions(administrator=True)
@command.command(name='enable', usage='<COMMAND NAME>')
async def command_enable(self, ctx: commands.Context, *, command_name: str):
"This command enables commands which have previously been disabled. This will allow them to be used again.\n It will also add the ... |
79266c55ca67ea589ae3a4161ab4545e5cc1fce14ab511604db1d53fd98e90d4 | @commands.has_permissions(administrator=True)
@command.command(name='disable', usage='<COMMAND NAME>')
async def command_disable(self, ctx: commands.Context, *, command_name: str):
"This command can disable other commands. Disabled commands cannot be used and are removed from the\n list of commands shown by ... | This command can disable other commands. Disabled commands cannot be used and are removed from the
list of commands shown by the help command. The command's help text will also not be viewable. Core
commands cannot be disabled. Disabled commands can be re-enabled with the `command enable` command. | core_commands.py | command_disable | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@command.command(name='disable', usage='<COMMAND NAME>')
async def command_disable(self, ctx: commands.Context, *, command_name: str):
"This command can disable other commands. Disabled commands cannot be used and are removed from the\n list of commands shown by ... | @commands.has_permissions(administrator=True)
@command.command(name='disable', usage='<COMMAND NAME>')
async def command_disable(self, ctx: commands.Context, *, command_name: str):
"This command can disable other commands. Disabled commands cannot be used and are removed from the\n list of commands shown by ... |
28f980f4d0d72e78a89a5b40d3627ca7f6ca224986a02050177522bb69d2b93c | @commands.has_permissions(administrator=True)
@command.command(name='show', usage='<COMMAND NAME>')
async def command_show(self, ctx: commands.Context, *, command_name: str):
'This command will show commands which have previously been hidden, reversing the hiding of the\n command. This will add the command b... | This command will show commands which have previously been hidden, reversing the hiding of the
command. This will add the command back into the list of commands shown by the help command. This
will not re-enable the command if it has been disabled. Showing disabled commands alone will not
be enough to re-add them to th... | core_commands.py | command_show | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@command.command(name='show', usage='<COMMAND NAME>')
async def command_show(self, ctx: commands.Context, *, command_name: str):
'This command will show commands which have previously been hidden, reversing the hiding of the\n command. This will add the command b... | @commands.has_permissions(administrator=True)
@command.command(name='show', usage='<COMMAND NAME>')
async def command_show(self, ctx: commands.Context, *, command_name: str):
'This command will show commands which have previously been hidden, reversing the hiding of the\n command. This will add the command b... |
48ffe4fb4e0da337b86ab56f35db3fd3e19cb538b1e331afdb32821f15ef1d4b | @commands.has_permissions(administrator=True)
@command.command(name='hide', usage='<COMMAND NAME>')
async def command_hide(self, ctx: commands.Context, *, command_name: str):
"This command will hide commands from the list of commands shown by the help command. It will\n not disable the viewing of the help te... | This command will hide commands from the list of commands shown by the help command. It will
not disable the viewing of the help text for the command if someone already knows it's name.
Commands who have been hidden can be un-hidden with the `command show` command. | core_commands.py | command_hide | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@command.command(name='hide', usage='<COMMAND NAME>')
async def command_hide(self, ctx: commands.Context, *, command_name: str):
"This command will hide commands from the list of commands shown by the help command. It will\n not disable the viewing of the help te... | @commands.has_permissions(administrator=True)
@command.command(name='hide', usage='<COMMAND NAME>')
async def command_hide(self, ctx: commands.Context, *, command_name: str):
"This command will hide commands from the list of commands shown by the help command. It will\n not disable the viewing of the help te... |
bd9353081692a35b328a2e84547034865403ec40d4b376875e7ea9b85cdb1203 | @commands.command(name='about', alias=['info'], usage='(MODULE NAME)')
async def about(self, ctx: commands.Context, *, module_name: str=None):
"This command gives information about modules, such as a description, authors, and other credits. Module\n authors can even add a small image to be displayed alongsid... | This command gives information about modules, such as a description, authors, and other credits. Module
authors can even add a small image to be displayed alongside this info. If no module name is given or the
bot's name is used then information about the bot itself is shown. | core_commands.py | about | Travus/Travus_Bot_Base | 2 | python | @commands.command(name='about', alias=['info'], usage='(MODULE NAME)')
async def about(self, ctx: commands.Context, *, module_name: str=None):
"This command gives information about modules, such as a description, authors, and other credits. Module\n authors can even add a small image to be displayed alongsid... | @commands.command(name='about', alias=['info'], usage='(MODULE NAME)')
async def about(self, ctx: commands.Context, *, module_name: str=None):
"This command gives information about modules, such as a description, authors, and other credits. Module\n authors can even add a small image to be displayed alongsid... |
17c3b294b2f17c40c8d7d58e1be3d553654500373a9ddd93f0fcd0e7b0c9f5ee | @commands.command(name='usage', usage='(MODULE NAME)')
async def usage(self, ctx: commands.Context, *, module_name: str=None):
'This command explains how a module is intended to be used. If no module name is given it will\n show some basic information about usage of the bot itself.'
if ((module_name is N... | This command explains how a module is intended to be used. If no module name is given it will
show some basic information about usage of the bot itself. | core_commands.py | usage | Travus/Travus_Bot_Base | 2 | python | @commands.command(name='usage', usage='(MODULE NAME)')
async def usage(self, ctx: commands.Context, *, module_name: str=None):
'This command explains how a module is intended to be used. If no module name is given it will\n show some basic information about usage of the bot itself.'
if ((module_name is N... | @commands.command(name='usage', usage='(MODULE NAME)')
async def usage(self, ctx: commands.Context, *, module_name: str=None):
'This command explains how a module is intended to be used. If no module name is given it will\n show some basic information about usage of the bot itself.'
if ((module_name is N... |
af9c25ed33a177b44b3adcc039363aca86d1cbd21537bded97755ecf4c8e9303 | @commands.has_permissions(administrator=True)
@commands.group(invoke_without_command=True, name='config', usage='<get/set/unset>')
async def config(self, ctx: commands.Context):
'This command is used to get, set and unset configuration options used by other modules or commands. All\n config options are saves... | This command is used to get, set and unset configuration options used by other modules or commands. All
config options are saves as strings. Converting them to the proper type is up to the module or command that
uses them. See the help text for the subcommands for more info. | core_commands.py | config | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@commands.group(invoke_without_command=True, name='config', usage='<get/set/unset>')
async def config(self, ctx: commands.Context):
'This command is used to get, set and unset configuration options used by other modules or commands. All\n config options are saves... | @commands.has_permissions(administrator=True)
@commands.group(invoke_without_command=True, name='config', usage='<get/set/unset>')
async def config(self, ctx: commands.Context):
'This command is used to get, set and unset configuration options used by other modules or commands. All\n config options are saves... |
9a25e00616faaec6d85e4d24120e311aa4233ae6030c366e78f8b6813577406b | @commands.has_permissions(administrator=True)
@config.command(name='get', usage='<CONFIG_OPTION/all>')
async def config_get(self, ctx: commands.Context, option: str):
'This command is used to get the value of config options. Using this, one can check what configuration\n options are set to. Using the keyword... | This command is used to get the value of config options. Using this, one can check what configuration
options are set to. Using the keyword `all` instead of an option name will print all options and their
values. | core_commands.py | config_get | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@config.command(name='get', usage='<CONFIG_OPTION/all>')
async def config_get(self, ctx: commands.Context, option: str):
'This command is used to get the value of config options. Using this, one can check what configuration\n options are set to. Using the keyword... | @commands.has_permissions(administrator=True)
@config.command(name='get', usage='<CONFIG_OPTION/all>')
async def config_get(self, ctx: commands.Context, option: str):
'This command is used to get the value of config options. Using this, one can check what configuration\n options are set to. Using the keyword... |
d87ab0f5113687dc2865474246b52c3633194516cd6114252c0683232b5798de | @commands.has_permissions(administrator=True)
@config.command(name='set', usage='CONFIG_OPTION> <VALUE>')
async def config_set(self, ctx: commands.Context, option: str, *, value: str):
'This command sets a configuration option. Configuration options are used by other modules or commands.\n Setting an option ... | This command sets a configuration option. Configuration options are used by other modules or commands.
Setting an option which already exists will overwrite the option. Setting an option which does not exist will
create it. The keyword all cannot be used as a configuration option as it is used by the get command to get... | core_commands.py | config_set | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@config.command(name='set', usage='CONFIG_OPTION> <VALUE>')
async def config_set(self, ctx: commands.Context, option: str, *, value: str):
'This command sets a configuration option. Configuration options are used by other modules or commands.\n Setting an option ... | @commands.has_permissions(administrator=True)
@config.command(name='set', usage='CONFIG_OPTION> <VALUE>')
async def config_set(self, ctx: commands.Context, option: str, *, value: str):
'This command sets a configuration option. Configuration options are used by other modules or commands.\n Setting an option ... |
7948e5e94307cd6c6079af149d8e7a7f357f58c1f152ca30463b74d3397e8059 | @commands.has_permissions(administrator=True)
@config.command(name='unset', usage='<CONFIG_OPTION> <VALUE>')
async def config_unset(self, ctx: commands.Context, option: str):
'This command allows for the removal of configuration options. Removing configuration options which are\n required by commands or modu... | This command allows for the removal of configuration options. Removing configuration options which are
required by commands or modules will stop these from working. | core_commands.py | config_unset | Travus/Travus_Bot_Base | 2 | python | @commands.has_permissions(administrator=True)
@config.command(name='unset', usage='<CONFIG_OPTION> <VALUE>')
async def config_unset(self, ctx: commands.Context, option: str):
'This command allows for the removal of configuration options. Removing configuration options which are\n required by commands or modu... | @commands.has_permissions(administrator=True)
@config.command(name='unset', usage='<CONFIG_OPTION> <VALUE>')
async def config_unset(self, ctx: commands.Context, option: str):
'This command allows for the removal of configuration options. Removing configuration options which are\n required by commands or modu... |
a9e56263cae071da584a53397b6526417a9e6b602e8ec664c250057e5aa8d4a0 | @commands.is_owner()
@commands.command(name='shutdown', aliases=['goodbye', 'goodnight'], usage='(TIME BEFORE SHUTDOWN)')
async def shutdown(self, ctx: commands.Context, countdown: str=None):
'This command turns the bot off. A delay can be set causing the bot to wait before shutting down. The time\n uses a f... | This command turns the bot off. A delay can be set causing the bot to wait before shutting down. The time
uses a format of numbers followed by units, see examples for details. Times supported are weeks (w), days (d),
hours (h), minutes (m) and seconds (s), and even negative numbers. For this command the delay must be b... | core_commands.py | shutdown | Travus/Travus_Bot_Base | 2 | python | @commands.is_owner()
@commands.command(name='shutdown', aliases=['goodbye', 'goodnight'], usage='(TIME BEFORE SHUTDOWN)')
async def shutdown(self, ctx: commands.Context, countdown: str=None):
'This command turns the bot off. A delay can be set causing the bot to wait before shutting down. The time\n uses a f... | @commands.is_owner()
@commands.command(name='shutdown', aliases=['goodbye', 'goodnight'], usage='(TIME BEFORE SHUTDOWN)')
async def shutdown(self, ctx: commands.Context, countdown: str=None):
'This command turns the bot off. A delay can be set causing the bot to wait before shutting down. The time\n uses a f... |
b08b40ad2b940c1aefda9259b57b7c58da60aad8724bcad29add63dcbb421a5d | async def load():
'Contains the logic for loading a module.'
if (f'{mod}.py' in listdir('modules')):
self.bot.load_extension(f'modules.{mod}')
(await self.bot.update_command_states())
(await ctx.send(f'Module `{mod_name}` successfully loaded.'))
self.log.info(f"{ctx.author.id}: l... | Contains the logic for loading a module. | core_commands.py | load | Travus/Travus_Bot_Base | 2 | python | async def load():
if (f'{mod}.py' in listdir('modules')):
self.bot.load_extension(f'modules.{mod}')
(await self.bot.update_command_states())
(await ctx.send(f'Module `{mod_name}` successfully loaded.'))
self.log.info(f"{ctx.author.id}: loaded '{mod}' module.")
else:
... | async def load():
if (f'{mod}.py' in listdir('modules')):
self.bot.load_extension(f'modules.{mod}')
(await self.bot.update_command_states())
(await ctx.send(f'Module `{mod_name}` successfully loaded.'))
self.log.info(f"{ctx.author.id}: loaded '{mod}' module.")
else:
... |
09298ab5c419c1b82bb5520a3b4010be1709326558f21855d50f432fe9a4366b | async def unload():
'Contains the logic for unloading a module.'
self.bot.unload_extension(f'modules.{mod}')
(await ctx.send(f'Module `{mod_name}` successfully unloaded.'))
self.log.info(f"{ctx.author.id}: unloaded '{mod}' module.") | Contains the logic for unloading a module. | core_commands.py | unload | Travus/Travus_Bot_Base | 2 | python | async def unload():
self.bot.unload_extension(f'modules.{mod}')
(await ctx.send(f'Module `{mod_name}` successfully unloaded.'))
self.log.info(f"{ctx.author.id}: unloaded '{mod}' module.") | async def unload():
self.bot.unload_extension(f'modules.{mod}')
(await ctx.send(f'Module `{mod_name}` successfully unloaded.'))
self.log.info(f"{ctx.author.id}: unloaded '{mod}' module.")<|docstring|>Contains the logic for unloading a module.<|endoftext|> |
f5d68f2dff9ce094b9000c649f9d61efdd2b6655d6f717c2a0b71d7d705813c1 | async def reload():
'Contains the logic for reloading a module.'
if (f'{mod}.py' in listdir('modules')):
self.bot.reload_extension(f'modules.{mod}')
(await self.bot.update_command_states())
(await ctx.send(f'Module `{mod_name}` successfully reloaded.'))
self.log.info(f"{ctx.autho... | Contains the logic for reloading a module. | core_commands.py | reload | Travus/Travus_Bot_Base | 2 | python | async def reload():
if (f'{mod}.py' in listdir('modules')):
self.bot.reload_extension(f'modules.{mod}')
(await self.bot.update_command_states())
(await ctx.send(f'Module `{mod_name}` successfully reloaded.'))
self.log.info(f"{ctx.author.id}: reloaded '{mod}' module.")
elif (... | async def reload():
if (f'{mod}.py' in listdir('modules')):
self.bot.reload_extension(f'modules.{mod}')
(await self.bot.update_command_states())
(await ctx.send(f'Module `{mod_name}` successfully reloaded.'))
self.log.info(f"{ctx.author.id}: reloaded '{mod}' module.")
elif (... |
9cecccf7a495b0685d93748e868b3a360e2b24053f0e8a093df959ab245bd4d0 | def bprop_to_augm(prim: Primitive, fn: FunctionType) -> Graph:
'Given a function for the bprop, make the augmented function.'
info = NamedDebugInfo(prim=prim, name=prim.name)
bprop = parse(fn)
bprop.debug.name = None
bprop.debug.about = About(info, 'grad_bprop')
bprop.output = bprop.apply(primop... | Given a function for the bprop, make the augmented function. | myia/prim/grad_implementations.py | bprop_to_augm | bartvm/myia | 0 | python | def bprop_to_augm(prim: Primitive, fn: FunctionType) -> Graph:
info = NamedDebugInfo(prim=prim, name=prim.name)
bprop = parse(fn)
bprop.debug.name = None
bprop.debug.about = About(info, 'grad_bprop')
bprop.output = bprop.apply(primops.cons_tuple, (), bprop.output)
(*args, dout) = bprop.para... | def bprop_to_augm(prim: Primitive, fn: FunctionType) -> Graph:
info = NamedDebugInfo(prim=prim, name=prim.name)
bprop = parse(fn)
bprop.debug.name = None
bprop.debug.about = About(info, 'grad_bprop')
bprop.output = bprop.apply(primops.cons_tuple, (), bprop.output)
(*args, dout) = bprop.para... |
b62e292c130902034a191427551f4f6ef1b81f25de0647dfcb095667bd8bcd59 | def register_bprop(prim):
'Register an augmented function for prim, given a backpropagator.'
def deco(fn):
fn2 = bprop_to_augm(prim, fn)
return register(prim)(fn2)
return deco | Register an augmented function for prim, given a backpropagator. | myia/prim/grad_implementations.py | register_bprop | bartvm/myia | 0 | python | def register_bprop(prim):
def deco(fn):
fn2 = bprop_to_augm(prim, fn)
return register(prim)(fn2)
return deco | def register_bprop(prim):
def deco(fn):
fn2 = bprop_to_augm(prim, fn)
return register(prim)(fn2)
return deco<|docstring|>Register an augmented function for prim, given a backpropagator.<|endoftext|> |
96939db84b12397368ddf23d98c9decb95dcb44ac71f2bb3d55e8e7445d47a35 | def register_augm(prim):
'Register an augmented function for prim.'
from ..debug.label import short_labeler, short_relation_symbols as syms
def deco(fn):
fn2 = parse(fn)
for g in manage(fn2, weak=True).graphs:
name = short_labeler.name(g)
name = name.replace('__fprop... | Register an augmented function for prim. | myia/prim/grad_implementations.py | register_augm | bartvm/myia | 0 | python | def register_augm(prim):
from ..debug.label import short_labeler, short_relation_symbols as syms
def deco(fn):
fn2 = parse(fn)
for g in manage(fn2, weak=True).graphs:
name = short_labeler.name(g)
name = name.replace('__fprop__', syms['grad_fprop'])
g.deb... | def register_augm(prim):
from ..debug.label import short_labeler, short_relation_symbols as syms
def deco(fn):
fn2 = parse(fn)
for g in manage(fn2, weak=True).graphs:
name = short_labeler.name(g)
name = name.replace('__fprop__', syms['grad_fprop'])
g.deb... |
6dd0fc47b249b6735b3967037086ed632b688712fb815919015fe58b03850b1d | @register_bprop(primops.add)
def bprop_add(x, y, dz):
'Backpropagator for primitive `add`.'
return (dz, dz) | Backpropagator for primitive `add`. | myia/prim/grad_implementations.py | bprop_add | bartvm/myia | 0 | python | @register_bprop(primops.add)
def bprop_add(x, y, dz):
return (dz, dz) | @register_bprop(primops.add)
def bprop_add(x, y, dz):
return (dz, dz)<|docstring|>Backpropagator for primitive `add`.<|endoftext|> |
df41264269371473ec66fe8cdd722890a53305f4eda40f92839e8f0e54d9ea14 | @register_bprop(primops.sub)
def bprop_sub(x, y, dz):
'Backpropagator for primitive `sub`.'
return (dz, (- dz)) | Backpropagator for primitive `sub`. | myia/prim/grad_implementations.py | bprop_sub | bartvm/myia | 0 | python | @register_bprop(primops.sub)
def bprop_sub(x, y, dz):
return (dz, (- dz)) | @register_bprop(primops.sub)
def bprop_sub(x, y, dz):
return (dz, (- dz))<|docstring|>Backpropagator for primitive `sub`.<|endoftext|> |
22f15a5752fda340e6a5e7a208ace713f956b4b48a80302f41328dc477e73fe8 | @register_bprop(primops.mul)
def bprop_mul(x, y, dz):
'Backpropagator for primitive `mul`.'
return ((dz * y), (dz * x)) | Backpropagator for primitive `mul`. | myia/prim/grad_implementations.py | bprop_mul | bartvm/myia | 0 | python | @register_bprop(primops.mul)
def bprop_mul(x, y, dz):
return ((dz * y), (dz * x)) | @register_bprop(primops.mul)
def bprop_mul(x, y, dz):
return ((dz * y), (dz * x))<|docstring|>Backpropagator for primitive `mul`.<|endoftext|> |
65ae29e6220c279ea99a9a5f5135acb973a985da9043a23d213d881a30d6c92f | @register_bprop(primops.div)
def bprop_div(x, y, dz):
'Backpropagator for primitive `div`.'
return ((dz / y), (((- dz) * x) / (y * y))) | Backpropagator for primitive `div`. | myia/prim/grad_implementations.py | bprop_div | bartvm/myia | 0 | python | @register_bprop(primops.div)
def bprop_div(x, y, dz):
return ((dz / y), (((- dz) * x) / (y * y))) | @register_bprop(primops.div)
def bprop_div(x, y, dz):
return ((dz / y), (((- dz) * x) / (y * y)))<|docstring|>Backpropagator for primitive `div`.<|endoftext|> |
5f1c60b11aecc62d93ac9aae41e6282ca06941d3a9ea0256ab4a5bf5ea5881ce | @register_bprop(primops.pow)
def bprop_pow(x, y, dz):
'Backpropagator for primitive `pow`.'
return ((dz * (y * (x ** (y - 1)))), ((dz * log(x)) * (x ** y))) | Backpropagator for primitive `pow`. | myia/prim/grad_implementations.py | bprop_pow | bartvm/myia | 0 | python | @register_bprop(primops.pow)
def bprop_pow(x, y, dz):
return ((dz * (y * (x ** (y - 1)))), ((dz * log(x)) * (x ** y))) | @register_bprop(primops.pow)
def bprop_pow(x, y, dz):
return ((dz * (y * (x ** (y - 1)))), ((dz * log(x)) * (x ** y)))<|docstring|>Backpropagator for primitive `pow`.<|endoftext|> |
1f4858d954aba856ce091ec6c41dba57d308e15a6ba7987407c14d49642fa952 | @register_bprop(primops.uadd)
def bprop_uadd(x, dz):
'Backpropagator for primitive `uadd`.'
return (dz,) | Backpropagator for primitive `uadd`. | myia/prim/grad_implementations.py | bprop_uadd | bartvm/myia | 0 | python | @register_bprop(primops.uadd)
def bprop_uadd(x, dz):
return (dz,) | @register_bprop(primops.uadd)
def bprop_uadd(x, dz):
return (dz,)<|docstring|>Backpropagator for primitive `uadd`.<|endoftext|> |
3bcf07eeabceacd7b3d1a555bf881fcb7ebbf06e11cb18afb7658e7d4499de4d | @register_bprop(primops.usub)
def bprop_usub(x, dz):
'Backpropagator for primitive `usub`.'
return ((- dz),) | Backpropagator for primitive `usub`. | myia/prim/grad_implementations.py | bprop_usub | bartvm/myia | 0 | python | @register_bprop(primops.usub)
def bprop_usub(x, dz):
return ((- dz),) | @register_bprop(primops.usub)
def bprop_usub(x, dz):
return ((- dz),)<|docstring|>Backpropagator for primitive `usub`.<|endoftext|> |
1729e4ee7f5077b3faf3c85bd26a90e4ea5c1210d100a477aa99a3e7c6c138a1 | @register_bprop(primops.gt)
def bprop_gt(x, y, dz):
'Backpropagator for primitive `gt`.'
return (zeros_like(x), zeros_like(y)) | Backpropagator for primitive `gt`. | myia/prim/grad_implementations.py | bprop_gt | bartvm/myia | 0 | python | @register_bprop(primops.gt)
def bprop_gt(x, y, dz):
return (zeros_like(x), zeros_like(y)) | @register_bprop(primops.gt)
def bprop_gt(x, y, dz):
return (zeros_like(x), zeros_like(y))<|docstring|>Backpropagator for primitive `gt`.<|endoftext|> |
dbca8e8c466106c629172ba39f95ef0961c7b5b050b42e4330aeee750ec06c8f | @register_bprop(primops.lt)
def bprop_lt(x, y, dz):
'Backpropagator for primitive `lt`.'
return (zeros_like(x), zeros_like(y)) | Backpropagator for primitive `lt`. | myia/prim/grad_implementations.py | bprop_lt | bartvm/myia | 0 | python | @register_bprop(primops.lt)
def bprop_lt(x, y, dz):
return (zeros_like(x), zeros_like(y)) | @register_bprop(primops.lt)
def bprop_lt(x, y, dz):
return (zeros_like(x), zeros_like(y))<|docstring|>Backpropagator for primitive `lt`.<|endoftext|> |
285b9cf89c4ec201671af49e15758b6054c491bf76405f36c247d1368a533259 | @register_bprop(primops.ge)
def bprop_ge(x, y, dz):
'Backpropagator for primitive `ge`.'
return (zeros_like(x), zeros_like(y)) | Backpropagator for primitive `ge`. | myia/prim/grad_implementations.py | bprop_ge | bartvm/myia | 0 | python | @register_bprop(primops.ge)
def bprop_ge(x, y, dz):
return (zeros_like(x), zeros_like(y)) | @register_bprop(primops.ge)
def bprop_ge(x, y, dz):
return (zeros_like(x), zeros_like(y))<|docstring|>Backpropagator for primitive `ge`.<|endoftext|> |
8c504a673a4fe67c626b9baec94df5a13541a6f010efc795b785faf3d5361b86 | @register_bprop(primops.le)
def bprop_le(x, y, dz):
'Backpropagator for primitive `le`.'
return (zeros_like(x), zeros_like(y)) | Backpropagator for primitive `le`. | myia/prim/grad_implementations.py | bprop_le | bartvm/myia | 0 | python | @register_bprop(primops.le)
def bprop_le(x, y, dz):
return (zeros_like(x), zeros_like(y)) | @register_bprop(primops.le)
def bprop_le(x, y, dz):
return (zeros_like(x), zeros_like(y))<|docstring|>Backpropagator for primitive `le`.<|endoftext|> |
569ebc58063d69c471bf914cd45799007882334d2a74b5c991f817be1eb68a77 | @register_bprop(primops.cons_tuple)
def bprop_cons_tuple(_head, _tail, dz):
'Backpropagator for primitive `cons_tuple`.'
return (head(dz), tail(dz)) | Backpropagator for primitive `cons_tuple`. | myia/prim/grad_implementations.py | bprop_cons_tuple | bartvm/myia | 0 | python | @register_bprop(primops.cons_tuple)
def bprop_cons_tuple(_head, _tail, dz):
return (head(dz), tail(dz)) | @register_bprop(primops.cons_tuple)
def bprop_cons_tuple(_head, _tail, dz):
return (head(dz), tail(dz))<|docstring|>Backpropagator for primitive `cons_tuple`.<|endoftext|> |
33772793c95a270dddf794f230d5cf142dd16bc9b6e081aa1e71980cdf128c96 | @register_bprop(primops.head)
def bprop_head(tup, dz):
'Backpropagator for primitive `head`.'
return (cons_tuple(dz, zeros_like(tail(tup))),) | Backpropagator for primitive `head`. | myia/prim/grad_implementations.py | bprop_head | bartvm/myia | 0 | python | @register_bprop(primops.head)
def bprop_head(tup, dz):
return (cons_tuple(dz, zeros_like(tail(tup))),) | @register_bprop(primops.head)
def bprop_head(tup, dz):
return (cons_tuple(dz, zeros_like(tail(tup))),)<|docstring|>Backpropagator for primitive `head`.<|endoftext|> |
f3bc52846fd81fd7c3b215e978e6033c9ee14831972731b496811e8573053c11 | @register_bprop(primops.tail)
def bprop_tail(tup, dz):
'Backpropagator for primitive `tail`.'
return (cons_tuple(zeros_like(head(tup)), dz),) | Backpropagator for primitive `tail`. | myia/prim/grad_implementations.py | bprop_tail | bartvm/myia | 0 | python | @register_bprop(primops.tail)
def bprop_tail(tup, dz):
return (cons_tuple(zeros_like(head(tup)), dz),) | @register_bprop(primops.tail)
def bprop_tail(tup, dz):
return (cons_tuple(zeros_like(head(tup)), dz),)<|docstring|>Backpropagator for primitive `tail`.<|endoftext|> |
ad6fc2d8cfed7da397a1964a3cf0dfd4fc306f488129cea8ed6d7c8bef13d1f2 | @register_bprop(primops.getitem)
def bprop_getitem(data, idx, dz):
'Backpropagator for primitive `getitem`.'
return (setitem(zeros_like(data), idx, dz), zeros_like(idx)) | Backpropagator for primitive `getitem`. | myia/prim/grad_implementations.py | bprop_getitem | bartvm/myia | 0 | python | @register_bprop(primops.getitem)
def bprop_getitem(data, idx, dz):
return (setitem(zeros_like(data), idx, dz), zeros_like(idx)) | @register_bprop(primops.getitem)
def bprop_getitem(data, idx, dz):
return (setitem(zeros_like(data), idx, dz), zeros_like(idx))<|docstring|>Backpropagator for primitive `getitem`.<|endoftext|> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.