Skip to content
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

fix: Initial set of type fixes #217

Merged
merged 6 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions plugins/plotly-express/src/deephaven/plot/express/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import json
from typing import Any

from deephaven.plugin.object_type import BidirectionalObjectType, MessageStream

Expand Down Expand Up @@ -59,20 +60,19 @@ def name(self) -> str:
Returns the name of the plugin

Returns:
str: The name of the plugin

The name of the plugin
"""
return NAME

def is_type(self, obj: any) -> bool:
def is_type(self, obj: Any) -> bool:
"""
Check if an object is a DeephavenFigure

Args:
obj: any: The object to check
obj: The object to check

Returns:
bool: True if the object is of the correct type, False otherwise
True if the object is of the correct type, False otherwise
"""
return isinstance(obj, DeephavenFigure)

Expand All @@ -84,11 +84,11 @@ def create_client_connection(
This sends an initial figure to the client.

Args:
obj: object: The object to create the connection for
connection: MessageStream: The connection to use
obj: The object to create the connection for
connection: The connection to use

Returns:
MessageStream: The client connection
The client connection
"""
figure_connection = DeephavenFigureConnection(obj, connection)
initial_message = json.dumps(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def register_into(cls, callback: Callback) -> None:
Register the DeephavenFigureType and a JsPlugin

Args:
callback: Registration.Callback:
Registration.Callback:
A function to call after registration

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def on_data(self, payload: bytes, references: list[Any]) -> tuple[bytes, list[An
references: References to objects on the server

Returns:
tuple[bytes, list[Any]]: The payload to send to the client and the
references to send to the client
The payload to send to the client and the references to send to the client
"""
return self._listener.process_message(payload, references)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def __init__(
Create a new listener for the figure

Args:
figure: DeephavenFigure: The figure to listen to
connection: MessageStream: The connection to send messages to
figure: The figure to listen to
connection: The connection to send messages to
"""
self._connection = connection

Expand Down Expand Up @@ -89,9 +89,9 @@ def _on_update(
meta table is updated, it will always trigger a rerender.

Args:
node: DeephavenFigureNode: The node to update. Changes will propagate up from this node.
update: TableUpdate: Not used. Required for the listener.
is_replay: bool: Not used. Required for the listener.
node: The node to update. Changes will propagate up from this node.
update: Not used. Required for the listener.
is_replay: Not used. Required for the listener.
"""
if self._connection:
revision = self._revision_manager.get_revision()
Expand All @@ -110,23 +110,22 @@ def _handle_retrieve_figure(self) -> tuple[bytes, list[Any]]:
figure.

Returns:
tuple[bytes, list[Any]]: The result of the message as a tuple of
(new payload, new references)
The result of the message as a tuple of (new payload, new references)
"""
return self._build_figure_message(self._get_figure())

def _build_figure_message(
self, figure: DeephavenFigure, revision: int = None
self, figure: DeephavenFigure, revision: int | None = None
) -> tuple[bytes, list[Any]]:
"""
Build a message to send to the client with the current figure.

Args:
figure: DeephavenFigure: The figure to send
figure: The figure to send
revision: The revision to send

Returns:
tuple[bytes, list[Any]]: The result of the message as a tuple of
(new payload, new references)
The result of the message as a tuple of (new payload, new references)
"""
exporter = self._exporter

Expand Down Expand Up @@ -158,18 +157,18 @@ def process_message(
and return the result.

Args:
payload: bytes: The payload to process
references: list[Any]: References to objects on the server
payload: The payload to process
references: References to objects on the server

Returns:
tuple[bytes, list[Any]]: The result of the message as a tuple of
(new payload, new references)
The result of the message as a tuple of (new payload, new references)

"""
# need to create a new exporter for each message
message = json.loads(payload.decode())
if message["type"] == "RETRIEVE":
return self._handle_retrieve_figure()
return b"", []

def __del__(self):
self._liveness_scope.release()
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ def iris(ticking: bool = True, size: int = 300) -> Table:
- The original Iris species labels are included (setosa, versicolor, and virginica).

Args:
ticking: bool: (Default value = True)
ticking:
If true, the table will tick using a replayer starting
with a third of the table already ticked. If false the
whole table will be returned as a static table.
size: int: (Default value = 300)
size:
The number of rows to create for the table

Returns:
Expand Down Expand Up @@ -121,7 +121,7 @@ def stocks(ticking: bool = True, hours_of_data: int = 1) -> Table:
already initilized so your example plots won't start empty.

Notes:
Containts the following columns:
Contains the following columns:
- timestamp: a time column starting from the date deephaven.io was registered
- sym: a string representing a fictional stock symbol
- exchange: a string representing a fictional stock exchange
Expand All @@ -134,10 +134,10 @@ def stocks(ticking: bool = True, hours_of_data: int = 1) -> Table:
- random: A random gaussian value using row index as seed

Args:
ticking: bool: (Default value = True)
ticking:
If true, the table will tick using a replayer, if
false the whole table will be returned as a static table.
hours_of_data: int: (Default value = 1)
hours_of_data:
The number of hours of data to return

Returns:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class DataMapping:
"""A DataMapping that maps plotly variables to table columns

Attributes:
_table: Table: The table to use for this data mapping
_data_mapping: list[dict[str, str]]: The variable to column
_table: The table to use for this data mapping
_data_mapping: The variable to column
dictionaries used in this mapping. They should map plotly variables
to table columns. One of these maps to one data trace.
_start_index: int: The index (which is an index in the plotly data)
_start_index: The index (which is an index in the plotly data)
that this DataMapping starts at
"""

Expand All @@ -31,14 +31,14 @@ def __init__(
self._data_mapping = data_mapping
self._start_index = start_index

def get_links(self: DataMapping, exporter: Exporter) -> list[dict[Any]]:
def get_links(self: DataMapping, exporter: Exporter) -> list[dict[Any, Any]]:
"""Get the json links for this data mapping

Args:
exporter: Exporter: The exporter, used to get the index of the table
exporter: The exporter, used to get the index of the table

Returns:
list[dict[Any]]: The column to json link mapping for this DataMapping
The column to json link mapping for this DataMapping

"""
return json_link_mapping(
Expand All @@ -49,10 +49,10 @@ def copy(self: DataMapping, offset: int) -> DataMapping:
"""Copy this DataMapping, adding a specific offset to the start_index

Args:
offset: int: The offset to offset the copy by
offset: The offset to offset the copy by

Returns:
DataMapping: The new DataMapping
The new DataMapping

"""
# only need a shallow copy as the underlying data mappings are
Expand Down
Loading
Loading