Skip to content

Commit 52e0db6

Browse files
committed
remove unnecessary actions that convert numpy floats to regular floats
1 parent 6695b70 commit 52e0db6

File tree

5 files changed

+19
-66
lines changed

5 files changed

+19
-66
lines changed

src/bim2fem/ifcplus/api/distribution_element.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,6 @@ def create_pipe_segment(
241241
object_z_axis_in_global_coordinates,
242242
)
243243

244-
object_z_axis_in_global_coordinates = (
245-
bim2fem.ifcplus.util.geometry.convert_3pt_ndarray_to_tuple_of_floats(
246-
numpy_3pt_array=object_z_axis_in_global_coordinates,
247-
)
248-
)
249-
250-
object_x_axis_in_global_coordinates = (
251-
bim2fem.ifcplus.util.geometry.convert_3pt_ndarray_to_tuple_of_floats(
252-
numpy_3pt_array=object_x_axis_in_global_coordinates,
253-
)
254-
)
255-
256244
length = float(np.linalg.norm(object_z_axis_in_global_coordinates))
257245

258246
outer_radius = nominal_diameter / 2 + thickness / 2
@@ -291,8 +279,8 @@ def create_pipe_segment(
291279
bim2fem.ifcplus.api.placement.edit_object_placement(
292280
product=pipe_segment,
293281
repositioned_origin=object_origin_in_global_coordinates,
294-
repositioned_z_axis=object_z_axis_in_global_coordinates,
295-
repositioned_x_axis=object_x_axis_in_global_coordinates,
282+
repositioned_z_axis=tuple(object_z_axis_in_global_coordinates.tolist()),
283+
repositioned_x_axis=tuple(object_x_axis_in_global_coordinates.tolist()),
296284
place_object_relative_to_parent=place_object_relative_to_parent,
297285
)
298286

src/bim2fem/ifcplus/api/system.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def create_pipe_run_from_polyline(
298298
return piping_elements
299299

300300

301-
def connect_two_distribution_ports_via_piping_with_no_intelligence(
301+
def connect_two_distribution_ports_via_pipe_run(
302302
ifc4_file: ifcopenshell.file,
303303
source_port: ifcopenshell.entity_instance,
304304
sink_port: ifcopenshell.entity_instance,
@@ -311,7 +311,7 @@ def connect_two_distribution_ports_via_piping_with_no_intelligence(
311311
spatial_element: ifcopenshell.entity_instance | None = None,
312312
add_shape_representation_to_ports: bool = False,
313313
) -> list[ifcopenshell.entity_instance]:
314-
"""Connect two IfcDistributionPorts using a single path pipe branch formed via no
314+
"""Connect two IfcDistributionPorts using a pipe run formed via no
315315
intelligent method."""
316316

317317
source_port_origin = bim2fem.ifcplus.util.system.get_port_location(
@@ -344,11 +344,13 @@ def connect_two_distribution_ports_via_piping_with_no_intelligence(
344344
).tolist()
345345
)
346346

347-
(
348-
delta_x_between_second_and_penultimate_point,
349-
delta_y_between_second_and_penultimate_point,
350-
_,
351-
) = tuple((np.array(penultimate_point) - np.array(second_point)).tolist())
347+
delta_x_between_second_and_penultimate_point = (
348+
np.array(penultimate_point) - np.array(second_point)
349+
)[0]
350+
351+
delta_y_between_second_and_penultimate_point = (
352+
np.array(penultimate_point) - np.array(second_point)
353+
)[1]
352354

353355
third_point = tuple(
354356
(

src/bim2fem/ifcplus/util/geometry.py

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -651,19 +651,11 @@ def from_3pt_polyline(
651651
- np.array(unit_vector_from_PC_to_PI) * tangent_length
652652
)
653653

654-
point_of_curvature = convert_3pt_ndarray_to_tuple_of_floats(
655-
numpy_3pt_array=point_of_curvature
656-
)
657-
658654
point_of_tangency = (
659655
np.array(point_of_intersection)
660656
+ np.array(unit_vector_from_PI_to_PT) * tangent_length
661657
)
662658

663-
point_of_tangency = convert_3pt_ndarray_to_tuple_of_floats(
664-
numpy_3pt_array=point_of_tangency
665-
)
666-
667659
unit_vector_from_PC_to_CC = calculate_cross_product_of_two_vectors(
668660
vector1=axis_of_rotation,
669661
vector2=unit_vector_from_PC_to_PI,
@@ -674,18 +666,14 @@ def from_3pt_polyline(
674666
+ np.array(unit_vector_from_PC_to_CC) * radius_of_curvature
675667
)
676668

677-
center_of_curvature = convert_3pt_ndarray_to_tuple_of_floats(
678-
numpy_3pt_array=center_of_curvature
679-
)
680-
681669
return cls(
682670
point_of_intersection=point_of_intersection,
683671
central_angle=float(central_angle),
684672
radius_of_curvature=float(radius_of_curvature),
685673
direction_of_axis_of_rotation=axis_of_rotation,
686-
point_of_curvature=point_of_curvature,
687-
point_of_tangency=point_of_tangency,
688-
center_of_curvature=center_of_curvature,
674+
point_of_curvature=tuple(point_of_curvature.tolist()),
675+
point_of_tangency=tuple(point_of_tangency.tolist()),
676+
center_of_curvature=tuple(center_of_curvature.tolist()),
689677
)
690678

691679
@classmethod
@@ -736,18 +724,14 @@ def from_PC_and_PT_and_PI(
736724
+ np.array(unit_vector_from_PC_to_CC) * radius_of_curvature
737725
)
738726

739-
center_of_curvature = convert_3pt_ndarray_to_tuple_of_floats(
740-
numpy_3pt_array=center_of_curvature
741-
)
742-
743727
return cls(
744728
point_of_intersection=point_of_intersection,
745729
central_angle=float(central_angle_of_curvature),
746730
radius_of_curvature=float(radius_of_curvature),
747731
direction_of_axis_of_rotation=axis_of_rotation,
748732
point_of_curvature=point_of_curvature,
749733
point_of_tangency=point_of_tangency,
750-
center_of_curvature=center_of_curvature,
734+
center_of_curvature=tuple(center_of_curvature.tolist()),
751735
)
752736

753737
@classmethod
@@ -801,14 +785,10 @@ def from_PC_and_PT_and_CC(
801785
* np.array(unit_vector_from_from_CC_to_PI)
802786
)
803787

804-
point_of_intersection = convert_3pt_ndarray_to_tuple_of_floats(
805-
numpy_3pt_array=point_of_intersection,
806-
)
807-
808788
return cls.from_PC_and_PT_and_PI(
809789
point_of_curvature=point_of_curvature,
810790
point_of_tangency=point_of_tangency,
811-
point_of_intersection=point_of_intersection,
791+
point_of_intersection=tuple(point_of_intersection.tolist()),
812792
)
813793

814794
@classmethod
@@ -846,13 +826,9 @@ def from_PC_and_CC_and_angle(
846826
rotated_vector
847827
)
848828

849-
point_of_tangency = convert_3pt_ndarray_to_tuple_of_floats(
850-
numpy_3pt_array=point_of_tangency
851-
)
852-
853829
return cls.from_PC_and_PT_and_CC(
854830
point_of_curvature=point_of_curvature,
855-
point_of_tangency=point_of_tangency,
831+
point_of_tangency=tuple(point_of_tangency.tolist()),
856832
point_on_center_of_curvature_side=point_of_center_of_curvature,
857833
radius_of_curvature=radius_of_curvature,
858834
)
@@ -900,11 +876,7 @@ def rotate_vector_about_axis(
900876
v * cos_angle + np.cross(k, v) * sin_angle + k * np.dot(k, v) * (1 - cos_angle)
901877
)
902878

903-
rotated_vector = convert_3pt_ndarray_to_tuple_of_floats(
904-
numpy_3pt_array=rotated_vector
905-
)
906-
907-
return rotated_vector
879+
return tuple(rotated_vector.tolist())
908880

909881

910882
def calculate_endpoint_coordinates_of_shortest_line_connecting_two_lines(

tests/ifcplus/api/test_distribution_element.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,13 @@
33
import ifcopenshell
44
import ifcopenshell.validate
55
import bim2fem.ifcplus.api.project
6-
import bim2fem.ifcplus.api.system
76
import bim2fem.ifcplus.util.geometry
87
import bim2fem.ifcplus.api.placement
98
import bim2fem.ifcplus.api.distribution_element
10-
import ifcopenshell.util.system
119
import bim2fem.ifcplus.api.material
12-
import ifcopenshell.api.root
13-
import ifcopenshell.api.spatial
14-
import ifcopenshell.api.geometry
15-
import bim2fem.ifcplus.api.geometry
16-
import ifcopenshell.util.representation
17-
import pytest
1810
from tests.conftest import OUTPUT_DIR_FOR_DISTRIBUTION_ELEMENT
1911
import bim2fem.ifcplus.util.geometry
2012
import numpy as np
21-
from typing import cast
2213

2314

2415
class TestCreatePipingElements:

tests/ifcplus/api/test_system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def test_connect_make_up_air_unit_and_hepa_filter_with_pipe_run(
154154
)
155155
)
156156

157-
bim2fem.ifcplus.api.system.connect_two_distribution_ports_via_piping_with_no_intelligence(
157+
bim2fem.ifcplus.api.system.connect_two_distribution_ports_via_pipe_run(
158158
ifc4_file=ifc_file_with_ventilation_distribution_system,
159159
source_port=mau_source_port,
160160
sink_port=hepa_sink_port,

0 commit comments

Comments
 (0)