From 36ac26cdcf0976484b9532b756263aa46cd82b56 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 17 Jun 2020 11:44:54 -0400 Subject: [PATCH] Add zeroed ohlc array constructor --- piker/ui/qt/_source.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/piker/ui/qt/_source.py b/piker/ui/qt/_source.py index 3d6fbae7..a23c9f41 100644 --- a/piker/ui/qt/_source.py +++ b/piker/ui/qt/_source.py @@ -31,6 +31,15 @@ OHLC_dtype = np.dtype( # } +def ohlc_zeros(length: int) -> np.ndarray: + """Construct an OHLC field formatted structarray. + + For "why a structarray" see here: https://stackoverflow.com/a/52443038 + Bottom line, they're faster then ``np.recarray``. + """ + return np.zeros(length, dtype=OHLC_dtype) + + @dataclass class Symbol: """I guess this is some kinda container thing for dealing with