From 7af61b73828e87be95a90be261a0f7224e8c210a Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Sun, 2 Feb 2025 14:19:45 +0100 Subject: [PATCH 1/5] add case where cycler is already a cycle --- ultraplot/axes/plot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ultraplot/axes/plot.py b/ultraplot/axes/plot.py index e1e83d3cd..338f1c844 100644 --- a/ultraplot/axes/plot.py +++ b/ultraplot/axes/plot.py @@ -2485,6 +2485,8 @@ def _parse_cycle( resolved_cycle = None case str() | int(): resolved_cycle = constructor.Cycle(cycle, **cycle_kw) + case constructor.Cycle(): + resolved_cycle = cycle case _: resolved_cycle = None From 4d43ce02bebaba7be2f23d839edd7e798754336f Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Sun, 2 Feb 2025 14:51:47 +0100 Subject: [PATCH 2/5] convert all to internal cycler; and add test --- ultraplot/axes/plot.py | 2 +- ultraplot/tests/test_constructor.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ultraplot/axes/plot.py b/ultraplot/axes/plot.py index 338f1c844..e77c723d9 100644 --- a/ultraplot/axes/plot.py +++ b/ultraplot/axes/plot.py @@ -2486,7 +2486,7 @@ def _parse_cycle( case str() | int(): resolved_cycle = constructor.Cycle(cycle, **cycle_kw) case constructor.Cycle(): - resolved_cycle = cycle + resolved_cycle = constructor.Cyce(cycle, *cycle_kw) case _: resolved_cycle = None diff --git a/ultraplot/tests/test_constructor.py b/ultraplot/tests/test_constructor.py index 942e5a05e..142237ebe 100644 --- a/ultraplot/tests/test_constructor.py +++ b/ultraplot/tests/test_constructor.py @@ -97,3 +97,20 @@ def test_manual_cycle(): props = ax._active_cycle.get_next() assert cycled_pos == parser._idx assert props == parser._cycler_items[parser._idx] + + +def test_pass_on_cycle(): + colors = ["red", "green", "black"] + cycle = uplt.Cycle( + colors, + marker=["X", "o"], + sizes=[20, 100], + edgecolors=["r", "k"], + ) + fig, ax = uplt.subplots() + ax.set_prop_cycle(cycle) + active_cycle = ax.axes._active_cycle + for color in colors: + print(colors) + assert color == active_cycle.get_next()["color"] + assert color == cycle.get_next()["color"] From f5639650a3d99c2f2e70f9b65959bc6bb9e634b6 Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Sun, 2 Feb 2025 14:54:02 +0100 Subject: [PATCH 3/5] cleanup --- ultraplot/tests/test_constructor.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ultraplot/tests/test_constructor.py b/ultraplot/tests/test_constructor.py index 142237ebe..912437614 100644 --- a/ultraplot/tests/test_constructor.py +++ b/ultraplot/tests/test_constructor.py @@ -101,16 +101,10 @@ def test_manual_cycle(): def test_pass_on_cycle(): colors = ["red", "green", "black"] - cycle = uplt.Cycle( - colors, - marker=["X", "o"], - sizes=[20, 100], - edgecolors=["r", "k"], - ) + cycle = uplt.Cycle(colors) fig, ax = uplt.subplots() ax.set_prop_cycle(cycle) active_cycle = ax.axes._active_cycle for color in colors: - print(colors) assert color == active_cycle.get_next()["color"] assert color == cycle.get_next()["color"] From b247774cfbda0448c2271b9fb8fc822d7fb1509d Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Sun, 2 Feb 2025 14:56:25 +0100 Subject: [PATCH 4/5] fix typo --- ultraplot/axes/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ultraplot/axes/plot.py b/ultraplot/axes/plot.py index e77c723d9..f333a198d 100644 --- a/ultraplot/axes/plot.py +++ b/ultraplot/axes/plot.py @@ -2486,7 +2486,7 @@ def _parse_cycle( case str() | int(): resolved_cycle = constructor.Cycle(cycle, **cycle_kw) case constructor.Cycle(): - resolved_cycle = constructor.Cyce(cycle, *cycle_kw) + resolved_cycle = constructor.Cycle(cycle, *cycle_kw) case _: resolved_cycle = None From b02e36d2cf416a087ff76288f5affd5798b386ef Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Sun, 2 Feb 2025 15:00:10 +0100 Subject: [PATCH 5/5] rm kw --- ultraplot/axes/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ultraplot/axes/plot.py b/ultraplot/axes/plot.py index f333a198d..4a11dd6e1 100644 --- a/ultraplot/axes/plot.py +++ b/ultraplot/axes/plot.py @@ -2486,7 +2486,7 @@ def _parse_cycle( case str() | int(): resolved_cycle = constructor.Cycle(cycle, **cycle_kw) case constructor.Cycle(): - resolved_cycle = constructor.Cycle(cycle, *cycle_kw) + resolved_cycle = constructor.Cycle(cycle) case _: resolved_cycle = None