-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests and extensions for components.DrawOrder
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Any, Sequence | ||
|
||
import numpy as np | ||
import pyarrow as pa | ||
|
||
|
||
class DrawOrderArrayExt: | ||
@staticmethod | ||
def _from_similar(data: Any | None, *, mono: type, mono_aliases: type, many: type, many_aliases: type, arrow: type): | ||
if isinstance(data, Sequence) and (len(data) > 0 and isinstance(data[0], mono)): | ||
array = np.asarray([draw_order.value for draw_order in data], np.float32) | ||
else: | ||
array = np.require(np.asarray(data), np.float32).flatten() | ||
|
||
return arrow().wrap_array(pa.array(array, type=arrow().storage_type)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters