From e945aa03f23343e3a805fdcfc8f767e7f29caa0a Mon Sep 17 00:00:00 2001 From: Saji Date: Tue, 8 Oct 2024 20:57:49 -0500 Subject: [PATCH] fix tests --- src/groovylight/common.py | 6 ++++-- src/groovylight/hub75.py | 3 +-- src/groovylight/tests/test_common.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/groovylight/common.py b/src/groovylight/common.py index b3b8c30..7dae2c3 100644 --- a/src/groovylight/common.py +++ b/src/groovylight/common.py @@ -24,9 +24,11 @@ Rgb111Layout = RGBLayout(1, 1, 1) class RGBView(data.View): - def bit_depth(self) -> int: - return max(self.red.shape(), self.green.shape(), self.blue.shape()) + return max( + self.red.shape().width, self.green.shape().width, self.blue.shape().width + ) + def channel_slice(self, bit: int) -> Rgb111Layout: """Select bits from each channel and use it to form an Rgb111Layout. This is useful for BCM stuff, since the bits are sliced to form a bitplane. diff --git a/src/groovylight/hub75.py b/src/groovylight/hub75.py index b2deb52..23c10e9 100644 --- a/src/groovylight/hub75.py +++ b/src/groovylight/hub75.py @@ -1,4 +1,4 @@ -from amaranth import Module, Cat, Mux, Print, ShapeLike, Signal, Assert, Array +from amaranth import Module, Cat, Mux, ShapeLike, Signal, Assert, Array from amaranth.build import Platform from amaranth.lib import wiring, data from amaranth.lib.wiring import In, Out @@ -313,7 +313,6 @@ class Hub75DataDriver(wiring.Component): return m - class Hub75Coordinator(wiring.Component): """A shared-control hub75 driver""" diff --git a/src/groovylight/tests/test_common.py b/src/groovylight/tests/test_common.py index a180063..f30dac5 100644 --- a/src/groovylight/tests/test_common.py +++ b/src/groovylight/tests/test_common.py @@ -7,14 +7,14 @@ from groovylight.common import Rgb888Layout, Rgb666Layout, RGBView def test_rgbview(): rgb = Rgb888Layout(0xAABBCC) - assert rgb.channel_size() == unsigned(8) + assert rgb.bit_depth() == 8 rgb18 = Rgb666Layout(0x2DEFD) slice = rgb.channel_slice(1) assert isinstance(slice, RGBView), "channel_slice should return another rgbview" - assert slice.channel_size() == unsigned(1), "channel_slice channel size should be 1" + assert slice.bit_depth() == 1, "channel_slice channel size should be 1" assert isinstance( rgb18.channel_slice(5), RGBView ), "channel_slice should return another rgbview"