Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
bc2db86
Feature: ColorSystem bool()
May 6, 2022
b66315f
Fix: Correct repr for HEX values and round() implmentation
May 6, 2022
0fc9191
Feature: bool and divmod
May 6, 2022
6627ec0
Feature: more tests for divmod
May 6, 2022
46ab7eb
feature: int()
May 6, 2022
a261806
feature: float()
May 6, 2022
23ba3b3
feature: iter()
May 6, 2022
6ab9bd6
feature: sum test
May 6, 2022
1a3034b
feature: len()
May 6, 2022
6f75f15
feature: hash() and ColorSystem._value_setter(values)
May 6, 2022
11c8e7e
feature: math.floor() and math.ceil()
May 6, 2022
34e6ec2
feature: abs()
May 6, 2022
7dd8cd5
feature: copy.copy()
May 6, 2022
29e5c9a
feature: __contains__
May 6, 2022
ea09b37
feature: math.trunc
May 6, 2022
5158e60
Change: removed not unse ful functions and replaced int() and float()…
May 6, 2022
23989f8
Fix: Unused import
May 6, 2022
6bb9e64
Fix: unused import and __all__ completion
May 6, 2022
f21d864
Change: map_color uses dictionary instead of long if statementr
May 6, 2022
3bd180c
Fix: Removed hash test, as they differ from version to version
May 6, 2022
51ba906
Change: Speed increase
May 6, 2022
ab68c70
Feature: Test for speed
May 6, 2022
93081ac
Speed: No Strict Type on defined colors
May 6, 2022
7174b83
Change: NestedColorSequence Speedup
May 6, 2022
6f43305
Fix: removed unused imports
May 6, 2022
4c7ec55
Change: No use of Partial method, HtmlColorTuples replace with HtmlCo…
May 6, 2022
403af49
Change; Speedup of NestedColorSequence, RgbControlledNest and StyleNest
May 6, 2022
5b9338a
Fix: missed NCSNO
May 6, 2022
6bdb9a4
Change: Further Speedup of Nested
May 6, 2022
e151a88
Change: Removed Keywords for speedup
May 6, 2022
051ecfe
Change: Speedup of System
May 7, 2022
c4081cf
Fix: Better custom and rgb functions for ForeNest,BackNest and Underl…
May 7, 2022
ff10e38
Change: TextNestedBig speed test addition
May 7, 2022
4d971bf
Change: Better _ColorConversionInput decorator instead of long if sta…
May 7, 2022
b7d5c53
Fix: Removal of StrictType
May 7, 2022
af30336
Change: Better TypeHinting
May 7, 2022
9c1a50b
Removed init.RoundUp
May 7, 2022
8f71276
Change to_... now uses color_conversions_mapped
May 7, 2022
544c503
Change: Removed rounds from Color Systems which did not need it
May 7, 2022
720ef79
Change: Final Cleanup
May 7, 2022
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
37 changes: 37 additions & 0 deletions Tests/BulkTests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ----------------------------------------------------------------------------------------------------------------------
# - Package Imports -
# ----------------------------------------------------------------------------------------------------------------------
# General Packages
from __future__ import annotations
import unittest

# Custom Library

# Custom Packages

# ----------------------------------------------------------------------------------------------------------------------
# - Code -
# ----------------------------------------------------------------------------------------------------------------------
class BulkTests(unittest.TestCase):
def Subtest_Equality(self, ObjectType:type, cases):
for value, result, value_printer in cases:
with self.subTest(ObjectType=ObjectType,value=value, result=result, value_printer=value_printer):
self.assertEqual(ObjectType(value), result)

def Subtest_Fail(self, ObjectType:type, cases):
for value, error in cases:
with self.subTest(ObjectType=ObjectType,value=value, error=error):
with self.assertRaises(error):
ObjectType(value)

def Subtest_ObjectOperation(self, ObjectType:type, args:tuple, kwargs:dict, cases):
for operation, oargs, okwargs,result in cases:
with self.subTest(ObjectType=ObjectType, args=args, kwargs=kwargs, oargs=oargs, okwargs=okwargs,result=result, ):
test_object = ObjectType(*args, **kwargs)
self.assertEqual(operation(test_object, *oargs, *okwargs), result)

def Subtest_ObjectOperationBulk(self, ObjectType:type, cases):
for operation, oargs, okwargs, args, kwargs,result in cases:
with self.subTest(ObjectType=ObjectType, args=args, kwargs=kwargs, operation=operation,oargs=oargs, okwargs=okwargs,result=result, ):
test_object = ObjectType(*args, **kwargs)
self.assertEqual(operation(test_object, *oargs, *okwargs), result)
1 change: 0 additions & 1 deletion Tests/ColorObjects/test_ColorTupleConversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

# Custom Library
from AthenaColor.Objects.Color.ColorTupleConversion import *
from AthenaColor.Objects.Color.ColorTupleConversion import NormalizeRgb

