Skip to content

Commit

Permalink
Make more return values concrete class types (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
randallfrank authored Sep 10, 2024
1 parent 15eb2c0 commit 0841f3e
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions src/ansys/pyensight/core/libuserd.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def data(self) -> List["numpy.array"]:
Returns
-------
List["numpy.array"]
List[numpy.array]
A list of two numpy arrays [X, Y].
"""
self._userd.connect_check()
Expand Down Expand Up @@ -236,7 +236,7 @@ def nodes(self) -> "numpy.array":
Returns
-------
"numpy.array"
numpy.array
A numpy array of packed values: x,y,z,z,y,z, ...
Examples
Expand Down Expand Up @@ -309,7 +309,7 @@ def element_conn(self, elem_type: int) -> "numpy.array":
Returns
-------
"numpy.array"
numpy.array
A numpy array of the node indices.
Examples
Expand Down Expand Up @@ -361,7 +361,7 @@ def element_conn_nsided(self, elem_type: int) -> List["numpy.array"]:
Returns
-------
List["numpy.array"]
List[numpy.array]
Two numpy arrays: num_nodes_per_element, nodes
"""
self._userd.connect_check()
Expand Down Expand Up @@ -412,7 +412,7 @@ def element_conn_nfaced(self, elem_type: int) -> List["numpy.array"]:
Returns
-------
List["numpy.array"]
List[numpy.array]
Three numpy arrays: num_faces_per_element, num_nodes_per_face, face_nodes
"""
self._userd.connect_check()
Expand Down Expand Up @@ -473,7 +473,7 @@ def variable_values(
Returns
-------
"numpy.array"
numpy.array
A numpy array or a single scalar float.
"""
self._userd.connect_check()
Expand Down Expand Up @@ -623,18 +623,42 @@ def queries(self) -> List[Query]:
out.append(Query(self._userd, query))
return out

def timevalues(self) -> List[float]:
def get_number_of_time_sets(self) -> int:
"""
Get the number of timesets in the dataset.
Returns
-------
int
The number of timesets.
"""
self._userd.connect_check()
pb = libuserd_pb2.Reader_get_number_of_time_setsRequest()
try:
reply = self._userd.stub.Reader_get_number_of_time_sets(
pb, metadata=self._userd.metadata()
)
except grpc.RpcError as e:
raise self._userd.libuserd_exception(e)
return reply.numberOfTimeSets

def timevalues(self, timeset: int = 1) -> List[float]:
"""
Get a list of the time step values in this dataset.
Parameters
----------
timeset : int, optional
The timestep to query (default is 1)
Returns
-------
List[float]
A list of time floats.
"""
self._userd.connect_check()
pb = libuserd_pb2.Reader_timevaluesRequest()
pb.timeSetNumber = 1
pb.timeSetNumber = timeset
try:
timevalues = self._userd.stub.Reader_timevalues(pb, metadata=self._userd.metadata())
except grpc.RpcError as e:
Expand Down Expand Up @@ -797,7 +821,7 @@ def read_dataset(self, file1: str, file2: str = "") -> "Reader":
Returns
-------
"Reader"
Reader
An instance of the `Reader` class.
"""
self._userd.connect_check()
Expand Down Expand Up @@ -1145,7 +1169,8 @@ def connect_check(self) -> None:
Raises
------
RuntimeError if there is no active connection.
RuntimeError
If there is no active connection.
"""
if not self._is_connected():
raise RuntimeError("gRPC connection not established")
Expand Down Expand Up @@ -1391,7 +1416,7 @@ def get_all_readers(self) -> List["ReaderInfo"]:
Returns
-------
List["ReaderInfo"]
List[ReaderInfo]
List of all ReaderInfo objects.
"""
self.connect_check()
Expand Down Expand Up @@ -1420,7 +1445,7 @@ def query_format(self, name1: str, name2: str = "") -> List["ReaderInfo"]:
Returns
-------
List["ReaderInfo"]
List[ReaderInfo]
List of ReaderInfo objects that might be able to read the dataset
"""
self.connect_check()
Expand Down

0 comments on commit 0841f3e

Please sign in to comment.