text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: notmatthancock/pylidc path: /pylidc/Scan.py
orted_dicom_file_names']
class Scan(Base):
"""
The Scan model class refers to the top-level XML file from the LIDC.
A scan has many :class:`pylidc.Annotation` objects, which correspond
to the `unblindedReadNodule` XML attributes for th... | code_fim | hard | {
"lang": "python",
"repo": "notmatthancock/pylidc",
"path": "/pylidc/Scan.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tol = self.slice_thickness if tol is None else tol
assert tol >= 0, "`tol` should be >= 0."
# Some special cases.
if N == 0:
return []
elif N == 1:
return [[self.annotations[0]]]
D = np.zeros((N,N)) # The distance matrix.
... | code_fim | hard | {
"lang": "python",
"repo": "notmatthancock/pylidc",
"path": "/pylidc/Scan.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> min_tol: float, default=0.1
If `tol` is reduced below `min_tol` (see the `factor` parameter),
then the routine exits because we conclude that the annotation
groups cannot be automatically reduced to have groups
with each group having `Annotations<=... | code_fim | hard | {
"lang": "python",
"repo": "notmatthancock/pylidc",
"path": "/pylidc/Scan.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ccampo133/coding-challenges path: /python/src/project-euler/2020/14.py
def collatz_func(n):
if n % 2 == 0:
return n // 2
return 3 * n + 1
<|fim_suffix|> max_len, num = 0, max_start
for i in range(max_start, 0, -1):
seq = sequence(i)
if len(seq) > max_len:
... | code_fim | medium | {
"lang": "python",
"repo": "ccampo133/coding-challenges",
"path": "/python/src/project-euler/2020/14.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> max_len, num = 0, max_start
for i in range(max_start, 0, -1):
seq = sequence(i)
if len(seq) > max_len:
max_len = len(seq)
num = i
return num
if __name__ == '__main__':
print(longest_chain(1000000))<|fim_prefix|># repo: ccampo133/coding-challenges ... | code_fim | medium | {
"lang": "python",
"repo": "ccampo133/coding-challenges",
"path": "/python/src/project-euler/2020/14.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oliver/timeplot path: /event.py
#
# Provides a global object (EventMgr) for accessing the global event loop.
#
class _EventClass:
def setImpl (self, impl):
<|fim_suffix|> def watchFd (self, fd, callback):
return self.impl.watchFd(fd, callback)
EventMgr = _EventClass()<|fim_middl... | code_fim | hard | {
"lang": "python",
"repo": "oliver/timeplot",
"path": "/event.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.impl.watchFd(fd, callback)
EventMgr = _EventClass()<|fim_prefix|># repo: oliver/timeplot path: /event.py
#
# Provides a global object (EventMgr) for accessing the global event loop.
#
class _EventClass:
def setImpl (self, impl):
self.impl = impl
def startTimer (sel... | code_fim | medium | {
"lang": "python",
"repo": "oliver/timeplot",
"path": "/event.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>register = template.Library()
ldr = loader.Loader()
@register.simple_tag
def render_bundle():
bundle_name = settings.CLJS_LOADER['CLJS_BUILD'].name
bundle = ldr.get_bundle(bundle_name)
tag = utils.to_tag(bundle)
return mark_safe(tag)<|fim_prefix|># repo: jstaffans/django-cljs-loader pat... | code_fim | easy | {
"lang": "python",
"repo": "jstaffans/django-cljs-loader",
"path": "/cljs_loader/templatetags/cljs_loader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@register.simple_tag
def render_bundle():
bundle_name = settings.CLJS_LOADER['CLJS_BUILD'].name
bundle = ldr.get_bundle(bundle_name)
tag = utils.to_tag(bundle)
return mark_safe(tag)<|fim_prefix|># repo: jstaffans/django-cljs-loader path: /cljs_loader/templatetags/cljs_loader.py
from djang... | code_fim | medium | {
"lang": "python",
"repo": "jstaffans/django-cljs-loader",
"path": "/cljs_loader/templatetags/cljs_loader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jstaffans/django-cljs-loader path: /cljs_loader/templatetags/cljs_loader.py
from django import template
from django.conf import settings
from django.utils.safestring import mark_safe
from cljs_loader import loader, utils
<|fim_suffix|> bundle_name = settings.CLJS_LOADER['CLJS_BUILD'].name
... | code_fim | medium | {
"lang": "python",
"repo": "jstaffans/django-cljs-loader",
"path": "/cljs_loader/templatetags/cljs_loader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> collatz_seq[collatz_number] = ctr
return ctr
if __name__ == '__main__':
start_time = time.time()
max_limit = 1000000
max_collatz_number = 1
max_counter = 0
for i in range(1, max_limit):
counter = colatz_counter(i)
if counter > max_counter:
max... | code_fim | hard | {
"lang": "python",
"repo": "vidyabhandary/projecteuler",
"path": "/src/problem14.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vidyabhandary/projecteuler path: /src/problem14.py
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 29 12:04:02 2019
@author: Vidya
Solution to Project Euler problem 14
https://projecteuler.net/problem=14
Problem Statement :
>>>>>>>>>>> Longest Collatz sequence
The following iterative seq... | code_fim | hard | {
"lang": "python",
"repo": "vidyabhandary/projecteuler",
"path": "/src/problem14.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xalien10/pyfortnox path: /fortnox/services/cost_center_services.py
class CostCenterService(object):
"""
:class:`fortnox.CostCenterService` is used by :class:`fortnox.Client` to make
actions related to CostCenter resource.
Normally you won't instantiate this class directly.
""... | code_fim | hard | {
"lang": "python",
"repo": "xalien10/pyfortnox",
"path": "/fortnox/services/cost_center_services.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Updates a CostCenter's information
If the specified CostCenter does not exist, this query will return an error
**Notice** if you want to update a CostCenter, you **must** make sure the CostCenter's name is unique within the scope of the specified resource
:calls: ``put /co... | code_fim | hard | {
"lang": "python",
"repo": "xalien10/pyfortnox",
"path": "/fortnox/services/cost_center_services.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :calls: ``put /costcenters/{code}``
:param int id: Unique identifier of a CostCenter.
:param tuple *args: (optional) Single object representing CostCenter resource which attributes should be updated.
:param dict **kwargs: (optional) CostCenter attributes to update.
... | code_fim | hard | {
"lang": "python",
"repo": "xalien10/pyfortnox",
"path": "/fortnox/services/cost_center_services.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_pyramid_shapes_map(self):
shape = list(self.shape)
level = 0
shapes_map = {level: shape}
last_level = False
while not last_level:
old_shape = shapes_map[level]
max_dim = max(old_shape)
closest_power = self.closest_po... | code_fim | hard | {
"lang": "python",
"repo": "fepegar/pyblock",
"path": "/volume.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fepegar/pyblock path: /volume.py
from pathlib import Path
import numpy as np
import nibabel as nib
import matplotlib.pyplot as plt
class Volume:
def __init__(self, path):
self.path = Path(path)
self.nifti = nib.load(str(self.path))
self.data = self.nifti.get_fdata()... | code_fim | medium | {
"lang": "python",
"repo": "fepegar/pyblock",
"path": "/volume.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_pyramid_shapes_map(self):
shape = list(self.shape)
level = 0
shapes_map = {level: shape}
last_level = False
while not last_level:
old_shape = shapes_map[level]
max_dim = max(old_shape)
closest_power = self.closest_p... | code_fim | hard | {
"lang": "python",
"repo": "fepegar/pyblock",
"path": "/volume.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SDRAST/Astronomy path: /IAU_names.py
# -*- coding: utf-8 -*-
"""
module IAU_names - IAU source name conversion and matching
IAU source nomenclature rules are here:
http://cdsweb.u-strasbg.fr/Dic/iau-spec.html
Coordinate based IAU source names can have the following forms. Lowercase
letters ind... | code_fim | hard | {
"lang": "python",
"repo": "SDRAST/Astronomy",
"path": "/IAU_names.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def parse_IAU_name(name):
"""
Parse an IAU source designation.
@param name : IAU source name
@type name : str
@return: (flag letter, x-coordinate, y-coordinate)
"""
# First see if there is a source type acronym
if diag:
print "parse_IAU_name: received",name
parts = name.split()
... | code_fim | hard | {
"lang": "python",
"repo": "SDRAST/Astronomy",
"path": "/IAU_names.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kwienken/softlayer-python path: /tests/CLI/modules/vs_tests.py
= {
'hostname': 'vs-test-like',
'domain': 'test.sftlyr.ws',
'maxCpu': 2,
'maxMemory': 1024,
'datacenter': {'name': 'dal05'},
'networkComponents': [{'maxSpeed': 10... | code_fim | hard | {
"lang": "python",
"repo": "kwienken/softlayer-python",
"path": "/tests/CLI/modules/vs_tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @mock.patch('SoftLayer.CLI.formatting.confirm')
def test_dns_sync_edit_a(self, confirm_mock):
confirm_mock.return_value = True
getResourceRecords = self.set_mock('SoftLayer_Dns_Domain',
'getResourceRecords')
getResourceRecords.retu... | code_fim | hard | {
"lang": "python",
"repo": "kwienken/softlayer-python",
"path": "/tests/CLI/modules/vs_tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kwienken/softlayer-python path: /tests/CLI/modules/vs_tests.py
t)
self.assertEqual(json.loads(result.output),
[{'datacenter': 'TEST00',
'primary_ip': '172.16.240.2',
'hostname': 'vs-test1',
... | code_fim | hard | {
"lang": "python",
"repo": "kwienken/softlayer-python",
"path": "/tests/CLI/modules/vs_tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: design-automation/video-generator path: /vid_generator.py
import glob
import argparse
import traceback
import sys, os
from vid_gen._movie_to_polly import *
from vid_gen._pptx_to_video import pptx_to_ingreds
from vid_gen._polly_JSON import VidsJSON, Video
from vid_gen._get_by_type import *
from vi... | code_fim | hard | {
"lang": "python",
"repo": "design-automation/video-generator",
"path": "/vid_generator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unit = unit[:-1]
vid_files = get_paths_by_typ(unit, "pptx")
vid_files.extend(get_paths_by_typ(unit, "mp4"))
if vid_files == None:
continue
json_path = os.path.join(unit, "videos.json... | code_fim | hard | {
"lang": "python",
"repo": "design-automation/video-generator",
"path": "/vid_generator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zichuan-scott-xu/automl-workflow path: /examples/DeepWisdom/Auto_Tabular/utils/sample.py
import numpy as np
import random
import os
from .eda import AutoEDA
from .data_utils import ohe2cat
from .log_utils import info, debug
class AutoSample:
def __init__(self, y_onehot):
self.auto_ed... | code_fim | hard | {
"lang": "python",
"repo": "zichuan-scott-xu/automl-workflow",
"path": "/examples/DeepWisdom/Auto_Tabular/utils/sample.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """获取每个类的索引"""
class_idx = {}
idx = np.arange(self.sample_num)
for i in range(self.class_num):
idx_list = idx[self.y_onehot[:,i] == 1]
class_idx[i] = list(idx_list)
return class_idx
def sample_fix_size_by_class(self, per_class_num, max_s... | code_fim | hard | {
"lang": "python",
"repo": "zichuan-scott-xu/automl-workflow",
"path": "/examples/DeepWisdom/Auto_Tabular/utils/sample.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scikit-hep/decaylanguage path: /src/decaylanguage/utils/__init__.py
# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/decaylanguage for details.
<|fim_suffix|>from .er... | code_fim | medium | {
"lang": "python",
"repo": "scikit-hep/decaylanguage",
"path": "/src/decaylanguage/utils/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>__all__ = (
"DescriptorFormat",
"LineFailure",
"iter_flatten",
"split",
"filter_lines",
"charge_conjugate_name",
)
def __dir__() -> tuple[str, ...]:
return __all__<|fim_prefix|># repo: scikit-hep/decaylanguage path: /src/decaylanguage/utils/__init__.py
# Copyright (c) 2018-2... | code_fim | hard | {
"lang": "python",
"repo": "scikit-hep/decaylanguage",
"path": "/src/decaylanguage/utils/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NYPL-Simplified/circulation path: /core/opds2_import.py
subject_metadata = SubjectData(
type=subject_type, identifier=subject.code, name=subject.name, weight=1
)
subject_metadata_list.append(subject_metadata)
self._logger.debug(
... | code_fim | hard | {
"lang": "python",
"repo": "NYPL-Simplified/circulation",
"path": "/core/opds2_import.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NYPL-Simplified/circulation path: /core/opds2_import.py
ributors: Parsed contributor object
:type contributors: List[core_ast.Contributor]
:param default_role: Default role
:type default_role: Optional[str]
:return: List of contributors metadata
:rtype: L... | code_fim | hard | {
"lang": "python",
"repo": "NYPL-Simplified/circulation",
"path": "/core/opds2_import.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> formats = self._find_formats_in_non_open_access_acquisition_links(
publication.links, links, rights_uri, circulation_data
)
circulation_data.formats.extend(formats)
metadata = Metadata(
data_source=data_source_name,
title=title,
... | code_fim | hard | {
"lang": "python",
"repo": "NYPL-Simplified/circulation",
"path": "/core/opds2_import.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mahabharathi/JPG-to-PNG-converter path: /PDFMerger.py
from PyPDF2 import PdfFileReader, PdfFileWriter, PdfFileMerger
import os
import sys
<|fim_suffix|> #current_directory
current_directory = os.getcwd()
pdf_path=os.path.join(current_directory, 'pdfFiles\\')
merger=PdfFileMerger(... | code_fim | easy | {
"lang": "python",
"repo": "mahabharathi/JPG-to-PNG-converter",
"path": "/PDFMerger.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #current_directory
current_directory = os.getcwd()
pdf_path=os.path.join(current_directory, 'pdfFiles\\')
merger=PdfFileMerger()
for pdf in pdf_list:
print(pdf,pdf_path)
merger.append(pdf_path+pdf)
merger.write('pdfFiles\merged.pdf')
pdfCombine(imputs)<|fi... | code_fim | easy | {
"lang": "python",
"repo": "mahabharathi/JPG-to-PNG-converter",
"path": "/PDFMerger.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kdonbekci/olympus path: /src/fitness.py
from helpers import MathOperations, Distributions
class Fitness:
def __init__(self):
self.history = []
def add_fitness_record(self, record):
self.history.append(record)
def __lt__(self, other):
assert not self.is_emtp... | code_fim | medium | {
"lang": "python",
"repo": "kdonbekci/olympus",
"path": "/src/fitness.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def clear(self):
self.history = []
def __repr__(self):
return '<Fitness-histrory:{}>'.format(self.history)
def fitness_tests():
pass
if __name__ == '__main__':
fitness_tests()<|fim_prefix|># repo: kdonbekci/olympus path: /src/fitness.py
from helpers import MathOperations... | code_fim | hard | {
"lang": "python",
"repo": "kdonbekci/olympus",
"path": "/src/fitness.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return '<Fitness-histrory:{}>'.format(self.history)
def fitness_tests():
pass
if __name__ == '__main__':
fitness_tests()<|fim_prefix|># repo: kdonbekci/olympus path: /src/fitness.py
from helpers import MathOperations, Distributions
class Fitness:
def __init__(self):
self.hi... | code_fim | medium | {
"lang": "python",
"repo": "kdonbekci/olympus",
"path": "/src/fitness.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
data = self.m_socket.recv(1024) # read from socket
# delete \r and \n line's ending
data=data.replace("\r","")
data=data.replace("\n","")
#get data for constructing the Message objet.
tabData=data.split(":")
... | code_fim | hard | {
"lang": "python",
"repo": "twpDone/SimpleAsIRC",
"path": "/Core.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # if the server sends a ping, ping back => send pong
if data.upper().__contains__("PING"):
self.m_socket.sendall('PONG\r\n')
except Exception as ex:
print("Erreur de reception")
print(ex)
##
# Ends the IRC protocol
# @no... | code_fim | hard | {
"lang": "python",
"repo": "twpDone/SimpleAsIRC",
"path": "/Core.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: twpDone/SimpleAsIRC path: /Core.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
# Core of the application, implement a part of the RFC 1459: Internet Relay Chat ProtocolA (Client side).
from Message import Message
from Action import Action
import socket
import string
import re
import time
#ssl... | code_fim | hard | {
"lang": "python",
"repo": "twpDone/SimpleAsIRC",
"path": "/Core.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Sometimes two different sections of a log will match a supplied time range. For example, the log file goes from Feb
# 12 06:30 to Feb 13 07:00, and the user asks for logs with timestamp 6:50. That's in both the Feb 12 and Feb 13 parts
# of the file. How do you want these seperated when they're pri... | code_fim | hard | {
"lang": "python",
"repo": "cole-brown/tgrep",
"path": "/config.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#----------------------------------------------------------------------------------------------------------------------
# stats: This is what you get when you use -v
#----------------------------------------------------------------------------------------------------------------------
stats = Statistics(... | code_fim | hard | {
"lang": "python",
"repo": "cole-brown/tgrep",
"path": "/config.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cole-brown/tgrep path: /config.py
####
###
##
# Don't delete stuff unless you want an error...
##
###
####
from extra import Configuration, Statistics
###
# Gentlemen, set your window width to 120 characters. You have been warned.
###
#---------------------------------------------------------... | code_fim | hard | {
"lang": "python",
"repo": "cole-brown/tgrep",
"path": "/config.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: emilyemorehouse/ast-and-me path: /code/tmp_rtrip/test/test_wait3.py
"""This test checks for correct wait3() behavior.
"""
import os
import time
import unittest
from test.fork_wait import ForkWait
from test.support import reap_children
if not hasattr(os, 'fork'):
raise unittest.SkipTest('os.fo... | code_fim | hard | {
"lang": "python",
"repo": "emilyemorehouse/ast-and-me",
"path": "/code/tmp_rtrip/test/test_wait3.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def wait_impl(self, cpid):
deadline = time.monotonic() + 10.0
while time.monotonic() <= deadline:
spid, status, rusage = os.wait3(os.WNOHANG)
if spid == cpid:
break
time.sleep(0.1)
self.assertEqual(spid, cpid)
self.ass... | code_fim | medium | {
"lang": "python",
"repo": "emilyemorehouse/ast-and-me",
"path": "/code/tmp_rtrip/test/test_wait3.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def tearDownModule():
reap_children()
if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: emilyemorehouse/ast-and-me path: /code/tmp_rtrip/test/test_wait3.py
"""This test checks for correct wait3() behavior.
"""
import os
import time
import unittest
from test.fork_wait import ForkWa... | code_fim | hard | {
"lang": "python",
"repo": "emilyemorehouse/ast-and-me",
"path": "/code/tmp_rtrip/test/test_wait3.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> request = CmdMessage_pb2.Request_Get_GameCenter()
request.ParseFromString(pkt)
logging.debug(u"c2sm_get_gamecenter() account_id:%s token:%s", request.account_id, request.token)
# 验证token是否有效
redishelper.instance.VerifyToken(client, request.account_id, request.token)
__cmdTable = {
... | code_fim | hard | {
"lang": "python",
"repo": "xiexiangwei/xGame",
"path": "/servermanager/clientparse.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># 客户端请求获取游戏中心地址
def c2sm_get_gamecenter(client, pkt):
request = CmdMessage_pb2.Request_Get_GameCenter()
request.ParseFromString(pkt)
logging.debug(u"c2sm_get_gamecenter() account_id:%s token:%s", request.account_id, request.token)
# 验证token是否有效
redishelper.instance.VerifyToken(client, ... | code_fim | hard | {
"lang": "python",
"repo": "xiexiangwei/xGame",
"path": "/servermanager/clientparse.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xiexiangwei/xGame path: /servermanager/clientparse.py
# coding=utf-8
'''
Created on 2016年1月11日
@author: xxw
'''
import struct
import json
from common import fprotocol, const, CmdMessage_pb2
import clientmanager
import logging
import redishelper
def s2sm_request_start(client, pkt):
reply = ... | code_fim | hard | {
"lang": "python",
"repo": "xiexiangwei/xGame",
"path": "/servermanager/clientparse.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ADR.analyzer(plane_parameters, performance_parameters, plot=True)<|fim_prefix|># repo: gralhaazulaerodesign/SimuladorGralha path: /ADR-master/main.py
import ADR
from ADR import parameters
<|fim_middle|>if __name__ == "__main__":
plane_parameters = parameters.get_plane_parameters()
performanc... | code_fim | medium | {
"lang": "python",
"repo": "gralhaazulaerodesign/SimuladorGralha",
"path": "/ADR-master/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gralhaazulaerodesign/SimuladorGralha path: /ADR-master/main.py
import ADR
from ADR import parameters
<|fim_suffix|> ADR.analyzer(plane_parameters, performance_parameters, plot=True)<|fim_middle|>if __name__ == "__main__":
plane_parameters = parameters.get_plane_parameters()
performanc... | code_fim | medium | {
"lang": "python",
"repo": "gralhaazulaerodesign/SimuladorGralha",
"path": "/ADR-master/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JJusti/CrypTen path: /crypten/nn/privacy/dp_split.py
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import crypten
import crypten.communicator... | code_fim | hard | {
"lang": "python",
"repo": "JJusti/CrypTen",
"path": "/crypten/nn/privacy/dp_split.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> To add DP noise at the aggregated gradient level,
we compute the jacobians for dP/dW in plaintext
so we can matrix multiply by dL/dP to compute our
gradients without performing a full backward pass in
crypten.
"""
# Compute dL/dP_j
self.loss.... | code_fim | hard | {
"lang": "python",
"repo": "JJusti/CrypTen",
"path": "/crypten/nn/privacy/dp_split.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Computes backward for non-RR variant.
To add DP noise at the aggregated gradient level,
we compute the jacobians for dP/dW in plaintext
so we can matrix multiply by dL/dP to compute our
gradients without performing a full backward pass in
crypten.
... | code_fim | hard | {
"lang": "python",
"repo": "JJusti/CrypTen",
"path": "/crypten/nn/privacy/dp_split.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _load_yaml_hierarchy_fixture(self, fixture):
file_name = "tests/fixtures/hierarchies/%s.yaml" % fixture
return self._load_yaml_file(file_name)
#pylint: disable=invalid-name
def test_valid_model_configuration_2018_05_04(self):
#pylint: disable=line-too-long
... | code_fim | medium | {
"lang": "python",
"repo": "stelligent/cumulogenesis",
"path": "/tests/integration/test_config_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stelligent/cumulogenesis path: /tests/integration/test_config_model.py
'''
Integration tests for model loading/validation/dumping to/from config.
This serves as the primary test for the config loader system as well, though
edge cases may deserve their own unit tests as well.
'''
import unittest
i... | code_fim | hard | {
"lang": "python",
"repo": "stelligent/cumulogenesis",
"path": "/tests/integration/test_config_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ribanez/pytorch_examples path: /RNN/RNN_Char.py
import torch
import torch.nn as nn
from torch.autograd import Variable
class CharRNN(nn.Module):
def __init__(self, input_size, hidden_size, voc_size, num_layers, recurrent_dropout, dropout):
super(CharRNN, self).__init__()
sel... | code_fim | hard | {
"lang": "python",
"repo": "ribanez/pytorch_examples",
"path": "/RNN/RNN_Char.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def init_weights(self):
initrange = 0.1
self.encoder.weight.data.uniform_(-initrange, initrange)
self.decoder.bias.data.fill_(0)
self.decoder.weight.data.uniform_(-initrange, initrange)
def forward(self, input, hidden):
emb = self.dropout(self.encoder(inpu... | code_fim | hard | {
"lang": "python",
"repo": "ribanez/pytorch_examples",
"path": "/RNN/RNN_Char.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.init_weights()
def init_weights(self):
initrange = 0.1
self.encoder.weight.data.uniform_(-initrange, initrange)
self.decoder.bias.data.fill_(0)
self.decoder.weight.data.uniform_(-initrange, initrange)
def forward(self, input, hidden):
emb = ... | code_fim | hard | {
"lang": "python",
"repo": "ribanez/pytorch_examples",
"path": "/RNN/RNN_Char.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fxsee1/ykdl path: /ykdl/extractors/generalembed.py
# -*- coding: utf-8 -*-
from ._common import *
'''
refer to http://open.youku.com/tools
'''
youku_embed_patterns = [
'youku\.com/v_show/id_([a-zA-Z0-9=]+)',
'player\.youku\.com/player\.php/sid/([a-zA-Z0-9=]+)/v\.swf',
'loader\.swf\... | code_fim | hard | {
"lang": "python",
"repo": "fxsee1/ykdl",
"path": "/ykdl/extractors/generalembed.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>'''
Sina
'''
sina_embed_patterns = [
'http://video.sina.com.cn/share/video/(\d+).swf'
]
'''
Bilibili
'''
bilibili_embed_patterns = [
'flashvars="aid=(\d+)'
]
class GeneralEmbed(EmbedExtractor):
name = 'GeneralEmbed (通用嵌入视频)'
def prepare_playlist(self):
def append_media_info(sit... | code_fim | hard | {
"lang": "python",
"repo": "fxsee1/ykdl",
"path": "/ykdl/extractors/generalembed.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for mid in matchall(html, *ifeng_embed_patterns):
append_media_info('ifeng.news', mid)
for mid in matchall(html, *weibo_embed_patterns):
append_media_info('weibo', 'http://weibo.com/p/' + mid)
for mid in matchall(html, *sina_embed_patterns):
ap... | code_fim | hard | {
"lang": "python",
"repo": "fxsee1/ykdl",
"path": "/ykdl/extractors/generalembed.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 1)
else:
print str(input_number) + " is not in any of those rooms!"<|fim_prefix|># repo: ntcho/Sunrin2017 path: /Software/Web Programming/Project07/exam_05.py
array = [-10.6, 0, 1, 18, 23.6, 45, 63, 86.1]
input_number = float(input("Enter number: "))
if array.index(input_number) >= 0:
print str... | code_fim | medium | {
"lang": "python",
"repo": "ntcho/Sunrin2017",
"path": "/Software/Web Programming/Project07/exam_05.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>input_number) + " is in room number " + str(array.index(input_number) + 1)
else:
print str(input_number) + " is not in any of those rooms!"<|fim_prefix|># repo: ntcho/Sunrin2017 path: /Software/Web Programming/Project07/exam_05.py
array = [-10.6, 0, 1, 18, 23.6, 45, 63, 86.1]
input_number = float(in... | code_fim | medium | {
"lang": "python",
"repo": "ntcho/Sunrin2017",
"path": "/Software/Web Programming/Project07/exam_05.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ntcho/Sunrin2017 path: /Software/Web Programming/Project07/exam_05.py
array = [-10.6, 0, 1, 18, 23.6, 45, 63, 86.1]
input_number = float(inp<|fim_suffix|> 1)
else:
print str(input_number) + " is not in any of those rooms!"<|fim_middle|>ut("Enter number: "))
if array.index(input_number) >= 0:... | code_fim | medium | {
"lang": "python",
"repo": "ntcho/Sunrin2017",
"path": "/Software/Web Programming/Project07/exam_05.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: awbooze/super-ai-hack-k-state-2019 path: /home/campusmaps/ksu/models.py
from django.db import models
# Create your models here.
class Building(models.Model):
<|fim_suffix|> def __str__(self):
return self.name
class Floor(models.Model):
building = models.ForeignKey(Building, on_de... | code_fim | medium | {
"lang": "python",
"repo": "awbooze/super-ai-hack-k-state-2019",
"path": "/home/campusmaps/ksu/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Room(models.Model):
floor = models.ForeignKey(Floor, on_delete=models.CASCADE)
number = models.CharField(max_length=10)
x = models.IntegerField(default=0)
y = models.IntegerField(default=0)
def __str__(self):
return self.number<|fim_prefix|># repo: awbooze/super-ai-hack-... | code_fim | hard | {
"lang": "python",
"repo": "awbooze/super-ai-hack-k-state-2019",
"path": "/home/campusmaps/ksu/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: metaspace2020/offsample path: /TagOff/metaspace/mol-db/app/model/base.py
from sqlalchemy import Column
from sqlalchemy import DateTime, func
from sqlalchemy.ext.declarative import declarative_base, declared_attr
from app import log
# from app.utils import alchemy
LOG = log.get_logger()
<|fim_s... | code_fim | hard | {
"lang": "python",
"repo": "metaspace2020/offsample",
"path": "/TagOff/metaspace/mol-db/app/model/base.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def to_dict(self):
return {attr: getattr(self, attr) for attr in self.FIELDS}
FIELDS = {
# 'created': alchemy.datetime_to_timestamp,
# 'modified': alchemy.datetime_to_timestamp,
}
Base = declarative_base(cls=BaseModel)<|fim_prefix|># repo: metaspace2020/offsample pat... | code_fim | hard | {
"lang": "python",
"repo": "metaspace2020/offsample",
"path": "/TagOff/metaspace/mol-db/app/model/base.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
demo = Convert()
file = '/mnt/d/temp/yolo3-pytorch-dvs/VOCdevkit/VOC2007/JPEGImages'
demo.path = file
demo.convert()<|fim_prefix|># repo: Adnios/yolov4-pytorch path: /VOCdevkit/VOC2007/jpg.py
from PIL import Image
import os
class Convert():
def __init__(s... | code_fim | hard | {
"lang": "python",
"repo": "Adnios/yolov4-pytorch",
"path": "/VOCdevkit/VOC2007/jpg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Adnios/yolov4-pytorch path: /VOCdevkit/VOC2007/jpg.py
from PIL import Image
import os
class Convert():
def __init__(self):
self.path = '' # 存放图片的文件夹路径
def convert(self):
filelist = os.listdir(self.path)
for item in filelist:
if item.endswith('.jpg'):... | code_fim | hard | {
"lang": "python",
"repo": "Adnios/yolov4-pytorch",
"path": "/VOCdevkit/VOC2007/jpg.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DDMAL/Rodan path: /rodan-main/code/rodan/jobs/pil_rodan/resize.py
from celery.utils.log import get_task_logger
from PIL import Image
from rodan.jobs.base import RodanTask
IDEAL_SSH_PX = 64. # SSH from old Salzinnes images
# We have to deal with very large images
# but keep some decompression ... | code_fim | hard | {
"lang": "python",
"repo": "DDMAL/Rodan",
"path": "/rodan-main/code/rodan/jobs/pil_rodan/resize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if 'Inverse Scale Ratio' in outputs:
inverse = 1 / ratio
scalepath = outputs['Inverse Scale Ratio'][0]['resource_path']
with open(scalepath, 'w') as f:
f.write(str(inverse))
def test_my_task(self, testcase):
import cv2
input_... | code_fim | hard | {
"lang": "python",
"repo": "DDMAL/Rodan",
"path": "/rodan-main/code/rodan/jobs/pil_rodan/resize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> width, height = image.size
width = int(width * ratio)
height = int(height * ratio)
image = image.resize((width, height))
image.save(outfile, 'PNG')
if 'Inverse Scale Ratio' in outputs:
inverse = 1 / ratio
scalepath = outputs['Inverse... | code_fim | hard | {
"lang": "python",
"repo": "DDMAL/Rodan",
"path": "/rodan-main/code/rodan/jobs/pil_rodan/resize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gkfthddk/keras path: /piter.py
import numpy as np
import datetime
import random
import ROOT as rt
from ROOT import gPad,gStyle
import math
import sys
from array import array
import matplotlib.pyplot as plt
for sample in ["zq","qq","zg","gg"]:
for pt in [100,200,500,1000]:
jname='Data/{}_pt_... | code_fim | hard | {
"lang": "python",
"repo": "gkfthddk/keras",
"path": "/piter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>qrt(pow(jet.dau_dphi[dausort[j]],2)+pow(jet.dau_deta[dausort[j]],2))/(1.*length)
else:
pass
jfile.Close()
f=open("{}ptlist{}".format(sample,pt),"write")
f.write(str(ptlist))
f.close()
f=open("{}drlist{}".format(sample,pt),"write")
f.write(str(drlist))
f.close(... | code_fim | hard | {
"lang": "python",
"repo": "gkfthddk/keras",
"path": "/piter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> maxlen=len(jet.dau_pt)
dausort=sorted(range(maxlen),key=lambda k: jet.dau_pt[k],reverse=True)
maxpt=max(jet.dau_pt)
if(maxpt==0):continue
for j in range(lg):
if(j<maxlen):
ptlist[j]=ptlist[j]+jet.dau_pt[dausort[j]]/(1.*length)
drlist[j]=drlist[j]+np.... | code_fim | hard | {
"lang": "python",
"repo": "gkfthddk/keras",
"path": "/piter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
action = ActionChains(self.driver)
action.move_to_element(lists[i]).perform()
time.sleep(3)
del action
i = 0
while i < len(lists):
mouseover(i)
i = i + 1
count = len(lists) - 1
school = self.driver.fi... | code_fim | hard | {
"lang": "python",
"repo": "komathi1607/cQube",
"path": "/tests/src/Regression_Testing/Test_Scripts/Click_on_Cluster_Validate_schools.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: komathi1607/cQube path: /tests/src/Regression_Testing/Test_Scripts/Click_on_Cluster_Validate_schools.py
import re
import time
import unittest
from selenium import webdriver
from selenium.webdriver import ActionChains
from Data.parameters import Data
from TS.reuse_func import cqube
from get_dir ... | code_fim | medium | {
"lang": "python",
"repo": "komathi1607/cQube",
"path": "/tests/src/Regression_Testing/Test_Scripts/Click_on_Cluster_Validate_schools.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.driver.find_element_by_xpath(Data.SARD11).click()
self.driver.find_element_by_xpath(Data.SARB3).click()
self.driver.find_element_by_xpath(Data.SARC4).click()
time.sleep(15)
data = self.driver.find_elements_by_xpath(Data.details)
for i in range(len(data)... | code_fim | hard | {
"lang": "python",
"repo": "komathi1607/cQube",
"path": "/tests/src/Regression_Testing/Test_Scripts/Click_on_Cluster_Validate_schools.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif request.method=='PUT':
banneroffers=JSONParser().parse(request)
banneroffers_data=BannerOffers.objects.get(_id=banneroffers['_id'])
banneroffers_data_serializer=BannerOffersSerializer(banneroffers_data,data=banneroffers)
if banneroffers_data_serializer.is_valid():
... | code_fim | hard | {
"lang": "python",
"repo": "01010010-01010011/i-today-astrology-app",
"path": "/indiaToday/astroApp/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if request.method=='GET':
horoscopes_data = Horoscopes.objects.all()
horoscopes_data_serializer=HoroscopesSerializer(horoscopes_data,many=True)
return JsonResponse(horoscopes_data_serializer.data,safe=False)
elif request.method=='POST':
horoscopes=JSONParser().pars... | code_fim | hard | {
"lang": "python",
"repo": "01010010-01010011/i-today-astrology-app",
"path": "/indiaToday/astroApp/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 01010010-01010011/i-today-astrology-app path: /indiaToday/astroApp/views.py
from django.shortcuts import render
from django.views.decorators.csrf import csrf_exempt
from rest_framework.decorators import api_view
from rest_framework.parsers import JSONParser
from django.http.response import JsonRe... | code_fim | hard | {
"lang": "python",
"repo": "01010010-01010011/i-today-astrology-app",
"path": "/indiaToday/astroApp/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PaulinaSzy/hearthbreaker path: /hearthbreaker/tags/action.py
o_with_minion',
'card': self.card
}
def __from_json__(self, card):
self.card = CardQuery.from_json(card)
return self
class Transform(Action):
def __init__(self, card):
if isinstance... | code_fim | hard | {
"lang": "python",
"repo": "PaulinaSzy/hearthbreaker",
"path": "/hearthbreaker/tags/action.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PaulinaSzy/hearthbreaker path: /hearthbreaker/tags/action.py
mmon',
'card': self.card
}
def __from_json__(self, card, count=1):
self.card = CardQuery.from_json(card)
self.count = count
return self
class ReplaceHeroWithMinion(Action):
# Used o... | code_fim | hard | {
"lang": "python",
"repo": "PaulinaSzy/hearthbreaker",
"path": "/hearthbreaker/tags/action.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return {
'name': 'silence'
}
class DestroyManaCrystal(Action):
def act(self, actor, target, other=None):
target.max_mana -= 1
if target.mana > 0:
target.mana -= 1
def __to_json__(self):
return {
'name': 'destroy_mana_cr... | code_fim | hard | {
"lang": "python",
"repo": "PaulinaSzy/hearthbreaker",
"path": "/hearthbreaker/tags/action.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mikequaid/DR path: /week7/lab01.03-dealingWithPages.py
# Pagination
import requests
import json
from xlwt import *
#url = "https://reports.sem-o.com/api/v1/documents/static-reports"
url= "https://reports.sem-o.com/api/v1/documents/static-reports?ReportName=Balancing%20and%20Imbalance%20Market%... | code_fim | hard | {
"lang": "python",
"repo": "mikequaid/DR",
"path": "/week7/lab01.03-dealingWithPages.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pageNumber +=1 # Increment page number
# output to console
# print (data)
# Output all names:
for reportName in listOfReports:
print(reportName)
filename = "allReports.json"
f = open(filename, 'w')
json.dump(data, f, indent=4)<|fim_prefix|># repo: mikequaid/DR path: /week7/lab01.03-dealingWit... | code_fim | hard | {
"lang": "python",
"repo": "mikequaid/DR",
"path": "/week7/lab01.03-dealingWithPages.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
The updated bucket.
"""
bucket_data = {}
update_mask = []
if args.IsSpecified('retention_days'):
bucket_data['retentionDays'] = args.retention_days
update_mask.append('retention_days')
if args.IsSpecified('display_name'):
bucket_data['displayName'] ... | code_fim | hard | {
"lang": "python",
"repo": "bopopescu/socialliteapp",
"path": "/google-cloud-sdk/lib/surface/logging/buckets/update.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bopopescu/socialliteapp path: /google-cloud-sdk/lib/surface/logging/buckets/update.py
# -*- coding: utf-8 -*- #
# Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
... | code_fim | hard | {
"lang": "python",
"repo": "bopopescu/socialliteapp",
"path": "/google-cloud-sdk/lib/surface/logging/buckets/update.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while not ale_game_over and framesElapsed < stepsRemaining and framesElapsed < maxEpisodeDuration:
framesElapsed += 1
frameSkipCounter = 0
while frameSkipCounter < frameSkip:
rewardPool += ale.act(action)
# if not ale.game_over() and startingLives == -1:... | code_fim | hard | {
"lang": "python",
"repo": "Mog333/DeepRL",
"path": "/run_dqtn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Mog333/DeepRL path: /run_dqtn.py
'''
Author: Robert Post
These functions run a standard DQN experiment accross multiple games or flavors of games for transfer learning experiments.
'''
import sys
import copy
import os
import cPickle
import time
import logging
import random
import numpy as np
... | code_fim | hard | {
"lang": "python",
"repo": "Mog333/DeepRL",
"path": "/run_dqtn.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sandialabs/slycat path: /web-server/plugins/slycat-dac/dac-generic-file-parser.py
t two rows.")
attributes = []
dimensions = [{"name":"row", "type":"int64", "begin":0, "end":len(rows[1:])}]
data = []
# go through the csv by column
for column in zip(*rows):
column_has... | code_fim | hard | {
"lang": "python",
"repo": "sandialabs/slycat",
"path": "/web-server/plugins/slycat-dac/dac-generic-file-parser.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sandialabs/slycat path: /web-server/plugins/slycat-dac/dac-generic-file-parser.py
n("File must contain at least two rows.")
attributes = []
dimensions = [{"name":"row", "type":"int64", "begin":0, "end":len(rows[1:])}]
data = []
# go through the csv by column
for column in zi... | code_fim | hard | {
"lang": "python",
"repo": "sandialabs/slycat",
"path": "/web-server/plugins/slycat-dac/dac-generic-file-parser.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> dac_error.quit_raise_exception(database, model, parse_error_log,
"Distance matrix files must have .dist extension.")
parse_error_log = dac_error.update_parse_log(database, model, parse_error_log, "Progress",
"Successfu... | code_fim | hard | {
"lang": "python",
"repo": "sandialabs/slycat",
"path": "/web-server/plugins/slycat-dac/dac-generic-file-parser.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ajaycharan/deep-visual-odometry path: /models/hand_crafted/alexnet_inspired/alexNet_14q/main.py
#!/usr/local/lib/python3.5/dist-packages
#This is the main file for the alexnet14 model
import os
import sys
import json
import matplotlib.pyplot as plt
from alexnet14 import train_model, create_model
... | code_fim | hard | {
"lang": "python",
"repo": "ajaycharan/deep-visual-odometry",
"path": "/models/hand_crafted/alexnet_inspired/alexNet_14q/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>plt.plot(history.history['rotation_loss'])
plt.plot(history.history['val_rotation_loss'])
plt.title('model rotation loss per epoch')
plt.ylabel('rotation loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
with open(os.path.join(PATH, "history_"+str(run)+".json"), 'w') a... | code_fim | hard | {
"lang": "python",
"repo": "ajaycharan/deep-visual-odometry",
"path": "/models/hand_crafted/alexnet_inspired/alexNet_14q/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>plt.plot(history.history['rotation_mean_absoulte_error'])
plt.plot(history.history['val_rotation_mean_absoulte_error'])
plt.title('model mean_absoulte_error per epoch')
plt.ylabel('rotation mean absoulute error')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
plt.plot(hist... | code_fim | hard | {
"lang": "python",
"repo": "ajaycharan/deep-visual-odometry",
"path": "/models/hand_crafted/alexnet_inspired/alexNet_14q/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mdabrowski1990/optimization path: /optimization/logging/utilities.py
"""Helper functions for logging purposes."""
__all__ = ["log_function_code"]
from typing import Callable
import inspect
def log_function_code(func_to_log: Callable) -> str:
"""
Extracts function code into str.
... | code_fim | medium | {
"lang": "python",
"repo": "mdabrowski1990/optimization",
"path": "/optimization/logging/utilities.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param func_to_log: Function object for which code to be extracted.
:return: Code of the function.
"""
if not callable(func_to_log):
TypeError(f"Parameter 'func_to_log' is not function. Actual value: {func_to_log}.")
function_definition = inspect.getsource(func_to_log)
if ... | code_fim | hard | {
"lang": "python",
"repo": "mdabrowski1990/optimization",
"path": "/optimization/logging/utilities.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.