Skip to content

Commit

Permalink
FIX-MERGE: linter fixes + merge from eleni's branch
Browse files Browse the repository at this point in the history
  • Loading branch information
9and3 committed Aug 24, 2024
2 parents 699e67d + 8a0ade7 commit a82b792
Show file tree
Hide file tree
Showing 12 changed files with 5,534 additions and 5,169 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
files: \.py$

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.11.0'
rev: 'v1.11.1'
hooks:
- id: mypy
files: (src/gh|tests|invokes\.py)
Expand All @@ -39,6 +39,6 @@ repos:
args: [--config=pyproject.toml]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
rev: v0.6.2
hooks:
- id: ruff
2 changes: 1 addition & 1 deletion deps/eigen
Submodule eigen updated from 92e373 to f91f8e
2 changes: 1 addition & 1 deletion deps/googletest
Submodule googletest updated 48 files
+43 −0 .github/workflows/gtest-ci.yml
+13 −13 BUILD.bazel
+1 −1 CMakeLists.txt
+9 −15 MODULE.bazel
+9 −5 README.md
+3 −36 WORKSPACE
+1 −1 ci/linux-presubmit.sh
+1 −6 ci/windows-presubmit.bat
+1 −1 docs/advanced.md
+3 −32 docs/gmock_cook_book.md
+9 −8 docs/primer.md
+30 −23 docs/quickstart-bazel.md
+2 −21 docs/reference/testing.md
+20 −59 googlemock/include/gmock/gmock-actions.h
+91 −105 googlemock/include/gmock/gmock-matchers.h
+3 −4 googlemock/include/gmock/gmock-more-actions.h
+6 −4 googlemock/include/gmock/gmock-spec-builders.h
+6 −8 googlemock/include/gmock/internal/gmock-internal-utils.h
+0 −1 googlemock/include/gmock/internal/gmock-port.h
+4 −4 googlemock/src/gmock-cardinalities.cc
+2 −3 googlemock/src/gmock-internal-utils.cc
+14 −13 googlemock/src/gmock-matchers.cc
+4 −52 googlemock/test/gmock-actions_test.cc
+7 −9 googlemock/test/gmock-matchers-arithmetic_test.cc
+2 −5 googlemock/test/gmock-matchers-comparisons_test.cc
+5 −16 googlemock/test/gmock-matchers-containers_test.cc
+2 −2 googlemock/test/gmock-matchers-misc_test.cc
+1 −1 googlemock/test/gmock_link_test.h
+1 −1 googletest/README.md
+1 −1 googletest/include/gtest/gtest-assertion-result.h
+4 −4 googletest/include/gtest/gtest-death-test.h
+4 −4 googletest/include/gtest/gtest-param-test.h
+61 −65 googletest/include/gtest/gtest-typed-test.h
+22 −23 googletest/include/gtest/internal/gtest-death-test-internal.h
+2 −2 googletest/include/gtest/internal/gtest-filepath.h
+45 −12 googletest/include/gtest/internal/gtest-internal.h
+4 −4 googletest/include/gtest/internal/gtest-param-util.h
+0 −2 googletest/include/gtest/internal/gtest-port-arch.h
+15 −37 googletest/include/gtest/internal/gtest-port.h
+3 −3 googletest/include/gtest/internal/gtest-type-util.h
+19 −34 googletest/src/gtest-port.cc
+39 −68 googletest/src/gtest.cc
+0 −1 googletest/test/googletest-color-test.py
+0 −2 googletest/test/googletest-death-test-test.cc
+0 −15 googletest/test/googletest-json-output-unittest.py
+0 −3 googletest/test/gtest_json_test_utils.py
+22 −10 googletest/test/gtest_unittest.cc
+10 −10 googletest_deps.bzl
16 changes: 13 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ exclude = [
"src/gh/components",
"src/gh/diffCheck/setup.py",
"temp",
"doc"
"doc",
"src/gh/diffCheck/diffCheck/__init__.py"
]

[[tool.mypy.overrides]]
Expand All @@ -18,18 +19,27 @@ module = [
"System.*",
"GH_IO.*",
"clr.*",
"diffcheck_bindings"
"diffcheck_bindings",
"diffCheck.diffcheck_bindings"
]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "pefile"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "diffCheck"
ignore_undefined_attributes = true



[tool.ruff]
exclude = [
"doc/",
"deps/",
"temp/"
]
]

[tool.ruff.per-file-ignores]
"src/gh/diffCheck/diffCheck/__init__.py" = ["F401", "F403" ,"E402"]
19 changes: 15 additions & 4 deletions src/gh/components/DF_cloud_mesh_distance/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

import Rhino.Geometry as rg
from ghpythonlib.componentbase import executingcomponent as component

from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML

import diffCheck
from diffCheck import df_cvt_bindings
from diffCheck import df_error_estimation
from diffCheck.df_geometries import DFBeam
from diffCheck.df_geometries import DFAssembly


