jupyter-xeus / xwidgets

C++ backend for Jupyter interactive widgets
BSD 3-Clause "New" or "Revised" License
138 stars 26 forks source link

[Schema] testing against the ipywidgets schema spec #111

Open SylvainCorlay opened 6 years ago

SylvainCorlay commented 6 years ago

It would be interesting to test xwidgets's properties against ipywidget's schemas.

SylvainCorlay commented 6 years ago

The current schema spec is a markdown style.

Maybe we could decide on a JSON spec instead of markdown, which we could generate for a list of types of widgets. https://github.com/jupyter-widgets/ipywidgets/issues/1979

SylvainCorlay commented 5 years ago

A simple means to get the default serialized state of e.g. Slider is:

#include <iostream>
#include "xwidgets/xslider.hpp"

// instantiate slider
xw::slider<double> slider;

// retrieve default state
xeus::xjson state; xeus::buffer_sequence buffers;
slider.serialize_state(state, buffers);

// compare state with reference model
std::cout << state << std::endl;
SylvainCorlay commented 5 years ago
from ipywidgets import IntSlider
s = IntSlider()
s.get_state()
SylvainCorlay commented 5 years ago
template <class WT>
void test_widget_schema(std::string& python_widget_type, std::string& python_widget_module)
{
    // instantiate python widget
    // use pybind11
    // get_state();

    auto s = WT();
     // serialize_state();
};
SylvainCorlay commented 5 years ago

https://github.com/QuantStack/xeus-python/blob/1b6558e4afd65bbefe05c645c3aac82f3d53622e/src/xinterpreter.cpp#L41