apple / turicreate

Turi Create simplifies the development of custom machine learning models.
BSD 3-Clause "New" or "Revised" License
11.19k stars 1.14k forks source link

Plot APIs should ValueError on incorrect input type #450

Closed znation closed 6 years ago

znation commented 6 years ago

The Plot APIs under tc.visualization expect certain data types, and when the wrong types are passed in, should give a friendly error message to the user explaining the mismatch. Instead, the API currently errors low-level in C++ and doesn't tell the user why it failed:

import turicreate as tc
sf = tc.SFrame.read_csv('https://docs-assets.developer.apple.com/turicreate/datasets/tc-clang-format-results.csv')
plt = tc.visualization.box_plot(sf, sf)
---------------------------------------------------------------------------
ToolkitError                              Traceback (most recent call last)
<ipython-input-9-97dd2288d4ba> in <module>()
----> 1 plt = tc.visualization.box_plot(sf, sf)

/Users/zach/turicreate/debug/src/unity/python/turicreate/visualization/show.pyc in box_plot(x, y, xlabel, ylabel, title)
    121     title = _get_title(title)
    122     plt_ref = tc.extensions.plot_boxes_and_whiskers(path_to_client, x, y, 
--> 123       xlabel, ylabel, title)
    124     return Plot(plt_ref)
    125 

/Users/zach/turicreate/debug/src/unity/python/turicreate/extensions.pyc in <lambda>(*args, **kwargs)
    171 
    172 def _make_injected_function(fn, arguments):
--> 173     return lambda *args, **kwargs: _run_toolkit_function(fn, arguments, args, kwargs)
    174 
    175 def _class_instance_from_name(class_name, *arg, **kwarg):

/Users/zach/turicreate/debug/src/unity/python/turicreate/extensions.pyc in _run_toolkit_function(fnname, arguments, args, kwargs)
    160     if not ret[0]:
    161         if len(ret[1]) > 0:
--> 162             raise _ToolkitError(ret[1])
    163         else:
    164             raise _ToolkitError("Toolkit failed with unknown error")

ToolkitError: boost::bad_get: failed value get using boost::get
shantanuchhabra commented 6 years ago

Fixed by #504