From 2fb1bc5cf715b7bbc0f23dd6132cb12f68c9985a Mon Sep 17 00:00:00 2001 From: ljeub-pometry <97447091+ljeub-pometry@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:58:46 +0200 Subject: [PATCH] Cleanup (#1689) * fix argument name * rename export to plot for optional dependencies * don't import the submodules directly --- python/pyproject.toml | 3 ++- python/python/raphtory/__init__.py | 4 ---- python/python/raphtory/plottingutils.py | 12 ++++++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 19b06ceb0a..174a2546c7 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -5,6 +5,7 @@ build-backend = "maturin" [project] name = "raphtory" requires-python = ">=3.8" +dynamic = ["version"] classifiers = [ "Programming Language :: Rust", "Programming Language :: Python :: Implementation :: CPython", @@ -30,7 +31,7 @@ slack = "https://join.slack.com/t/raphtory/shared_invite/zt-xbebws9j-VgPIFRleJFJ youtube = "https://www.youtube.com/@pometry8546/videos" [project.optional-dependencies] -export = ["seaborn >= 0.11.2"] +plot = ["seaborn >= 0.11.2"] [tool.maturin] features = ["pyo3/extension-module"] diff --git a/python/python/raphtory/__init__.py b/python/python/raphtory/__init__.py index b5a499c04a..494f6be6e4 100644 --- a/python/python/raphtory/__init__.py +++ b/python/python/raphtory/__init__.py @@ -7,9 +7,6 @@ sys.modules["raphtory.vectors"] = vectors sys.modules["raphtory.graphql"] = graphql -from .nullmodels import * -from .plottingutils import * - __doc__ = raphtory.__doc__ if hasattr(raphtory, "__all__"): __all__ = raphtory.__all__ @@ -18,7 +15,6 @@ graph_gen.__doc__ = "Generate Raphtory graphs from attachment models" graph_loader.__doc__ = "Load and save Raphtory graphs from/to file(s)" - try: from importlib.metadata import version as _version diff --git a/python/python/raphtory/plottingutils.py b/python/python/raphtory/plottingutils.py index 045f324383..5fe393eba5 100644 --- a/python/python/raphtory/plottingutils.py +++ b/python/python/raphtory/plottingutils.py @@ -186,8 +186,8 @@ def cdf(observations, normalised=True): list(float): x coordinates for the cdf list(float): y coordinates for the cdf """ - data = np.array(listlike, dtype=object) - N = len(listlike) + data = np.array(observations, dtype=object) + N = len(observations) x = np.sort(data) if normalised: @@ -209,11 +209,11 @@ def ccdf(observations, normalised=True): list(float): x coordinates for the cdf list(float): y coordinates for the cdf """ - x, y = cdf(listlike, normalised) + x, y = cdf(observations, normalised) if normalised: return x, 1.0 - y else: - return x, len(listlike) - y + return x, len(observations) - y def lorenz(observations): @@ -227,9 +227,9 @@ def lorenz(observations): list(float): x coordinates for the cdf list(float): y coordinates for the cdf """ - tmp_arr = np.array(sorted(listlike)) + tmp_arr = np.array(sorted(observations)) # print(tmp_arr[0]) - x = np.arange(listlike.size) / (listlike.size - 1) + x = np.arange(observations.size) / (observations.size - 1) y = tmp_arr.cumsum() / tmp_arr.sum() return x, y