input
stringlengths
11
7.65k
target
stringlengths
22
8.26k
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def test_question_reviewers_not_needed_if_no_reviewers_no_sugestions( self): stats = suggestion_services.get_community_contribution_stats() self._assert_community_contribution_stats_is_in_default_state() self.assertFalse(stats.are_question_reviewers_needed())
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def test_validate_question_reviewer_count_fails_for_negative_count(self): community_contribution_stats = ( suggestion_services.get_community_contribution_stats() ) community_contribution_stats.question_reviewer_count = ( self.negative_count ) with self.as...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def test_validate_question_suggestion_count_fails_for_negative_count(self): community_contribution_stats = ( suggestion_services.get_community_contribution_stats() ) community_contribution_stats.question_suggestion_count = ( self.negative_count ) with sel...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def test_validate_question_reviewer_count_fails_for_non_integer_count( self): community_contribution_stats = ( suggestion_services.get_community_contribution_stats() ) community_contribution_stats.question_reviewer_count = ( self.non_integer_count ) ...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def test_validate_question_suggestion_count_fails_for_non_integer_count( self): community_contribution_stats = ( suggestion_services.get_community_contribution_stats() ) community_contribution_stats.question_suggestion_count = ( self.non_integer_count ...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def main(unused_argv): tpu_cluster_resolver = contrib_cluster_resolver.TPUClusterResolver( FLAGS.tpu, zone=FLAGS.tpu_zone, project=FLAGS.gcp_project) config = contrib_tpu.RunConfig( cluster=tpu_cluster_resolver, model_dir=FLAGS.model_dir, save_checkpoints_steps=FLAGS.iterations_per_loop, ...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def test_telemetry_finish(runner, live_mock_server, parse_ctx): with runner.isolated_filesystem(): run = wandb.init() run.finish() ctx_util = parse_ctx(live_mock_server.get_ctx()) telemetry = ctx_util.telemetry assert telemetry and 2 in telemetry.get("3", [])
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1] in app.config.get('ALLOWED_EXTENSIONS')
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def test_telemetry_imports_hf(runner, live_mock_server, parse_ctx): with runner.isolated_filesystem(): run = wandb.init() with mock.patch.dict("sys.modules", {"transformers": mock.Mock()}): import transformers run.finish() ctx_util = parse_ctx(live_mock_server....
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def unique_name(): now_time = datetime.datetime.now().strftime("%Y%m%d%H%M%S") random_num = random.randint(0, 100) if random_num <= 10: random_num = str(0) + str(random_num) unique_num = str(now_time) + str(random_num) return unique_num
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def test_telemetry_imports_catboost(runner, live_mock_server, parse_ctx): with runner.isolated_filesystem(): with mock.patch.dict("sys.modules", {"catboost": mock.Mock()}): import catboost run = wandb.init() run.finish() ctx_util = parse_ctx(live_mock_server...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def image_thumbnail(filename): filepath = os.path.join(app.config.get('UPLOAD_FOLDER'), filename) im = Image.open(filepath) w, h = im.size if w > h: im.thumbnail((106, 106*h/w)) else: im.thumbnail((106*w/h, 106)) im.save(os.path.join(app.config.get('UPLOAD_FOLDER'), os...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def test_telemetry_imports_jax(runner, live_mock_server, parse_ctx): with runner.isolated_filesystem(): import jax wandb.init() wandb.finish() ctx_util = parse_ctx(live_mock_server.get_ctx()) telemetry = ctx_util.telemetry # jax in finish modules but not in init mo...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def image_delete(filename): thumbnail_filepath = os.path.join(app.config.get('UPLOAD_FOLDER'), filename) filepath = thumbnail_filepath.replace('_thumbnail', '') os.remove(filepath) os.remove(thumbnail_filepath)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def test_telemetry_run_organizing_init(runner, live_mock_server, parse_ctx): with runner.isolated_filesystem(): wandb.init(name="test_name", tags=["my-tag"], config={"abc": 123}, id="mynewid") wandb.finish() ctx_util = parse_ctx(live_mock_server.get_ctx()) telemetry = ctx_util.telem...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _rematcher(regex): """compile the regexp with the best available regexp engine and return a matcher function""" m = util.re.compile(regex) try: # slightly faster, provided by facebook's re2 bindings return m.test_match except AttributeError: return m.match
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def refresh(): win.Refresh() print type(win)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _expandsets(kindpats, ctx): """Returns the kindpats list with the 'set' patterns expanded.""" fset = set() other = [] for kind, pat, source in kindpats: if kind == "set": if not ctx: raise error.ProgrammingError("fileset expression with no " "context") ...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def create_texture(): global rgbtex rgbtex = glGenTextures(1) glBindTexture(TEXTURE_TARGET, rgbtex) glTexImage2D(TEXTURE_TARGET,0,GL_RGB,640,480,0,GL_RGB,GL_UNSIGNED_BYTE,None)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _expandsubinclude(kindpats, root): """Returns the list of subinclude matcher args and the kindpats without the subincludes in it.""" relmatchers = [] other = [] for kind, pat, source in kindpats: if kind == "subinclude": sourceroot = pathutil.dirname(util.normpath(source)) ...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def EVT_LEFT_DOWN(event): global _mpos _mpos = event.Position
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _kindpatsalwaysmatch(kindpats): """ "Checks whether the kindspats match everything, as e.g. 'relpath:.' does. """ for kind, pat, source in kindpats: # TODO: update me? if pat != "" or kind not in ["relpath", "glob"]: return False return True
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def EVT_LEFT_UP(event): global _mpos _mpos = None
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def normalize(patterns, default, root, cwd, auditor, warn): kp = _donormalize(patterns, default, root, cwd, auditor, warn) kindpats = [] for kind, pats, source in kp: if kind not in ("re", "relre"): # regex can't be normalized p = pats ...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def EVT_MOTION(event): global _mpos if event.LeftIsDown(): if _mpos: (x,y),(mx,my) = event.Position,_mpos rotangles[0] += y-my rotangles[1] += x-mx refresh() _mpos = event.Position
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def exact(root, cwd, files, badfn=None): return exactmatcher(root, cwd, files, badfn=badfn)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def EVT_MOUSEWHEEL(event): global zoomdist dy = event.WheelRotation zoomdist *= np.power(0.95, -dy) refresh()
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def always(root, cwd): return alwaysmatcher(root, cwd)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def mouse_rotate(xAngle, yAngle, zAngle): glRotatef(xAngle, 1.0, 0.0, 0.0); glRotatef(yAngle, 0.0, 1.0, 0.0); glRotatef(zAngle, 0.0, 0.0, 1.0);
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def never(root, cwd): return nevermatcher(root, cwd)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def playcolors(): while 1: global clearcolor clearcolor = [np.random.random(),0,0,0] time.sleep(0.1) refresh()
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def union(matches, root, cwd): """Union a list of matchers. If the list is empty, return nevermatcher. If the list only contains one non-None value, return that matcher. Otherwise return a union matcher. """ matches = list(filter(None, matches)) if len(matches) == 0: return nevermat...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def update(dt=0): global projpts, rgb, depth depth,_ = freenect.sync_get_depth() rgb,_ = freenect.sync_get_video() q = depth X,Y = np.meshgrid(range(640),range(480)) # YOU CAN CHANGE THIS AND RERUN THE PROGRAM! # Point cloud downsampling d = 4 projpts = calibkinect.depth2xyzuv(q[::d,::d],X[::d,::d],Y[...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def badmatch(match, badfn): """Make a copy of the given matcher, replacing its bad method with the given one. """ m = copy.copy(match) m.bad = badfn return m
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def update_join(): update_on() try: _thread.join() except: update_off()
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _donormalize(patterns, default, root, cwd, auditor, warn): """Convert 'kind:pat' from the patterns list to tuples with kind and normalized and rooted patterns and with listfiles expanded.""" kindpats = [] for kind, pat in [_patsplit(p, default) for p in patterns]: if kind in cwdrelativepatte...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def update_on(): global _updating if not '_updating' in globals(): _updating = False if _updating: return
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _testrefastpath(repat): """Test if a re pattern can use fast path. That is, for every "$A/$B" path the pattern matches, "$A" must also be matched, Return True if we're sure it is. Return False otherwise. """ # XXX: It's very hard to implement this. These are what need to be # supported...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _run(): while _updating: update()
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _globpatsplit(pat): """Split a glob pattern. Return a list. A naive version is "path.split("/")". This function handles more cases, like "{*,{a,b}*/*}". >>> _globpatsplit("*/**/x/{a,b/c}") ['*', '**', 'x', '{a,b/c}'] """ result = [] buf = "" parentheses = 0 for ch in pat: ...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def update_off(): global _updating _updating = False
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __init__(self, *args, **kwargs): # If True, avoid entering subdirectories, and match everything recursively, # unconditionally. self.matchrecursive = False # If True, avoid entering subdirectories, and return "unsure" for # everything. This is set to True when complex re patt...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def loopcv(): import cv while 1: cv.ShowImage('hi',get_depth().astype(np.uint8)) cv.WaitKey(10)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def insert(self, path, matchrecursive=True, globpats=None, repats=None): """Insert a directory path to this tree. If matchrecursive is True, mark the directory as unconditionally include files and subdirs recursively. If globpats or repats are specified, append them to the patterns bei...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def visitdir(self, path): """Similar to matcher.visitdir""" path = normalizerootdir(path, "visitdir") if self.matchrecursive: return "all" elif self.unsurerecursive: return True elif path == "": return True if self._kindpats and self._...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _compiledpats(self): pat, matchfunc = _buildregexmatch(self._kindpats, "") return matchfunc
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _compileddirpats(self): pat, matchfunc = _buildregexmatch( [("glob", p, "") for p in self._globdirpats], "$" ) return matchfunc
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _split(self, path): if "/" in path: subdir, rest = path.split("/", 1) else: subdir, rest = path, "" if not subdir: raise error.ProgrammingError("path cannot be absolute") return subdir, rest
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _remainingpats(pat, prefix): """list of patterns with prefix stripped >>> _remainingpats("a/b/c", "") ['a/b/c'] >>> _remainingpats("a/b/c", "a") ['b/c'] >>> _remainingpats("a/b/c", "a/b") ['c'] >>> _remainingpats("a/b/c", "a/b/c") [] >>> _remainingpats("", "") [] """...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _buildvisitdir(kindpats): """Try to build an efficient visitdir function Return a visitdir function if it's built. Otherwise return None if there are unsupported patterns. >>> _buildvisitdir([('include', 'foo', '')]) >>> _buildvisitdir([('relglob', 'foo', '')]) >>> t = _buildvisitdir([ ...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __init__(self, root, cwd, badfn=None, relativeuipath=True): self._root = root self._cwd = cwd if badfn is not None: self.bad = badfn self._relativeuipath = relativeuipath
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __repr__(self): return "<%s>" % self.__class__.__name__
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __call__(self, fn): return self.matchfn(fn)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __iter__(self): for f in self._files: yield f
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def bad(self, f, msg): """Callback from dirstate.walk for each explicit file that can't be found/accessed, with an error message."""
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def abs(self, f): """Convert a repo path back to path that is relative to the root of the matcher.""" return f
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def rel(self, f): """Convert repo path back to path that is relative to cwd of matcher.""" return util.pathto(self._root, self._cwd, f)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def uipath(self, f): """Convert repo path to a display path. If patterns or -I/-X were used to create this matcher, the display path will be relative to cwd. Otherwise it is relative to the root of the repo.""" return (self._relativeuipath and self.rel(f)) or self.abs(f)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def files(self): """Explicitly listed files or patterns or roots: if no patterns or .always(): empty list, if exact: list exact files, if not .anypats(): list all files and dirs, else: optimal roots""" return self._files
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _fileset(self): return set(self._files)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def exact(self, f): """Returns True if f is in .files().""" return f in self._fileset
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def matchfn(self, f): return False
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def visitdir(self, dir): """Decides whether a directory should be visited based on whether it has potential matches in it or one of its subdirectories. This is based on the match's primary, included, and excluded patterns. Returns the string 'all' if the given directory and all subdirec...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def always(self): """Matcher will match everything and .files() will be empty -- optimization might be possible.""" return False
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def isexact(self): """Matcher will match exactly the list of files in .files() -- optimization might be possible.""" return False
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def prefix(self): """Matcher will match the paths in .files() recursively -- optimization might be possible.""" return False
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def anypats(self): """None of .always(), .isexact(), and .prefix() is true -- optimizations will be difficult.""" return not self.always() and not self.isexact() and not self.prefix()
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __init__(self, root, cwd, badfn=None, relativeuipath=False): super(alwaysmatcher, self).__init__( root, cwd, badfn, relativeuipath=relativeuipath )
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def always(self): return True
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def matchfn(self, f): return True
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def visitdir(self, dir): return "all"
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __repr__(self): return "<alwaysmatcher>"
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __init__(self, root, cwd, badfn=None): super(nevermatcher, self).__init__(root, cwd, badfn)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def isexact(self): return True
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def visitdir(self, dir): return False
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __repr__(self): return "<nevermatcher>"
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __init__(self, root, cwd, badfn=None, gitignorepaths=None): super(gitignorematcher, self).__init__(root, cwd, badfn) gitignorepaths = gitignorepaths or [] self._matcher = pathmatcher.gitignorematcher(root, gitignorepaths)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def matchfn(self, f): # XXX: is_dir is set to True here for performance. # It should be set to whether "f" is actually a directory or not. return self._matcher.match_relative(f, True)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def explain(self, f): return self._matcher.explain(f, True)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") matched = self._matcher.match_relative(dir, True) if matched: # Everything in the directory is selected (ignored) return "all" else: # Not sure return True
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __repr__(self): return "<gitignorematcher>"
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __init__(self, root, cwd, badfn=None, rules=[]): super(treematcher, self).__init__(root, cwd, badfn) rules = list(rules) self._matcher = pathmatcher.treematcher(rules) self._rules = rules
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def matchfn(self, f): return self._matcher.matches(f)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def visitdir(self, dir): matched = self._matcher.match_recursive(dir) if matched is None: return True elif matched is True: return "all" else: assert matched is False return False
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __repr__(self): return "<treematcher rules=%r>" % self._rules
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def normalizerootdir(dir, funcname): if dir == ".": util.nouideprecwarn( "match.%s() no longer accepts '.', use '' instead." % funcname, "20190805" ) return "" return dir
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _kindpatstoglobs(kindpats, recursive=False): """Attempt to convert 'kindpats' to glob patterns that can be used in a treematcher. kindpats should be already normalized to be relative to repo root. If recursive is True, `glob:a*` will match both `a1/b` and `a1`, otherwise `glob:a*` will only ma...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _makeglobrecursive(pat): """Make a glob pattern recursive by appending "/**" to it""" if pat.endswith("/") or not pat: return pat + "**" else: return pat + "/**"
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _convertretoglobs(repat): """Attempt to convert a regular expression pattern to glob patterns. A single regular expression pattern might be converted into multiple glob patterns. Return None if conversion is unsupported. >>> _convertretoglobs("abc*") is None True >>> _convertretoglobs...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __init__(self, root, cwd, kindpats, ctx=None, badfn=None): super(patternmatcher, self).__init__(root, cwd, badfn) # kindpats are already normalized to be relative to repo-root. # Can we use tree matcher? rules = _kindpatstoglobs(kindpats, recursive=False) fallback = True ...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def _dirs(self): return set(util.dirs(self._fileset))
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") if self._prefix and dir in self._fileset: return "all" if not self._prefix: return True return ( dir in self._fileset or dir in self._dirs or any(parentdir in self...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def prefix(self): return self._prefix
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __repr__(self): return "<patternmatcher patterns=%r>" % self._pats
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __init__(self, root, cwd, kindpats, ctx=None, badfn=None): super(includematcher, self).__init__(root, cwd, badfn) # Can we use tree matcher? rules = _kindpatstoglobs(kindpats, recursive=True) fallback = True if rules is not None: try: matcher = tr...
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") if self._prefix and dir in self._roots: return "all" return ( dir in self._roots or dir in self._dirs or any(parentdir in self._roots for parentdir in util.finddirs(dir)) )
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __repr__(self): return "<includematcher includes=%r>" % self._pats
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __init__(self, root, cwd, files, badfn=None): super(exactmatcher, self).__init__(root, cwd, badfn) if isinstance(files, list): self._files = files else: self._files = list(files)
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") return dir in self._dirs
def emit(self, level, message): raise NotImplementedError('Please implement an emit method')
def __repr__(self): return "<exactmatcher files=%r>" % self._files