Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@observe('colors', 'formats', 'locations', 'reduce_points', 'vector_field_color')
def _set_need_rebuild(self, _):
"""Handle changes to attributes that need to regenerate everything."""
# Because matplotlib doesn't let you just change these properties, we need
# to trigger a clear and re-call of contour()
self.clear()
@observe('queue')
def _queue_changed(self, change):
self._update_context(change)
@traitlets.observe('throttle')
def _on_throttle(self, change):
self.throttle_motor.throttle = change['new'] * self.throttle_gain.value
@observe('foreground')
def _on_foreground_change(self, changed):
self._send_msg(event='set_foreground_by_name', name=changed['new'])
# Changing a layer resets the opacity, so we re-trigger the opacity setting
self._send_msg(event='set_foreground_opacity',
value=self.foreground_opacity * 100)
@observe('scheme_name')
def _scheme_name_changed(self, change):
self.log.debug("Using scheme %r" % change['new'])
self.scheme = globals()[change['new']]
@observe('value')
def _propagate_value(self, change):
if change.new is None:
index = None
elif self.index is not None and self._options_values[self.index] == change.new:
index = self.index
else:
index = self._options_values.index(change.new)
if self.index != index:
self.index = index
@traitlets.observe("model")
def _sync_model_to_view(self, change):
new = change["new"]
string = "{:.4f}, {:.4f}".format(
# https://xkcd.com/2170/
*(reversed(new) if self.model_is_latlon else new)
)
self.value = string
@tl.observe("dims", "idims")
def _set_property(self, d):
self._properties.add(d["name"])
@observe('comm')
def _comm_changed(self, change):
"""Called when the comm is changed."""
if change['new'] is None:
return
self._model_id = self.model_id
self.comm.on_msg(self._handle_msg)
Widget.widgets[self.model_id] = self
@observe('ipython_dir')
def _ipython_dir_changed(self, change):
old = change['old']
new = change['new']
if old is not Undefined:
str_old = py3compat.cast_bytes_py2(os.path.abspath(old),
sys.getfilesystemencoding()
)
if str_old in sys.path:
sys.path.remove(str_old)
str_path = py3compat.cast_bytes_py2(os.path.abspath(new),
sys.getfilesystemencoding()
)
sys.path.append(str_path)
ensure_dir_exists(new)
readme = os.path.join(new, 'README')
readme_src = os.path.join(get_ipython_package_dir(), u'config', u'profile', 'README')