lca_index
int64
0
223
idx
stringlengths
7
11
line_type
stringclasses
6 values
ground_truth
stringlengths
2
35
completions
sequencelengths
3
1.16k
prefix
stringlengths
298
32.8k
postfix
stringlengths
0
28.6k
repo
stringclasses
34 values
202
202-124-28
inproject
arg
[ "add", "arg", "clean", "flag", "FLAGS", "furl", "normalize", "params", "schema", "settings", "unquote", "urlencode", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.
(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-126-20
inproject
encode
[ "capitalize", "casefold", "center", "count", "encode", "endswith", "expandtabs", "find", "format", "format_map", "index", "isalnum", "isalpha", "isascii", "isdecimal", "isdigit", "isidentifier", "islower", "isnumeric", "isprintable", "isspace", "istitle", "isupper", "join", "ljust", "lower", "lstrip", "maketrans", "partition", "removeprefix", "removesuffix", "replace", "rfind", "rindex", "rjust", "rpartition", "rsplit", "rstrip", "split", "splitlines", "startswith", "strip", "swapcase", "title", "translate", "upper", "zfill", "__add__", "__annotations__", "__class__", "__contains__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__ge__", "__getattribute__", "__getitem__", "__getnewargs__", "__gt__", "__hash__", "__init__", "__init_subclass__", "__iter__", "__le__", "__len__", "__lt__", "__mod__", "__module__", "__mul__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__rmul__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.
()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-126-53
inproject
split
[ "capitalize", "casefold", "center", "count", "encode", "endswith", "expandtabs", "find", "format", "format_map", "index", "isalnum", "isalpha", "isascii", "isdecimal", "isdigit", "isidentifier", "islower", "isnumeric", "isprintable", "isspace", "istitle", "isupper", "join", "ljust", "lower", "lstrip", "maketrans", "partition", "removeprefix", "removesuffix", "replace", "rfind", "rindex", "rjust", "rpartition", "rsplit", "rstrip", "split", "splitlines", "startswith", "strip", "swapcase", "title", "translate", "upper", "zfill", "__add__", "__annotations__", "__class__", "__contains__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__ge__", "__getattribute__", "__getitem__", "__getnewargs__", "__gt__", "__hash__", "__init__", "__init_subclass__", "__iter__", "__le__", "__len__", "__lt__", "__mod__", "__module__", "__mul__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__rmul__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.
("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-129-22
inproject
text
[ "html", "http", "images", "meta", "text", "urls", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.
.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-129-27
inproject
decode
[ "decode", "encode", "fingerprint", "hashlib", "normalize", "re", "slugify", "unquote", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.
(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-135-20
inproject
urls
[ "html", "http", "images", "meta", "text", "urls", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.
.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-135-25
inproject
arg
[ "add", "arg", "clean", "flag", "FLAGS", "furl", "normalize", "params", "schema", "settings", "unquote", "urlencode", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.
(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-137-36
inproject
Template
[ "Font", "font", "Overlay", "overlay", "Template", "template", "Text", "text", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.
.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-137-45
inproject
create
[ "build_custom_url", "build_example_url", "build_path", "build_self_url", "check", "clean", "create", "delete", "directory", "example", "get_image", "id", "image", "jsonify", "matches", "mro", "name", "overlay", "source", "styles", "text", "valid", "_embed", "_update_example", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__lt__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.
(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-138-28
inproject
image
[ "build_custom_url", "build_example_url", "build_path", "build_self_url", "check", "clean", "create", "delete", "directory", "example", "get_image", "id", "image", "jsonify", "matches", "name", "overlay", "source", "styles", "text", "valid", "_embed", "_update_example", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__lt__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.
.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-138-34
inproject
exists
[ "absolute", "anchor", "as_posix", "as_uri", "attrname", "chmod", "cwd", "drive", "exists", "expanduser", "func", "glob", "group", "hardlink_to", "home", "is_absolute", "is_block_device", "is_char_device", "is_dir", "is_fifo", "is_file", "is_mount", "is_relative_to", "is_reserved", "is_socket", "is_symlink", "iterdir", "joinpath", "lchmod", "link_to", "lock", "lstat", "match", "mkdir", "name", "open", "owner", "parent", "parents", "parts", "read_bytes", "read_text", "readlink", "relative_to", "rename", "replace", "resolve", "rglob", "rmdir", "root", "samefile", "stat", "stem", "suffix", "suffixes", "symlink_to", "touch", "unlink", "with_name", "with_stem", "with_suffix", "write_bytes", "write_text", "_accessor", "_cached_cparts", "_cparts", "_format_parsed_parts", "_from_parsed_parts", "_from_parts", "_hash", "_make_child", "_make_child_relpath", "_parse_args", "_pparts", "_str", "__annotations__", "__bytes__", "__class__", "__class_getitem__", "__delattr__", "__dict__", "__dir__", "__doc__", "__enter__", "__eq__", "__exit__", "__format__", "__fspath__", "__ge__", "__get__", "__getattribute__", "__gt__", "__hash__", "__init__", "__init_subclass__", "__le__", "__lt__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__rtruediv__", "__set_name__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__truediv__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.
(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-139-23
inproject
error
[ "addFilter", "addHandler", "callHandlers", "critical", "debug", "disabled", "error", "exception", "fatal", "filter", "filters", "findCaller", "getChild", "getEffectiveLevel", "handle", "handlers", "hasHandlers", "info", "isEnabledFor", "level", "log", "makeRecord", "name", "parent", "propagate", "removeFilter", "removeHandler", "setLevel", "warn", "warning", "_cache", "_log", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.
(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-141-35
inproject
PLACEHOLDER
[ "ALLOWED_EXTENSIONS", "ALLOWED_WATERMARKS", "BASE_URL", "BUGSNAG_API_KEY", "DEBUG", "DEFAULT_EXTENSION", "DEFAULT_FONT", "DEFAULT_SIZE", "DEFAULT_STYLE", "DEFAULT_WATERMARK", "DEPLOYED", "DISABLED_WATERMARK", "IMAGES_DIRECTORY", "MAXIMUM_FRAMES", "MAXIMUM_PIXELS", "MINIMUM_FONT_SIZE", "os", "Path", "PLACEHOLDER", "PLACEHOLDER_SUFFIX", "PORT", "PREVIEW_SIZE", "PREVIEW_TEXT", "RELEASE_STAGE", "REMOTE_TRACKING_ERRORS", "REMOTE_TRACKING_ERRORS_LIMIT", "REMOTE_TRACKING_URL", "ROOT", "SCHEME", "SERVER_NAME", "SUFFIX", "TEST_IMAGES", "TEST_IMAGES_DIRECTORY", "TRACK_REQUESTS", "WATERMARK_HEIGHT", "WORKERS", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.
: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-144-26
inproject
urls
[ "html", "http", "images", "meta", "text", "urls", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.
.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-144-31
inproject
arg
[ "add", "arg", "clean", "flag", "FLAGS", "furl", "normalize", "params", "schema", "settings", "unquote", "urlencode", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.
(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-144-58
inproject
DEFAULT_STYLE
[ "ALLOWED_EXTENSIONS", "ALLOWED_WATERMARKS", "BASE_URL", "BUGSNAG_API_KEY", "DEBUG", "DEFAULT_EXTENSION", "DEFAULT_FONT", "DEFAULT_SIZE", "DEFAULT_STYLE", "DEFAULT_WATERMARK", "DEPLOYED", "DISABLED_WATERMARK", "IMAGES_DIRECTORY", "MAXIMUM_FRAMES", "MAXIMUM_PIXELS", "MINIMUM_FONT_SIZE", "os", "Path", "PLACEHOLDER", "PLACEHOLDER_SUFFIX", "PORT", "PREVIEW_SIZE", "PREVIEW_TEXT", "RELEASE_STAGE", "REMOTE_TRACKING_ERRORS", "REMOTE_TRACKING_ERRORS_LIMIT", "REMOTE_TRACKING_URL", "ROOT", "SCHEME", "SERVER_NAME", "SUFFIX", "TEST_IMAGES", "TEST_IMAGES_DIRECTORY", "TRACK_REQUESTS", "WATERMARK_HEIGHT", "WORKERS", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.
, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-147-34
inproject
check
[ "build_custom_url", "build_example_url", "build_path", "build_self_url", "check", "clean", "create", "delete", "directory", "example", "get_image", "id", "image", "jsonify", "matches", "name", "overlay", "source", "styles", "text", "valid", "_embed", "_update_example", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__lt__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.
(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-155-30
inproject
Template
[ "Font", "font", "Overlay", "overlay", "Template", "template", "Text", "text", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.
.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-156-29
random
DEFAULT_STYLE
[ "ALLOWED_EXTENSIONS", "ALLOWED_WATERMARKS", "BASE_URL", "BUGSNAG_API_KEY", "DEBUG", "DEFAULT_EXTENSION", "DEFAULT_FONT", "DEFAULT_SIZE", "DEFAULT_STYLE", "DEFAULT_WATERMARK", "DEPLOYED", "DISABLED_WATERMARK", "IMAGES_DIRECTORY", "MAXIMUM_FRAMES", "MAXIMUM_PIXELS", "MINIMUM_FONT_SIZE", "os", "Path", "PLACEHOLDER", "PLACEHOLDER_SUFFIX", "PORT", "PREVIEW_SIZE", "PREVIEW_TEXT", "RELEASE_STAGE", "REMOTE_TRACKING_ERRORS", "REMOTE_TRACKING_ERRORS_LIMIT", "REMOTE_TRACKING_URL", "ROOT", "SCHEME", "SERVER_NAME", "SUFFIX", "TEST_IMAGES", "TEST_IMAGES_DIRECTORY", "TRACK_REQUESTS", "WATERMARK_HEIGHT", "WORKERS", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.
status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-167-22
inproject
urls
[ "html", "http", "images", "meta", "text", "urls", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.
.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-167-27
inproject
arg
[ "add", "arg", "clean", "flag", "FLAGS", "furl", "normalize", "params", "schema", "settings", "unquote", "urlencode", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.
(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-167-54
inproject
DEFAULT_STYLE
[ "ALLOWED_EXTENSIONS", "ALLOWED_WATERMARKS", "BASE_URL", "BUGSNAG_API_KEY", "DEBUG", "DEFAULT_EXTENSION", "DEFAULT_FONT", "DEFAULT_SIZE", "DEFAULT_STYLE", "DEFAULT_WATERMARK", "DEPLOYED", "DISABLED_WATERMARK", "IMAGES_DIRECTORY", "MAXIMUM_FRAMES", "MAXIMUM_PIXELS", "MINIMUM_FONT_SIZE", "os", "Path", "PLACEHOLDER", "PLACEHOLDER_SUFFIX", "PORT", "PREVIEW_SIZE", "PREVIEW_TEXT", "RELEASE_STAGE", "REMOTE_TRACKING_ERRORS", "REMOTE_TRACKING_ERRORS_LIMIT", "REMOTE_TRACKING_URL", "ROOT", "SCHEME", "SERVER_NAME", "SUFFIX", "TEST_IMAGES", "TEST_IMAGES_DIRECTORY", "TRACK_REQUESTS", "WATERMARK_HEIGHT", "WORKERS", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.
, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-169-21
inproject
urls
[ "html", "http", "images", "meta", "text", "urls", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.
.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-169-26
inproject
schema
[ "add", "arg", "clean", "flag", "FLAGS", "furl", "normalize", "params", "schema", "settings", "unquote", "urlencode", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.
(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-178-22
inproject
urls
[ "html", "http", "images", "meta", "text", "urls", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.
.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-178-27
inproject
arg
[ "add", "arg", "clean", "flag", "FLAGS", "furl", "normalize", "params", "schema", "settings", "unquote", "urlencode", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.
(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-183-19
inproject
Font
[ "Font", "font", "Overlay", "overlay", "Template", "template", "Text", "text", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.
.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-183-24
inproject
objects
[ "alias", "data", "filename", "id", "mro", "objects", "path", "_", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.
.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-183-32
inproject
get
[ "all", "get", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.
(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-199-25
inproject
to_thread
[ "AbstractChildWatcher", "AbstractEventLoop", "AbstractEventLoopPolicy", "AbstractServer", "ALL_COMPLETED", "all_tasks", "as_completed", "base_events", "base_futures", "base_subprocess", "base_tasks", "BaseChildWatcher", "BaseDefaultEventLoopPolicy", "BaseEventLoop", "BaseProtocol", "BaseTransport", "BoundedSemaphore", "BufferedProtocol", "CancelledError", "compat", "Condition", "CONNECT_PIPE_INIT_DELAY", "CONNECT_PIPE_MAX_DELAY", "constants", "coroutine", "coroutines", "create_subprocess_exec", "create_subprocess_shell", "create_task", "current_task", "DatagramProtocol", "DatagramTransport", "DefaultEventLoopPolicy", "DEVNULL", "ensure_future", "ERROR_CONNECTION_ABORTED", "ERROR_CONNECTION_REFUSED", "Event", "events", "exceptions", "FastChildWatcher", "FIRST_COMPLETED", "FIRST_EXCEPTION", "FlowControlMixin", "format_helpers", "Future", "futures", "gather", "get_child_watcher", "get_event_loop", "get_event_loop_policy", "get_running_loop", "Handle", "IncompleteReadError", "INFINITE", "InvalidStateError", "IocpProactor", "iscoroutine", "iscoroutinefunction", "isfuture", "LifoQueue", "LimitOverrunError", "Lock", "locks", "log", "mixins", "MultiLoopChildWatcher", "new_event_loop", "NULL", "open_connection", "open_unix_connection", "PIPE", "PipeServer", "PriorityQueue", "proactor_events", "ProactorEventLoop", "Process", "Protocol", "protocols", "Queue", "QueueEmpty", "QueueFull", "queues", "ReadTransport", "run", "run_coroutine_threadsafe", "runners", "SafeChildWatcher", "selector_events", "SelectorEventLoop", "Semaphore", "SendfileNotAvailableError", "Server", "set_child_watcher", "set_event_loop", "set_event_loop_policy", "shield", "sleep", "sslproto", "staggered", "start_server", "start_unix_server", "STDOUT", "StreamReader", "StreamReaderProtocol", "streams", "StreamWriter", "subprocess", "SubprocessProtocol", "SubprocessStreamProtocol", "SubprocessTransport", "sys", "Task", "tasks", "ThreadedChildWatcher", "threads", "TimeoutError", "TimerHandle", "to_thread", "Transport", "transports", "trsock", "unix_events", "wait", "wait_for", "windows_events", "windows_utils", "WindowsProactorEventLoopPolicy", "WindowsSelectorEventLoopPolicy", "wrap_future", "WriteTransport", "__all__", "__doc__", "__file__", "__main__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.
( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-200-14
inproject
images
[ "html", "http", "images", "meta", "text", "urls", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.
.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-200-21
inproject
save
[ "add_blurred_background", "add_counter", "add_watermark", "annotations", "Dimensions", "embed", "EXCEPTIONS", "fit_image", "Font", "get_font", "get_image_element", "get_image_elements", "get_stroke_width", "get_text_offset", "get_text_size", "get_text_size_minus_font_offset", "Image", "ImageDraw", "ImageFilter", "ImageFont", "ImageOps", "ImageSequence", "io", "Iterator", "load", "logger", "Offset", "Path", "Point", "preview", "render_animation", "render_image", "resize_image", "save", "settings", "split_2", "split_3", "Template", "Text", "UnidentifiedImageError", "wrap", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.
, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.file(path, status)
jacebrowning__memegen
202
202-210-26
inproject
file
[ "BaseHTTPResponse", "convenience", "empty", "file", "file_stream", "html", "HTTPResponse", "json", "json_dumps", "JSONResponse", "raw", "redirect", "ResponseStream", "text", "types", "validate_file", "__all__", "__doc__", "__file__", "__name__", "__package__" ]
import asyncio from contextlib import suppress from sanic import exceptions, response from sanic.log import logger from .. import models, settings, utils async def generate_url( request, template_id: str = "", *, template_id_required: bool = False ): if request.form: payload = dict(request.form) for key in list(payload.keys()): if "lines" not in key and "style" not in key: payload[key] = payload.pop(key)[0] else: try: payload = request.json or {} except exceptions.InvalidUsage: payload = {} with suppress(KeyError): payload["style"] = payload.pop("style[]") with suppress(KeyError): payload["text_lines"] = payload.pop("text_lines[]") if template_id_required: try: template_id = payload["template_id"] except KeyError: return response.json({"error": '"template_id" is required'}, status=400) else: template_id = utils.text.slugify(template_id) style: str = utils.urls.arg(payload, "", "style", "overlay", "alt") if isinstance(style, list): style = ",".join([(s.strip() or "default") for s in style]) while style.endswith(",default"): style = style.removesuffix(",default") text_lines = utils.urls.arg(payload, [], "text_lines") font = utils.urls.arg(payload, "", "font") background = utils.urls.arg(payload, "", "background", "image_url") extension = utils.urls.arg(payload, "", "extension") if style == "animated": extension = "gif" style = "" status = 201 if template_id: template: models.Template = models.Template.objects.get_or_create(template_id) url = template.build_custom_url( request, text_lines, style=style, font=font, extension=extension, ) if not template.valid: status = 404 template.delete() else: template = models.Template("_custom") url = template.build_custom_url( request, text_lines, background=background, style=style, font=font, extension=extension, ) url, _updated = await utils.meta.tokenize(request, url) if payload.get("redirect", False): return response.redirect(utils.urls.add(url, status="201")) return response.json({"url": url}, status=status) async def preview_image(request, id: str, lines: list[str], style: str): error = "" id = utils.urls.clean(id) if utils.urls.schema(id): template = await models.Template.create(id) if not template.image.exists(): logger.error(f"Unable to download image URL: {id}") template = models.Template.objects.get("_error") error = "Invalid Background" else: template = models.Template.objects.get_or_none(id) if not template: logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") error = "Unknown Template" if not any(line.strip() for line in lines): lines = template.example if not utils.urls.schema(style): style = style.strip().lower() if not await template.check(style): error = "Invalid Overlay" data, content_type = await asyncio.to_thread( utils.images.preview, template, lines, style=style, watermark=error.upper() ) return response.raw(data, content_type=content_type) async def render_image( request, id: str, slug: str = "", watermark: str = "", extension: str = settings.DEFAULT_EXTENSION, ): lines = utils.text.decode(slug) asyncio.create_task(utils.meta.track(request, lines)) status = int(utils.urls.arg(request.args, "200", "status")) if any(len(part.encode()) > 200 for part in slug.split("/")): logger.error(f"Slug too long: {slug}") slug = slug[:50] + "..." lines = utils.text.decode(slug) template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 414 elif id == "custom": url = utils.urls.arg(request.args, None, "background", "alt") if url: template = await models.Template.create(url) if not template.image.exists(): logger.error(f"Unable to download image URL: {url}") template = models.Template.objects.get("_error") if url != settings.PLACEHOLDER: status = 415 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style") if not utils.urls.schema(style): style = style.lower() if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 else: logger.error("No image URL specified for custom template") template = models.Template.objects.get("_error") style = settings.DEFAULT_STYLE status = 422 else: template = models.Template.objects.get_or_none(id) if not template or not template.image.exists(): logger.error(f"No such template: {id}") template = models.Template.objects.get("_error") if id != settings.PLACEHOLDER: status = 404 style = utils.urls.arg(request.args, settings.DEFAULT_STYLE, "style", "alt") if not await template.check(style): if utils.urls.schema(style): status = 415 elif style != settings.PLACEHOLDER: status = 422 if extension not in settings.ALLOWED_EXTENSIONS: extension = settings.DEFAULT_EXTENSION status = 422 font_name = utils.urls.arg(request.args, "", "font") if font_name == settings.PLACEHOLDER: font_name = "" else: try: models.Font.objects.get(font_name) except ValueError: font_name = "" status = 422 try: size = int(request.args.get("width", 0)), int(request.args.get("height", 0)) if 0 < size[0] < 10 or 0 < size[1] < 10: raise ValueError(f"dimensions are too small: {size}") except ValueError as e: logger.error(f"Invalid size: {e}") size = 0, 0 status = 422 frames = int(request.args.get("frames", 0)) path = await asyncio.to_thread( utils.images.save, template, lines, watermark, font_name=font_name, extension=extension, style=style, size=size, maximum_frames=frames, ) return await response.
(path, status)
jacebrowning__memegen
215
215-25-24
commited
load
[ "add_constructor", "add_implicit_resolver", "add_multi_constructor", "add_multi_representer", "add_path_resolver", "add_representer", "AliasEvent", "AliasToken", "AnchorToken", "BaseDumper", "BaseLoader", "BlockEndToken", "BlockEntryToken", "BlockMappingStartToken", "BlockSequenceStartToken", "CBaseDumper", "CBaseLoader", "CDangerDumper", "CDangerLoader", "CDumper", "CEmitter", "CLoader", "CollectionEndEvent", "CollectionNode", "CollectionStartEvent", "compose", "compose_all", "composer", "constructor", "CParser", "CSafeDumper", "CSafeLoader", "cyaml", "DirectiveToken", "DocumentEndEvent", "DocumentEndToken", "DocumentStartEvent", "DocumentStartToken", "dump", "dump_all", "Dumper", "dumper", "emit", "emitter", "error", "Event", "events", "FlowEntryToken", "FlowMappingEndToken", "FlowMappingStartToken", "FlowSequenceEndToken", "FlowSequenceStartToken", "full_load", "full_load_all", "FullLoader", "io", "KeyToken", "load", "load_all", "Loader", "loader", "MappingEndEvent", "MappingNode", "MappingStartEvent", "Mark", "MarkedYAMLError", "Node", "NodeEvent", "nodes", "parse", "parser", "reader", "representer", "resolver", "safe_dump", "safe_dump_all", "safe_load", "safe_load_all", "SafeDumper", "SafeLoader", "ScalarEvent", "ScalarNode", "ScalarToken", "scan", "scanner", "SequenceEndEvent", "SequenceNode", "SequenceStartEvent", "serialize", "serialize_all", "serializer", "StreamEndEvent", "StreamEndToken", "StreamStartEvent", "StreamStartToken", "TagToken", "Token", "tokens", "unsafe_load", "unsafe_load_all", "ValueToken", "warnings", "YAMLError", "YAMLObject", "YAMLObjectMetaclass", "_yaml", "__doc__", "__file__", "__name__", "__package__", "__version__", "__with_libyaml__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.
(f_yml, Loader=yaml.FullLoader) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.finditer( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex._write_str_index(file, item) elif isinstance(item, dict): SectionIndex._write_dict_index(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex._write_index_file(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.generate(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.generate(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.load() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.generate(nav_item=config["nav"]) Reference.generate("reference") Index.generate( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
215
215-25-48
commited
FullLoader
[ "add_constructor", "add_implicit_resolver", "add_multi_constructor", "add_multi_representer", "add_path_resolver", "add_representer", "AliasEvent", "AliasToken", "AnchorToken", "BaseDumper", "BaseLoader", "BlockEndToken", "BlockEntryToken", "BlockMappingStartToken", "BlockSequenceStartToken", "CBaseDumper", "CBaseLoader", "CDangerDumper", "CDangerLoader", "CDumper", "CEmitter", "CLoader", "CollectionEndEvent", "CollectionNode", "CollectionStartEvent", "compose", "compose_all", "composer", "constructor", "CParser", "CSafeDumper", "CSafeLoader", "cyaml", "DirectiveToken", "DocumentEndEvent", "DocumentEndToken", "DocumentStartEvent", "DocumentStartToken", "dump", "dump_all", "Dumper", "dumper", "emit", "emitter", "error", "Event", "events", "FlowEntryToken", "FlowMappingEndToken", "FlowMappingStartToken", "FlowSequenceEndToken", "FlowSequenceStartToken", "full_load", "full_load_all", "FullLoader", "io", "KeyToken", "load", "load_all", "Loader", "loader", "MappingEndEvent", "MappingNode", "MappingStartEvent", "Mark", "MarkedYAMLError", "Node", "NodeEvent", "nodes", "parse", "parser", "reader", "representer", "resolver", "safe_dump", "safe_dump_all", "safe_load", "safe_load_all", "SafeDumper", "SafeLoader", "ScalarEvent", "ScalarNode", "ScalarToken", "scan", "scanner", "SequenceEndEvent", "SequenceNode", "SequenceStartEvent", "serialize", "serialize_all", "serializer", "StreamEndEvent", "StreamEndToken", "StreamStartEvent", "StreamStartToken", "TagToken", "Token", "tokens", "unsafe_load", "unsafe_load_all", "ValueToken", "warnings", "YAMLError", "YAMLObject", "YAMLObjectMetaclass", "_yaml", "__doc__", "__file__", "__name__", "__package__", "__version__", "__with_libyaml__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.load(f_yml, Loader=yaml.
) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.finditer( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex._write_str_index(file, item) elif isinstance(item, dict): SectionIndex._write_dict_index(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex._write_index_file(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.generate(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.generate(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.load() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.generate(nav_item=config["nav"]) Reference.generate("reference") Index.generate( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
215
215-45-24
random
finditer
[ "A", "ASCII", "compile", "copyreg", "DEBUG", "DOTALL", "enum", "error", "escape", "findall", "finditer", "fullmatch", "functools", "I", "IGNORECASE", "L", "LOCALE", "M", "Match", "match", "MULTILINE", "Pattern", "purge", "RegexFlag", "S", "Scanner", "search", "split", "sre_compile", "sre_parse", "sub", "subn", "T", "TEMPLATE", "template", "U", "UNICODE", "VERBOSE", "X", "_cache", "_compile", "_compile_repl", "_expand", "_locale", "_MAXCACHE", "_pickle", "_special_chars_map", "_subx", "__all__", "__doc__", "__file__", "__name__", "__package__", "__version__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.load(f_yml, Loader=yaml.FullLoader) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.
( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex._write_str_index(file, item) elif isinstance(item, dict): SectionIndex._write_dict_index(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex._write_index_file(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.generate(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.generate(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.load() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.generate(nav_item=config["nav"]) Reference.generate("reference") Index.generate( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
215
215-79-29
infile
_write_str_index
[ "generate", "mro", "_write_dict_index", "_write_index_file", "_write_str_index", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.load(f_yml, Loader=yaml.FullLoader) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.finditer( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex.
(file, item) elif isinstance(item, dict): SectionIndex._write_dict_index(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex._write_index_file(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.generate(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.generate(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.load() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.generate(nav_item=config["nav"]) Reference.generate("reference") Index.generate( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
215
215-81-29
infile
_write_dict_index
[ "generate", "mro", "_write_dict_index", "_write_index_file", "_write_str_index", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.load(f_yml, Loader=yaml.FullLoader) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.finditer( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex._write_str_index(file, item) elif isinstance(item, dict): SectionIndex.
(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex._write_index_file(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.generate(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.generate(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.load() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.generate(nav_item=config["nav"]) Reference.generate("reference") Index.generate( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
215
215-140-29
infile
_write_index_file
[ "generate", "mro", "_write_dict_index", "_write_index_file", "_write_str_index", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.load(f_yml, Loader=yaml.FullLoader) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.finditer( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex._write_str_index(file, item) elif isinstance(item, dict): SectionIndex._write_dict_index(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex.
(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.generate(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.generate(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.load() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.generate(nav_item=config["nav"]) Reference.generate("reference") Index.generate( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
215
215-142-29
infile
generate
[ "generate", "mro", "_write_dict_index", "_write_index_file", "_write_str_index", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.load(f_yml, Loader=yaml.FullLoader) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.finditer( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex._write_str_index(file, item) elif isinstance(item, dict): SectionIndex._write_dict_index(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex._write_index_file(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.
(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.generate(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.load() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.generate(nav_item=config["nav"]) Reference.generate("reference") Index.generate( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
215
215-145-29
infile
generate
[ "generate", "mro", "_write_dict_index", "_write_index_file", "_write_str_index", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.load(f_yml, Loader=yaml.FullLoader) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.finditer( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex._write_str_index(file, item) elif isinstance(item, dict): SectionIndex._write_dict_index(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex._write_index_file(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.generate(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.
(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.load() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.generate(nav_item=config["nav"]) Reference.generate("reference") Index.generate( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
215
215-186-26
commited
load
[ "load", "mro", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.load(f_yml, Loader=yaml.FullLoader) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.finditer( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex._write_str_index(file, item) elif isinstance(item, dict): SectionIndex._write_dict_index(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex._write_index_file(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.generate(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.generate(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.
() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.generate(nav_item=config["nav"]) Reference.generate("reference") Index.generate( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
215
215-194-17
infile
generate
[ "generate", "mro", "_write_dict_index", "_write_index_file", "_write_str_index", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.load(f_yml, Loader=yaml.FullLoader) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.finditer( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex._write_str_index(file, item) elif isinstance(item, dict): SectionIndex._write_dict_index(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex._write_index_file(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.generate(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.generate(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.load() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.
(nav_item=config["nav"]) Reference.generate("reference") Index.generate( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
215
215-196-14
infile
generate
[ "generate", "mro", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.load(f_yml, Loader=yaml.FullLoader) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.finditer( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex._write_str_index(file, item) elif isinstance(item, dict): SectionIndex._write_dict_index(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex._write_index_file(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.generate(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.generate(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.load() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.generate(nav_item=config["nav"]) Reference.
("reference") Index.generate( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
215
215-198-10
infile
generate
[ "generate", "mro", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
"""Generate the code reference pages and navigation.""" # pylint: disable=too-few-public-methods from pathlib import Path from typing import Union, List import re import yaml import mkdocs_gen_files # type: ignore class MkdocsConfig: """A class for working with mkdocs configuration.""" @staticmethod def load() -> dict: """ A method for loading mkdocs configuration. Returns: A dictionary that contains the mkdocs configuration. """ with open(Path(__file__).parent / "mkdocs.yml", "rt", encoding="utf8") as f_yml: return yaml.load(f_yml, Loader=yaml.FullLoader) class Index: """A class for creating index file from README.""" @staticmethod def generate(readme: Path, site: str, ipynbs: List[str]) -> None: """ A method for generating the index file. Args: readme: README.md path. site: Site url. ipynbs: List of html links that are ipynb files. """ with open(readme, "rt", encoding="utf8") as f_readme: content = f_readme.read() for match in re.finditer( rf"\[([^]]*)\]\(({site}/)([^]]*)(.html)([^]]*)?\)", content, ): if match[0] in ipynbs: content = content.replace( match[0], f"[{match[1]}]({match[3]}.ipynb{match[5]})" ) else: content = content.replace( match[0], f"[{match[1]}]({match[3]}.md{match[5]})" ) content = content.replace(f"{site}/", "") with mkdocs_gen_files.open("index.md", "w") as f_index: f_index.write(content) class SectionIndex: """A class for creating section index files.""" @staticmethod def _write_index_file(file: str, toc: list) -> None: """ A method for writing table of contents into a section index file. Args: file: The section index file. toc: Items of the table of contents. """ for item in toc: if isinstance(item, str): SectionIndex._write_str_index(file, item) elif isinstance(item, dict): SectionIndex._write_dict_index(file, item) else: raise NotImplementedError(f"{item}") @staticmethod def _write_str_index(file: str, item: str) -> None: """ A method for writing an str toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: parts = item.split("/") part = parts[-1].replace(".md", "").capitalize() link = Path(item).relative_to(Path(file).parent) f_index.write(f"* [{part}]({link})\n") @staticmethod def _write_dict_index(file: str, item: dict) -> None: """ A method for writing a dict toc item into a section index file. Args: file: The section index file. item: Item of the table of contents. """ with mkdocs_gen_files.open(file, "a") as f_index: for key in item: if isinstance(item[key], str): link = Path(item[key]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue if item[key] and isinstance(item[key], list): if isinstance(item[key][0], str): if item[key][0].endswith("index.md"): link = Path(item[key][0]).relative_to(Path(file).parent) f_index.write(f"* [{key}]({link})\n") continue raise NotImplementedError(f"{item}") @staticmethod def generate(nav_item: Union[list, dict, str]) -> None: """ A method for creating section indices for the navigation. Args: nav_item: Part of the navigation. """ if isinstance(nav_item, list): if ( nav_item and isinstance(nav_item[0], str) and nav_item[0].endswith("index.md") ): SectionIndex._write_index_file(file=nav_item[0], toc=nav_item[1:]) for item in nav_item: SectionIndex.generate(nav_item=item) elif isinstance(nav_item, dict): for key in nav_item: SectionIndex.generate(nav_item=nav_item[key]) class Reference: """A class for creating code reference.""" @staticmethod def generate(folder: str) -> None: """ A method for generate code reference. Args: folder: Reference destination folder. """ for path in sorted(Path("src").rglob("*.py")): module_path = path.relative_to("src").with_suffix("") doc_path = path.relative_to("src").with_suffix(".md") full_doc_path = Path(folder, doc_path) parts = tuple(module_path.parts) if parts[-1] == "__init__": parts = parts[:-1] doc_path = doc_path.with_name("index.md") full_doc_path = full_doc_path.with_name("index.md") elif parts[-1] == "__main__": continue with mkdocs_gen_files.open(full_doc_path, "w") as f_md: item = ".".join(parts) f_md.write(f"::: {item}") def main() -> None: """ The main method. It prepares files for the documentation site. """ config = MkdocsConfig.load() site_url = config["site_url"] if site_url.endswith("/"): site_url = site_url[:-1] index_ipynbs: List[str] = [] SectionIndex.generate(nav_item=config["nav"]) Reference.generate("reference") Index.
( readme=Path(__file__).parent / ".." / ".." / "README.md", site=site_url, ipynbs=index_ipynbs, ) main()
vizzuhq__ipyvizzu
216
216-10-30
inproject
module_name
[ "module_name", "mro", "overwrite_imports", "__annotations__", "__base__", "__bases__", "__basicsize__", "__call__", "__class__", "__delattr__", "__dict__", "__dictoffset__", "__dir__", "__doc__", "__eq__", "__flags__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__instancecheck__", "__itemsize__", "__module__", "__mro__", "__name__", "__ne__", "__new__", "__prepare__", "__qualname__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasscheck__", "__subclasses__", "__text_signature__", "__weakrefoffset__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.
("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-15-18
inproject
add_df
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.
(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-22-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_if_pandas_not_installed", "test_add_df_with_df", "test_add_df_with_df_and_max_rows", "test_add_df_with_df_and_with_include_index", "test_add_df_with_df_contains_na", "test_add_df_with_empty_df", "test_add_df_with_none", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.
.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-22-18
inproject
add_df
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.
(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-22-28
inproject
DataFrame
[ "annotations", "api", "array", "arrays", "ArrowDtype", "bdate_range", "BooleanDtype", "Categorical", "CategoricalDtype", "CategoricalIndex", "compat", "concat", "conftest", "core", "crosstab", "cut", "DataFrame", "date_range", "DateOffset", "DatetimeIndex", "DatetimeTZDtype", "describe_option", "errors", "eval", "ExcelFile", "ExcelWriter", "factorize", "Flags", "Float32Dtype", "Float64Dtype", "from_dummies", "get_dummies", "get_option", "Grouper", "HDFStore", "Index", "IndexSlice", "infer_freq", "Int16Dtype", "Int32Dtype", "Int64Dtype", "Int8Dtype", "Interval", "interval_range", "IntervalDtype", "IntervalIndex", "io", "isna", "isnull", "json_normalize", "lreshape", "melt", "merge", "merge_asof", "merge_ordered", "MultiIndex", "NA", "NamedAgg", "NaT", "notna", "notnull", "offsets", "option_context", "options", "pandas", "Period", "period_range", "PeriodDtype", "PeriodIndex", "pivot", "pivot_table", "plotting", "qcut", "RangeIndex", "read_clipboard", "read_csv", "read_excel", "read_feather", "read_fwf", "read_gbq", "read_hdf", "read_html", "read_json", "read_orc", "read_parquet", "read_pickle", "read_sas", "read_spss", "read_sql", "read_sql_query", "read_sql_table", "read_stata", "read_table", "read_xml", "reset_option", "Series", "set_eng_float_format", "set_option", "show_versions", "SparseDtype", "StringDtype", "test", "testing", "tests", "Timedelta", "timedelta_range", "TimedeltaIndex", "Timestamp", "to_datetime", "to_numeric", "to_pickle", "to_timedelta", "tseries", "UInt16Dtype", "UInt32Dtype", "UInt64Dtype", "UInt8Dtype", "unique", "util", "value_counts", "wide_to_long", "_built_with_meson", "_config", "_e", "_err", "_is_numpy_dev", "_libs", "_module", "_testing", "_typing", "_version", "_version_meson", "__all__", "__doc__", "__docformat__", "__file__", "__git_version__", "__name__", "__package__", "__version__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.
()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-30-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_if_pandas_not_installed", "test_add_df_with_df", "test_add_df_with_df_and_max_rows", "test_add_df_with_df_and_with_include_index", "test_add_df_with_df_contains_na", "test_add_df_with_empty_df", "test_add_df_with_none", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.
.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-30-18
inproject
add_df
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.
(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-46-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_if_pandas_not_installed", "test_add_df_with_df", "test_add_df_with_df_and_max_rows", "test_add_df_with_df_and_with_include_index", "test_add_df_with_df_contains_na", "test_add_df_with_empty_df", "test_add_df_with_none", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.
.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-46-18
inproject
add_df
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.
(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-54-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_if_pandas_not_installed", "test_add_df_with_df", "test_add_df_with_df_and_max_rows", "test_add_df_with_df_and_with_include_index", "test_add_df_with_df_contains_na", "test_add_df_with_empty_df", "test_add_df_with_none", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.
.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-54-18
inproject
add_df
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.
(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-55-13
random
assertEqual
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_if_pandas_not_installed", "test_add_df_with_df", "test_add_df_with_df_and_max_rows", "test_add_df_with_df_and_with_include_index", "test_add_df_with_df_contains_na", "test_add_df_with_empty_df", "test_add_df_with_none", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.
( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-63-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_df", "test_add_data_frame_with_df_contains_na", "test_add_data_frame_with_empty_df", "test_add_data_frame_with_none", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.
.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-63-18
inproject
add_data_frame
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.
(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-70-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_df", "test_add_data_frame_with_df_contains_na", "test_add_data_frame_with_empty_df", "test_add_data_frame_with_none", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.
.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-70-18
inproject
add_data_frame
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.
(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-70-36
inproject
DataFrame
[ "annotations", "api", "array", "arrays", "ArrowDtype", "bdate_range", "BooleanDtype", "Categorical", "CategoricalDtype", "CategoricalIndex", "compat", "concat", "conftest", "core", "crosstab", "cut", "DataFrame", "date_range", "DateOffset", "DatetimeIndex", "DatetimeTZDtype", "describe_option", "errors", "eval", "ExcelFile", "ExcelWriter", "factorize", "Flags", "Float32Dtype", "Float64Dtype", "from_dummies", "get_dummies", "get_option", "Grouper", "HDFStore", "Index", "IndexSlice", "infer_freq", "Int16Dtype", "Int32Dtype", "Int64Dtype", "Int8Dtype", "Interval", "interval_range", "IntervalDtype", "IntervalIndex", "io", "isna", "isnull", "json_normalize", "lreshape", "melt", "merge", "merge_asof", "merge_ordered", "MultiIndex", "NA", "NamedAgg", "NaT", "notna", "notnull", "offsets", "option_context", "options", "pandas", "Period", "period_range", "PeriodDtype", "PeriodIndex", "pivot", "pivot_table", "plotting", "qcut", "RangeIndex", "read_clipboard", "read_csv", "read_excel", "read_feather", "read_fwf", "read_gbq", "read_hdf", "read_html", "read_json", "read_orc", "read_parquet", "read_pickle", "read_sas", "read_spss", "read_sql", "read_sql_query", "read_sql_table", "read_stata", "read_table", "read_xml", "reset_option", "Series", "set_eng_float_format", "set_option", "show_versions", "SparseDtype", "StringDtype", "test", "testing", "tests", "Timedelta", "timedelta_range", "TimedeltaIndex", "Timestamp", "to_datetime", "to_numeric", "to_pickle", "to_timedelta", "tseries", "UInt16Dtype", "UInt32Dtype", "UInt64Dtype", "UInt8Dtype", "unique", "util", "value_counts", "wide_to_long", "_built_with_meson", "_config", "_e", "_err", "_is_numpy_dev", "_libs", "_module", "_testing", "_typing", "_version", "_version_meson", "__all__", "__doc__", "__docformat__", "__file__", "__git_version__", "__name__", "__package__", "__version__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.
()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-86-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_df", "test_add_data_frame_with_df_contains_na", "test_add_data_frame_with_empty_df", "test_add_data_frame_with_none", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.
.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-86-18
inproject
add_data_frame
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.
(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-95-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_with_empty_series", "test_add_df_with_series", "test_add_df_with_series_and_with_include_index", "test_add_df_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.
.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-95-18
inproject
add_df
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.
(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-95-28
inproject
Series
[ "annotations", "api", "array", "arrays", "ArrowDtype", "bdate_range", "BooleanDtype", "Categorical", "CategoricalDtype", "CategoricalIndex", "compat", "concat", "conftest", "core", "crosstab", "cut", "DataFrame", "date_range", "DateOffset", "DatetimeIndex", "DatetimeTZDtype", "describe_option", "errors", "eval", "ExcelFile", "ExcelWriter", "factorize", "Flags", "Float32Dtype", "Float64Dtype", "from_dummies", "get_dummies", "get_option", "Grouper", "HDFStore", "Index", "IndexSlice", "infer_freq", "Int16Dtype", "Int32Dtype", "Int64Dtype", "Int8Dtype", "Interval", "interval_range", "IntervalDtype", "IntervalIndex", "io", "isna", "isnull", "json_normalize", "lreshape", "melt", "merge", "merge_asof", "merge_ordered", "MultiIndex", "NA", "NamedAgg", "NaT", "notna", "notnull", "offsets", "option_context", "options", "pandas", "Period", "period_range", "PeriodDtype", "PeriodIndex", "pivot", "pivot_table", "plotting", "qcut", "RangeIndex", "read_clipboard", "read_csv", "read_excel", "read_feather", "read_fwf", "read_gbq", "read_hdf", "read_html", "read_json", "read_orc", "read_parquet", "read_pickle", "read_sas", "read_spss", "read_sql", "read_sql_query", "read_sql_table", "read_stata", "read_table", "read_xml", "reset_option", "Series", "set_eng_float_format", "set_option", "show_versions", "SparseDtype", "StringDtype", "test", "testing", "tests", "Timedelta", "timedelta_range", "TimedeltaIndex", "Timestamp", "to_datetime", "to_numeric", "to_pickle", "to_timedelta", "tseries", "UInt16Dtype", "UInt32Dtype", "UInt64Dtype", "UInt8Dtype", "unique", "util", "value_counts", "wide_to_long", "_built_with_meson", "_config", "_e", "_err", "_is_numpy_dev", "_libs", "_module", "_testing", "_typing", "_version", "_version_meson", "__all__", "__doc__", "__docformat__", "__file__", "__git_version__", "__name__", "__package__", "__version__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.
()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-102-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_with_empty_series", "test_add_df_with_series", "test_add_df_with_series_and_with_include_index", "test_add_df_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.
.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-102-18
inproject
add_df
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.
(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-102-30
inproject
in_pd_series_dimension
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_with_empty_series", "test_add_df_with_series", "test_add_df_with_series_and_with_include_index", "test_add_df_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.
) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-103-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_with_empty_series", "test_add_df_with_series", "test_add_df_with_series_and_with_include_index", "test_add_df_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.
.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-103-18
inproject
add_df
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.
(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-103-30
inproject
in_pd_series_measure
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_with_empty_series", "test_add_df_with_series", "test_add_df_with_series_and_with_include_index", "test_add_df_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.
) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-110-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_with_empty_series", "test_add_df_with_series", "test_add_df_with_series_and_with_include_index", "test_add_df_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.
.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-110-18
inproject
add_df
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.
(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-110-30
inproject
in_pd_series_dimension_with_nan
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_with_empty_series", "test_add_df_with_series", "test_add_df_with_series_and_with_include_index", "test_add_df_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.
) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-111-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_with_empty_series", "test_add_df_with_series", "test_add_df_with_series_and_with_include_index", "test_add_df_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.
.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-111-18
inproject
add_df
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.
(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-111-30
inproject
in_pd_series_measure_with_nan
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_with_empty_series", "test_add_df_with_series", "test_add_df_with_series_and_with_include_index", "test_add_df_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.
) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-118-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_with_empty_series", "test_add_df_with_series", "test_add_df_with_series_and_with_include_index", "test_add_df_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.
.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-118-18
inproject
add_df
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.
( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-134-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_empty_series", "test_add_data_frame_with_series", "test_add_data_frame_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.
.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-134-18
inproject
add_data_frame
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.
(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-134-36
inproject
Series
[ "annotations", "api", "array", "arrays", "ArrowDtype", "bdate_range", "BooleanDtype", "Categorical", "CategoricalDtype", "CategoricalIndex", "compat", "concat", "conftest", "core", "crosstab", "cut", "DataFrame", "date_range", "DateOffset", "DatetimeIndex", "DatetimeTZDtype", "describe_option", "errors", "eval", "ExcelFile", "ExcelWriter", "factorize", "Flags", "Float32Dtype", "Float64Dtype", "from_dummies", "get_dummies", "get_option", "Grouper", "HDFStore", "Index", "IndexSlice", "infer_freq", "Int16Dtype", "Int32Dtype", "Int64Dtype", "Int8Dtype", "Interval", "interval_range", "IntervalDtype", "IntervalIndex", "io", "isna", "isnull", "json_normalize", "lreshape", "melt", "merge", "merge_asof", "merge_ordered", "MultiIndex", "NA", "NamedAgg", "NaT", "notna", "notnull", "offsets", "option_context", "options", "pandas", "Period", "period_range", "PeriodDtype", "PeriodIndex", "pivot", "pivot_table", "plotting", "qcut", "RangeIndex", "read_clipboard", "read_csv", "read_excel", "read_feather", "read_fwf", "read_gbq", "read_hdf", "read_html", "read_json", "read_orc", "read_parquet", "read_pickle", "read_sas", "read_spss", "read_sql", "read_sql_query", "read_sql_table", "read_stata", "read_table", "read_xml", "reset_option", "Series", "set_eng_float_format", "set_option", "show_versions", "SparseDtype", "StringDtype", "test", "testing", "tests", "Timedelta", "timedelta_range", "TimedeltaIndex", "Timestamp", "to_datetime", "to_numeric", "to_pickle", "to_timedelta", "tseries", "UInt16Dtype", "UInt32Dtype", "UInt64Dtype", "UInt8Dtype", "unique", "util", "value_counts", "wide_to_long", "_built_with_meson", "_config", "_e", "_err", "_is_numpy_dev", "_libs", "_module", "_testing", "_typing", "_version", "_version_meson", "__all__", "__doc__", "__docformat__", "__file__", "__git_version__", "__name__", "__package__", "__version__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.
()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-141-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_empty_series", "test_add_data_frame_with_series", "test_add_data_frame_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.
.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-141-18
inproject
add_data_frame
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.
(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-141-38
inproject
in_pd_series_dimension
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_empty_series", "test_add_data_frame_with_series", "test_add_data_frame_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.
) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-142-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_empty_series", "test_add_data_frame_with_series", "test_add_data_frame_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.
.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-142-18
inproject
add_data_frame
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.
(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-142-38
inproject
in_pd_series_measure
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_empty_series", "test_add_data_frame_with_series", "test_add_data_frame_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.
) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-149-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_empty_series", "test_add_data_frame_with_series", "test_add_data_frame_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.
.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-149-18
inproject
add_data_frame
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.
(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-149-38
inproject
in_pd_series_dimension_with_nan
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_empty_series", "test_add_data_frame_with_series", "test_add_data_frame_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.
) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-150-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_empty_series", "test_add_data_frame_with_series", "test_add_data_frame_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.
.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-150-18
inproject
add_data_frame
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.
(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-150-38
inproject
in_pd_series_measure_with_nan
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_data_frame_with_empty_series", "test_add_data_frame_with_series", "test_add_data_frame_with_series_contains_na", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.
) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-159-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_index_with_df", "test_add_df_index_with_none", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.
.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-159-18
inproject
add_df_index
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.
(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-167-13
inproject
data
[ "addClassCleanup", "addCleanup", "addTypeEqualityFunc", "assert_", "assertAlmostEqual", "assertAlmostEquals", "assertCountEqual", "assertDictContainsSubset", "assertDictEqual", "assertEqual", "assertEquals", "assertFalse", "assertGreater", "assertGreaterEqual", "assertIn", "assertIs", "assertIsInstance", "assertIsNone", "assertIsNot", "assertIsNotNone", "assertLess", "assertLessEqual", "assertListEqual", "assertLogs", "assertMultiLineEqual", "assertNotAlmostEqual", "assertNotAlmostEquals", "assertNotEqual", "assertNotEquals", "assertNotIn", "assertNotIsInstance", "assertNotRegex", "assertNotRegexpMatches", "assertRaises", "assertRaisesRegex", "assertRaisesRegexp", "assertRegex", "assertRegexpMatches", "assertSequenceEqual", "assertSetEqual", "assertTrue", "assertTupleEqual", "assertWarns", "assertWarnsRegex", "asset_dir", "countTestCases", "data", "debug", "defaultTestResult", "doClassCleanups", "doCleanups", "fail", "failIf", "failIfAlmostEqual", "failIfEqual", "failUnless", "failUnlessAlmostEqual", "failUnlessEqual", "failUnlessRaises", "failureException", "id", "in_pd_df_by_series", "in_pd_df_by_series_with_duplicated_popularity", "in_pd_df_by_series_with_index", "in_pd_df_by_series_with_nan", "in_pd_series_dimension", "in_pd_series_dimension_with_index", "in_pd_series_dimension_with_nan", "in_pd_series_measure", "in_pd_series_measure_with_index", "in_pd_series_measure_with_nan", "longMessage", "maxDiff", "ref_pd_df_by_series", "ref_pd_df_by_series_max_rows", "ref_pd_df_by_series_only_index", "ref_pd_df_by_series_with_duplicated_popularity", "ref_pd_df_by_series_with_index", "ref_pd_df_by_series_with_nan", "ref_pd_series", "ref_pd_series_only_index", "ref_pd_series_with_index", "ref_pd_series_with_nan", "run", "set_up_pd_df", "set_up_pd_series", "setUp", "setUpClass", "shortDescription", "skipTest", "subTest", "tearDown", "tearDownClass", "test_add_df_index_with_df", "test_add_df_index_with_none", "_addSkip", "_formatMessage", "_getAssertEqualityFunc", "_testMethodDoc", "_testMethodName", "__annotations__", "__call__", "__class__", "__delattr__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init__", "__init_subclass__", "__module__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.
.add_df_index(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu
216
216-167-18
inproject
add_df_index
[ "add_data_frame", "add_data_frame_index", "add_df", "add_df_index", "add_dimension", "add_measure", "add_np_array", "add_record", "add_records", "add_series", "add_series_list", "add_spark_df", "build", "clear", "copy", "dump", "filter", "from_json", "fromkeys", "get", "items", "keys", "pop", "popitem", "set_filter", "setdefault", "update", "values", "_add_named_value", "_add_value", "__annotations__", "__class__", "__class_getitem__", "__contains__", "__delattr__", "__delitem__", "__dict__", "__dir__", "__doc__", "__eq__", "__format__", "__getattribute__", "__getitem__", "__hash__", "__init__", "__init_subclass__", "__ior__", "__iter__", "__len__", "__module__", "__ne__", "__new__", "__or__", "__reduce__", "__reduce_ex__", "__repr__", "__reversed__", "__setattr__", "__setitem__", "__sizeof__", "__slots__", "__str__" ]
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring import pandas as pd from tests.test_data import DataWithAssets from tests.utils.import_error import RaiseImportError class TestDf(DataWithAssets): def test_add_df_if_pandas_not_installed(self) -> None: with RaiseImportError.module_name("pandas"): with self.assertRaises(ImportError): self.data.add_df(pd.DataFrame()) def test_add_df_with_none(self) -> None: self.data.add_df(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_empty_df(self) -> None: self.data.add_df(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_df_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_df(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) def test_add_df_with_df_and_with_include_index(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_df(df, include_index="Index") self.assertEqual( self.ref_pd_df_by_series_with_index, self.data.build(), ) def test_add_df_with_df_and_max_rows(self) -> None: df = self.in_pd_df_by_series self.data.add_df(df, max_rows=2) self.assertEqual( self.ref_pd_df_by_series_max_rows, self.data.build(), ) class TestDataFrame(DataWithAssets): def test_add_data_frame_with_none(self) -> None: self.data.add_data_frame(None) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_empty_df(self) -> None: self.data.add_data_frame(pd.DataFrame()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_df(self) -> None: df = self.in_pd_df_by_series_with_duplicated_popularity self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_duplicated_popularity, self.data.build(), ) def test_add_data_frame_with_df_contains_na(self) -> None: df = self.in_pd_df_by_series_with_nan self.data.add_data_frame(df) self.assertEqual( self.ref_pd_df_by_series_with_nan, self.data.build(), ) class TestDfWithSeries(DataWithAssets): def test_add_df_with_empty_series(self) -> None: self.data.add_df(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_with_series(self) -> None: self.data.add_df(self.in_pd_series_dimension) self.data.add_df(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_df_with_series_contains_na(self) -> None: self.data.add_df(self.in_pd_series_dimension_with_nan) self.data.add_df(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) def test_add_df_with_series_and_with_include_index(self) -> None: self.data.add_df( self.in_pd_series_dimension_with_index, include_index="DimensionIndex", ) self.data.add_df( self.in_pd_series_measure_with_index, include_index="MeasureIndex", ) self.assertEqual( self.ref_pd_series_with_index, self.data.build(), ) class TestDataFrameWithSeries(DataWithAssets): def test_add_data_frame_with_empty_series(self) -> None: self.data.add_data_frame(pd.Series()) self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_with_series(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension) self.data.add_data_frame(self.in_pd_series_measure) self.assertEqual( self.ref_pd_series, self.data.build(), ) def test_add_data_frame_with_series_contains_na(self) -> None: self.data.add_data_frame(self.in_pd_series_dimension_with_nan) self.data.add_data_frame(self.in_pd_series_measure_with_nan) self.assertEqual( self.ref_pd_series_with_nan, self.data.build(), ) class TestDfIndex(DataWithAssets): def test_add_df_index_with_none(self) -> None: self.data.add_df_index(None, column_name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_df_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.
(df, column_name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: self.data.add_data_frame_index(None, name="Index") self.assertEqual( {"data": {}}, self.data.build(), ) def test_add_data_frame_index_with_df(self) -> None: df = self.in_pd_df_by_series_with_index self.data.add_data_frame_index(df, name="Index") self.assertEqual( self.ref_pd_df_by_series_only_index, self.data.build(), ) class TestDfIndexWithSeries(DataWithAssets): def test_add_df_index_with_series(self) -> None: self.data.add_df_index( self.in_pd_series_dimension_with_index, column_name="DimensionIndex", ) self.data.add_df_index( self.in_pd_series_measure_with_index, column_name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), ) class TestDataFrameIndexWithSeries(DataWithAssets): def test_add_data_frame_index_with_series(self) -> None: self.data.add_data_frame_index( self.in_pd_series_dimension_with_index, name="DimensionIndex", ) self.data.add_data_frame_index( self.in_pd_series_measure_with_index, name="MeasureIndex", ) self.assertEqual( self.ref_pd_series_only_index, self.data.build(), )
vizzuhq__ipyvizzu