less invasive error handling
This commit is contained in:
@@ -1,7 +1,61 @@
|
||||
%matplotlib inline
|
||||
import numpy as np
|
||||
import seaborn as sns
|
||||
import matplotlib.pyplot as plt
|
||||
sns.set(style="white", context="talk")
|
||||
rs = np.random.RandomState(7)
|
||||
|
||||
:- use_module( library(python) ).
|
||||
pos={0:(0,0),
|
||||
1:(1,0),
|
||||
2:(0,1),
|
||||
3:(1,1),
|
||||
4:(0.1,0.9),
|
||||
5:(0.3,1.1),
|
||||
6:(0.9,0.9)
|
||||
}
|
||||
|
||||
:- := import(pandas)).
|
||||
names={4:'MMM',
|
||||
5:'XXX',
|
||||
6:'ZZZ'}
|
||||
|
||||
pred2panda(Pred, Obj) :-
|
||||
|
||||
def plot1(y10,y20):
|
||||
def gen(f,f0):
|
||||
return [f[0],f[1],-f[2]]/max(f,f0)
|
||||
ax1 = plt.subplot2grid((1,2), (0,0), colspan=2)
|
||||
ax2 = plt.subplot2grid((1,2), (0,1), colspan=2)
|
||||
ax3 = plt.subplot2grid((2,2), (2,0), colspan=2, rowspan=2)
|
||||
|
||||
xs = ["+-","++","--"]
|
||||
y1 = gen(y10, y20)
|
||||
sns.barplot(xs, y1, palette="RdBu_r", ax=ax1)
|
||||
y2 = gen(y20,y10)
|
||||
sns.barplot(xs, y2, palette="Set3", ax=ax2)
|
||||
# Finalize the plot
|
||||
# sns.despine(bottom=True)
|
||||
|
||||
|
||||
G=nx.Graph()
|
||||
i=0
|
||||
G.pos={} # location
|
||||
G.pop={} # size
|
||||
lpos={0:(0,0),1:(0,0),2:(0,0),3:(0,0)}
|
||||
last=len(pos)-1
|
||||
for i in range(4,len(pos)):
|
||||
G.pos[i]=pos[i]
|
||||
G.pop[i]=2000
|
||||
(x,y) = pos[i]
|
||||
lpos[i] = (x,y-0.05)
|
||||
if i > 4:
|
||||
G.add_edge(i-1,i)
|
||||
else:
|
||||
G.add_edge(2,i)
|
||||
G.add_edge(3,last)
|
||||
nx.draw_networkx_nodes(G,pos,nodelist=range(4,len(pos)),ax=ax3)
|
||||
nx.draw_networkx_nodes(G,pos,nodelist=[0,1,2,3],node_color='b',ax=ax3)
|
||||
nx.draw_networkx_edges(G,pos,alpha=0.5,ax=ax3)
|
||||
nx.draw_networkx_labels(G,lpos,names,alpha=0.5,ax=ax3)
|
||||
plt.axis('off')
|
||||
plt.tight_layout(h_pad=3)
|
||||
plt.savefig("house_with_colors.png") # save as png
|
||||
|
||||
plot1([20,30,10],[30,30,5])
|
||||
|
@@ -21,7 +21,7 @@
|
||||
typedef YAP_Arity arity_t;
|
||||
|
||||
extern atom_t ATOM_true, ATOM_false, ATOM_colon, ATOM_dot, ATOM_none, ATOM_t,
|
||||
ATOM_comma, ATOM_builtin, ATOM_V, ATOM_A, ATOM_self;
|
||||
ATOM_comma, ATOM_builtin, ATOM_V, ATOM_A, ATOM_self;
|
||||
|
||||
extern functor_t FUNCTOR_dollar1, FUNCTOR_abs1, FUNCTOR_all1, FUNCTOR_any1,
|
||||
FUNCTOR_bin1, FUNCTOR_brackets1, FUNCTOR_comma2, FUNCTOR_dir1,
|
||||
@@ -39,6 +39,8 @@ extern PyObject *py_F2P;
|
||||
|
||||
extern bool python_in_python;
|
||||
|
||||
#define PythonReturn PyGILState_Release(gstate) && return
|
||||
|
||||
static inline Py_ssize_t get_p_int(PyObject *o, Py_ssize_t def) {
|
||||
if (o == NULL)
|
||||
return def;
|
||||
@@ -94,7 +96,6 @@ static inline PyObject *atom_to_python_string(term_t t) {
|
||||
extern PyObject *compound_to_pyeval(term_t t, functor_t fun);
|
||||
extern PyObject *compound_to_pytree(term_t t, functor_t fun);
|
||||
|
||||
|
||||
extern PyObject *yap_to_python(YAP_Term t, bool eval);
|
||||
extern PyObject *term_to_python(term_t t, bool eval);
|
||||
extern foreign_t python_to_ptr(PyObject *pVal, term_t t);
|
||||
|
@@ -138,9 +138,9 @@ class YAPKernel(KernelBase):
|
||||
implementation = 'YAP'
|
||||
implementation_version = release.version
|
||||
language_info = {
|
||||
'name': 'python',
|
||||
'name': 'prolog',
|
||||
'version': sys.version.split()[0],
|
||||
'mimetype': 'text/x-python',
|
||||
'mimetype': 'text/x-prolog',
|
||||
'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