From b167c4c40ea0f8f85deaae4ce16ff20501d54463 Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Wed, 24 Apr 2024 10:37:32 +0200 Subject: [PATCH 1/3] remove maps --- CHANGELOG.md | 1 + src/compas/utilities/maps.py | 127 ----------------------------------- 2 files changed, 1 insertion(+), 127 deletions(-) delete mode 100644 src/compas/utilities/maps.py diff --git a/CHANGELOG.md b/CHANGELOG.md index a967fc1b524..a7c24db8ac4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Removed `compas.scene.SceneObjectNode`, functionalities merged into `compas.scene.SceneObject`. * Removed `compas.scene.SceneTree`, functionalities merged into `compas.scene.Scene`. +* Removed `compas.utilities.maps` since functionality is replaced by `compas.tolerance`. ## [2.1.0] 2024-03-01 diff --git a/src/compas/utilities/maps.py b/src/compas/utilities/maps.py deleted file mode 100644 index bd555f8c98a..00000000000 --- a/src/compas/utilities/maps.py +++ /dev/null @@ -1,127 +0,0 @@ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import compas - - -def geometric_key(xyz, precision=None, sanitize=True): - """Convert XYZ coordinates to a string that can be used as a dict key. - - Parameters - ---------- - xyz : list[float] - The XYZ coordinates. - precision : str, optional - A formatting option that specifies the precision of the - individual numbers in the string. - Supported values are any float precision (e.g. ``'3f'``), or decimal integer (``'d'``). - Default is ``None``, in which case the global precision setting will be used (:attr:`compas.PRECISION`). - sanitize : bool, optional - If True, minus signs ("-") will be removed from values that are equal to zero up to the given precision. - - Returns - ------- - str - The string representation of the given coordinates. - - See also - -------- - geometric_key_xy - - Examples - -------- - >>> from math import pi - >>> geometric_key([pi, pi, pi]) - '3.142,3.142,3.142' - - """ - x, y, z = xyz - if not precision: - precision = compas.PRECISION - if precision == "d": - return "{0},{1},{2}".format(int(x), int(y), int(z)) - if sanitize: - minzero = "-{0:.{1}}".format(0.0, precision) - if "{0:.{1}}".format(x, precision) == minzero: - x = 0.0 - if "{0:.{1}}".format(y, precision) == minzero: - y = 0.0 - if "{0:.{1}}".format(z, precision) == minzero: - z = 0.0 - return "{0:.{3}},{1:.{3}},{2:.{3}}".format(x, y, z, precision) - - -def reverse_geometric_key(gkey): - """Reverse a geometric key string into xyz coordinates. - - Parameters - ---------- - gkey : str - A geometric key. - - Returns - ------- - list[float] - A list of XYZ coordinates. - - See Also - -------- - geometric_key - - Examples - -------- - >>> from math import pi - >>> xyz = [pi, pi, pi] - >>> gkey = geometric_key(xyz) - >>> reverse_geometric_key(gkey) - [3.142, 3.142, 3.142] - - """ - xyz = gkey.split(",") - return [float(i) for i in xyz] - - -def geometric_key_xy(xy, precision=None, sanitize=True): - """Convert XY coordinates to a string that can be used as a dict key. - - Parameters - ---------- - xy : list[float] - The XY(Z) coordinates. - precision : str, optional - A formatting option that specifies the precision of the - individual numbers in the string. - Supported values are any float precision (e.g. ``'3f'``), or decimal integer (``'d'``). - Default is ``None``, inwhich case the global precision setting will be used (``compas.PRECISION``). - sanitize : bool, optional - If True, minus signs ("-") will be removed from values that are equal to zero up to the given precision. - - Returns - ------- - str - The string representation of the given coordinates. - - See also - -------- - geometric_key - - Examples - -------- - >>> from math import pi - >>> geometric_key_xy([pi, pi, pi]) - '3.142,3.142' - - """ - x, y = xy[:2] - if not precision: - precision = compas.PRECISION - if precision == "d": - return "{0},{1}".format(int(x), int(y)) - if sanitize: - minzero = "-{0:.{1}}".format(0.0, precision) - if "{0:.{1}}".format(x, precision) == minzero: - x = 0.0 - if "{0:.{1}}".format(y, precision) == minzero: - y = 0.0 - return "{0:.{2}},{1:.{2}}".format(x, y, precision) From c46bdb5794280741dbacefe5801a9b66d19b7a34 Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Wed, 24 Apr 2024 10:44:58 +0200 Subject: [PATCH 2/3] update imports --- src/compas/utilities/__init__.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/compas/utilities/__init__.py b/src/compas/utilities/__init__.py index 5602a9ceb5b..2b926960a1a 100644 --- a/src/compas/utilities/__init__.py +++ b/src/compas/utilities/__init__.py @@ -9,19 +9,6 @@ print_profile, ) -from ..itertools import ( - flatten, - reshape, - grouper, - iterable_like, - linspace, - meshgrid, - normalize_values, - pairwise, - remap_values, - window, -) -from .maps import geometric_key, geometric_key_xy, reverse_geometric_key from .remote import download_file_from_remote from .ssh import SSH @@ -33,19 +20,6 @@ "abstractclassmethod", "memoize", "print_profile", - "normalize_values", - "remap_values", - "meshgrid", - "linspace", - "reshape", - "flatten", - "pairwise", - "window", - "iterable_like", - "grouper", - "geometric_key", - "reverse_geometric_key", - "geometric_key_xy", "download_file_from_remote", "SSH", ] From 1a966c07cafc43d60f4e5e386080fabd77e0875a Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Wed, 24 Apr 2024 15:58:10 +0200 Subject: [PATCH 3/3] more precise log --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90ce7a3904b..92c64bd17c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,7 +38,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Removed `compas.scene.SceneObjectNode`, functionalities merged into `compas.scene.SceneObject`. * Removed `compas.scene.SceneTree`, functionalities merged into `compas.scene.Scene`. * Removed default implementation of `compas.geometry.trimesh_geodistance` since nonexistent. -* Removed `compas.utilities.maps` since functionality is replaced by `compas.tolerance`. +* Removed `compas.utilities.geometric_key` and replaced it by `compas.tolerance.TOL.geometric_key`. +* Removed `compas.utilities.geometric_key_xy`. ## [2.1.0] 2024-03-01 @@ -50,6 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Added `compas.datastructures.Tree.to_graph()`. ### Changed + * Changed `compas.datastructures.TreeNode` to skip serialising `attributes`, `name` and `children` if being empty. * Changed `compas.datastructures.TreeNode.__repr__` to omit `name` if `None`. * Fix bug in `compas_rhino.geometry.NurbsCurve.from_parameters` and `compas_rhino.geometry.NurbsCurve.from_points` related to the value of the parameter `degree`.