update yap_kernel
lbfgs
This commit is contained in:
Vitor Santos Costa
2018-10-15 13:48:49 +01:00
parent 127ebb2523
commit b31493c777
26 changed files with 1721 additions and 1591 deletions

View File

@@ -1,21 +1,22 @@
"""prompt-toolkit utilities
Everything in this module is a private API,
not to be used outside yap_ipython.
not to be used outside IPython.
"""
# Copyright (c) yap_ipython Development Team.
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import unicodedata
from wcwidth import wcwidth
from yap_ipython.core.completer import (
from IPython.core.completer import (
provisionalcompleter, cursor_to_position,
_deduplicate_completions)
from prompt_toolkit.completion import Completer, Completion
from prompt_toolkit.layout.lexers import Lexer
from prompt_toolkit.layout.lexers import PygmentsLexer
from prompt_toolkit.lexers import Lexer
from prompt_toolkit.lexers import PygmentsLexer
from prompt_toolkit.patch_stdout import patch_stdout
import pygments.lexers as pygments_lexers
@@ -51,15 +52,12 @@ def _adjust_completion_text_based_on_context(text, body, offset):
class IPythonPTCompleter(Completer):
"""Adaptor to provide yap_ipython completions to prompt_toolkit"""
def __init__(self, ipy_completer=None, shell=None, patch_stdout=None):
"""Adaptor to provide IPython completions to prompt_toolkit"""
def __init__(self, ipy_completer=None, shell=None):
if shell is None and ipy_completer is None:
raise TypeError("Please pass shell=an InteractiveShell instance.")
self._ipy_completer = ipy_completer
self.shell = shell
if patch_stdout is None:
raise TypeError("Please pass patch_stdout")
self.patch_stdout = patch_stdout
@property
def ipy_completer(self):
@@ -75,7 +73,7 @@ class IPythonPTCompleter(Completer):
# is imported). This context manager ensures that doesn't interfere with
# the prompt.
with self.patch_stdout(), provisionalcompleter():
with patch_stdout(), provisionalcompleter():
body = document.text
cursor_row = document.cursor_position_row
cursor_col = document.cursor_position_col
@@ -143,7 +141,7 @@ class IPythonPTLexer(Lexer):
'latex': PygmentsLexer(l.TexLexer),
}
def lex_document(self, cli, document):
def lex_document(self, document):
text = document.text.lstrip()
lexer = self.python_lexer
@@ -157,4 +155,4 @@ class IPythonPTLexer(Lexer):
lexer = l
break
return lexer.lex_document(cli, document)
return lexer.lex_document(document)