#!/usr/bin/env python
# coding: utf-8
# # Magics to Access the JVM Kernels from Python
#
# BeakerX has magics for Python so you can run cells in the other languages.
# The first few cells below show how complete the implementation is with Groovy, then we have just one cell in each other language.
#
# There are also [Polyglot Magics](../groovy/PolyglotMagic.ipynb) magics for accessing Python from the JVM.
#
# Fleshing out the polyglot support in BeakerX with communication between languages ([#5039](https://github.com/twosigma/beakerx/issues/5039)) is on the agenda.
#
# ## Groovy
# In[ ]:
get_ipython().run_cell_magic('groovy', '', 'println("stdout works")\nf = {it + " work"}\nf("results")\n')
# In[ ]:
get_ipython().run_cell_magic('groovy', '', 'new Plot(title:"plots work", initHeight: 200)\n')
# In[ ]:
get_ipython().run_cell_magic('groovy', '', '[a:"tables", b:"work"]\n')
# In[ ]:
get_ipython().run_cell_magic('groovy', '', '"errors work"/1\n')
# In[ ]:
get_ipython().run_cell_magic('groovy', '', 'HTML("
HTML works
")\n')
# In[ ]:
get_ipython().run_cell_magic('groovy', '', "def p = new Plot(title : 'Plots Work', xLabel: 'Horizontal', yLabel: 'Vertical');\np << new Line(x: [0, 1, 2, 3, 4, 5], y: [0, 1, 6, 5, 2, 8])\n")
# ## Java
# In[ ]:
get_ipython().run_cell_magic('java', '', 'import java.util.List;\nimport com.twosigma.beakerx.chart.xychart.Plot;\nimport java.util.Arrays;\n\nPlot p = new Plot();\n\np.setTitle("Java Works");\np.setXLabel("Horizontal");\np.setYLabel("Vertical");\n\nBars b = new Bars();\n\nList