path
stringlengths
15
77
type
stringclasses
1 value
project
stringclasses
1 value
commit_hash
stringlengths
40
40
commit_message
stringlengths
15
198
ground_truth
stringlengths
26
155
main_code
stringlengths
176
2.5k
context
stringlengths
91
9.37k
coeditor.model/RetrievalDecodingResult.exact_match_accuracy
Modified
temp-1
ed6838082d5251960112524997fdb2cffc0bee7e
Fix TkDelta from output_tks.
<0>:<add> label_delta = TkDelta.from_output_tks(prob.edit_lines, mp["labels"])
# module: coeditor.model @dataclass class RetrievalDecodingResult: def exact_match_accuracy(self) -> tuple[CountedSum, dict[int, bool]]: ex2correct = dict[int, bool]() bad_probs = list[C3Problem]() for i, mp in enumerate(self.predictions): ...
===========unchanged ref 0=========== at: coeditor._utils cprint(color: str, *elems, sep: Optional[str]=..., end: Optional[str]=..., file: Optional[SupportsWrite[str]]=..., flush: bool=...) at: coeditor.c3problem C3Problem(span: ChangedCodeSpan, edit_line_ids: Sequence[int], relevant_change...
coeditor.model/RetrievalEditorModel.predict_on_batch
Modified
temp-1
ed6838082d5251960112524997fdb2cffc0bee7e
Fix TkDelta from output_tks.
<0>:<add> pred = apply_output_tks_to_change(change_tks, 0, out)
# module: coeditor.model class RetrievalEditorModel(T5PreTrainedModel): @torch.autocast("cuda") def predict_on_batch( self, batch: dict, + originals: Sequence[TokenSeq], - requests: Sequence["EditRequest"], dec_args: Decod...
===========above chunk 0=========== # module: coeditor.model class RetrievalEditorModel(T5PreTrainedModel): @torch.autocast("cuda") def predict_on_batch( self, batch: dict, + originals: Sequence[TokenSeq], - requests: Sequence["EditRequest"], ...
coeditor.encoding/TkDelta.from_output_tks
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> deltas = {l: seg_to_tuple(seg) for l, seg in zip(lines, segs.values()) if seg}
# module: coeditor.encoding @dataclass(frozen=True) class TkDelta: @staticmethod + def from_output_tks(lines: Sequence[int], tks: TokenSeq) -> "TkDelta": - def from_output_tks(tks: TokenSeq) -> "TkDelta": ad_tks = (Add_id, Del_id) def seg_to...
===========unchanged ref 0=========== at: coeditor._utils assert_eq(x: T1, y: T1, message: Callable[[], str]=lambda: "") -> None at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding Add_id = get_tk_id(Add) Del_id = get_tk_id(Del) output...
coeditor.scoped_changes/line_range
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> return LineRange(start, end)
# module: coeditor.scoped_changes def line_range(start: int, end: int, can_be_empty: bool = False) -> LineRange: if not can_be_empty and start >= end: raise ValueError(f"Bad line range: {start=}, {end=}") - return LineRange((start, end)) <0>
===========unchanged ref 0=========== at: coeditor.scoped_changes.LineRange start: int ===========changed ref 0=========== # module: coeditor.scoped_changes + class LineRange(NamedTuple): + start: int + until: int + ===========changed ref 1=========== # module: coeditor.sc...
coeditor.scoped_changes/ChangeScope._search_span
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> if line in span.line_range:
# module: coeditor.scoped_changes @dataclass class ChangeScope: def _search_span(self, line: int) -> "StatementSpan | None": for span in self.spans: - if span.line_range[0] <= line < span.line_range[1]: <0> return span return None...
===========unchanged ref 0=========== at: coeditor.common ElemPath = str at: coeditor.scoped_changes.ChangeScope path: ProjectPath tree: ScopeTree spans: Sequence["StatementSpan"] subscopes: Mapping[str, Self] parent_scope: "ChangeScope | ...
coeditor.scoped_changes/ChangedSpan.__repr__
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> return f"ChangeSpan(module={self.module}, range={self.line_range}, scope={self.scope.earlier.path.path}, type={self.change.as_char()})"
# module: coeditor.scoped_changes @dataclass(frozen=True) class ChangedSpan: def __repr__(self) -> str: - return f"ChangeSpan(scope={self.path}, range={self.line_range}, type={self.change.as_char()})" <0>
===========unchanged ref 0=========== at: coeditor.common print_err(*, sep: Optional[str]=..., end: Optional[str]=..., flush: bool=...) -> None ===========changed ref 0=========== # module: coeditor.scoped_changes @dataclass(frozen=True) class ChangedSpan: - @property - def...
coeditor.scoped_changes/JModuleChange.__repr__
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> return f"JModuleChange({self.changed})"
# module: coeditor.scoped_changes @dataclass(frozen=True) class JModuleChange: def __repr__(self) -> str: - change_dict = {k.path: v.change.as_char() for k, v in self.changed.items()} - return f"JModuleChange({change_dict})" <0>
===========unchanged ref 0=========== at: coeditor.change.Added after: E1 as_char() at: coeditor.change.Deleted before: E1 as_char() at: coeditor.change.Modified before: E1 after: E1 unchanged: bool = False as...
coeditor.scoped_changes/code_to_module
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> return parso.parse(code)
# module: coeditor.scoped_changes def code_to_module(code: str) -> ptree.Module: - m = jedi.Script(code)._module_node - assert isinstance(m, ptree.Module) - return m <0>
===========unchanged ref 0=========== at: coeditor.change Modified(before: E1, after: E1, unchanged: bool=False) at: coeditor.scoped_changes ChangedSpan(change: Change[str], parent_scopes: Sequence[Change[ChangeScope]], line_range: LineRange) ===========changed ref 0=========== ...
coeditor.c3problem/C3ProblemGenerator.pre_edit_analysis
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> script, lines_to_analyze, silent=True
# module: coeditor.c3problem class C3ProblemGenerator(ProjectChangeProcessor[C3Problem]): def pre_edit_analysis( self, pstate: ProjectState, modules: Mapping[RelPath, JModule], changes: Mapping[ModuleName, JModuleChange], ) -> Mappi...
===========unchanged ref 0=========== at: coeditor.c3problem LineUsageAnalysis(line2usages: Mapping[int, set[PyDefinition]]) at: coeditor.c3problem.C3ProblemGenerator.__init__ self.analyzer = analyzer self._is_training: bool = False at: coeditor.c3problem.JediUsageAnal...
coeditor.model/C3DataLoader._to_tokenized
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> max_workers=self.workers,
# module: coeditor.model @dataclass class C3DataLoader: def _to_tokenized(self, probs: Sequence[C3Problem]) -> Iterable[TkC3Problem]: probs = list(probs) if self.transform is not None: # we can afford to store all transformed problems beforehand ...
===========unchanged ref 0=========== at: coeditor._utils pmap(f: Callable[..., T1], iter3: Iterable[Any], iter4: Iterable[Any], iter5: Iterable[Any], iter6: Iterable[Any], /, *iterables: Iterable[Any], desc: str | None=None, key_args: Mapping[str, Any] | None=None, max_workers: int | None=None, chunksize: ...
coeditor.model/C3DataLoader._problems_to_batches
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> yield self.pack_batch(current_batch)
# module: coeditor.model @dataclass class C3DataLoader: def _problems_to_batches(self, problems: Iterable[TkC3Problem]) -> Iterable[dict]: <s> current_batch = [] current_cost = 0 for tk_prob in problems: all_refs = [x[1] for x in tk_...
===========above chunk 0=========== # module: coeditor.model @dataclass class C3DataLoader: def _problems_to_batches(self, problems: Iterable[TkC3Problem]) -> Iterable[dict]: # offset: -1 - def pack_batch(rows: list[dict]): - assert rows, "empty batch found" - ...
tests.test_edits/TestChangeIdentities.test_delta_decomposition
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> print_err(c.earlier)
# module: tests.test_edits class TestChangeIdentities: def test_delta_decomposition(self): for name, c in self.cases.items(): original, delta = TkDelta.from_change_tks(change_to_tokens(c)) expect = delta.apply_to_input(original) k...
===========unchanged ref 0=========== at: coeditor.change.Added after: E1 at: coeditor.change.Deleted before: E1 at: coeditor.change.Modified before: E1 after: E1 unchanged: bool = False at: coeditor.common SEP = "-" * 80 ...
tests.test_analysis/test_anlayzing_defs
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> analysis = analyzer.get_line_usages(script, range(0, 46), silent=True)
# module: tests.test_analysis def test_anlayzing_defs(): analyzer = JediUsageAnalyzer() project = jedi.Project(path=testcase_root, added_sys_path=[proj_root() / "src"]) script = jedi.Script(path=testcase_root / "defs.py", project=project) - analysis = analyzer.get_line_...
===========below chunk 0=========== # module: tests.test_analysis def test_anlayzing_defs(): # offset: 1 <s> string annotations for now ) assert_has_usages( analysis.line2usages[40], "parso.tree.BaseNode.__init__.children", ) assert_has_u...
tests.test_analysis/test_anlayzing_usages
Modified
temp-1
126ebdc082f96cc4670cb37357e850d259b00c68
Initial implementation of new service. - Make LineRange a class. - Fix JModuleChanges. - Seperate out some C3 generator logic.
<0>:<add> analysis = analyzer.get_line_usages(script, range(0, 63), silent=True)
# module: tests.test_analysis def test_anlayzing_usages(): analyzer = JediUsageAnalyzer() project = jedi.Project(path=testcase_root, added_sys_path=[proj_root() / "src"]) script = jedi.Script(path=testcase_root / "usages.py", project=project) - analysis = analyzer.get_l...
===========unchanged ref 0=========== at: coeditor._utils proj_root() -> Path at: coeditor.c3problem.JediUsageAnalyzer get_line_usages(script: jedi.Script, lines_to_analyze: Collection[int], silent: bool=False) at: coeditor.c3problem.JediUsageAnalyzer.__post_init__ self.err...
coeditor.encoding/TkDelta.from_output_tks
Modified
temp-1
f15359a0a5fb8953d3296a0483517e4c98cbf2e6
Improve service UX with inversed changes.
<0>:<add> return tuple(remove_newline(x) for x in result)
# module: coeditor.encoding @dataclass(frozen=True) class TkDelta: @staticmethod def from_output_tks(lines: Sequence[int], tks: TokenSeq) -> "TkDelta": ad_tks = (Add_id, Del_id) + + def remove_newline(seg: TokenSeq): + if seg and seg[-...
===========unchanged ref 0=========== at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding Add_id = get_tk_id(Add) Del_id = get_tk_id(Del) Newline_id = get_tk_id("\n") at: coeditor.encoding.TkDelta _deltas: Mapping[int, tuple[TokenSeq, ...
coeditor.scoped_changes/JModuleChange.from_modules
Modified
temp-1
f15359a0a5fb8953d3296a0483517e4c98cbf2e6
Improve service UX with inversed changes.
<0>:<add> module_change.map(lambda m: m.as_scope), tuple(), only_ast_changes
# module: coeditor.scoped_changes @dataclass(frozen=True) class JModuleChange: @staticmethod + def from_modules(module_change: Change[JModule], only_ast_changes: bool = True): - def from_modules(module_change: Change[JModule]): "Compute the change spans from two...
===========unchanged ref 0=========== at: coeditor.change Change = Added[E1] | Deleted[E1] | Modified[E1] at: coeditor.scoped_changes ChangedSpan(change: Change[str], parent_scopes: Sequence[Change[ChangeScope]], line_range: LineRange) JModule(mname: ModuleName, tree: ptree.Mod...
coeditor.scoped_changes/_parse_module_script
Modified
temp-1
f15359a0a5fb8953d3296a0483517e4c98cbf2e6
Improve service UX with inversed changes.
<0>:<add> print_err(f"project: {project.path}", file=sys.stderr)
# module: coeditor.scoped_changes + def _parse_module_script(project: jedi.Project, path: Path): - def _parse_module_script(project: Path, path: Path): assert path.is_absolute(), f"Path is not absolute: {path=}" script = jedi.Script(path=path, project=project) mcontext = scri...
===========unchanged ref 0=========== at: coeditor.common T1 = TypeVar("T1") T2 = TypeVar("T2") at: copy deepcopy(x: _T, memo: Optional[Dict[int, Any]]=..., _nil: Any=...) -> _T at: jedi.api Script(code=None, *, path=None, environment=None, project=None) ...
coeditor.scoped_changes/get_changed_spans
Modified
temp-1
f15359a0a5fb8953d3296a0483517e4c98cbf2e6
Improve service UX with inversed changes.
<0>:<add> if only_ast_changes and code_equal(old_scope.spans_code, new_scope.spans_code):
# module: coeditor.scoped_changes def get_changed_spans( scope_change: Change[ChangeScope], parent_changes: tuple[Change[ChangeScope], ...] = (), + only_ast_changes: bool = True, ) -> list[ChangedSpan]: """ Extract the change spans from scope change. ...
===========below chunk 0=========== # module: coeditor.scoped_changes def get_changed_spans( scope_change: Change[ChangeScope], parent_changes: tuple[Change[ChangeScope], ...] = (), + only_ast_changes: bool = True, ) -> list[ChangedSpan]: # offset: 1 <s>], parent_changes ...
coeditor.c3problem/C3GeneratorCache.create_problem
Modified
temp-1
f15359a0a5fb8953d3296a0483517e4c98cbf2e6
Improve service UX with inversed changes.
<0>:<add> edit_lines, # one additional line for appending
# module: coeditor.c3problem class C3GeneratorCache: def create_problem( self, target: ChangedSpan, + edit_lines: Sequence[int] | None, changed: Mapping[ModuleName, JModuleChange], target_usages: LineUsageAnalysis, s...
===========above chunk 0=========== # module: coeditor.c3problem class C3GeneratorCache: def create_problem( self, target: ChangedSpan, + edit_lines: Sequence[int] | None, changed: Mapping[ModuleName, JModuleChange], target_usages: LineUsageAnaly...
coeditor.service/ServiceResponse.to_json
Modified
temp-1
f15359a0a5fb8953d3296a0483517e4c98cbf2e6
Improve service UX with inversed changes.
<0>:<add> "old_code": self.input_code,
# module: coeditor.service @dataclass class ServiceResponse: def to_json(self): return { "target_file": self.target_file, "edit_start": self.edit_start, "edit_end": self.edit_end, - "old_code": self.old_code,...
===========changed ref 0=========== # module: coeditor.service @dataclass class ServiceResponse: target_file: str edit_start: tuple[int, int] edit_end: tuple[int, int] + input_code: str - old_code: str suggestions: list[EditSuggestion] ===========changed ref ...
coeditor.service/ServiceResponse.print
Modified
temp-1
f15359a0a5fb8953d3296a0483517e4c98cbf2e6
Improve service UX with inversed changes.
<0>:<add> print(self.input_code, file=file)
# module: coeditor.service @dataclass class ServiceResponse: def print(self, file=sys.stdout): print(f"Target file: {self.target_file}", file=file) print(f"Edit range: {self.edit_start} - {self.edit_end}", file=file) for i, s in enumerate(self.sugges...
===========unchanged ref 0=========== at: coeditor.service EditSuggestion(score: float, change_preview: str, new_code: str) at: dataclasses dataclass(_cls: Type[_T]) -> Type[_T] dataclass(*, init: bool=..., repr: bool=..., eq: bool=..., order: bool=..., unsafe_hash: bool=..., frozen...
coeditor.service/EditPredictionService.suggest_edit
Modified
temp-1
f15359a0a5fb8953d3296a0483517e4c98cbf2e6
Improve service UX with inversed changes.
<0>:<add> input_code=old_code,
# module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, + edit_lines: Sequence[int], - line: int, log_dir: Path | None = Path(".coeditor_logs"), ) -> ServiceResponse: ...
===========above chunk 0=========== # module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, + edit_lines: Sequence[int], - line: int, log_dir: Path | None = Path(".coeditor_logs"), ) -> Ser...
coeditor.service/EditPredictionService.apply_edit_to_elem
Modified
temp-1
f15359a0a5fb8953d3296a0483517e4c98cbf2e6
Improve service UX with inversed changes.
<0>:<add> preview = default_show_diff(current_code, new_change.after)
# module: coeditor.service @dataclass class EditPredictionService: @staticmethod def apply_edit_to_elem( problem: C3Problem, out_tks: TokenSeq, ) -> tuple[Modified[str], str]: change_tks = problem.span.original.tolist() ...
===========unchanged ref 0=========== at: coeditor.c3problem C3Problem(span: ChangedCodeSpan, edit_line_ids: Sequence[int], relevant_changes: Sequence[ChangedCodeSpan], relevant_unchanged: Mapping["PyFullName", "PyDefinition"], change_type: Change[None], src_info: SrcInfo, transformations: tuple[str, ...]=(...
coeditor.encoding/TkDelta.from_output_tks
Modified
temp-1
a19ca9519caf03745b65f959367091eee884fc98
- return target lines in service response.
<0>:<add> assert_eq(len(segs), len(lines))
# module: coeditor.encoding @dataclass(frozen=True) class TkDelta: @staticmethod + def from_output_tks( + lines: Sequence[int], tks: TokenSeq, allow_truncated_tks: bool = True + ) -> "TkDelta": - def from_output_tks(lines: Sequence[int], tks: TokenSeq) -> ...
===========unchanged ref 0=========== at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding Add_id = get_tk_id(Add) Del_id = get_tk_id(Del) Newline_id = get_tk_id("\n") output_ids_as_seqs(output_ids: Iterable[Token]) -> dict[Token, TokenSeq]...
coeditor.c3problem/TkC3Problem.input_tks
Modified
temp-1
a19ca9519caf03745b65f959367091eee884fc98
- return target lines in service response.
<0>:<add> return self.header.tolist() + self.main_input.tolist()
# module: coeditor.c3problem @dataclass(frozen=True) class TkC3Problem(TokenizedEdit): @property def input_tks(self) -> TokenSeq: - return self.input.tolist() <0>
===========unchanged ref 0=========== at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding.TokenizedEdit input_tks: TokenSeq output_tks: TokenSeq main_tks: TokenSeq path: ProjectPath change_type: Change[None] BAD_D...
coeditor.c3problem/C3ProblemTokenizer.tokenize_problem
Modified
temp-1
a19ca9519caf03745b65f959367091eee884fc98
- return target lines in service response.
<0>:<add> TkArray.new(scope_tks),
# module: coeditor.c3problem @dataclass class C3ProblemTokenizer: def tokenize_problem( self, problem: C3Problem, ) -> TkC3Problem: <s>chunk)) for i, chunk in enumerate(below_chunks) ] all_refs = above_...
===========above chunk 0=========== # module: coeditor.c3problem @dataclass class C3ProblemTokenizer: def tokenize_problem( self, problem: C3Problem, ) -> TkC3Problem: # offset: -1 <s>tks = join_list(origin_lines[:edit_start] + [TokenSeq()], Newline_id) ...
coeditor.model/RetrievalDecodingResult.show_prediction
Modified
temp-1
a19ca9519caf03745b65f959367091eee884fc98
- return target lines in service response.
<0>:<add> header=TkArray.new([]),
# module: coeditor.model @dataclass class RetrievalDecodingResult: @classmethod def show_prediction(cls, prob: C3Problem, pred: RetrievalModelPrediction) -> str: span = prob.span tk_prob = TkC3Problem( + main_input=TkArray.new(pred["input...
===========unchanged ref 0=========== at: coeditor.c3problem.C3Problem span: ChangedCodeSpan edit_line_ids: Sequence[int] relevant_changes: Sequence[ChangedCodeSpan] relevant_unchanged: Mapping["PyFullName", "PyDefinition"] change_type: Change[None] ...
coeditor.model/RetrievalEditorModel.predict_on_batch
Modified
temp-1
a19ca9519caf03745b65f959367091eee884fc98
- return target lines in service response.
<0>:<add> pred = tokens_to_change(inline_output_tokens(change_tks, out))
# module: coeditor.model class RetrievalEditorModel(T5PreTrainedModel): @torch.autocast("cuda") def predict_on_batch( self, batch: dict, originals: Sequence[TokenSeq], dec_args: DecodingArgs, n_solutions: int = 1, ...
===========above chunk 0=========== # module: coeditor.model class RetrievalEditorModel(T5PreTrainedModel): @torch.autocast("cuda") def predict_on_batch( self, batch: dict, originals: Sequence[TokenSeq], dec_args: DecodingArgs, n_soluti...
coeditor.service/ServiceResponse.print
Modified
temp-1
a19ca9519caf03745b65f959367091eee884fc98
- return target lines in service response.
<0>:<add> print(f"Target lines: {self.target_lines}", file=file)
# module: coeditor.service @dataclass class ServiceResponse: def print(self, file=sys.stdout): print(f"Target file: {self.target_file}", file=file) print(f"Edit range: {self.edit_start} - {self.edit_end}", file=file) <0> for i, s in enumerate(self.sugges...
===========unchanged ref 0=========== at: coeditor.service.EditSuggestion score: float change_preview: str new_code: str at: coeditor.service.ServiceResponse target_file: str edit_start: tuple[int, int] edit_end: tuple[int, int] ...
coeditor.service/EditPredictionService.suggest_edit
Modified
temp-1
a19ca9519caf03745b65f959367091eee884fc98
- return target lines in service response.
<0>:<add> target_lines=target_lines,
# module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> ServiceResponse: <s>_dir}") ...
===========above chunk 0=========== # module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> ServiceResponse: ...
coeditor.c3problem/C3ProblemTokenizer.__post_init__
Modified
temp-1
dcf432c49b5076a6d10b6299451cc66978201ea6
Remove unused cachetools.
<0>:<add> self._offset_cache = dict[int, TkArray]()
# module: coeditor.c3problem @dataclass class C3ProblemTokenizer: def __post_init__(self): - self._offset_cache = LRUCache[int, TkArray](maxsize=100) <0>
===========unchanged ref 0=========== at: coeditor.tk_array TkArray()
coeditor.c3problem/C3Problem.print
Modified
temp-1
ae76b72f59bc67bc17f0d8c134675a4f97cad381
Better edit range control: support editing below.
<0>:<add> ("edit_line_ids", str(self.edit_line_ids)),
# module: coeditor.c3problem @dataclass(frozen=True) class C3Problem: def print(self): main_change = self.span.delta.apply_to_change(self.span.original.tolist()) print_sections( ("summary", self.summary()), ("main change", decod...
===========unchanged ref 0=========== at: coeditor.c3problem.C3Problem span: ChangedCodeSpan edit_line_ids: Sequence[int] relevant_changes: Sequence[ChangedCodeSpan] relevant_unchanged: Sequence[ChangedCodeSpan] change_type: Change[None] src_i...
coeditor.c3problem/C3GeneratorCache.create_problem
Modified
temp-1
ae76b72f59bc67bc17f0d8c134675a4f97cad381
Better edit range control: support editing below.
<0>:<add> line_ids,
# module: coeditor.c3problem class C3GeneratorCache: def create_problem( self, target: ChangedSpan, + target_lines: Sequence[int], - edit_lines: Sequence[int] | None, changed: Mapping[ModuleName, JModuleChange], target...
===========above chunk 0=========== # module: coeditor.c3problem class C3GeneratorCache: def create_problem( self, target: ChangedSpan, + target_lines: Sequence[int], - edit_lines: Sequence[int] | None, changed: Mapping[ModuleName, JModuleChange], ...
coeditor.c3problem/C3ProblemSimpleSplit.transform
Modified
temp-1
ae76b72f59bc67bc17f0d8c134675a4f97cad381
Better edit range control: support editing below.
<0>:<add> l_range = prob.edit_line_ids
# module: coeditor.c3problem @dataclass class C3ProblemSimpleSplit(C3ProblemTransform): def transform(self, prob: C3Problem) -> Sequence[C3Problem]: delta = prob.span.delta - l_range = prob.edit_lines <0> assert isinstance(l_range, range) sta...
===========unchanged ref 0=========== at: abc abstractmethod(callable: _FuncT) -> _FuncT ABC() at: coeditor.c3problem C3Problem(span: ChangedCodeSpan, edit_line_ids: Sequence[int], relevant_changes: Sequence[ChangedCodeSpan], relevant_unchanged: Sequence[ChangedCodeSpan], chang...
coeditor.c3problem/C3ProblemChangeDropout.transform
Modified
temp-1
ae76b72f59bc67bc17f0d8c134675a4f97cad381
Better edit range control: support editing below.
<0>:<add> l_range = prob.edit_line_ids
# module: coeditor.c3problem @dataclass class C3ProblemChangeDropout(C3ProblemTransform): def transform(self, prob: C3Problem) -> Sequence[C3Problem]: original = prob.span.original delta = prob.span.delta - l_range = prob.edit_lines <0> asser...
===========below chunk 0=========== # module: coeditor.c3problem @dataclass class C3ProblemChangeDropout(C3ProblemTransform): def transform(self, prob: C3Problem) -> Sequence[C3Problem]: # offset: 1 <s> delta2_groups = delta2.change_groups() if not delta2_groups: ...
coeditor.c3problem/C3ProblemTokenizer.tokenize_problem
Modified
temp-1
ae76b72f59bc67bc17f0d8c134675a4f97cad381
Better edit range control: support editing below.
<0>:<add> for i, l in enumerate(problem.edit_line_ids):
# module: coeditor.c3problem @dataclass class C3ProblemTokenizer: def tokenize_problem( self, problem: C3Problem, ) -> TkC3Problem: span = problem.span original: TokenSeq = span.original.tolist() tk_delta:...
===========below chunk 0=========== # module: coeditor.c3problem @dataclass class C3ProblemTokenizer: def tokenize_problem( self, problem: C3Problem, ) -> TkC3Problem: # offset: 1 <s>output = truncate_output_tks(chunk_input, chunk_output) # tr...
coeditor.model/RetrievalDecodingResult.exact_match_accuracy
Modified
temp-1
ae76b72f59bc67bc17f0d8c134675a4f97cad381
Better edit range control: support editing below.
<0>:<add> line_shift = prob.edit_line_ids[0]
# module: coeditor.model @dataclass class RetrievalDecodingResult: def exact_match_accuracy(self) -> tuple[CountedSum, dict[int, bool]]: ex2correct = dict[int, bool]() bad_probs = list[C3Problem]() for i, mp in enumerate(self.predictions): ...
===========unchanged ref 0=========== at: coeditor._utils cprint(color: str, *elems, sep: Optional[str]=..., end: Optional[str]=..., file: Optional[SupportsWrite[str]]=..., flush: bool=...) at: coeditor.c3problem C3Problem(span: ChangedCodeSpan, edit_line_ids: Sequence[int], relevant_change...
coeditor.service/ChangeDetector.get_problem
Modified
temp-1
ae76b72f59bc67bc17f0d8c134675a4f97cad381
Better edit range control: support editing below.
<0>:<add> cspan, target_lines, changed, target_usages, src_info
# module: coeditor.service @dataclass class ChangeDetector: def get_problem( self, target_file: RelPath, target_lines: Sequence[int] | int, ) -> C3Problem: <s> len(cspans) != 1: # Create a trivial change for the targ...
===========above chunk 0=========== # module: coeditor.service @dataclass class ChangeDetector: def get_problem( self, target_file: RelPath, target_lines: Sequence[int] | int, ) -> C3Problem: # offset: -1 <s> case Deleted(): ...
coeditor.service/EditPredictionService.suggest_edit
Modified
temp-1
ae76b72f59bc67bc17f0d8c134675a4f97cad381
Better edit range control: support editing below.
<0>:<add> print(f"{problem.edit_line_ids=}", file=f)
# module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> ServiceResponse: <s>.predict_on_...
===========above chunk 0=========== # module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> ServiceResponse: ...
coeditor.service/EditPredictionService.apply_edit_to_elem
Modified
temp-1
ae76b72f59bc67bc17f0d8c134675a4f97cad381
Better edit range control: support editing below.
<0>:<add> delta = TkDelta.from_output_tks(problem.edit_line_ids, out_tks)
# module: coeditor.service @dataclass class EditPredictionService: @staticmethod def apply_edit_to_elem( problem: C3Problem, out_tks: TokenSeq, ) -> tuple[Modified[str], str]: change_tks = problem.span.original.tolist() - ...
===========unchanged ref 0=========== at: coeditor.c3problem C3Problem(span: ChangedCodeSpan, edit_line_ids: Sequence[int], relevant_changes: Sequence[ChangedCodeSpan], relevant_unchanged: Mapping["PyFullName", "PyDefinition"], change_type: Change[None], src_info: SrcInfo, transformations: tuple[str, ...]=(...
scripts.start_server/start_server
Modified
temp-1
ae76b72f59bc67bc17f0d8c134675a4f97cad381
Better edit range control: support editing below.
<0>:<add> print(f"Starting suggestion server at localhost:{port}")
# module: scripts.start_server - def start_server( - device, port: int, drop_comments: bool = False, print_stats: bool = True - ): + def start_server(device, port: int, print_stats: bool = True): <s> model.to(device) print(f"Model '{model_path}' loaded on device:", device) ...
===========above chunk 0=========== # module: scripts.start_server - def start_server( - device, port: int, drop_comments: bool = False, print_stats: bool = True - ): + def start_server(device, port: int, print_stats: bool = True): # offset: -1 # this newer model is trained with comments ...
coeditor.service/ChangeDetector.get_problem
Modified
temp-1
f36e2f042ab0df36e0ad78e6db345ea669d32d3d
Improve apply_edit_to_elem.
<0>:<add> return prob, span
# module: coeditor.service @dataclass class ChangeDetector: def get_problem( self, target_file: RelPath, target_lines: Sequence[int] | int, + ) -> tuple[C3Problem, StatementSpan]: - ) -> C3Problem: <s>) == 0: #...
===========above chunk 0=========== # module: coeditor.service @dataclass class ChangeDetector: def get_problem( self, target_file: RelPath, target_lines: Sequence[int] | int, + ) -> tuple[C3Problem, StatementSpan]: - ) -> C3Problem: # offset: -1 ...
coeditor.service/ServiceResponse.to_json
Modified
temp-1
f36e2f042ab0df36e0ad78e6db345ea669d32d3d
Improve apply_edit_to_elem.
<0>:<add> "target_lines": list(self.target_lines),
# module: coeditor.service @dataclass class ServiceResponse: def to_json(self): return { "target_file": self.target_file, "edit_start": self.edit_start, "edit_end": self.edit_end, "old_code": self.input_cod...
===========unchanged ref 0=========== at: coeditor.service.EditSuggestion score: float change_preview: str new_code: str to_json() at: coeditor.service.ServiceResponse target_file: str edit_start: tuple[int, int] edit_end: tup...
coeditor.service/EditPredictionService.suggest_edit
Modified
temp-1
f36e2f042ab0df36e0ad78e6db345ea669d32d3d
Improve apply_edit_to_elem.
<0>:<add> target_file=str(self.project / file),
# module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> ServiceResponse: <s> ...
===========above chunk 0=========== # module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> ServiceResponse: ...
coeditor.service/EditPredictionService.apply_edit_to_elem
Modified
temp-1
f36e2f042ab0df36e0ad78e6db345ea669d32d3d
Improve apply_edit_to_elem.
<0>:<add> return new_code, change_preview
# module: coeditor.service @dataclass class EditPredictionService: @staticmethod def apply_edit_to_elem( + current_code: str, problem: C3Problem, out_tks: TokenSeq, + ) -> tuple[str, str]: - ) -> tuple[Modified[str], str]: ...
===========unchanged ref 0=========== at: coeditor.c3problem C3Problem(span: ChangedCodeSpan, edit_line_ids: Sequence[int], relevant_changes: Sequence[ChangedCodeSpan], relevant_unchanged: Mapping["PyFullName", "PyDefinition"], change_type: Change[None], src_info: SrcInfo, transformations: tuple[str, ...]=(...
scripts.start_server/start_server
Modified
temp-1
17324431420bcb39712641ef584f624739828518
Update start_server api.
<0>:<add> response = service.suggest_edit(path, lines, log_dir)
# module: scripts.start_server def start_server(device, port: int, print_stats: bool = True): <s> on device:", device) batch_args = BatchArgs.service_default() dec_args = DecodingArgs(do_sample=False, num_beams=4, length_penalty=0.0) services = dict[Path, EditPredi...
===========above chunk 0=========== # module: scripts.start_server def start_server(device, port: int, print_stats: bool = True): # offset: -1 # this newer model is trained with comments model_path = "MrVPlusOne/coeditor-xl-c3-dropout-v1.4" model = RetrievalEditorModel.load(model_pat...
coeditor.c3problem/C3GeneratorCache.__init__
Modified
temp-1
ee631b00e147dd9af4b1fd9cbb7e3c71bb944333
Speed up ChangeDetector.get_problem via caching.
<0>:<add> self._mod_hier = ModuleHierarchy.from_modules(pre_module_map)
# module: coeditor.c3problem class C3GeneratorCache: def __init__(self, pre_module_map: Mapping[ModuleName, JModule]): + # stores the changed headers + self._header_cache = dict[ProjectPath, ChangedHeader]() - self.header_cache = dict[ProjectPath, ChangedHeader]...
===========unchanged ref 0=========== at: coeditor.c3problem ChangedHeader(change_tks: TkArray, type: str, line_range: LineRange, path: ProjectPath) ChangedCodeSpan(headers: Sequence[ChangedHeader], original: TkArray, delta: TkDelta, line_range: LineRange, module: ModuleName) at: coedi...
coeditor.c3problem/C3GeneratorCache.get_pre_spans
Modified
temp-1
ee631b00e147dd9af4b1fd9cbb7e3c71bb944333
Speed up ChangeDetector.get_problem via caching.
<0>:<add> def_cache[path] = cspans
# module: coeditor.c3problem class C3GeneratorCache: def get_pre_spans(self, used: PyDefinition) -> list[ChangedCodeSpan]: <s>tree, ptree.Function) ) case StatementSpan(): stmt_spans.append(elem) # add collaps...
===========above chunk 0=========== # module: coeditor.c3problem class C3GeneratorCache: def get_pre_spans(self, used: PyDefinition) -> list[ChangedCodeSpan]: # offset: -1 "Get the (pre-edit) spans for the given definition." + def_cache = self._pre_def_cache - cspan_c...
coeditor.c3problem/C3GeneratorCache.to_header
Modified
temp-1
ee631b00e147dd9af4b1fd9cbb7e3c71bb944333
Speed up ChangeDetector.get_problem via caching.
<0>:<add> self._header_cache[path] = ch
# module: coeditor.c3problem class C3GeneratorCache: def to_header(self, cs: Change[ChangeScope]) -> ChangedHeader: path = cs.earlier.path + if (ch := self._header_cache.get(path)) is None: - if (ch := self.header_cache.get(path)) is None: he...
===========unchanged ref 0=========== at: coeditor.c3problem.C3GeneratorCache.get_relevant_unchanged sorted_defs = list(reversed(parent_defs)) used_defs = set(sorted_defs) at: coeditor.c3problem.ChangedCodeSpan headers: Sequence[ChangedHeader] original: TkArray ...
coeditor.service/ChangeDetector.__post_init__
Modified
temp-1
ee631b00e147dd9af4b1fd9cbb7e3c71bb944333
Speed up ChangeDetector.get_problem via caching.
<0>:<add> self.jproj = jedi.Project(path=proj, added_sys_path=[proj / "src"])
# module: coeditor.service @dataclass class ChangeDetector: def __post_init__(self): self.script_cache = TimedCache() self.analyzer = JediUsageAnalyzer() self._index_cache = TimedCache[RelPath, JModule, CommitHash]() + self._now_cache = T...
===========unchanged ref 0=========== at: coeditor.c3problem JediUsageAnalyzer(include_parent_usages: bool=True, include_builtins: bool=False) at: coeditor.common RelPath = NewType("RelPath", Path) TimedCache() at: coeditor.scoped_changes JModule(mname: ModuleN...
coeditor.service/ChangeDetector._parse_index_module
Modified
temp-1
ee631b00e147dd9af4b1fd9cbb7e3c71bb944333
Speed up ChangeDetector.get_problem via caching.
<0>:<add> self._updated_index_modules.add(mname)
# module: coeditor.service @dataclass class ChangeDetector: def _parse_index_module(self, path: RelPath) -> JModule: + code = file_content_from_commit(self.project, "", path.as_posix()) - code = self._get_index_content(path) mod = parso.parse(code) ...
===========unchanged ref 0=========== at: coeditor._utils assert_eq(x: T1, y: T1, message: Callable[[], str]=lambda: "") -> None at: coeditor.common RelPath = NewType("RelPath", Path) at: coeditor.service SysTime = float at: coeditor.service.ChangeDetector ...
coeditor.service/ChangeDetector.get_problem
Modified
temp-1
ee631b00e147dd9af4b1fd9cbb7e3c71bb944333
Speed up ChangeDetector.get_problem via caching.
<0>:<add> prob = self.gcache.create_problem(
# module: coeditor.service @dataclass class ChangeDetector: def get_problem( self, target_file: RelPath, target_lines: Sequence[int] | int, ) -> tuple[C3Problem, StatementSpan]: <s>) > 1: warnings.warn( ...
===========above chunk 0=========== # module: coeditor.service @dataclass class ChangeDetector: def get_problem( self, target_file: RelPath, target_lines: Sequence[int] | int, ) -> tuple[C3Problem, StatementSpan]: # offset: -1 <s>(rel_path) ...
coeditor.service/EditPredictionService.suggest_edit
Modified
temp-1
a551a61fd2b4a8731ea5c88e927a3b8f83d0eb9c
Optimize service params.
<0>:<add> input_code=span.code,
# module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> ServiceResponse: <s>) ...
===========above chunk 0=========== # module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> ServiceResponse: ...
coeditor._utils/compute_line_diffs
Modified
temp-1
c12caf0fb8dc2e6b2930f770fe911f9ed359960b
Improve suggestion preview. - Now shows changes of the target region only.
<0>:<add> elif tag != "?":
# module: coeditor._utils def compute_line_diffs( before: Sequence[str], after: Sequence[str], keep_explain_lines: bool = False ): SizeLimit = 8000 if ( sum(len(x) for x in before) > SizeLimit or sum(len(x) for x in after) > SizeLimit ...
===========unchanged ref 0=========== at: coeditor._utils compute_line_diffs_fast(before: Sequence[str], after: Sequence[str]) at: difflib Differ(linejunk: Optional[_JunkCallback]=..., charjunk: Optional[_JunkCallback]=...) at: difflib.Differ compare(a: Sequence[_StrType], ...
coeditor.service/ChangeDetector.get_problem
Modified
temp-1
c12caf0fb8dc2e6b2930f770fe911f9ed359960b
Improve suggestion preview. - Now shows changes of the target region only.
<0>:<add> edit_stop = min(edit_start + self.max_lines_to_edit, cspan.line_range[1])
# module: coeditor.service @dataclass class ChangeDetector: def get_problem( self, target_file: RelPath, target_lines: Sequence[int] | int, ) -> tuple[C3Problem, StatementSpan]: <s> first one." ) ...
===========above chunk 0=========== # module: coeditor.service @dataclass class ChangeDetector: def get_problem( self, target_file: RelPath, target_lines: Sequence[int] | int, ) -> tuple[C3Problem, StatementSpan]: # offset: -1 <s> ...
coeditor.service/EditPredictionService.suggest_edit
Modified
temp-1
c12caf0fb8dc2e6b2930f770fe911f9ed359960b
Improve suggestion preview. - Now shows changes of the target region only.
<0>:<add> input_code=target.current_code,
# module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> ServiceResponse: <s>( ...
===========above chunk 0=========== # module: coeditor.service @dataclass class EditPredictionService: def suggest_edit( self, file: Path, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> ServiceResponse: ...
coeditor.service/ServiceResponse.to_json
Modified
temp-1
4d326a6e8e4a96693abfe2110182b60a17001a0b
Support line status visualization.
<0>:<add> "suggestions": [s for s in self.suggestions],
# module: coeditor.service @dataclass class ServiceResponse: def to_json(self): return { "target_file": self.target_file, "edit_start": self.edit_start, "edit_end": self.edit_end, "old_code": self.input_cod...
===========unchanged ref 0=========== at: coeditor.service.ServiceResponse target_file: str edit_start: tuple[int, int] edit_end: tuple[int, int] target_lines: Sequence[int] input_code: str suggestions: list[EditSuggestion] at: sys ...
coeditor.service/ServiceResponse.print
Modified
temp-1
4d326a6e8e4a96693abfe2110182b60a17001a0b
Support line status visualization.
<0>:<add> print(textwrap.indent(s["change_preview"], "\t"), file=file)
# module: coeditor.service @dataclass class ServiceResponse: def print(self, file=sys.stdout): print(f"Target file: {self.target_file}", file=file) print(f"Edit range: {self.edit_start} - {self.edit_end}", file=file) target_lines = self.target_lines ...
===========unchanged ref 0=========== at: coeditor.service.ServiceResponse edit_start: tuple[int, int] edit_end: tuple[int, int] target_lines: Sequence[int] suggestions: list[EditSuggestion] at: textwrap indent(text: str, prefix: str, predicate: Option...
coeditor.c3problem/PyDefinition.from_name
Modified
temp-1
499b1221d86c51463671e7dc35f97df30938c479
New encoding for changed and unchanged refs.
<0>:<add> yield PyDefinition(full_name, start_pos, end_pos, signatures)
# module: coeditor.c3problem @dataclass(frozen=True) class PyDefinition: @staticmethod def from_name(name: classes.BaseName) -> Iterable["PyDefinition"]: if ( not name.in_builtin_module() and (full_name := name.full_name) ...
===========unchanged ref 0=========== at: coeditor.c3problem PyFullName = NewType("PyFullName", str) PyDefinition(full_name: PyFullName, start_pos: tuple[int, int], end_pos: tuple[int, int]) at: coeditor.c3problem.PyDefinition full_name: PyFullName start_pos: tuple...
coeditor.c3problem/C3ProblemTokenizer._group_encode_changed_refs
Modified
temp-1
499b1221d86c51463671e7dc35f97df30938c479
New encoding for changed and unchanged refs.
<0>:<add> return join_list(self._encode_changed_ref(x) for x in changes)
# module: coeditor.c3problem @dataclass class C3ProblemTokenizer: def _group_encode_changed_refs( self, changes: Sequence[ChangedCodeSpan] + ) -> Sequence[TkArray]: - ) -> Sequence[TokenSeq]: - module2changes = groupby(changes, lambda c: c.module) ...
===========unchanged ref 0=========== at: coeditor._utils groupby(iterable: Iterable[T1], keyfunc: Callable[[T1], T2]) -> dict[T2, list[T1]] at: coeditor.c3problem ChangedHeader(change_tks: TkArray, type: str, line_range: LineRange, path: ProjectPath) ChangedCodeSpan(headers: S...
scripts.start_server/start_server
Modified
temp-1
499b1221d86c51463671e7dc35f97df30938c479
New encoding for changed and unchanged refs.
<0>:<add> dec_args = DecodingArgs(do_sample=False, num_beams=4)
# module: scripts.start_server def start_server(device, port: int, print_stats: bool = True): # this newer model is trained with comments model_path = "MrVPlusOne/coeditor-xl-c3-dropout-v1.4" model = RetrievalEditorModel.load(model_path) model.to(device) pri...
===========unchanged ref 0=========== at: IPython.core.display_functions display(*, include=None, exclude=None, metadata=None, transient=None, display_id=None, raw=False, clear=False, source=_sentinel, **kwargs) at: coeditor._utils timed_action(name: str, silent: bool=False) at: co...
coeditor._utils/compute_line_diffs
Modified
temp-1
c1a8d33c4eeaf20faca18a12b759677f80dbda72
Improve line diffs. - Now for replace, `+` comes before `-`.
<0>:<add> for line in compare(before, after):
# module: coeditor._utils def compute_line_diffs( before: Sequence[str], after: Sequence[str], keep_explain_lines: bool = False ): SizeLimit = 8000 + differ = _ModifiedDiffer() if ( sum(len(x) for x in before) > SizeLimit or sum(len(x) ...
===========unchanged ref 0=========== at: difflib SequenceMatcher(isjunk: Optional[Callable[[_T], bool]]=..., a: Sequence[_T]=..., b: Sequence[_T]=..., autojunk: bool=...) _keep_original_ws(s, tag_s) Differ(linejunk: Optional[_JunkCallback]=..., charjunk: Optional[_JunkCallback]=.....
coeditor.encoding/TkDelta.change_groups
Modified
temp-1
c1a8d33c4eeaf20faca18a12b759677f80dbda72
Improve line diffs. - Now for replace, `+` comes before `-`.
<0>:<add> while i < len(keys) and is_next(i - 1, i) and is_key_type(i, Del_id):
# module: coeditor.encoding @dataclass(frozen=True) class TkDelta: def change_groups(self) -> Sequence[Sequence[DeltaKey]]: <s>] return l1 == l2 or (l2 == l1 + 1) + def is_same_line(key1: int, key2: int): + if key2 >= len(keys): ...
===========above chunk 0=========== # module: coeditor.encoding @dataclass(frozen=True) class TkDelta: def change_groups(self) -> Sequence[Sequence[DeltaKey]]: # offset: -1 """Group individual changes into logical groups using heuristics. Currently, this only groups a <de...
coeditor.common/random_subset
Modified
temp-1
16aba227a72a38fa84d6def0ae82aeb8a152563e
Keep items order in random_subset.
<0>:<add> ids = _subset_ids(ids)
# module: coeditor.common def random_subset(all, n: int, rng: random.Random | int | None = None): if rng is None: rng = random.Random() elif isinstance(rng, int): rng = random.Random(rng) + + def _subset_ids(ids: list[int]): + rng.shuf...
===========unchanged ref 0=========== at: random Random(x: Any=...) at: random.Random VERSION = 3 # used by getstate/setstate _randbelow = _randbelow_with_getrandbits shuffle(x: MutableSequence[Any], random: Optional[Callable[[], float]]=...) -> None a...
tests.test_edits/TestChangeIdentities.test_tk_encodings
Modified
temp-1
bd89c861a6d0df7743a0e8b8351a2bc7cd9d44a4
More edits tests.
<0>:<add> c_rec2 = tokens_to_change(inlined)
# module: tests.test_edits class TestChangeIdentities: def test_tk_encodings(self): <s> * 40) - # print(show_change(c)) c_tokens = change_to_tokens(c) + print_sections( + ("c_tokens", decode_tokens(c_tokens)), - ...
===========above chunk 0=========== # module: tests.test_edits class TestChangeIdentities: def test_tk_encodings(self): # offset: -1 for name, c in self.cases.items(): + print("=" * 40, name, "=" * 40) - # print(show_change(c)) c_tokens = chang...
tests.test_edits/TestChangeIdentities.test_get_new_target_lines
Modified
temp-1
bd89c861a6d0df7743a0e8b8351a2bc7cd9d44a4
More edits tests.
<0>:<add> n_origin_lines = len(tk_splitlines(original))
# module: tests.test_edits class TestChangeIdentities: def test_get_new_target_lines(self): for name, c in self.cases.items(): original, delta = TkDelta.from_change_tks(change_to_tokens(c)) - n_origin_lines = len(split_list(original, Newline_id)) <0...
===========unchanged ref 0=========== at: coeditor.common SEP = "-" * 80 random_subset(all: Mapping[T1, T2], n: int, rng: random.Random | int | None=None) -> dict[T1, T2] random_subset(all: Sequence[T1], n: int, rng: random.Random | int | None=None) -> list[T1] print_err(*,...
coeditor.common/assert_str_equal
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> raise AssertionError(f"Strings didn't match: {name}")
# module: coeditor.common + def assert_str_equal(actual: str, expect: str, name: str | None = None): - def assert_str_equal(actual: str, expect: str): + actual = actual.rstrip() + expect = expect.rstrip() if actual != expect: print_err(f"{expect = }") ...
===========unchanged ref 0=========== at: sys stderr: TextIO ===========changed ref 0=========== # module: coeditor.common + def fix_newline(text: str): + if text.endswith("\n"): + return text + return text + "\n" +
coeditor.encoding/TkDelta.apply_to_input
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> lines = tk_splitlines(input)
# module: coeditor.encoding @dataclass(frozen=True) class TkDelta: def apply_to_input(self, input: TokenSeq): - lines = split_list(input, Newline_id) <0> new_lines = list[TokenSeq]() for i, line in enumerate(lines): deleted = False ...
===========unchanged ref 0=========== at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding Add_id = get_tk_id(Add) Del_id = get_tk_id(Del) tk_splitlines(tks: TokenSeq) DeltaKey = NewType("DeltaKey", tuple[int, int]) at: coeditor.en...
coeditor.encoding/TkDelta.apply_to_change
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> lines = tk_splitlines(change)
# module: coeditor.encoding @dataclass(frozen=True) class TkDelta: def apply_to_change(self, change: TokenSeq) -> TokenSeq: - lines = split_list(change, Newline_id) <0> new_lines = list[TokenSeq]() for i, line in enumerate(lines): ...
===========unchanged ref 0=========== at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding Add_id = get_tk_id(Add) Del_id = get_tk_id(Del) tk_splitlines(tks: TokenSeq) at: coeditor.encoding.TkDelta _deltas: Mapping[int, tuple[TokenSeq, ...
coeditor.encoding/change_tks_to_original_delta
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> diffs = tk_splitlines(change)
# module: coeditor.encoding def change_tks_to_original_delta(change: TokenSeq) -> tuple[TokenSeq, TkDelta]: - diffs = split_list(change, Newline_id) <0> input_lines: list[TokenSeq] = [] line_delta: list[TokenSeq] = [] deltas = dict[int, tuple[TokenSeq, ...]]() ...
===========unchanged ref 0=========== at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding Add_id = get_tk_id(Add) Del_id = get_tk_id(Del) tk_splitlines(tks: TokenSeq) TkDelta(_deltas: Mapping[int, tuple[TokenSeq, ...]]) =========...
coeditor.encoding/tokens_to_change
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> tk_lines = tk_splitlines(tokens)
# module: coeditor.encoding def tokens_to_change(tokens: TokenSeq) -> Modified[str]: "Decode a token sequence into a change." - tk_lines = split_list(tokens, Newline_id) <0> before_lines = list[TokenSeq]() after_lines = list[TokenSeq]() for tk_line in tk_li...
===========unchanged ref 0=========== at: coeditor.change Modified(before: E1, after: E1, unchanged: bool=False) at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding Add_id = get_tk_id(Add) Del_id = get_tk_id(Del) tk_splitlines(tks: Tok...
coeditor.encoding/code_to_input
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> tk_lines = tk_splitlines(code_tks)
# module: coeditor.encoding def code_to_input(code_tks: TokenSeq) -> TokenSeq: """ Convert the original code into model input by inserting <extra_id> tokens. In this format, there will be an <extra_id> token at the beginning of each line. An additional <extra_i...
===========unchanged ref 0=========== at: coeditor.change Modified(before: E1, after: E1, unchanged: bool=False) at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding N_Extra_Ids = 100 get_extra_id(i: int) -> Token tk_splitlines(tks: Tok...
coeditor.encoding/change_tks_to_input_output
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> tk_lines = tk_splitlines(tks)
# module: coeditor.encoding def change_tks_to_input_output(tks: TokenSeq) -> tuple[TokenSeq, TokenSeq]: "See `change_to_input_output`." - tk_lines = split_list(tks, Newline_id) <0> input_lines: list[TokenSeq] = [] out_buff = TokenSeq() output_segs: list[Tok...
===========below chunk 0=========== # module: coeditor.encoding def change_tks_to_input_output(tks: TokenSeq) -> tuple[TokenSeq, TokenSeq]: # offset: 1 <s>ks) msg = f"Invalid output tokens.\n Output segs: {str_segs}\n Change: {show_change(change)}" raise ValueError(msg) r...
coeditor.encoding/TokenizedEdit.show
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> for line_tks in tk_splitlines(self.main_tks):
# module: coeditor.encoding class TokenizedEdit(ABC): def show(self, pred_tks: TokenSeq | None = None) -> str: <s>.append(Newline_id) seg = seg + origin_line label = show_label(id_map.get(k, -1)) lines.append(f"{label}:{in...
===========above chunk 0=========== # module: coeditor.encoding class TokenizedEdit(ABC): def show(self, pred_tks: TokenSeq | None = None) -> str: # offset: -1 def show_label(i: int): return f" <{i}>" if i <= 9 else f"<{i}>" def show_content(tks: TokenSeq...
coeditor.encoding/TokenizedEdit.is_repetitive_edit
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> for line in tk_splitlines(seg):
# module: coeditor.encoding class TokenizedEdit(ABC): def is_repetitive_edit(self, blue_threshold=0.8) -> bool: <s>strip() return encode_single_line(s) else: return [] + ctx_lines = tk_splitlines(self.input_tks)...
===========above chunk 0=========== # module: coeditor.encoding class TokenizedEdit(ABC): def is_repetitive_edit(self, blue_threshold=0.8) -> bool: # offset: -1 """Check if all additions in the output_tokens can be matched to an addition in the input_tokens with a BLEU score ...
coeditor.encoding/compress_change_tks
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> lines = tk_splitlines(tks)
# module: coeditor.encoding def compress_change_tks(tks: TokenSeq, max_ctx: int): - lines = split_list(tks, sep=Newline_id) <0> to_keep = [False for _ in lines] # mark which lines to keep for i, line in enumerate(lines): if line and (line[0] == Add_id or line[...
===========unchanged ref 0=========== at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding Add_id = get_tk_id(Add) Del_id = get_tk_id(Del) tk_splitlines(tks: TokenSeq) encode_single_line(text: str, add_special_tokens=False) -> TokenSeq ...
coeditor.c3problem/C3Problem.line_ids_to_input_lines
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> for i, tks in enumerate(tk_splitlines(change_tks)):
# module: coeditor.c3problem @dataclass(frozen=True) class C3Problem: def line_ids_to_input_lines(self, line_ids: Sequence[int]) -> Sequence[int]: """Convert the edit lines (which are line ids including deleted lines) into normal line numbers that do not include d...
===========unchanged ref 0=========== at: coeditor.c3problem.C3Problem span: ChangedCodeSpan edit_line_ids: Sequence[int] relevant_changes: Sequence[ChangedCodeSpan] relevant_unchanged: Mapping["PyFullName", "PyDefinition"] change_type: Change[None] ...
coeditor.c3problem/C3GeneratorCache.create_problem
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> for i, tks in enumerate(tk_splitlines(changed_code)):
# module: coeditor.c3problem class C3GeneratorCache: def create_problem( self, target: ChangedSpan, target_lines: Sequence[int], changed: Mapping[ModuleName, JModuleChange], target_usages: LineUsageAnalysis, src_in...
===========above chunk 0=========== # module: coeditor.c3problem class C3GeneratorCache: def create_problem( self, target: ChangedSpan, target_lines: Sequence[int], changed: Mapping[ModuleName, JModuleChange], target_usages: LineUsageAnalysis, ...
coeditor.c3problem/C3ProblemTokenizer.tokenize_problem
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> origin_lines = tk_splitlines(original)
# module: coeditor.c3problem @dataclass class C3ProblemTokenizer: def tokenize_problem( self, problem: C3Problem, ) -> TkC3Problem: span = problem.span original: TokenSeq = span.original.tolist() tk_delta:...
===========below chunk 0=========== # module: coeditor.c3problem @dataclass class C3ProblemTokenizer: def tokenize_problem( self, problem: C3Problem, ) -> TkC3Problem: # offset: 1 <s>_output) # try move some prev_change_tks into the input ...
coeditor.service/get_tk_lines
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> lines = tk_splitlines(tks)
# module: coeditor.service def get_tk_lines(tks: TokenSeq, line_ids: Sequence[int]) -> TokenSeq: - lines = split_list(tks, Newline_id) <0> return join_list((lines[i] for i in line_ids), Newline_id)
===========unchanged ref 0=========== at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding tk_splitlines(tks: TokenSeq) at: typing Sequence = _alias(collections.abc.Sequence, 1) ===========changed ref 0=========== # module: coeditor.encoding + de...
tests.test_edits/assert_change_eq
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> assert_str_equal(get_after(actual), get_after(expected), name)
# module: tests.test_edits def assert_change_eq(actual: Change[str], expected: Change[str], name: str): + assert_str_equal(get_before(actual), get_before(expected), name) - assert_str_equal(get_before(actual), get_before(expected)) - assert_str_equal(get_after(actual), get_after(expe...
===========unchanged ref 0=========== at: coeditor.change Change = Added[E1] | Deleted[E1] | Modified[E1] at: coeditor.common assert_str_equal(actual: str, expect: str, name: str | None=None) at: tests.test_edits get_before(change: Change[str]) -> str get_after...
tests.test_edits/assert_tks_eq
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> assert_str_equal(actual_str, expected_str, name)
# module: tests.test_edits def assert_tks_eq(actual: TokenSeq, expected: TokenSeq, name: str): - if actual != expected: - print_sections( + actual_str = decode_tokens(actual) + expected_str = decode_tokens(expected) - ("Expected", decode_tokens(expected)),...
===========unchanged ref 0=========== at: coeditor.common TokenSeq = list[Token] assert_str_equal(actual: str, expect: str, name: str | None=None) at: coeditor.encoding decode_tokens(tokens: TokenSeq, prettify: bool=False) -> str ===========changed ref 0=========== ...
tests.test_edits/test_splitlines
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> assert_tks_eq(join_list(tk_lines, Newline_id), enc, "join_list(tk_lines)")
# module: tests.test_edits def test_splitlines(): for n in range(100): rand_input = [random.choice(["a", "b", "c", "\n"]) for _ in range(n)] + input = "".join(rand_input).rstrip("\n") - input = fix_line_end("".join(rand_input)) lines = splitlines...
===========unchanged ref 0=========== at: coeditor.common splitlines(text: str) -> list[str] count_lines(text: str) -> int join_list(segs: Iterable[Iterable[T1]], sep: T1 | None=None) -> list[T1] at: coeditor.encoding Newline_id = get_tk_id("\n") tk_sp...
tests.test_edits/TestChangeIdentities.test_str_encodings
Modified
temp-1
8b7c5296eb4ca6b0b898bd216b0369226d60f406
handle trailing spaces in test.
<0>:<add> assert_str_equal(after, get_after(c), name)
# module: tests.test_edits class TestChangeIdentities: def test_str_encodings(self): for name, c in self.cases.items(): try: line_diffs = change_to_line_diffs(c) print("line_diffs\n------\n" + "\n".join(line_diffs)) ...
===========unchanged ref 0=========== at: coeditor.common print_err(*, sep: Optional[str]=..., end: Optional[str]=..., flush: bool=...) -> None assert_str_equal(actual: str, expect: str, name: str | None=None) at: coeditor.encoding change_to_line_diffs(change: Change[str]) -> l...
coeditor.c3problem/C3ProblemSimpleSplit.transform
Modified
temp-1
93d3a66a05da77b6c712854834bafe308e32b75b
- Fix dataclasses.replace. - Fix module usages in `pre_edit_analysis` - Sort changes using heuristic.
<0>:<add> prob, edit_line_ids=range(i, j), transformations=new_trans
# module: coeditor.c3problem @dataclass class C3ProblemSimpleSplit(C3ProblemTransform): def transform(self, prob: C3Problem) -> Sequence[C3Problem]: delta = prob.span.delta l_range = prob.edit_line_ids assert isinstance(l_range, range) ...
===========unchanged ref 0=========== at: coeditor.c3problem ChangedHeader(change_tks: TkArray, type: str, line_range: LineRange, path: ProjectPath) at: coeditor.c3problem.C3GeneratorCache.__init__ self._header_cache = dict[ProjectPath, ChangedHeader]() self._cspan_cache = dict...
coeditor.c3problem/C3ProblemChangeDropout.transform
Modified
temp-1
93d3a66a05da77b6c712854834bafe308e32b75b
- Fix dataclasses.replace. - Fix module usages in `pre_edit_analysis` - Sort changes using heuristic.
<0>:<add> edit_line_ids=edit_line_ids,
# module: coeditor.c3problem @dataclass class C3ProblemChangeDropout(C3ProblemTransform): def transform(self, prob: C3Problem) -> Sequence[C3Problem]: <s> new_original = TkArray.new(delta1.apply_to_change(original.tolist())) new_trans = prob.transformations + ("split"...
===========above chunk 0=========== # module: coeditor.c3problem @dataclass class C3ProblemChangeDropout(C3ProblemTransform): def transform(self, prob: C3Problem) -> Sequence[C3Problem]: # offset: -1 <s>.change_groups() should_dropout = len(grouped_keys) >= 2 if shoul...
coeditor.model/RetrievalEditorModel.train_on_data
Modified
temp-1
dc0c6ac79c708b98a9b584d564abb3ab2a411ddf
- Fix dataloader _post_process. - Save model more frequently during training.
<0>:<add> # callbacks=[EarlyStoppingCallback(early_stopping_patience=1)],
# module: coeditor.model class RetrievalEditorModel(T5PreTrainedModel): def train_on_data( self, training_name: str, train_loader: "C3DataLoader", eval_loader: "C3DataLoader", train_args: "TrainingArgs", ) -> None: ...
===========above chunk 0=========== # module: coeditor.model class RetrievalEditorModel(T5PreTrainedModel): def train_on_data( self, training_name: str, train_loader: "C3DataLoader", eval_loader: "C3DataLoader", train_args: "TrainingArgs", ...
coeditor.c3problem/C3ProblemTokenizer._group_encode_unchanged_refs
Modified
temp-1
7f98c4b39feed113e3d26b70307448229081e7c1
Add class sibling usages. Improve used ref ordering.
<0>:<add> last_parent = parent
# module: coeditor.c3problem @dataclass class C3ProblemTokenizer: def _group_encode_unchanged_refs( self, elems: Mapping[PyFullName, PyDefinition] ) -> Sequence[TkArray]: + def sort_key(e: PyDefinition): + return (e.parent, min(e.start_locs...
===========unchanged ref 0=========== at: coeditor.c3problem.C3ProblemTokenizer VERSION = "2.5" max_ref_tks: int = 512 max_query_tks: int = 512 max_output_tks: int = 256 max_scope_tks: int = 128 max_ref_tks_sum: int = 512 * 12 ref...
coeditor.encoding/TokenizedEdit.show
Modified
temp-1
31c7e81854ab4b6527ea4770eb5cba7041b6f0a8
Fix exact match accuracy.
<0>:<add> origin_line = self.BAD_DELETE
# module: coeditor.encoding class TokenizedEdit(ABC): def show(self, pred_tks: TokenSeq | None = None) -> str: <s>tks[1:]) elif tks and tks[0] == Del_id: return "- " + decode_tokens(tks[1:]) else: return " " + d...
===========above chunk 0=========== # module: coeditor.encoding class TokenizedEdit(ABC): def show(self, pred_tks: TokenSeq | None = None) -> str: # offset: -1 def show_label(i: int): return f" <{i}>" if i <= 9 else f"<{i}>" def show_content(tks: TokenSeq...
coeditor.model/RetrievalDecodingResult.exact_match_accuracy
Modified
temp-1
31c7e81854ab4b6527ea4770eb5cba7041b6f0a8
Fix exact match accuracy.
<0>:<add> ex2correct[i] = is_correct
# module: coeditor.model @dataclass class RetrievalDecodingResult: def exact_match_accuracy(self) -> tuple[CountedSum, dict[int, bool]]: ex2correct = dict[int, bool]() bad_probs = list[C3Problem]() for i, mp in enumerate(self.predictions): ...
===========unchanged ref 0=========== at: coeditor._utils cprint(color: str, *elems, sep: Optional[str]=..., end: Optional[str]=..., file: Optional[SupportsWrite[str]]=..., flush: bool=...) at: coeditor.c3problem C3Problem(span: ChangedCodeSpan, edit_line_ids: Sequence[int], relevant_change...
coeditor.model/RetrievalEditorModel.train_on_data
Modified
temp-1
43582c1474adb11a85ed0bf327e072ff7419fba4
Update traning scripts.
<0>:<add> save_steps=max(500, min(5000, epoch_steps // 5)),
# module: coeditor.model class RetrievalEditorModel(T5PreTrainedModel): def train_on_data( self, training_name: str, train_loader: "C3DataLoader", eval_loader: "C3DataLoader", train_args: "TrainingArgs", ) -> None: ...
===========above chunk 0=========== # module: coeditor.model class RetrievalEditorModel(T5PreTrainedModel): def train_on_data( self, training_name: str, train_loader: "C3DataLoader", eval_loader: "C3DataLoader", train_args: "TrainingArgs", ...
scripts.train_model/train_model
Modified
temp-1
43582c1474adb11a85ed0bf327e072ff7419fba4
Update traning scripts.
<0>:<add> pprint(train_loader.get_batch_stats())
# module: scripts.train_model def train_model( dataset_name: str, model_variant: str, encoder: C3CombinedEncoder = C3CombinedEncoder(), batch_args=BatchArgs.train_default(), eval_batch_args=BatchArgs.eval_default(), train_args=TrainingArgs(), ...
===========above chunk 0=========== # module: scripts.train_model def train_model( dataset_name: str, model_variant: str, encoder: C3CombinedEncoder = C3CombinedEncoder(), batch_args=BatchArgs.train_default(), eval_batch_args=BatchArgs.eval_default(), train_args=T...
coeditor.service/EditPredictionService._suggest_edit_two_steps
Modified
temp-1
5b896681fc006d5248b4a146b1f31189dbf31e7a
Service upgrade to support extension v0.3.5. - Add new server method `initialize` and `get_result`. - Support output line status.
<0>:<add> output_status=output_status,
# module: coeditor.service @dataclass class EditPredictionService: def _suggest_edit_two_steps( self, file: RelPath, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> tuple[_EditRegion, Calla...
===========above chunk 0=========== # module: coeditor.service @dataclass class EditPredictionService: def _suggest_edit_two_steps( self, file: RelPath, edit_lines: Sequence[int] | int, log_dir: Path | None = Path(".coeditor_logs"), ) -> tuple[...
scripts.start_server/start_server
Modified
temp-1
5b896681fc006d5248b4a146b1f31189dbf31e7a
Service upgrade to support extension v0.3.5. - Add new server method `initialize` and `get_result`. - Support output line status.
<0>:<add> response = cont.get()
# module: scripts.start_server def start_server(device, port: int, print_stats: bool = True): <s> <add> @method + @handle_error + def submit_problem( + id: int, project: str, file: str, lines: Sequence[int] | int, writeLogs: bool + ): + target_dir = ...
===========above chunk 0=========== # module: scripts.start_server def start_server(device, port: int, print_stats: bool = True): # offset: -1 <s> ( + get_model_dir(trained=False) + / "coeditor-xl-c3-dropout-v1.5" + / "checkpoint-230000" + ) model = RetrievalE...
scripts.start_server/start_server
Modified
temp-1
dff3d37085f62984add2598f6e095b7ab3ed51d1
v0.3.5 quick fix. - Use request time instead of counter.
<0>:<add> if cont.id > time:
# module: scripts.start_server def start_server(device, port: int, print_stats: bool = True): <s> @handle_error def submit_problem( + time: int, project: str, file: str, lines: Sequence[int] | int, writeLogs: bool - id: int, project: str, file: str, lines: Sequence...
===========above chunk 0=========== # module: scripts.start_server def start_server(device, port: int, print_stats: bool = True): # offset: -1 - # this newer model is trained with comments # model_path = "MrVPlusOne/coeditor-xl-c3-dropout-v1.5" - model_path = ( - get_model_dir(...
coeditor.encoding/truncate_section
Modified
temp-1
988f27c554771e639fd8c0e03b67f336c3a715dc
Change TruncateAt to a normal class.
<0>:<add> assert_eq(direction, TruncateAt.Right)
# module: coeditor.encoding def truncate_section( sec: TokenSeq, + direction: TruncateAt.Value, - direction: TruncateAt, limit: int, add_bos: bool = True, inplace: bool = False, ) -> TokenSeq: if len(sec) <= limit: return ...
===========unchanged ref 0=========== at: coeditor._utils assert_eq(x: T1, y: T1, message: Callable[[], str]=lambda: "") -> None at: coeditor.common TokenSeq = list[Token] at: coeditor.encoding BOS_id = get_tk_id("<s>") EOS_id = get_tk_id("</s>") T...
tests.test_edits/test_splitlines
Modified
temp-1
aab89e924dbff5dc3021355d563ef87f4973efa4
Fix test rng seeds.
<0>:<add> rand_input = [rng.choice(["a", "b", "c", "\n"]) for _ in range(n)]
# module: tests.test_edits def test_splitlines(): + rng = get_rng() for n in range(100): - rand_input = [random.choice(["a", "b", "c", "\n"]) for _ in range(n)] <0> input = "".join(rand_input).rstrip("\n") lines = splitlines(input) #...
===========unchanged ref 0=========== at: coeditor.common splitlines(text: str) -> list[str] count_lines(text: str) -> int assert_str_equal(actual: str, expect: str, name: str | None=None) at: coeditor.encoding decode_tokens(tokens: TokenSeq, prettify: bool=False) ...
tests.test_edits/TestChangeIdentities.test_random_subset
Modified
temp-1
aab89e924dbff5dc3021355d563ef87f4973efa4
Fix test rng seeds.
<0>:<add> y_map = random_subset(x_map, 20, rng)
# module: tests.test_edits class TestChangeIdentities: def test_random_subset(self): + rng = get_rng() + def is_sorted(xs): return list(xs) == list(sorted(xs)) xs = range(50) assert is_sorted(xs) + for ...
===========unchanged ref 0=========== at: coeditor.common random_subset(all: Mapping[T1, T2], n: int, rng: random.Random | int | None=None) -> dict[T1, T2] random_subset(all: Sequence[T1], n: int, rng: random.Random | int | None=None) -> list[T1] at: coeditor.encoding decode_tokens(...
tests.test_edits/TestChangeIdentities.test_delta_decomposition
Modified
temp-1
aab89e924dbff5dc3021355d563ef87f4973efa4
Fix test rng seeds.
<0>:<add> n_keys = int(len(keys) * rng.random())
# module: tests.test_edits class TestChangeIdentities: def test_delta_decomposition(self): + rng = get_rng() + for name, c in self.cases.items(): original, delta = TkDelta.from_change_tks(change_to_tokens(c)) assert_tks_eq(original...
===========unchanged ref 0=========== at: coeditor.common print_sections(*, sep: str=SEP, file: TextIO=sys.stdout) -> None random_subset(all: Mapping[T1, T2], n: int, rng: random.Random | int | None=None) -> dict[T1, T2] random_subset(all: Sequence[T1], n: int, rng: random.Random | int ...
tests.test_edits/TestChangeIdentities.test_get_new_target_lines
Modified
temp-1
aab89e924dbff5dc3021355d563ef87f4973efa4
Fix test rng seeds.
<0>:<add> n_keys = int(len(keys) * rng.random())
# module: tests.test_edits class TestChangeIdentities: def test_get_new_target_lines(self): + rng = get_rng() + for name, c in self.cases.items(): original, delta = TkDelta.from_change_tks(change_to_tokens(c)) n_origin_lines = len(...
===========unchanged ref 0=========== at: coeditor._utils add_line_numbers(code: str, start: int=1) at: coeditor.common SEP = "-" * 80 random_subset(all: Mapping[T1, T2], n: int, rng: random.Random | int | None=None) -> dict[T1, T2] random_subset(all: Sequence[T1], n: i...