code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def cli(family_file, family_type, to_json, to_madeline, to_ped, to_dict,
outfile, logfile, loglevel):
from pprint import pprint as pp
my_parser = FamilyParser(family_file, family_type)
if to_json:
if outfile:
outfile.write(my_parser.to_json())
else:
print(my_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12']}; {'id': '4', 'type': 'identifi... | Cli for testing the ped parser. |
def view_admin_log():
build = g.build
log_list = (
models.AdminLog.query
.filter_by(build_id=build.id)
.order_by(models.AdminLog.created.desc())
.all())
return render_template(
'view_admin_log.html',
build=build,
log_list=log_list) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'view_admin_log'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '46']}; {'id... | Page for viewing the log of admin activity. |
def caesar_app(parser, cmd, args):
parser.add_argument('shift', type=int, help='the shift to apply')
parser.add_argument('value', help='the value to caesar crypt, read from stdin if omitted', nargs='?')
parser.add_argument(
'-s', '--shift-range',
dest='shift_ranges',
action='append',... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'caesar_app'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Caesar crypt a value with a key. |
def close(self):
if self._closing or self._handle.closed:
return
elif self._protocol is None:
raise TransportError('transport not started')
if self._write_buffer_size == 0:
self._handle.close(self._on_close_complete)
assert self._handle.closed
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Close the transport after all oustanding data has been written. |
def gas_price_strategy_middleware(make_request, web3):
def middleware(method, params):
if method == 'eth_sendTransaction':
transaction = params[0]
if 'gasPrice' not in transaction:
generated_gas_price = web3.eth.generateGasPrice(transaction)
if generat... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gas_price_strategy_middleware'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'childre... | Includes a gas price using the gas price strategy |
def _validate_and_parse_course_key(self, course_key):
try:
return CourseKey.from_string(course_key)
except InvalidKeyError:
raise ValidationError(_("Invalid course key: {}").format(course_key)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate_and_parse_course_key'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'childr... | Returns a validated parsed CourseKey deserialized from the given course_key. |
def __add_item(self, item, keys=None):
if(not keys or not len(keys)):
raise Exception('Error in %s.__add_item(%s, keys=tuple/list of items): need to specify a tuple/list containing at least one key!'
% (self.__class__.__name__, str(item)))
direct_key = tuple(k... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__add_item'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Internal method to add an item to the multi-key dictionary |
def clear(self):
self.__modified_data__ = {}
self.__deleted_fields__ = [field for field in self.__original_data__.keys()] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Clears all the data in the object, keeping original data |
def getDownloader(self, url):
filename = self.namer(url, self.stripUrl)
if filename is None:
filename = url.rsplit('/', 1)[1]
dirname = getDirname(self.name)
return ComicImage(self.name, url, self.stripUrl, dirname, filename, self.session, text=self.text) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getDownloader'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Get an image downloader. |
def validate(self, password, user=None):
user_inputs = []
if user is not None:
for attribute in self.user_attributes:
if hasattr(user, attribute):
user_inputs.append(getattr(user, attribute))
results = zxcvbn(password, user_inputs=user_inputs)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Validate method, run zxcvbn and check score. |
def getLogger(name):
log = logging.getLogger(name)
log.addHandler(_NullHandler())
return log | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getLogger'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'};... | Create and return a logger with the specified name. |
def find_one(self, cls, id):
found = self.find_by_index(cls, 'id', id)
return found[0] if found else None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_one'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Find single keyed row - as per the gludb spec. |
def detect_lang(path):
blob = FileBlob(path, os.getcwd())
if blob.is_text:
print('Programming language of the file detected: {0}'.format(blob.language.name))
return blob.language.name
else:
print('File not a text file. Exiting...')
sys.exit() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'detect_lang'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'... | Detect the language used in the given file. |
def show_bandwidth_limit_rule(self, rule, policy, body=None):
return self.get(self.qos_bandwidth_limit_rule_path %
(policy, rule), body=body) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_bandwidth_limit_rule'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', '... | Fetches information of a certain bandwidth limit rule. |
def all_collections(db):
include_pattern = r'(?!system\.)'
return (
db[name]
for name in db.list_collection_names()
if re.match(include_pattern, name)
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all_collections'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'd... | Yield all non-sytem collections in db. |
def database_current_migration(self):
if not self.migration_table.exists(self.session.bind):
return None
if self.migration_data is None:
return None
return self.migration_data.version | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'database_current_migration'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Return the current migration in the database. |
def _check_file_io(self):
folder = 'Model' + str(self.flags['RUN_NUM']) + '/'
folder_restore = 'Model' + str(self.flags['MODEL_RESTORE']) + '/'
self.flags['RESTORE_DIRECTORY'] = self.flags['SAVE_DIRECTORY'] + self.flags[
'MODEL_DIRECTORY'] + folder_restore
self.flags['LOGGING... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_file_io'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Create and define logging directory |
def image(self):
if self._image is None:
self._populate_from_rasterio_object(read_image=True)
return self._image | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'image'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Raster bitmap in numpy array. |
def cli(location, **kwargs):
locations = []
try:
for line in fileinput.input():
locations.append(line.strip())
except:
pass
for item in location:
if os.path.exists(item):
with open(item, 'rb') as f:
locations += f.read().splitlines()
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'location... | Geocode an arbitrary number of strings from Command Line. |
def as_python(self, name: str) -> str:
if self._map_valuetype:
return self.map_as_python(name)
else:
return self.obj_as_python(name) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'as_python'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Return the python representation of the class represented by this object |
def _unpack_lookupswitch(bc, offset):
jump = (offset % 4)
if jump:
offset += (4 - jump)
(default, npairs), offset = _unpack(_struct_ii, bc, offset)
switches = list()
for _index in range(npairs):
pair, offset = _unpack(_struct_ii, bc, offset)
switches.append(pair)
return (... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_unpack_lookupswitch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | function for unpacking the lookupswitch op arguments |
def import_description(text):
xml = ''
is_in_ul = False
for line in text.split('\n'):
line = line.strip()
if len(line) == 0:
continue
line_li = _import_description_to_list_element(line)
if line_li:
if not is_in_ul:
xml += '<ul>\n'
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_description'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Convert ASCII text to AppStream markup format |
def to_dict(self):
d = super(TargetExecutionContext, self).to_dict()
d['id'] = self.id
return d | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Save this target execution context into a dictionary. |
def delete(request, obj_id=None):
data = request.DELETE or json.loads(request.body)
guids = data.get('guids').split(',')
objects = getObjectsFromGuids(guids)
gallery = Gallery.objects.get(pk=obj_id)
LOGGER.info('{} removed {} from {}'.format(request.user.email, guids, gallery))
for o in objects:... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'reque... | Removes ImageVideo objects from Gallery |
def delete_source(ident):
source = get_source(ident)
source.deleted = datetime.now()
source.save()
signals.harvest_source_deleted.send(source)
return source | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_source'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ide... | Delete an harvest source |
def scale(self, scale_xy):
"Returns the pix object rescaled according to the proportions given."
with _LeptonicaErrorTrap():
return Pix(lept.pixScale(self._cdata, scale_xy[0], scale_xy[1])) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scale'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Returns the pix object rescaled according to the proportions given. |
def first_n_items(array, n_desired):
if n_desired < 1:
raise ValueError('must request at least one item')
if array.size == 0:
return []
if n_desired < array.size:
indexer = _get_indexer_at_least_n_items(array.shape, n_desired,
from_end=... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'first_n_items'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Returns the first n_desired items of an array |
def rowkey(self, row):
'returns a tuple of the key for the given row'
return tuple(c.getTypedValueOrException(row) for c in self.keyCols) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rowkey'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | returns a tuple of the key for the given row |
def accel_decrease_transparency(self, *args):
transparency = self.settings.styleBackground.get_int('transparency')
if int(transparency) + 2 < MAX_TRANSPARENCY:
self.settings.styleBackground.set_int('transparency', int(transparency) + 2)
return True | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'accel_decrease_transparency'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children'... | Callback to decrease transparency. |
def handle(self, *args, **options):
for plan_data in Plan.api_list():
plan = Plan.sync_from_stripe_data(plan_data)
print("Synchronized plan {0}".format(plan.id)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Call sync_from_stripe_data for each plan returned by api_list. |
def CalcRad(lat):
"Radius of curvature in meters at specified latitude."
a = 6378.137
e2 = 0.081082 * 0.081082
sc = math.sin(Deg2Rad(lat))
x = a * (1.0 - e2)
z = 1.0 - e2 * sc * sc
y = pow(z, 1.5)
r = x / y
r = r * 1000.0
return r | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'CalcRad'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'... | Radius of curvature in meters at specified latitude. |
def emitCurrentChanged(self):
if not self.signalsBlocked():
self.currentIndexChanged.emit(self.currentIndex())
self.currentUrlChanged.emit(self.currentUrl())
self.canGoBackChanged.emit(self.canGoBack())
self.canGoForwardChanged.emit(self.canGoForward()) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'emitCurrentChanged'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Emits the current index changed signal provided signals are not blocked. |
def _find_fuzzy_line(
py_line_no, py_by_line_no, cheetah_by_line_no, prefer_first
):
stripped_line = _fuzz_py_line(py_by_line_no[py_line_no])
cheetah_lower_bound, cheetah_upper_bound = _find_bounds(
py_line_no, py_by_line_no, cheetah_by_line_no,
)
sliced = list(enumerate(cheetah_by_line_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_fuzzy_line'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children':... | Attempt to fuzzily find matching lines. |
def set(self, val):
msg = ExtendedSend(
address=self._address,
commandtuple=COMMAND_THERMOSTAT_SET_HEAT_SETPOINT_0X6D_NONE,
cmd2=int(val * 2),
userdata=Userdata())
msg.set_checksum()
self._send_method(msg, self._set_heat_point_ack) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Set the heat set point. |
def on(self):
on_command = ExtendedSend(self._address,
COMMAND_LIGHT_ON_0X11_NONE,
self._udata,
cmd2=0xff)
on_command.set_checksum()
self._send_method(on_command, self._on_message_received) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id':... | Send an ON message to device group. |
def add_soup(response, soup_config):
if ("text/html" in response.headers.get("Content-Type", "") or
Browser.__looks_like_html(response)):
response.soup = bs4.BeautifulSoup(response.content, **soup_config)
else:
response.soup = None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_soup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'res... | Attaches a soup object to a requests response. |
def help(self):
result = [
'=' * 50,
self.name
]
if self.doc:
result.extend([
'=' * 30,
self.doc
])
override = self.overrides
while override:
if isinstance(override, Shovel):
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'help'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Return the help string of the task |
def _get_cores_and_type(numcores, paralleltype, scheduler):
if scheduler is not None:
paralleltype = "ipython"
if paralleltype is None:
paralleltype = "local"
if not numcores or int(numcores) < 1:
numcores = 1
return paralleltype, int(numcores) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_cores_and_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [... | Return core and parallelization approach from command line providing sane defaults. |
def clean(self):
if not self.metrics:
self.metrics = dict(
(name, spec.default)
for name, spec in (metric_catalog.get(self.__class__, {})
.items()))
return super(WithMetrics, self).clean() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Fill metrics with defaults on create |
def main(argv: Optional[Sequence[str]] = None) -> None:
parser = ArgumentParser(description="Convert Jupyter Notebook exams to PDFs")
parser.add_argument(
"--exam",
type=int,
required=True,
help="Exam number to convert",
dest="exam_num",
)
parser.add_argument(
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_default_parameter', 'children': ['5', ... | Parse arguments and process the exam assignment. |
def add_package(self, package):
self._data.setdefault('packages', {})
self._data['packages'][package.name] = package.source
for package in package.deploy_packages:
self.add_package(package)
self._save() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_package'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Add a package to this project |
def experimental(name=None):
def inner(func):
@functools.wraps(func)
def wrapper(*fargs, **kw):
fname = name
if name is None:
fname = func.__name__
warnings.warn("%s" % fname, category=ExperimentalWarning,
stacklevel=2)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'experimental'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}... | A simple decorator to mark functions and methods as experimental. |
def read_plain_float(file_obj, count):
return struct.unpack("<{}f".format(count).encode("utf-8"), file_obj.read(4 * count)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_plain_float'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Read `count` 32-bit floats using the plain encoding. |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 19