class DFCloudMeshDistance(component):
def RunScript(self,
i_cloud_source: typing.List[rg.PointCloud],
i_beams: typing.List[DFBeam],
i_assembly: DFAssembly,
i_signed_flag: bool,
i_swap: bool,
i_analysis_resolution):
Expand All @@ -24,9 +24,20 @@ def RunScript(self,
scalef = diffCheck.df_util.get_doc_2_meters_unitf()
i_analysis_resolution = 0.1 / scalef

# Based on cloud source input + beam size, decide whether to calculate joints or entire assembly and output respective message
if len(i_assembly.beams) == len(i_cloud_source):
ghenv.Component.Message = "Per Beam" # noqa: F821
rh_mesh_target_list = [beam.to_mesh(i_analysis_resolution) for beam in i_assembly.beams]
elif len(i_assembly.all_joints) == len(i_cloud_source):
ghenv.Component.Message = "Per Joint" # noqa: F821
rh_mesh_target_list = [joint.to_mesh(i_analysis_resolution) for joint in i_assembly._all_joints]
else:
ghenv.Component.AddRuntimeMessage(RML.Warning, "The input number of objects to compare matches neither the number of beams nor the number of joints") # noqa: F821
return None, None, None, None, None, None

# conversion
df_cloud_source_list = [df_cvt_bindings.cvt_rhcloud_2_dfcloud(i_cl_s) for i_cl_s in i_cloud_source]
rh_mesh_target_list = [beam.to_mesh(i_analysis_resolution) for beam in i_beams]


# calculate distances
o_result = df_error_estimation.df_cloud_2_rh_mesh_comparison(df_cloud_source_list, rh_mesh_target_list, i_signed_flag, i_swap)
Expand Down
10 changes: 5 additions & 5 deletions src/gh/components/DF_cloud_mesh_distance/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"subcategory": "Analysis",
"description": "Computes the distance between a point cloud and a mesh",
"exposure": 4,
"instanceGuid": "534a24ba-7e32-482f-a3d7-293647185122",
"instanceGuid": "eda01e34-b89b-4e3c-a9b6-0178a05ae81b",
"ghpython": {
"hideOutput": true,
"hideInput": true,
Expand All @@ -26,13 +26,13 @@
"typeHintID": "pointcloud"
},
{
"name": "i_beams",
"nickname": "i_beams",
"description": "The target DFbeams",
"name": "i_assembly",
"nickname": "i_assembly",
"description": "The target DFAssembly",
"optional": false,
"allowTreeAccess": true,
"showTypeHints": true,
"scriptParamAccess": "list",
"scriptParamAccess": "item",
"wireDisplay": "default",
"sourceCount": 0,
"typeHintID": "ghdoc"
Expand Down
23 changes: 13 additions & 10 deletions src/gh/components/DF_joint_segmentator/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import Rhino

import diffCheck
from diffCheck import diffcheck_bindings
from diffCheck import df_cvt_bindings as df_cvt

Expand All @@ -15,20 +16,22 @@
class DFJointSegmentator(component):
def __init__(self):
super(DFJointSegmentator, self).__init__()
def RunScript(self,
i_clusters: typing.List[Rhino.Geometry.PointCloud],
def RunScript(self,
i_clusters: typing.List[Rhino.Geometry.PointCloud],
i_assembly: diffCheck.df_geometries.DFAssembly,
i_angle_threshold: float,
i_distance_threshold: float):

if i_angle_threshold is None : i_angle_threshold = 0.1
if i_distance_threshold is None : i_distance_threshold = 0.1

if i_angle_threshold is None:
i_angle_threshold = 0.1
if i_distance_threshold is None:
i_distance_threshold = 0.1

if len(i_clusters) == 0:
raise ValueError("No clusters given.")
if not isinstance(i_clusters[0], Rhino.Geometry.PointCloud):
raise ValueError("The input clusters must be PointClouds.")

# get number of joints
n_joints = i_assembly.total_number_joints

Expand Down Expand Up @@ -60,13 +63,13 @@ def RunScript(self,
# find the corresponding clusters and merge them
df_joint_segment = diffcheck_bindings.dfb_segmentation.DFSegmentation.associate_clusters(df_joint, df_cloud_clusters, i_angle_threshold, i_distance_threshold)
diffcheck_bindings.dfb_segmentation.DFSegmentation.clean_unassociated_clusters(df_cloud_clusters, [df_joint_segment], [df_joint], i_angle_threshold, i_distance_threshold)

# register the merged clusters to the reference point cloud
registration = diffcheck_bindings.dfb_registrations.DFRefinedRegistration.O3DICP(df_joint_segment, ref_df_joint_cloud)
res = registration.transformation_matrix
transforms.append(df_cvt.cvt_ndarray_2_rh_transform(res))
rh_joint_segments.append(df_cvt.cvt_dfcloud_2_rhcloud(df_joint_segment))

o_joint_segments = []
o_transforms = []
o_reference_point_clouds = []
Expand All @@ -76,6 +79,6 @@ def RunScript(self,
o_transforms.append(transform)
o_reference_point_clouds.append(_joint_cloud)
else:
ghenv.Component.AddRuntimeMessage(RML.Warning, "Some joints could not be segmented and were ignored.")
ghenv.Component.AddRuntimeMessage(RML.Warning, "Some joints could not be segmented and were ignored.") # noqa: F821

return o_joint_segments, o_transforms, o_reference_point_clouds
return o_joint_segments, o_transforms, o_reference_point_clouds
3 changes: 2 additions & 1 deletion src/gh/diffCheck/diffCheck/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
os.add_dll_directory(extra_dll_dir)

# import the bindings
from . import diffcheck_bindings
from . import diffcheck_bindings # type: ignore[attr-defined]
from . import df_cvt_bindings # type: ignore[attr-defined]
4 changes: 2 additions & 2 deletions src/gh/diffCheck/diffCheck/df_geometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def __post_init__(self):
self._all_sidefaces: typing.List[DFFace] = []

self._all_joints: typing.List[DFJoint] = []

def __repr__(self):
return f"Assembly: {self.name}, Beams: {len(self.beams)}"

Expand Down Expand Up @@ -451,4 +451,4 @@ def all_joints(self):
self._all_joints = []
for beam in self.beams:
self._all_joints.extend(beam.joints)
return self._all_joints
return self._all_joints
Loading

0 comments on commit a82b792

Please sign in to comment.