Skip to content

Commit

Permalink
Merge branch 'main' into trimesh-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Apr 24, 2024
2 parents c70306b + 6ce0be1 commit f0bffd1
Show file tree
Hide file tree
Showing 285 changed files with 1,018 additions and 1,249 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ insert_final_newline = true
indent_style = space
indent_size = 4
charset = utf-8
max_line_length = 120
max_line_length = 179

[*.{bat,cmd,ps1}]
end_of_line = crlf
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

* Changed and update the `compas_view2` examples into `compas_viewer`.
* Changed and updated the `compas_view2` examples into `compas_viewer`.
* Changed `compas.scene.Scene` to inherent from `compas.datastructrues.Tree`.
* Changed `compas.scene.SceneObject` to inherent from `compas.datastructrues.TreeNode`.
Expand All @@ -26,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fixed various bugs in `compas.geometry.Quaternion`.
* Changed repo config to `pyproject.toml`.
* Fixed broken import in `copas.geometry.trimesh_smoothing_numpy`.
* Changed `RhinoBrep.trimmed` to return single result or raise `BrepTrimmingError` instead of returning a list.
* Changed order of imports according to `isort` and changed line length to `179`.

### Removed

Expand Down
3 changes: 1 addition & 2 deletions docs/devguide/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ Naming conventions
Line length
-----------

**COMPAS uses a line length of 120 characters**. While longer than the 80 characters recommended by ``PEP8``, it is in our opinion a more reasonable limit for modern displays.
This is enforced and can be automatically set using ``black -l 120``.
**COMPAS uses a line length of 180 characters**. While longer than the 80 characters recommended by ``PEP8``, it is in our opinion a more reasonable limit for modern displays.

**Indentations are 4 spaces**. Tab to spaces setting can be set in ``.editorconfig`` which is respected by most editors. For more information see `EditorConfig <https://editorconfig.org/>`_.

Expand Down
2 changes: 1 addition & 1 deletion docs/devguide/workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ To set up a developer environment
.. code-block:: bash
cd path/to/compas
pip install -r requirements-dev.txt
pip install -e ".[dev]"
4. Make sure all tests pass and the code is free of lint:

Expand Down
14 changes: 4 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,15 @@ replace = "[{new_version}] {now:%Y-%m-%d}"
# ============================================================================

[tool.black]
# we should set this to 179
line-length = 120
line-length = 179

[tool.ruff]
# we should set this to 179
line-length = 120
line-length = 179
indent-width = 4
target-version = "py39"

