Python Library improved
This commit is contained in:
@@ -8,8 +8,10 @@ add_custom_target ( YAPKernel ALL
|
||||
DEPENDS yap_kernel.py
|
||||
)
|
||||
|
||||
set( PYTHON_INSTALL install)
|
||||
|
||||
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} install -f
|
||||
|
||||
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} ${PYTHON_INSTALL} -f
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
|
||||
|
||||
install(FILES jupyter.yap
|
||||
|
@@ -1,30 +0,0 @@
|
||||
"""
|
||||
Paired Density and Scatterplot Matrix
|
||||
=====================================
|
||||
|
||||
_thumb: .5, .5
|
||||
"""
|
||||
import seaborn as sns
|
||||
import matplotlib.pyplot as plt
|
||||
sns.set(style="white")
|
||||
|
||||
df = sns.load_dataset("iris")
|
||||
|
||||
g = sns.PairGrid(df, diag_sharey=False)
|
||||
g.map_lower(sns.kdeplot, cmap="Blues_d")
|
||||
g.map_upper(plt.scatter)
|
||||
g.map_diag(sns.kdeplot, lw=3)
|
||||
|
||||
"""
|
||||
Grouped barplots
|
||||
================
|
||||
|
||||
_thumb: .45, .5
|
||||
"""
|
||||
sns.set(style="whitegrid")
|
||||
|
||||
# Draw a nested barplot to show survival for class and sex
|
||||
g = sns.factorplot(x="class", y="survived", hue="sex", data=[15,30,5],
|
||||
size=3, kind="bar", palette="muted")
|
||||
g.despine(left=True)
|
||||
g.set_ylabels("survival probability")
|
@@ -161,24 +161,21 @@ class YAPInteractiveShell:
|
||||
# print('{0}'.format(f.getvalue()))
|
||||
# Execute the user code
|
||||
if run:
|
||||
# this new vs should contain bindings to vars
|
||||
vs= self.q.namedVars()
|
||||
#numbervars
|
||||
i=0
|
||||
# iteraw
|
||||
for eq in vs:
|
||||
name = eq[0]
|
||||
# this is tricky, we're going to bind the variables in the term so thay we can
|
||||
# output X=Y. The Python way is to use dictionares.
|
||||
#Instead, we use the T function to tranform the Python term back to Prolog
|
||||
binding = yap.T(eq[1])
|
||||
if binding.isVar():
|
||||
binding.unify(name)
|
||||
else:
|
||||
i = binding.numberVars(i, True)
|
||||
print(name + " = " + binding.text())
|
||||
#ok, that was Prolog code
|
||||
print("yes")
|
||||
myvs = self.q.namedVarsCopy()
|
||||
if myvs:
|
||||
i = 0
|
||||
for peq in myvs:
|
||||
name = peq[0]
|
||||
bind = peq[1]
|
||||
if bind.isVar():
|
||||
var = yap.YAPAtom('$VAR')
|
||||
f = yap.YAPFunctor(var, 1)
|
||||
bind.unify(yap.YAPApplTerm(f, (name)))
|
||||
else:
|
||||
i = bind.numberVars(i, True)
|
||||
print(name.text() + " = " + bind.text())
|
||||
else:
|
||||
print("yes")
|
||||
if self.q.deterministic():
|
||||
self.closeq()
|
||||
else:
|
||||
|
@@ -138,9 +138,9 @@ class YAPKernel(KernelBase):
|
||||
implementation = 'YAP'
|
||||
implementation_version = release.version
|
||||
language_info = {
|
||||
'name': 'prolog',
|
||||
'name': 'python',
|
||||
'version': sys.version.split()[0],
|
||||
'mimetype': 'text/x-prolog',
|
||||
'mimetype': 'text/x-python',
|
||||
'codemirror_mode': {
|
||||
'name': 'prolog',
|
||||
'version': sys.version_info[0]
|
||||
@@ -333,7 +333,7 @@ class YAPKernel(KernelBase):
|
||||
|
||||
elif hist_access_type == 'range':
|
||||
hist = self.shell.history_manager.get_range(session, start, stop,
|
||||
raw=raw, output=output)
|
||||
raw=raw, output=output)
|
||||
|
||||
elif hist_access_type == 'search':
|
||||
hist = self.shell.history_manager.search(
|
||||
|
Reference in New Issue
Block a user