-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modernize IEX_Trading #398
base: main
Are you sure you want to change the base?
Conversation
Not ready for review yet, just showing initial progress made. |
Your changes were successfully integrated in the dev site, make sure to review |
@jtao1 please check for typos e.g. in the first section of the first notebook: "datashader via the HoloViewsAPI." should be: "Datashader via the HoloViews API." |
Please try to replace the use of a Bokeh custom hover tool with HoloViews |
more typos: "Note: If you display the spikes object at this time, it will probably freeze or crash your browser tb!" "We will use the responsive=True option to make our rasters fill the scren:" |
In IEX_stocks, the plots display as intended, but I don't know how to get rid of the warnings. I am running into an conversion issue between DateTime and Floats. I tried converting the timestamps which are of type DateTime into floats but that didn't work as it led to a similar issue. Traceback```WARNING:param.dynamic_operation: Callable raised "UFuncTypeError(<ufunc 'less_equal'>, (<class 'numpy.dtypes.DateTime64DType'>, <class 'numpy.dtypes.Float64DType'>, None))".
Invoked as dynamic_operation(x_range=(nan, nan))
WARNING:param.dynamic_operation: Callable raised "UFuncTypeError(<ufunc 'less_equal'>, (<class 'numpy.dtypes.DateTime64DType'>, <class 'numpy.dtypes.Float64DType'>, None))".
Invoked as dynamic_operation(x_range=(nan, nan))
numpy.exceptions.DTypePromotionError: The DType <class 'numpy.dtypes.DateTime64DType'> could not be promoted by <class 'numpy.dtypes.Float64DType'>. This means that no common DType exists for the given inputs. For example they cannot be stored in a single array unless the dtype is `object`. The full list of DTypes is: (<class 'numpy.dtypes.DateTime64DType'>, <class 'numpy.dtypes.Float64DType'>)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/plotting/util.py", line 293, in get_plot_frame
return map_obj[key]
~~~~~~~^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
val = self._execute_callback(*tuple_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
retval = self.callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 552, in __call__
return self.callable()
^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/util/__init__.py", line 1038, in dynamic_operation
key, obj = resolve(key, kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/util/__init__.py", line 1027, in resolve
return key, map_obj[key]
~~~~~~~^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
val = self._execute_callback(*tuple_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
retval = self.callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 552, in __call__
return self.callable()
^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/util/__init__.py", line 1038, in dynamic_operation
key, obj = resolve(key, kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/util/__init__.py", line 1027, in resolve
return key, map_obj[key]
~~~~~~~^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
val = self._execute_callback(*tuple_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
retval = self.callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 552, in __call__
return self.callable()
^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/util/__init__.py", line 1038, in dynamic_operation
key, obj = resolve(key, kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/util/__init__.py", line 1027, in resolve
return key, map_obj[key]
~~~~~~~^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
val = self._execute_callback(*tuple_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
retval = self.callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 552, in __call__
return self.callable()
^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 197, in dynamic_mul
self_el = self.select(HoloMap, **key_map) if self.kdims else self[()]
~~~~^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
val = self._execute_callback(*tuple_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
retval = self.callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 552, in __call__
return self.callable()
^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 197, in dynamic_mul
self_el = self.select(HoloMap, **key_map) if self.kdims else self[()]
~~~~^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
val = self._execute_callback(*tuple_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
retval = self.callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 581, in __call__
ret = self.callable(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/util/__init__.py", line 1038, in dynamic_operation
key, obj = resolve(key, kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/util/__init__.py", line 1027, in resolve
return key, map_obj[key]
~~~~~~~^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
val = self._execute_callback(*tuple_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
retval = self.callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/spaces.py", line 581, in __call__
ret = self.callable(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/util/__init__.py", line 1039, in dynamic_operation
return apply(obj, *key, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/util/__init__.py", line 1031, in apply
processed = self._process(element, key, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/util/__init__.py", line 1013, in _process
return self.p.operation.process_element(element, key, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/operation.py", line 194, in process_element
return self._apply(element, key)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/core/operation.py", line 141, in _apply
ret = self._process(element, key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/operation/datashader.py", line 682, in _process
info = self._get_sampling(element, x, y, ndim=1, default=default)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/holoviews/operation/resample.py", line 141, in _get_sampling
x_range = (np.nanmin([np.nanmax([x0, ex0]), ex1]),
^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/numpy/lib/nanfunctions.py", line 483, in nanmax
res = np.amax(a, axis=axis, out=out, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/numpy/core/fromnumeric.py", line 2827, in amax
return _wrapreduction(a, np.maximum, 'max', axis, None, out,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/Impor/holoviz-examples/examples/iex_trading/envs/default/lib/python3.11/site-packages/numpy/core/fromnumeric.py", line 88, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
numpy.core._exceptions._UFuncNoLoopError: ufunc 'less_equal' did not contain a loop with signature matching types (<class 'numpy.dtypes.DateTime64DType'>, <class 'numpy.dtypes.Float64DType'>) -> None``` |
Your changes were successfully integrated in the dev site, make sure to review |
try |
Your changes were successfully integrated in the dev site, make sure to review |
Modernizing an example checklist
Preliminary checks
Change ‘anaconda-project.yml’ to use the latest workable version of packages
hvplot<0.9
tohvplot
,panel>=0.12,<1.0
topanel>=0.12
) of all other dependencies. Removing the upper pins of dependencies could necessitate code revisions in the notebooks to address any errors encountered in the updated environment. Should complexities or extensive time requirements arise, document issues for team discussion on whether to re-pin specific packages or explore other solutions.hvplot
tohvplot>=0.9.2
,hvplot>=0.8
tohvplot>=0.9.2
). Usually, the new/updated lower pin of a dependency will be the version resolved afteranaconda prepare
has been run. Execute!conda list
in a notebook, oranaconda run conda list
in the terminal, to display the version of each dependency installed in the environment. Adjusting the lower pin helps ensure that the locks produced for each platform (linux-64, win-64, osx-64, osx-arm64) rely on the tested dependencies and not on some older versions.Plot API updates (discussed on a per-example basis)
datashade
withrasterize
(read this page). Essentially,rasterize
allows Bokeh to handle the colormapping instead of Datashader.Interactivity API updates (discussed on a per-example basis)
pn.interact
usage.param.watch()
usage. This is pretty low-level and verbose approach and should not be used in Examples unless required, or an Example is specifically trying to demo its usage in an advanced workflow.pn.bind()
. Read this page for explanation.view()
method and call it directly, update the class by inheriting frompn.viewable.Viewer
and replaceview()
by__panel__()
. Here is an example.Panel App updates (discussed on a per-example basis)
pn.Column
, or more complicated to incorporate widgets, etc. Make the final app.servable()
.command: dashboard
declaration in theanaconda-project.yml
file), try adding it.template = pn.template.BootstrampTemplate
, but if building up an app across multiple cells, it is probably cleaner to declare the template at the top withpn.extension(template='bootstrap')
. See how to guide on setting a template.General code quality updates
warnings.simplefilter(‘ignore’)
somewhere at the start of the notebook, remove this line. Try to update the code to remove the warnings, if any. If updating the code to remove the warnings is taking significant amount of time and effort, bring it up for discussion and we may decide to disable warnings again.Text content
Visual appearance - Example
Visual appearance - Gallery
Ml Annotators
toML Annotators
), if not, add/update theexamples_config.title
field inanaconda-project.yml
description
field inanaconda-project.yml
Workflow (after you have made the changes above)
doit validate:<projectname>
doit test:<projectname>
doit doc_one –name <projectname>
. It’s better if the project notebook(s) is saved with its outputs (but be sure to clear outputs before committing to the examples repo!) when building the docs. Then open this file in your browser./builtdocs/index.html
and check how the site looks.