def __init__(self): missing = [] if not HAVE_WIDGETS: missing.append('ipywidgets') elif not HAVE_IPYTHON: missing.append('IPython') if missing: raise ValueError( "IPythonWidgetProgressPublisher needs ipywidgets and IPython:" "\nMissing:\n{}".format(bulleted_list(missing)) ) # Heading for progress display. self._heading = ipywidgets.HTML() # Percent Complete Indicator to the left of the bar. indicator_width = '120px' self._percent_indicator = ipywidgets.HTML( layout={'width': indicator_width}, ) # The progress bar itself. self._bar = ipywidgets.FloatProgress( value=0.0, min=0.0, max=100.0, bar_style='info', # Leave enough space for the percent indicator. layout={'width': 'calc(100% - {})'.format(indicator_width)}, ) bar_and_percent = ipywidgets.HBox([self._percent_indicator, self._bar]) # Collapsable details tab underneath the progress bar. self._details_body = ipywidgets.HTML() self._details_tab = ipywidgets.Accordion( children=[self._details_body], selected_index=None, # Start in collapsed state. layout={ # Override default border settings to make details tab less # heavy. 'border': '1px', }, ) # There's no public interface for setting title in the constructor :/. self._details_tab.set_title(0, 'Details') # Container for the combined widget. self._layout = ProgressBarContainer( [ self._heading, bar_and_percent, self._details_tab, ], # Overall layout consumes 75% of the page. layout={'width': '75%'}, ) self._displayed = False
def _ensure_can_load(self, loader, terms): """Ensure that ``loader`` can load ``terms``.""" if not loader.currency_aware: bad = [t for t in terms if t.currency_conversion is not None] if bad: raise ValueError( "Requested currency conversion is not supported for the " "following terms:\n{}".format(bulleted_list(bad)))
def get_column(cls, name): """Look up a column by name. Parameters ---------- name : str Name of the column to look up. Returns ------- column : zipline.pipeline.data.BoundColumn Column with the given name. Raises ------ AttributeError If no column with the given name exists. """ clsdict = vars(cls) try: maybe_column = clsdict[name] if not isinstance(maybe_column, _BoundColumnDescr): raise KeyError(name) except KeyError: raise AttributeError( "{dset} has no column {colname!r}:\n\n" "Possible choices are:\n" "{choices}".format( dset=cls.qualname, colname=name, choices=bulleted_list( sorted(cls._column_names), max_count=10, ), ) ) # Resolve column descriptor into a BoundColumn. return maybe_column.__get__(None, cls)