# Custom Packages
# ----------------------------------------------------------------------------------------------------------------------
Expand Down
138 changes: 138 additions & 0 deletions Tests/ColorObjects/test_Dunders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# ----------------------------------------------------------------------------------------------------------------------
# - Package Imports -
# ----------------------------------------------------------------------------------------------------------------------
# General Packages
from __future__ import annotations
import copy
import operator

# Custom Library
from AthenaColor import RGB, RGBA, HEX, HEXA, HSL, HSV, CMYK

# Custom Packages
from Tests.BulkTests import BulkTests

# ----------------------------------------------------------------------------------------------------------------------
# - Code -
# ----------------------------------------------------------------------------------------------------------------------
class DunderTesting(BulkTests):
def test_RGB(self):
objectType=RGB
casesOperation=(
#operation oargs okwargs args kwargs result
(str, (), {}, (0,0,0), {}, "0;0;0"),
(repr, (), {}, (0,0,0), {}, "RGB(r=0,g=0,b=0)"),
(round, (), {}, (0,0,0), {}, RGB(0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless
(bool, (), {}, (0,0,0), {}, False),
(bool, (), {}, (0,0,1), {}, True),
(divmod, (8,), {}, (127,71,54), {}, (RGB(r=15,g=8,b=6), RGB(r=7,g=7,b=6))),
(divmod, ((8,4,2),), {}, (127,71,54), {}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))),
(divmod, (RGB(8,4,2),), {}, (127,71,54), {}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))),
(divmod, (HSL(180,.5,.5),), {}, (127,71,54), {}, (RGB(r=1,g=0,b=0), RGB(r=63,g=71,b=54))),
(sum, (), {}, (127,127,127), {}, 381),
(max, (), {}, (52,128,255), {}, 255),
(min, (), {}, (52,128,255), {}, 52),
(copy.copy, (), {}, (52,128,255), {}, RGB(52,128,255)),
(operator.contains,(52,), {}, (52,128,255), {}, True),
(operator.contains,(12,), {}, (52,128,255), {}, False),
)
self.Subtest_ObjectOperationBulk(objectType, casesOperation)

def test_HEX(self):
objectType=HEX
casesOperation=(
#operation oargs okwargs args kwargs result
(str, (), {}, ("#000000",), {}, "#000000"),
(repr, (), {}, ("#000000",), {}, 'HEX(hex_value="#000000")'),
(round, (), {}, ("#000000",), {}, HEX("#000000")), # doesn't really impact the RGB or HEX objects, but exsists nonetheless
(bool, (), {}, ("#000000",), {}, False),
(bool, (), {}, ("#000001",), {}, True),
(divmod, (8,), {}, ("#7f4736",), {}, (HEX("#0f0806"), HEX("#070706"))),

)
self.Subtest_ObjectOperationBulk(objectType, casesOperation)

def test_RGBA(self):
objectType=RGBA
casesOperation=(
#operation oargs okwargs args kwargs result
(str, (), {}, (0,0,0), {}, "0;0;0;0"),
(repr, (), {}, (0,0,0), {}, "RGBA(r=0,g=0,b=0,a=0)"),
(round, (), {}, (0,0,0), {}, RGBA(0,0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless
(bool, (), {}, (0,0,0), {}, False),
(bool, (), {}, (0,0,1), {}, True),
(divmod, (8,), {}, (127,71,54,28), {}, (RGBA(r=15,g=8,b=6,a=3), RGBA(r=7,g=7,b=6,a=4))),
(divmod, ((8,4,2,5),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=5), RGBA(r=7,g=3,b=0,a=3))),
(divmod, (RGBA(8,4,2,1),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=28), RGBA(r=7,g=3,b=0,a=0))),
(divmod, (HSL(180,.5,.5),), {}, (127,71,54,28), {}, (RGBA(r=1,g=0,b=0,a=0), RGBA(r=63,g=71,b=54,a=28))),
)
self.Subtest_ObjectOperationBulk(objectType, casesOperation)

def test_HEXA(self):
objectType=HEXA
casesOperation=(
#operation oargs okwargs args kwargs result
(str, (), {}, ("#00000000",), {}, "#00000000"),
(repr, (), {}, ("#00000000",), {}, 'HEXA(hex_value="#00000000")'),
(round, (), {}, ("#00000000",), {}, HEXA("#00000000")), # doesn't really impact the RGB or HEX objects, but exsists nonetheless
(bool, (), {}, ("#00000000",), {}, False),
(bool, (), {}, ("#00000100",), {}, True),
(divmod, (8,), {}, ("#7f473612",), {}, (HEXA(hex_value="#0f080602"), HEXA(hex_value="#07070602"))),
(divmod, ((8,4,2,5),), {}, ("#7f473612",), {}, (HEXA(hex_value="#0f111b03"), HEXA(hex_value="#07030003"))),
(divmod, (RGBA(8,4,2,1),), {}, ("#7f473612",), {}, (HEXA(hex_value="#0f111b12"), HEXA(hex_value="#07030000"))),
(divmod, (HEXA("#0f111b12"),),{}, ("#7f473612",), {}, (HEXA(hex_value="#08040201"), HEXA(hex_value="#07030000"))),
(divmod, (HSL(180,.5,.5),), {}, ("#7f473612",), {}, (HEXA(hex_value="#01000000"), HEXA(hex_value="#3f473612"))),
)
self.Subtest_ObjectOperationBulk(objectType, casesOperation)

