diff --git a/CHANGELOG.md b/CHANGELOG.md index 08909ca73e1..92c64bd17c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +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.geometric_key` and replaced it by `compas.tolerance.TOL.geometric_key`. +* Removed `compas.utilities.geometric_key_xy`. ## [2.1.0] 2024-03-01 @@ -49,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`. 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", ] 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)