From ff8b2f39e49a8bad379e36cd4c25ef8939ececbb Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 30 Aug 2023 10:55:17 +0200 Subject: [PATCH 1/8] fixed beam and assembly Data interface --- src/compas_timber/assembly/assembly.py | 16 +++++++------- src/compas_timber/parts/beam.py | 29 +++++++++++--------------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/compas_timber/assembly/assembly.py b/src/compas_timber/assembly/assembly.py index b9e58472a..4f1956926 100644 --- a/src/compas_timber/assembly/assembly.py +++ b/src/compas_timber/assembly/assembly.py @@ -40,16 +40,16 @@ def __str__(self): self.guid, len(self.beams), len(self.joints) ) - @Assembly.data.setter - def data(self, value): - Assembly.data.fset(self, value) - # restore what got removed to avoid circular reference - for part in self.parts(): + @classmethod + def from_data(cls, data): + assembly = super(TimberAssembly, cls).from_data(data) + for part in assembly.parts(): if isinstance(part, Beam): - self._beams.append(part) + assembly._beams.append(part) if isinstance(part, Joint): - self._joints.append(part) - part.restore_beams_from_keys(self) + assembly._joints.append(part) + part.restore_beams_from_keys(assembly) + return assembly @property def beams(self): diff --git a/src/compas_timber/parts/beam.py b/src/compas_timber/parts/beam.py index 06503fc78..75a15a9d1 100644 --- a/src/compas_timber/parts/beam.py +++ b/src/compas_timber/parts/beam.py @@ -31,7 +31,7 @@ def _create_box(frame, xsize, ysize, zsize): boxframe = frame.copy() depth_offset = boxframe.xaxis * xsize * 0.5 boxframe.point += depth_offset - return Box(boxframe, xsize, ysize, zsize) + return Box(xsize, ysize, zsize, frame=boxframe) def _create_mesh_shape(xsize, ysize, zsize): @@ -112,7 +112,6 @@ class Beam(Part): def __init__(self, frame, length, width, height, geometry_type, **kwargs): super(Beam, self).__init__(frame=frame) # TODO: add setter so that only that makes sure the frame is orthonormal --> needed for comparisons - self.frame = frame self.width = width self.height = height self.length = length @@ -122,17 +121,19 @@ def __init__(self, frame, length, width, height, geometry_type, **kwargs): @property def data(self): - data = {"width": self.width, "height": self.height, "length": self.length, "geometry_type": self.geometry_type} - data.update(super(Beam, self).data) + data = { + "frame": self.frame, + "width": self.width, + "height": self.height, + "length": self.length, + "geometry_type": self.geometry_type, + } + data.update(self.attributes) return data - @data.setter - def data(self, data): - Part.data.fset(self, data) - self.width = data["width"] - self.height = data["height"] - self.length = data["length"] - self.geometry_type = data["geometry_type"] + @classmethod + def from_data(cls, data): + return cls(**data) @property def tolerance(self): @@ -256,12 +257,6 @@ def is_identical(self, other): # TODO: skip joints and features ? ) - @classmethod - def from_data(cls, data): - """Alternative to None default __init__ parameters.""" - obj = cls(**data) - obj.data = data - return obj def get_geometry(self, with_features=False): """Returns the geometry representation of this beam. From cfacbfbeaab83ece1d52db41a4f4c9d10e361845 Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 30 Aug 2023 14:36:39 +0200 Subject: [PATCH 2/8] updated lines.json to new serialization format --- data/lines.json | 115 +----------------------------------------------- 1 file changed, 1 insertion(+), 114 deletions(-) diff --git a/data/lines.json b/data/lines.json index a8881d399..aad21d6f0 100644 --- a/data/lines.json +++ b/data/lines.json @@ -1,114 +1 @@ -[ - { - "dtype": "compas.geometry/Line", - "value": { - "start": [ - 3.0, - 0.0, - 0.0 - ], - "end": [ - 0.0, - 0.0, - 0.0 - ] - }, - "guid": "8ff21348-f55c-46e6-82d5-a9542830f4be" - }, - { - "dtype": "compas.geometry/Line", - "value": { - "start": [ - 3.0, - 2.0, - 0.0 - ], - "end": [ - 3.0, - 0.0, - 0.0 - ] - }, - "guid": "7b3f783e-6a2f-46fa-86b4-2d1cbb15b754" - }, - { - "dtype": "compas.geometry/Line", - "value": { - "start": [ - 0.0, - 2.0, - 0.0 - ], - "end": [ - 3.0, - 2.0, - 0.0 - ] - }, - "guid": "e1d4c133-6670-4a98-a7da-30472903ffc6" - }, - { - "dtype": "compas.geometry/Line", - "value": { - "start": [ - 0.0, - 0.0, - 0.0 - ], - "end": [ - 0.0, - 2.0, - 0.0 - ] - }, - "guid": "31745ab4-9181-424a-9a44-1ab30fe1f1d6" - }, - { - "dtype": "compas.geometry/Line", - "value": { - "start": [ - 1.3073011262590537, - 1.0, - 0.0 - ], - "end": [ - 3.0, - 1.0, - 0.0 - ] - }, - "guid": "9c9876bd-183f-4333-9053-cb582092f3ab" - }, - { - "dtype": "compas.geometry/Line", - "value": { - "start": [ - 1.1146022525181074, - 2.0, - 0.0 - ], - "end": [ - 1.5, - 0.0, - 0.0 - ] - }, - "guid": "6c2576ec-c87b-4084-98a9-14beac674402" - }, - { - "dtype": "compas.geometry/Line", - "value": { - "start": [ - 0.77180331565990912, - 2.0, - 0.0 - ], - "end": [ - 0.27664929575362163, - 0.0, - 0.0 - ] - }, - "guid": "bfdd9ed2-1f50-46a8-91dc-e3dd5908e54e" - } -] +[{"dtype": "compas.geometry/Line", "guid": "ed0d2832-440a-4c95-aa4d-d14f4bcd3adf", "data": {"start": [0.0, -0.029999999999999999, 0.0], "end": [0.0, 2.0300000000000002, 0.0]}}, {"dtype": "compas.geometry/Line", "guid": "f286692e-e844-40fd-b61a-777394791829", "data": {"start": [-0.029999999999999805, 2.0, 0.0], "end": [3.0299999999999998, 2.0, 0.0]}}, {"dtype": "compas.geometry/Line", "guid": "4b3f61f6-854c-416f-8aaf-0cf3eb642057", "data": {"start": [3.0, 2.0299999999999998, 0.0], "end": [3.0, -0.029999999999999805, 0.0]}}, {"dtype": "compas.geometry/Line", "guid": "3fd24451-c642-43e2-a5fc-909b44d12973", "data": {"start": [3.0299999999999998, 0.0, 0.0], "end": [-0.030000000000000249, 0.0, 0.0]}}, {"dtype": "compas.geometry/Line", "guid": "0e8a3ffb-eeb4-4d08-8ce5-bd8b1fb18be7", "data": {"start": [0.57191292303231478, 2.0, 0.0], "end": [0.26499265851842146, 0.0, 0.0]}}, {"dtype": "compas.geometry/Line", "guid": "3ff5ce61-e88c-4a4e-9ac3-ffb50fc0b7b0", "data": {"start": [1.2278797628757312, 2.0, 0.0], "end": [1.5, 0.0, 0.0]}}, {"dtype": "compas.geometry/Line", "guid": "cea4d142-f2de-4bbd-b6a7-c78683bcf5ff", "data": {"start": [1.3639398814378656, 1.0, 0.0], "end": [3.0, 1.0, 0.0]}}] From 7f5182c605ea5d41cded822db5a76a7ac10c7fb4 Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 30 Aug 2023 14:50:52 +0200 Subject: [PATCH 3/8] fixed beam order in neighbors test --- tests/compas_timber/test_joint.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/compas_timber/test_joint.py b/tests/compas_timber/test_joint.py index 557530568..6973ad8d1 100644 --- a/tests/compas_timber/test_joint.py +++ b/tests/compas_timber/test_joint.py @@ -84,16 +84,16 @@ def test_deepcopy(mocker): def test_find_neighbors(example_beams): expected_result = [ - set([0, 3]), - set([0, 6]), set([0, 1]), - set([0, 5]), + set([0, 3]), set([1, 2]), set([1, 4]), + set([1, 5]), set([2, 3]), set([2, 6]), - set([2, 5]), - set([4, 5]), + set([3, 4]), + set([3, 5]), + set([5, 6]), ] result = find_neighboring_beams(example_beams) # beam objects => sets of keys for easy comparison From 186dac5a39ca8ca036c63db1fb5987a2d2ccd5ef Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 30 Aug 2023 14:51:21 +0200 Subject: [PATCH 4/8] formatting --- src/compas_timber/parts/beam.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compas_timber/parts/beam.py b/src/compas_timber/parts/beam.py index 75a15a9d1..c7baf9ca0 100644 --- a/src/compas_timber/parts/beam.py +++ b/src/compas_timber/parts/beam.py @@ -257,7 +257,6 @@ def is_identical(self, other): # TODO: skip joints and features ? ) - def get_geometry(self, with_features=False): """Returns the geometry representation of this beam. From 2b2ac73b212d270376078eba7477f5cf0fde8045 Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 30 Aug 2023 14:54:34 +0200 Subject: [PATCH 5/8] udpated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index be34e7230..616f17122 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +* Adapted the `Data` interface of `Beam` and `Assembly` according to the changes in COMPAS core. + ### Removed From 07c3297da854a9156d047067ecec138725827094 Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 30 Aug 2023 16:04:02 +0200 Subject: [PATCH 6/8] fixed unexpected section title in docs --- docs/installation.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/installation.rst b/docs/installation.rst index c37e1c326..c24953313 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -4,10 +4,7 @@ Installation .. rst-class:: lead - Your options are: - - Contents - ======== + The following installation possibilties are available: .. toctree:: :maxdepth: 1 @@ -15,4 +12,4 @@ Installation installation/installation_quick installation/installation_manual - installation/installation_dev \ No newline at end of file + installation/installation_dev From a938e78ea80f20fdad46f82ecdcc4239600a5ea2 Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 30 Aug 2023 16:43:47 +0200 Subject: [PATCH 7/8] pinned sphinx version due to breaking changes --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index b13b4d709..37e8787e8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -16,7 +16,7 @@ pydocstyle pytest >=3.2 pytest-mock sphinx_compas_theme >=0.13 -sphinx >=3.4 +sphinx ==7.1.2 twine matplotlib Rtree From 4be9f25e373660c09354372bb99f58550b80681b Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 30 Aug 2023 17:02:39 +0200 Subject: [PATCH 8/8] dropped python3.7 support --- .github/workflows/build.yml | 2 +- setup.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff50109d9..b7aabed30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python: ['3.7', '3.8', '3.9', '3.10'] + python: ['3.8', '3.9', '3.10'] steps: - uses: actions/checkout@v3 diff --git a/setup.py b/setup.py index 0b1efde52..b58c3909d 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,6 @@ def read(*names, **kwargs): "Operating System :: Microsoft :: Windows", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -58,7 +57,7 @@ def read(*names, **kwargs): include_package_data=True, zip_safe=False, install_requires=requirements, - python_requires=">=3.7", + python_requires=">=3.8", extras_require=optional_requirements, entry_points={ "console_scripts": [],