[tool.ruff.lint]
# we should add "I"
select = ["E", "F"]
# we should remove this
ignore = ["E501"]
select = ["E", "F", "I"]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["I001"]
Expand All @@ -151,8 +146,7 @@ known-first-party = [
convention = "numpy"

[tool.ruff.lint.pycodestyle]
# we should set this to 179
max-doc-length = 120
max-doc-length = 179

[tool.ruff.format]
docstring-code-format = true
Expand Down
2 changes: 1 addition & 1 deletion src/compas/_iotools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""For the time being, these functions are only for internal use."""

from contextlib import contextmanager
import io
from contextlib import contextmanager

try:
from urllib.request import urlopen
Expand Down
3 changes: 2 additions & 1 deletion src/compas/_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,8 @@ def _get_win_folder_from_registry(csidl_name):


def _get_win_folder_with_pywin32(csidl_name):
from win32com.shell import shellcon, shell
from win32com.shell import shell
from win32com.shell import shellcon

dir = shell.SHGetFolderPath(0, getattr(shellcon, csidl_name), 0, 0)
# Try to make this a unicode path because SHGetFolderPath does
Expand Down
3 changes: 2 additions & 1 deletion src/compas/colors/colordict.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from compas.data import Data

from .color import Color


Expand Down
2 changes: 1 addition & 1 deletion src/compas/colors/colormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from compas.itertools import linspace

from .color import Color
from .mpl_colormap import _magma_data
from .mpl_colormap import _inferno_data
from .mpl_colormap import _magma_data
from .mpl_colormap import _plasma_data
from .mpl_colormap import _viridis_data

Expand Down
2 changes: 1 addition & 1 deletion src/compas/data/coercion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from .validators import is_item_iterable

Expand Down
7 changes: 3 additions & 4 deletions src/compas/data/data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

try:
from typing import TypeVar # noqa: F401
Expand All @@ -10,13 +10,12 @@
pass

import hashlib
from uuid import uuid4
from uuid import UUID
from copy import deepcopy
from uuid import UUID
from uuid import uuid4

import compas


# ==============================================================================
# If you ever feel tempted to use ABCMeta in your code: don't, just DON'T.
# Assigning __metaclass__ = ABCMeta to a class causes a severe memory leak/performance
Expand Down
2 changes: 1 addition & 1 deletion src/compas/data/encoders.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

try:
from typing import Type # noqa: F401
Expand Down
5 changes: 3 additions & 2 deletions src/compas/data/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from __future__ import division
from __future__ import print_function

import os
import json
import os


def dataclass_dataschema(cls): # type: (...) -> dict
Expand Down Expand Up @@ -119,10 +119,11 @@ def compas_dataclasses(): # type: (...) -> list
"""
from collections import deque
from compas.data import Data

import compas.colors # noqa: F401
import compas.datastructures # noqa: F401
import compas.geometry # noqa: F401
from compas.data import Data

tovisit = deque([Data])
dataclasses = []
Expand Down
2 changes: 1 addition & 1 deletion src/compas/data/validators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

try:
basestring # type: ignore
Expand Down
3 changes: 2 additions & 1 deletion src/compas/datastructures/assembly/assembly.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from compas.datastructures import Datastructure
from compas.datastructures import Graph

from .exceptions import AssemblyError


Expand Down
8 changes: 4 additions & 4 deletions src/compas/datastructures/assembly/part.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from compas.data import Data
from compas.datastructures import Datastructure
from compas.geometry import Brep
from compas.geometry import Frame
from compas.geometry import Polyhedron
from compas.geometry import Brep
from compas.datastructures import Datastructure
from compas.data import Data


class Feature(Data):
Expand Down
20 changes: 8 additions & 12 deletions src/compas/datastructures/cell_network/cell_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,34 @@

from random import sample

from compas.datastructures import Mesh
from compas.datastructures import Graph
from compas.datastructures.datastructure import Datastructure
from compas.datastructures.attributes import VertexAttributeView
from compas.datastructures import Mesh
from compas.datastructures.attributes import CellAttributeView
from compas.datastructures.attributes import EdgeAttributeView
from compas.datastructures.attributes import FaceAttributeView
from compas.datastructures.attributes import CellAttributeView

from compas.datastructures.attributes import VertexAttributeView
from compas.datastructures.datastructure import Datastructure
from compas.files import OBJ

from compas.geometry import Line
from compas.geometry import Point
from compas.geometry import Polygon
from compas.geometry import Polyhedron
from compas.geometry import Vector
from compas.geometry import add_vectors
from compas.geometry import bestfit_plane
from compas.geometry import bounding_box
from compas.geometry import centroid_points
from compas.geometry import centroid_polygon
from compas.geometry import centroid_polyhedron
from compas.geometry import distance_point_point
from compas.geometry import length_vector
from compas.geometry import normal_polygon
from compas.geometry import normalize_vector
from compas.geometry import volume_polyhedron
from compas.geometry import add_vectors
from compas.geometry import bestfit_plane
from compas.geometry import project_point_plane
from compas.geometry import scale_vector
from compas.geometry import subtract_vectors
from compas.geometry import bounding_box

from compas.geometry import volume_polyhedron
from compas.itertools import pairwise

from compas.tolerance import TOL


Expand Down
5 changes: 2 additions & 3 deletions src/compas/datastructures/graph/duality.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from math import pi

from compas.itertools import pairwise
from compas.geometry import angle_vectors
from compas.geometry import is_ccw_xy

from compas.itertools import pairwise

PI2 = 2.0 * pi

Expand Down
36 changes: 17 additions & 19 deletions src/compas/datastructures/graph/graph.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from random import sample
from ast import literal_eval
from itertools import combinations
from random import sample

import compas

Expand All @@ -13,42 +13,40 @@
else:
from collections.abc import Mapping

from compas.tolerance import TOL
from compas.datastructures.attributes import EdgeAttributeView
from compas.datastructures.attributes import NodeAttributeView
from compas.datastructures.datastructure import Datastructure
from compas.files import OBJ
from compas.geometry import Box
from compas.geometry import Line
from compas.geometry import Point
from compas.geometry import Vector
from compas.geometry import Line
from compas.geometry import Box
from compas.geometry import add_vectors
from compas.geometry import bounding_box
from compas.geometry import centroid_points
from compas.geometry import subtract_vectors
from compas.geometry import distance_point_point
from compas.geometry import midpoint_line
from compas.geometry import normalize_vector
from compas.geometry import add_vectors
from compas.geometry import oriented_bounding_box
from compas.geometry import scale_vector
from compas.geometry import subtract_vectors
from compas.geometry import transform_points
from compas.geometry import bounding_box
from compas.geometry import oriented_bounding_box
from compas.tolerance import TOL
from compas.topology import astar_shortest_path
from compas.topology import breadth_first_traverse
from compas.topology import connected_components

from compas.datastructures.datastructure import Datastructure
from compas.datastructures.attributes import NodeAttributeView
from compas.datastructures.attributes import EdgeAttributeView

from .operations.split import graph_split_edge
from .duality import graph_find_cycles
from .operations.join import graph_join_edges

from .operations.split import graph_split_edge
from .planarity import graph_count_crossings
from .planarity import graph_embed_in_plane
from .planarity import graph_find_crossings
from .planarity import graph_is_crossed
from .planarity import graph_is_planar
from .planarity import graph_is_planar_embedding
from .planarity import graph_is_xy
from .planarity import graph_count_crossings
from .planarity import graph_find_crossings
from .planarity import graph_embed_in_plane
from .smoothing import graph_smooth_centroid
from .duality import graph_find_cycles


class Graph(Datastructure):
Expand Down
14 changes: 4 additions & 10 deletions src/compas/datastructures/graph/operations/join.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from compas.tolerance import TOL
from compas.itertools import pairwise
from compas.tolerance import TOL


def graph_join_edges(graph, key):
Expand Down Expand Up @@ -104,15 +104,9 @@ def graph_polylines(graph, splits=None):
# get adjacent edges until the polyline is closed...
while polyline[0] != polyline[-1]:
# ... or until both end are non-two-valent vertices
if (
len(graph.neighbors(polyline[-1])) != 2
or TOL.geometric_key(graph.node_coordinates(polyline[-1])) in stop_geom_keys
):
if len(graph.neighbors(polyline[-1])) != 2 or TOL.geometric_key(graph.node_coordinates(polyline[-1])) in stop_geom_keys:
polyline = list(reversed(polyline))
if (
len(graph.neighbors(polyline[-1])) != 2
or TOL.geometric_key(graph.node_coordinates(polyline[-1])) in stop_geom_keys
):
if len(graph.neighbors(polyline[-1])) != 2 or TOL.geometric_key(graph.node_coordinates(polyline[-1])) in stop_geom_keys:
break

# add next edge
Expand Down
2 changes: 1 addition & 1 deletion src/compas/datastructures/graph/operations/split.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function


def graph_split_edge(graph, edge, t=0.5):
Expand Down
Loading

0 comments on commit f0bffd1

Please sign in to comment.