def test_HSV(self):
objectType=HSV
casesOperation=(
#operation oargs okwargs args kwargs result
(str, (), {}, (180,.5,.5), {}, "180;0.5;0.5"),
(repr, (), {}, (180,.5,.5), {}, 'HSV(h=180,s=0.5,v=0.5)'),
(round, (), {}, (180,.5,.5), {}, HSV(180,0,0)),
(round, (5,), {}, (180,.123456,.123456), {}, HSV(180,.12346,.12346)),
(bool, (), {}, (0,0,0), {}, False),
(bool, (), {}, (0,0,1), {}, True),
(divmod, (8,), {}, (180,.5,.5), {}, (HSV(h=22,s=0.0,v=0.0), HSV(h=4,s=0.5,v=0.5))),
(divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.024999999999999974,v=0.01999999999999999))),
(divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSV(h=9,s=0.0,v=1), HSV(h=0,s=0.5,v=0.0040000000000000036))),
(divmod, (HSV(8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.024999999999999974,v=0.01999999999999999))),
)
self.Subtest_ObjectOperationBulk(objectType, casesOperation)

def test_HSL(self):
objectType=HSL
casesOperation=(
#operation oargs okwargs args kwargs result
(str, (), {}, (180,.5,.5), {}, "180;0.5;0.5"),
(repr, (), {}, (180,.5,.5), {}, 'HSL(h=180,s=0.5,l=0.5)'),
(round, (), {}, (180,.5,.5), {}, HSL(180,0,0)),
(round, (5,), {}, (180,.123456,.123456), {}, HSL(180,.12346,.12346)),
(bool, (), {}, (0,0,0), {}, False),
(bool, (), {}, (0,0,1), {}, True),
(divmod, (8,), {}, (180,.5,.5), {}, (HSL(h=22,s=0.0,l=0.0), HSL(h=4,s=0.5,l=0.5))),
(divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.024999999999999974,l=0.01999999999999999))),
(divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSL(h=9,s=0.0,l=1), HSL(h=0,s=0.5,l=0.01999999999999999))),
(divmod, (HSL(8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.024999999999999974,l=0.01999999999999999))),
)
self.Subtest_ObjectOperationBulk(objectType, casesOperation)

def test_CMYK(self):
objectType=CMYK
casesOperation=(
#operation oargs okwargs args kwargs result
(str, (), {}, (.5,.5,.5,.5), {}, "0.5;0.5;0.5;0.5"),
(repr, (), {}, (.5,.5,.5,.5), {}, 'CMYK(c=0.5,m=0.5,y=0.5,k=0.5)'),
(round, (), {}, (.5,.5,.5,.5), {}, CMYK(0,0,0,0)),
(round, (5,), {}, (.123456,.123456,.123456,.123456), {}, CMYK(.12346,.12346,.12346,.12346)),
(divmod, ((8,4,2,5),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=0.0,y=0.0,k=0.0), CMYK(c=0.5,m=0.5,y=0.5,k=0.5))),
(divmod, ((.8,.4,.2,.5),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1.0,y=1,k=1.0), CMYK(c=0.5,m=0.09999999999999998,y=0.09999999999999998,k=0.0))),
(bool, (), {}, (0,0,0,0), {}, False),
(bool, (), {}, (0,0,0,1), {}, True),
(divmod, (8,), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=0.0,y=0.0,k=0.0), CMYK(c=0.5,m=0.5,y=0.5,k=0.5))),
(divmod, ((8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.024999999999999974,y=0.01999999999999999,k=0.00999999999999999))),
(divmod, (CMYK(8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.024999999999999974,y=0.01999999999999999,k=0.00999999999999999))),
)
self.Subtest_ObjectOperationBulk(objectType, casesOperation)
4 changes: 2 additions & 2 deletions Tests/ColorObjects/test_HEX.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def CreateColor(hex_str = "#204080") -> HEX:
def test_input(self):
with self.assertRaises(TypeError):
HEX(1)
with self.assertRaises(TypeError):
with self.assertRaises(ValueError):
HEX(b"#123456")
with self.assertRaises(ValueError):
HEX("#123456789")
Expand All @@ -35,7 +35,7 @@ def test_input(self):
HEX(**{"hex_value":"#123456","a":1})

def test_repr(self):
self.assertEqual(repr(self.CreateColor()),"HEX(r=32,g=64,b=128)")
self.assertEqual(repr(self.CreateColor()),'HEX(hex_value="#204080")')

def test_str(self):
self.assertEqual(str(self.CreateColor()),"#204080")
Expand Down
Loading