From 57b64ffe3727e12765244e9fc3ba208f3ace1080 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Sat, 14 Oct 2023 00:59:05 -0400 Subject: [PATCH] add in operator to PlotArea --- fastplotlib/layouts/_base.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/fastplotlib/layouts/_base.py b/fastplotlib/layouts/_base.py index c5dcb0581..536a119e4 100644 --- a/fastplotlib/layouts/_base.py +++ b/fastplotlib/layouts/_base.py @@ -516,6 +516,28 @@ def __getitem__(self, name: str): f"The current selectors are:\n {selector_names}" ) + def __contains__(self, item: Union[str, Graphic]): + to_check = [*self.graphics, *self.selectors] + + if isinstance(item, Graphic): + if item in to_check: + return True + else: + return False + + elif isinstance(item, str): + for graphic in to_check: + # only check named graphics + if graphic.name is None: + continue + + if graphic.name == item: + return True + + return False + + raise TypeError("PlotArea `in` operator accepts only `Graphic` or `str` types") + def __str__(self): if self.name is None: name = "unnamed" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy