From 385d43b6333c031132509c1d11e0029791a3e2a5 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 20 Jan 2025 12:14:51 -0700 Subject: [PATCH 01/20] Add write image function. --- dimes/dimensional_plot.py | 7 ++++++- poetry.lock | 19 +++++++++++++++++-- pyproject.toml | 29 +++++++++++++++-------------- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index 0222f7d..cf3725c 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -313,7 +313,7 @@ def add_display_data( self.subplots[subplot_index] = DimensionalSubplot() self.subplots[subplot_index].add_display_data(display_data) # type: ignore[union-attr] - def finalize_plot(self): + def finalize_plot(self, width=None, height=None): """Once all DisplayData objects have been added, generate plot and subplots.""" if not self.is_finalized: grid_line_width = 1.5 @@ -456,6 +456,11 @@ def write_html_plot(self, path: Path) -> None: self.finalize_plot() self.figure.write_html(path) + def write_image_plot(self, path: Path, width: int, height: int, scale: int) -> None: + "Write plots to html file at specified path." + self.finalize_plot() + self.figure.write_image(path, scale=scale) + def get_subplot_domains(number_of_subplots: int, gap: float = 0.05) -> list[tuple[float, float]]: """Calculate and return the 'Y' domain ranges for a given number of subplots with the specified gap size.""" diff --git a/poetry.lock b/poetry.lock index 0adf3c2..7082bd1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "astroid" @@ -173,6 +173,21 @@ files = [ [package.extras] colors = ["colorama (>=0.4.6)"] +[[package]] +name = "kaleido" +version = "0.2.1" +description = "Static image export for web-based visualization libraries with zero dependencies" +optional = false +python-versions = "*" +files = [ + {file = "kaleido-0.2.1-py2.py3-none-macosx_10_11_x86_64.whl", hash = "sha256:ca6f73e7ff00aaebf2843f73f1d3bacde1930ef5041093fe76b83a15785049a7"}, + {file = "kaleido-0.2.1-py2.py3-none-macosx_11_0_arm64.whl", hash = "sha256:bb9a5d1f710357d5d432ee240ef6658a6d124c3e610935817b4b42da9c787c05"}, + {file = "kaleido-0.2.1-py2.py3-none-manylinux1_x86_64.whl", hash = "sha256:aa21cf1bf1c78f8fa50a9f7d45e1003c387bd3d6fe0a767cfbbf344b95bdc3a8"}, + {file = "kaleido-0.2.1-py2.py3-none-manylinux2014_aarch64.whl", hash = "sha256:845819844c8082c9469d9c17e42621fbf85c2b237ef8a86ec8a8527f98b6512a"}, + {file = "kaleido-0.2.1-py2.py3-none-win32.whl", hash = "sha256:ecc72635860be616c6b7161807a65c0dbd9b90c6437ac96965831e2e24066552"}, + {file = "kaleido-0.2.1-py2.py3-none-win_amd64.whl", hash = "sha256:4670985f28913c2d063c5734d125ecc28e40810141bdb0a46f15b76c1d45f23c"}, +] + [[package]] name = "koozie" version = "1.3.0" @@ -498,4 +513,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "a0c4e1d087dae51b0d98ddb13075bd77d317b193b0a185cbea6f30c7c3eacb9d" +content-hash = "7079ef6f7385f8e6e83f49172804cec963f0f36e57a5f1cbb0363c1f6546a1bd" diff --git a/pyproject.toml b/pyproject.toml index 9b7e2bc..ce3c27b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,36 +1,37 @@ [tool.poetry] -name = "dimes" +authors = ["Big Ladder Software"] +description = "A dimensionally aware scientific plotting package." +keywords = ["template"] +license = "BSD-3" +name = "dimes" +readme = "README.md" +repository = "https://github.com/bigladder/dimes" version = "0.0.0" # Generated from git on CI -description = "A dimensionally aware scientific plotting package." -authors = ["Big Ladder Software"] -license = "BSD-3" -readme = "README.md" -keywords = ["template"] -repository = "https://github.com/bigladder/dimes" [tool.poetry.dependencies] -python = "^3.10" -plotly = "*" +kaleido = "==0.2.1" koozie = "^1.3.0" +plotly = "*" +python = "^3.10" [tool.poetry.dev-dependencies] -pytest = "^7.1.3" -pylint = "*" black = "*" mypy = "*" +pylint = "*" +pytest = "^7.1.3" [build-system] -requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" +requires = ["poetry-core>=1.0.0"] [tool.black] line-length = 120 [tool.mypy] +check_untyped_defs = true disallow_incomplete_defs = true no_implicit_optional = true -check_untyped_defs = true [[tool.mypy.overrides]] -module = "dimes.*" disable_error_code = ["import"] +module = "dimes.*" From 2d0cca9071f6d7abd3421c20e68905229c91209a Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 20 Jan 2025 13:02:36 -0700 Subject: [PATCH 02/20] Set width and height of image. --- dimes/dimensional_plot.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index cf3725c..f5acc18 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -325,6 +325,10 @@ def finalize_plot(self, width=None, height=None): self.figure.layout["plot_bgcolor"] = WHITE self.figure.layout["font_color"] = BLACK self.figure.layout["title_x"] = 0.5 + if width is not None: + self.figure.layout["width"] = width + if height is not None: + self.figure.layout["height"] = height xy_common_axis_format = { "mirror": True, "linecolor": BLACK, @@ -458,7 +462,7 @@ def write_html_plot(self, path: Path) -> None: def write_image_plot(self, path: Path, width: int, height: int, scale: int) -> None: "Write plots to html file at specified path." - self.finalize_plot() + self.finalize_plot(width, height) self.figure.write_image(path, scale=scale) From 5f5b23364c5978e1d0a2397299ecefb57f39341b Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 20 Jan 2025 13:39:00 -0700 Subject: [PATCH 03/20] Update width and height. --- dimes/dimensional_plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index f5acc18..831836e 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -462,7 +462,7 @@ def write_html_plot(self, path: Path) -> None: def write_image_plot(self, path: Path, width: int, height: int, scale: int) -> None: "Write plots to html file at specified path." - self.finalize_plot(width, height) + self.finalize_plot(width=width, height=height) self.figure.write_image(path, scale=scale) From 8db411be30abd20f9dba7e454bf1d85f249d8fde Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 20 Jan 2025 13:48:42 -0700 Subject: [PATCH 04/20] Allow width and height set to None. --- dimes/dimensional_plot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index 831836e..91902d7 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -6,6 +6,7 @@ from datetime import datetime import math import bisect +from typing import Union from plotly.graph_objects import Figure, Scatter # type: ignore from plotly.colors import sample_colorscale @@ -460,7 +461,7 @@ def write_html_plot(self, path: Path) -> None: self.finalize_plot() self.figure.write_html(path) - def write_image_plot(self, path: Path, width: int, height: int, scale: int) -> None: + def write_image_plot(self, path: Path, width: Union[int, None], height: Union[int, None], scale: int) -> None: "Write plots to html file at specified path." self.finalize_plot(width=width, height=height) self.figure.write_image(path, scale=scale) From b32df3351b3652551909b047d3f52bc9bb26e219 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 20 Jan 2025 13:51:58 -0700 Subject: [PATCH 05/20] Set default width and height value to None. --- dimes/dimensional_plot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index 91902d7..dc38806 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -461,7 +461,9 @@ def write_html_plot(self, path: Path) -> None: self.finalize_plot() self.figure.write_html(path) - def write_image_plot(self, path: Path, width: Union[int, None], height: Union[int, None], scale: int) -> None: + def write_image_plot( + self, path: Path, scale: int, width: Union[int, None] = None, height: Union[int, None] = None + ) -> None: "Write plots to html file at specified path." self.finalize_plot(width=width, height=height) self.figure.write_image(path, scale=scale) From 0412b8929906b70fd770dae12e3e138e19b0b9e6 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 20 Jan 2025 14:03:04 -0700 Subject: [PATCH 06/20] Add figure print statement. --- dimes/dimensional_plot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index dc38806..3349a16 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -467,6 +467,7 @@ def write_image_plot( "Write plots to html file at specified path." self.finalize_plot(width=width, height=height) self.figure.write_image(path, scale=scale) + print(self.figure) def get_subplot_domains(number_of_subplots: int, gap: float = 0.05) -> list[tuple[float, float]]: From 4891e18641b4d05788df1ef4488c62fdee92c6d1 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 20 Jan 2025 14:18:12 -0700 Subject: [PATCH 07/20] Use update to define layout width and height. --- dimes/dimensional_plot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index 3349a16..7a49153 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -326,10 +326,10 @@ def finalize_plot(self, width=None, height=None): self.figure.layout["plot_bgcolor"] = WHITE self.figure.layout["font_color"] = BLACK self.figure.layout["title_x"] = 0.5 - if width is not None: - self.figure.layout["width"] = width - if height is not None: - self.figure.layout["height"] = height + # if width is not None: + self.figure.layout.update({"width": width}) + # if height is not None: + self.figure.layout.update({"height": height}) xy_common_axis_format = { "mirror": True, "linecolor": BLACK, From 898ddf040d1f70617c69b6ee6e6cc3e3e259edcc Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 20 Jan 2025 14:53:21 -0700 Subject: [PATCH 08/20] Update width and height. --- dimes/dimensional_plot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index 7a49153..c407895 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -327,9 +327,10 @@ def finalize_plot(self, width=None, height=None): self.figure.layout["font_color"] = BLACK self.figure.layout["title_x"] = 0.5 # if width is not None: - self.figure.layout.update({"width": width}) + # self.figure.layout.update({"width": width}) # if height is not None: - self.figure.layout.update({"height": height}) + # self.figure.layout.update({"height": height}) + self.figure.layout.update({"width": 720, "height": 1280}) xy_common_axis_format = { "mirror": True, "linecolor": BLACK, From e4d1c649c270f5b08fc848e6896b8a1823868bc0 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 20 Jan 2025 15:16:57 -0700 Subject: [PATCH 09/20] Move width and height to DimensiuonalPlot. --- dimes/dimensional_plot.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index c407895..4dc99d0 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -228,6 +228,8 @@ def __init__( x_axis: DimensionalData | TimeSeriesAxis | list[SupportsFloat] | list[datetime], title: str | None = None, additional_info: str | None = None, + width: int | None = None, + height: int | None = None, ): self.figure = Figure() self.x_axis: DimensionalData | TimeSeriesAxis @@ -241,6 +243,12 @@ def __init__( self.subplots: list[DimensionalSubplot | None] = [None] self.is_finalized = False self.figure.layout["title"] = title + print(self.figure) + print(self.figure.layout) + self.figure.layout["width"] = width + self.figure.layout["height"] = height + print(self.figure) + print(self.figure.layout) if additional_info is not None: self.figure.add_trace( Scatter( @@ -314,7 +322,7 @@ def add_display_data( self.subplots[subplot_index] = DimensionalSubplot() self.subplots[subplot_index].add_display_data(display_data) # type: ignore[union-attr] - def finalize_plot(self, width=None, height=None): + def finalize_plot(self): """Once all DisplayData objects have been added, generate plot and subplots.""" if not self.is_finalized: grid_line_width = 1.5 @@ -326,11 +334,6 @@ def finalize_plot(self, width=None, height=None): self.figure.layout["plot_bgcolor"] = WHITE self.figure.layout["font_color"] = BLACK self.figure.layout["title_x"] = 0.5 - # if width is not None: - # self.figure.layout.update({"width": width}) - # if height is not None: - # self.figure.layout.update({"height": height}) - self.figure.layout.update({"width": 720, "height": 1280}) xy_common_axis_format = { "mirror": True, "linecolor": BLACK, @@ -462,11 +465,9 @@ def write_html_plot(self, path: Path) -> None: self.finalize_plot() self.figure.write_html(path) - def write_image_plot( - self, path: Path, scale: int, width: Union[int, None] = None, height: Union[int, None] = None - ) -> None: + def write_image_plot(self, path: Path, scale: int) -> None: "Write plots to html file at specified path." - self.finalize_plot(width=width, height=height) + self.finalize_plot() self.figure.write_image(path, scale=scale) print(self.figure) From 721f755a588757febfad55ba9edaa23e81f9d3e4 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 20 Jan 2025 15:24:54 -0700 Subject: [PATCH 10/20] Use update. --- dimes/dimensional_plot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index 4dc99d0..caa4056 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -242,11 +242,13 @@ def __init__( self.x_axis = x_axis self.subplots: list[DimensionalSubplot | None] = [None] self.is_finalized = False + print(self.figure) + print(self.figure.layout) self.figure.layout["title"] = title print(self.figure) print(self.figure.layout) - self.figure.layout["width"] = width - self.figure.layout["height"] = height + self.figure.layout.update({"width":width}) + self.figure.layout.update({"height":height}) print(self.figure) print(self.figure.layout) if additional_info is not None: From d3e6f2428b36d159f345f14465b5de5b60acfae0 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 20 Jan 2025 15:25:28 -0700 Subject: [PATCH 11/20] Delete print. --- dimes/dimensional_plot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index caa4056..fe08d9d 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -471,7 +471,6 @@ def write_image_plot(self, path: Path, scale: int) -> None: "Write plots to html file at specified path." self.finalize_plot() self.figure.write_image(path, scale=scale) - print(self.figure) def get_subplot_domains(number_of_subplots: int, gap: float = 0.05) -> list[tuple[float, float]]: From 41d985d6f965d8a2687acf0141396d42979df5ad Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Tue, 21 Jan 2025 13:46:14 -0700 Subject: [PATCH 12/20] Set width and height in DimensionalPlot. --- dimes/dimensional_plot.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index fe08d9d..9aa1dcb 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -242,15 +242,9 @@ def __init__( self.x_axis = x_axis self.subplots: list[DimensionalSubplot | None] = [None] self.is_finalized = False - print(self.figure) - print(self.figure.layout) self.figure.layout["title"] = title - print(self.figure) - print(self.figure.layout) - self.figure.layout.update({"width":width}) - self.figure.layout.update({"height":height}) - print(self.figure) - print(self.figure.layout) + self.figure.layout["width"] = width + self.figure.layout["height"] = height if additional_info is not None: self.figure.add_trace( Scatter( From 7fdcadecc2efe7e7b5f84e26b20a2ca4e8f90dcd Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Tue, 21 Jan 2025 13:49:27 -0700 Subject: [PATCH 13/20] Remove Union type hint import. --- dimes/dimensional_plot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index 9aa1dcb..1d0db48 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -6,7 +6,6 @@ from datetime import datetime import math import bisect -from typing import Union from plotly.graph_objects import Figure, Scatter # type: ignore from plotly.colors import sample_colorscale From 1becdf7124d6c120d2c42565ff006543a52451fc Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Tue, 21 Jan 2025 13:59:10 -0700 Subject: [PATCH 14/20] Add type hint and default value of None for scale in write_image_plot function. --- dimes/dimensional_plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index 1d0db48..993f330 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -460,7 +460,7 @@ def write_html_plot(self, path: Path) -> None: self.finalize_plot() self.figure.write_html(path) - def write_image_plot(self, path: Path, scale: int) -> None: + def write_image_plot(self, path: Path, scale: int | None = None) -> None: "Write plots to html file at specified path." self.finalize_plot() self.figure.write_image(path, scale=scale) From 0202348cac22b7ccc4e99d7d8ed916b1ca063666 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Fri, 31 Jan 2025 07:14:51 -0700 Subject: [PATCH 15/20] Add note for scale; raise ValueError for scale; add float type hint for scale. --- dimes/dimensional_plot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index 993f330..f9e0f06 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -460,8 +460,14 @@ def write_html_plot(self, path: Path) -> None: self.finalize_plot() self.figure.write_html(path) - def write_image_plot(self, path: Path, scale: int | None = None) -> None: - "Write plots to html file at specified path." + def write_image_plot(self, path: Path, scale: int | float | None = None) -> None: + """ + Write plots to html file at specified path. + scale (int, float, None): Adjusts the resolution of the output image. + A value cannot be equal to or less than 0 or greater than 16. + """ + if (scale > 16) | (scale <= 0): + raise ValueError(f"Scale value {scale} cannot be greater than 16 or less than or equal to 0.") self.finalize_plot() self.figure.write_image(path, scale=scale) From dfb51d0d7fe2fd51f4a538746d1a3e07a83972b6 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Fri, 31 Jan 2025 07:16:42 -0700 Subject: [PATCH 16/20] Add note for kaleido import. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ce3c27b..5fa7824 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ repository = "https://github.com/bigladder/dimes" version = "0.0.0" # Generated from git on CI [tool.poetry.dependencies] -kaleido = "==0.2.1" +kaleido = "==0.2.1" # Required by plotly to save figures as images koozie = "^1.3.0" plotly = "*" python = "^3.10" From a66ef3528ad69de14b75fb5414340ae27fb08f36 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Fri, 31 Jan 2025 07:16:57 -0700 Subject: [PATCH 17/20] Add whitespace. --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5fa7824..fa6cbaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,9 +10,9 @@ version = "0.0.0" # Generated from git on CI [tool.poetry.dependencies] kaleido = "==0.2.1" # Required by plotly to save figures as images -koozie = "^1.3.0" -plotly = "*" -python = "^3.10" +koozie = "^1.3.0" +plotly = "*" +python = "^3.10" [tool.poetry.dev-dependencies] black = "*" From d948352cd0e1c77107152375740c57de222026d1 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 3 Feb 2025 09:48:30 -0700 Subject: [PATCH 18/20] Move width and height from DimensionalPlot init to write_image_plot. --- dimes/dimensional_plot.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index f9e0f06..fac26c9 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -227,8 +227,6 @@ def __init__( x_axis: DimensionalData | TimeSeriesAxis | list[SupportsFloat] | list[datetime], title: str | None = None, additional_info: str | None = None, - width: int | None = None, - height: int | None = None, ): self.figure = Figure() self.x_axis: DimensionalData | TimeSeriesAxis @@ -242,8 +240,6 @@ def __init__( self.subplots: list[DimensionalSubplot | None] = [None] self.is_finalized = False self.figure.layout["title"] = title - self.figure.layout["width"] = width - self.figure.layout["height"] = height if additional_info is not None: self.figure.add_trace( Scatter( @@ -460,14 +456,19 @@ def write_html_plot(self, path: Path) -> None: self.finalize_plot() self.figure.write_html(path) - def write_image_plot(self, path: Path, scale: int | float | None = None) -> None: + def write_image_plot( + self, path: Path, width: int | None = None, height: int | None = None, scale: int | float | None = None + ) -> None: """ Write plots to html file at specified path. scale (int, float, None): Adjusts the resolution of the output image. A value cannot be equal to or less than 0 or greater than 16. """ - if (scale > 16) | (scale <= 0): - raise ValueError(f"Scale value {scale} cannot be greater than 16 or less than or equal to 0.") + if scale is not None: + if (scale > 16) | (scale <= 0): + raise ValueError(f"Scale value {scale} cannot be greater than 16 or less than or equal to 0.") + self.figure.layout["width"] = width + self.figure.layout["height"] = height self.finalize_plot() self.figure.write_image(path, scale=scale) From e4c95ef034dcd9044e02251c156a7ff6459c313e Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 3 Feb 2025 09:48:58 -0700 Subject: [PATCH 19/20] Set width and height to None in write_html_plot. --- dimes/dimensional_plot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dimes/dimensional_plot.py b/dimes/dimensional_plot.py index fac26c9..e65ab1f 100644 --- a/dimes/dimensional_plot.py +++ b/dimes/dimensional_plot.py @@ -453,6 +453,8 @@ def finalize_plot(self): def write_html_plot(self, path: Path) -> None: "Write plots to html file at specified path." + self.figure.layout["width"] = None + self.figure.layout["height"] = None self.finalize_plot() self.figure.write_html(path) From 0e9221a36662e8972cb23a0b284cdc928e02a5f4 Mon Sep 17 00:00:00 2001 From: Nathan Oliver Date: Mon, 3 Feb 2025 11:40:10 -0700 Subject: [PATCH 20/20] Undo alphabetical order. --- pyproject.toml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fa6cbaf..e9f0aef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,37 +1,37 @@ [tool.poetry] -authors = ["Big Ladder Software"] -description = "A dimensionally aware scientific plotting package." -keywords = ["template"] -license = "BSD-3" -name = "dimes" -readme = "README.md" -repository = "https://github.com/bigladder/dimes" +name = "dimes" version = "0.0.0" # Generated from git on CI +description = "A dimensionally aware scientific plotting package." +authors = ["Big Ladder Software"] +license = "BSD-3" +readme = "README.md" +keywords = ["template"] +repository = "https://github.com/bigladder/dimes" [tool.poetry.dependencies] +python = "^3.10" +plotly = "*" +koozie = "^1.3.0" kaleido = "==0.2.1" # Required by plotly to save figures as images -koozie = "^1.3.0" -plotly = "*" -python = "^3.10" [tool.poetry.dev-dependencies] +pytest = "^7.1.3" +pylint = "*" black = "*" mypy = "*" -pylint = "*" -pytest = "^7.1.3" [build-system] -build-backend = "poetry.core.masonry.api" requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" [tool.black] line-length = 120 [tool.mypy] -check_untyped_defs = true disallow_incomplete_defs = true no_implicit_optional = true +check_untyped_defs = true [[tool.mypy.overrides]] -disable_error_code = ["import"] module = "dimes.*" +disable_error_code = ["import"]