diff --git a/src/ifcopenshell-python/ifcopenshell/api/cogo/add_survey_point.py b/src/ifcopenshell-python/ifcopenshell/api/cogo/add_survey_point.py index 83141b5b6f..c7aded6bb5 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cogo/add_survey_point.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cogo/add_survey_point.py @@ -20,7 +20,10 @@ import ifcopenshell from ifcopenshell import entity_instance import typing -def add_survey_point(file: ifcopenshell.file, survey_point: entity_instance, site:entity_instance = None) -> entity_instance: + +def add_survey_point( + file: ifcopenshell.file, survey_point: entity_instance, site: entity_instance = None +) -> entity_instance: """ Adds a single survey point to the model based on IFC Concept Template 4.1.7.1.2.5. Survey points are located relative to IfcRepresentationContext.WorldCoordinateSystem @@ -34,14 +37,21 @@ def add_survey_point(file: ifcopenshell.file, survey_point: entity_instance, sit annotation = ifcopenshell.api.cogo.add_survey_point(file,file.createIfcCartesianPoint(4000.0,3500.0))) """ - context = ifcopenshell.util.representation.get_context(file,"Model","Annotation","MODEL_VIEW") - shape_representation = file.createIfcShapeRepresentation(ContextOfItems=context,RepresentationIdentifier='Annotation',RepresentationType='Point',Items=[survey_point]) + context = ifcopenshell.util.representation.get_context(file, "Model", "Annotation", "MODEL_VIEW") + shape_representation = file.createIfcShapeRepresentation( + ContextOfItems=context, RepresentationIdentifier="Annotation", RepresentationType="Point", Items=[survey_point] + ) representation = file.createIfcProductDefinitionShape(Representations=[shape_representation]) - annotation = file.createIfcAnnotation(ifcopenshell.guid.new(),ObjectPlacement=context.WorldCoordinateSystem,Representation=representation,PredefinedType="SURVEY") - - if (site == None): + annotation = file.createIfcAnnotation( + ifcopenshell.guid.new(), + ObjectPlacement=context.WorldCoordinateSystem, + Representation=representation, + PredefinedType="SURVEY", + ) + + if site == None: site = file.by_type("IfcSite")[0] - ifcopenshell.api.spatial.assign_container(file,relating_structure=site,products=[annotation]) + ifcopenshell.api.spatial.assign_container(file, relating_structure=site, products=[annotation]) return annotation diff --git a/src/ifcopenshell-python/ifcopenshell/api/cogo/assign_survey_point.py b/src/ifcopenshell-python/ifcopenshell/api/cogo/assign_survey_point.py index 0208a93fb4..c9a6ba0acc 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cogo/assign_survey_point.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cogo/assign_survey_point.py @@ -20,6 +20,7 @@ import ifcopenshell from ifcopenshell import entity_instance import typing + def assign_survey_point(annotation: entity_instance, survey_point: entity_instance): """ Assigns a coordinate point to a survey point annotation diff --git a/src/ifcopenshell-python/ifcopenshell/api/cogo/bearing2dd.py b/src/ifcopenshell-python/ifcopenshell/api/cogo/bearing2dd.py index 1625e16a98..895215f066 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cogo/bearing2dd.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cogo/bearing2dd.py @@ -18,7 +18,8 @@ import ifcopenshell.util.geolocation -def bearing2dd(bearing: str)->float: + +def bearing2dd(bearing: str) -> float: """ Converts a quadrant bearing string to decimal degrees @@ -35,26 +36,26 @@ def bearing2dd(bearing: str)->float: """ error_msg = "Invalid bearing string" - bearing = bearing.strip() # trim external white space - bearing = ' '.join(bearing.split()) # make sure all parts separated by a single space + bearing = bearing.strip() # trim external white space + bearing = " ".join(bearing.split()) # make sure all parts separated by a single space parts = bearing.split() nParts = len(parts) if nParts < 3 or 5 < nParts: raise ValueError(error_msg) - + cY = parts[0] cY = cY.upper() - if cY != 'N' and cY != 'S': + if cY != "N" and cY != "S": raise ValueError(error_msg) cX = parts[-1] cX = cX.upper() - if cX != 'E' and cX != 'W': + if cX != "E" and cX != "W": raise ValueError(error_msg) - + d = 0 m = 0 - s = 0. + s = 0.0 ms = 0 if nParts == 3: @@ -69,38 +70,37 @@ def bearing2dd(bearing: str)->float: # s in a decimal number # need to break it into whole seconds and milliseconds - ms = 100.*(s - int(s)) + ms = 100.0 * (s - int(s)) s = int(s) if d < 0 or (m < 0 or 60 <= m) or (s < 0 or 60 <= s) or ms < 0: raise ValueError(error_msg) - - if cY == 'N' and cX == 'E': - angle = 90. - sign = -1. - elif cY == 'N' and cX == 'W': - angle = 90. - sign = 1. - elif cY == 'S' and cX == 'E': - angle = 270. - sign = 1. - elif cY == 'S' and cX == 'W': - angle = 270. - sign = -1. + + if cY == "N" and cX == "E": + angle = 90.0 + sign = -1.0 + elif cY == "N" and cX == "W": + angle = 90.0 + sign = 1.0 + elif cY == "S" and cX == "E": + angle = 270.0 + sign = 1.0 + elif cY == "S" and cX == "W": + angle = 270.0 + sign = -1.0 try: - dms = ifcopenshell.util.geolocation.dms2dd(d,m,s,ms) + dms = ifcopenshell.util.geolocation.dms2dd(d, m, s, ms) except ValueError: raise ValueError(error_msg) - - if dms < 0. or 90. < dms: + + if dms < 0.0 or 90.0 < dms: raise ValueError(error_msg) - angle += sign*dms + angle += sign * dms # S 90 E will evaluate to 360 - if angle == 360.: - angle = 0. + if angle == 360.0: + angle = 0.0 return angle - diff --git a/src/ifcopenshell-python/ifcopenshell/api/cogo/edit_survey_point.py b/src/ifcopenshell-python/ifcopenshell/api/cogo/edit_survey_point.py index 46aaa1eff3..d2208dc649 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cogo/edit_survey_point.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cogo/edit_survey_point.py @@ -20,7 +20,8 @@ import ifcopenshell from ifcopenshell import entity_instance import typing -def edit_survey_point(annotation: entity_instance, x:float,y:float,z:float=0.0): + +def edit_survey_point(annotation: entity_instance, x: float, y: float, z: float = 0.0): """ Edits the location of a previously defined survey point @@ -35,6 +36,6 @@ def edit_survey_point(annotation: entity_instance, x:float,y:float,z:float=0.0): ifcopenshell.api.cogo.edit_surve_point(annotation,3500.0,2000.0) """ if annotation.Representation.Representations[0].Items[0].Dim == 2: - annotation.Representation.Representations[0].Items[0].Coordinates = ((x,y)) + annotation.Representation.Representations[0].Items[0].Coordinates = (x, y) else: - annotation.Representation.Representations[0].Items[0].Coordinates = ((x,y,z)) + annotation.Representation.Representations[0].Items[0].Coordinates = (x, y, z) diff --git a/src/ifcopenshell-python/ifcopenshell/util/stationing.py b/src/ifcopenshell-python/ifcopenshell/util/stationing.py index 3fff28b844..83669631ea 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/stationing.py +++ b/src/ifcopenshell-python/ifcopenshell/util/stationing.py @@ -20,6 +20,7 @@ import math import ifcopenshell import ifcopenshell.util.unit + def station_as_string(file: ifcopenshell.file, sta: float): """ Returns a stringized version of a station. Example 100.0 is 1+00.00 as a stationing string. @@ -28,18 +29,21 @@ def station_as_string(file: ifcopenshell.file, sta: float): :param station: the station to be stringized :return: stringized station """ - - unit_type = ifcopenshell.util.unit.get_project_unit(file,"LENGTHUNIT") + + unit_type = ifcopenshell.util.unit.get_project_unit(file, "LENGTHUNIT") if unit_type.is_a("IfcConversionBasedUnit"): - station = ifcopenshell.util.unit.convert(sta,from_unit=unit_type.Name,from_prefix=None,to_unit="foot",to_prefix=None) + station = ifcopenshell.util.unit.convert( + sta, from_unit=unit_type.Name, from_prefix=None, to_unit="foot", to_prefix=None + ) plus_seperator = 2 precision = 2 else: - station = ifcopenshell.util.unit.convert(sta,from_unit=unit_type.Name,from_prefix=unit_type.Prefix,to_unit="meter",to_prefix=None) + station = ifcopenshell.util.unit.convert( + sta, from_unit=unit_type.Name, from_prefix=unit_type.Prefix, to_unit="meter", to_prefix=None + ) plus_seperator = 3 precision = 3 - value = math.fabs(station) shifter = math.pow(10.0, plus_seperator) @@ -48,7 +52,7 @@ def station_as_string(file: ifcopenshell.file, sta: float): # Check to make sure that v2 is not basically the same as shifter # If station = 69500.00000, we sometimes get 694+100.00 instead of 695+00.00 - if math.isclose(v2-shifter, 0., abs_tol=5.0 * math.pow(10.0, -(precision + 1))): + if math.isclose(v2 - shifter, 0.0, abs_tol=5.0 * math.pow(10.0, -(precision + 1))): v2 = 0.0 v1 += 1 diff --git a/src/ifcopenshell-python/test/api/alignment/test_add_segment_to_layout.py b/src/ifcopenshell-python/test/api/alignment/test_add_segment_to_layout.py index fb88f14f59..78edd9d9e0 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_add_segment_to_layout.py +++ b/src/ifcopenshell-python/test/api/alignment/test_add_segment_to_layout.py @@ -22,11 +22,12 @@ import ifcopenshell.api.context from ifcopenshell.api.alignment._add_segment_to_layout import _add_segment_to_layout + def test_add_segment_to_layout(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -36,7 +37,7 @@ def test_add_segment_to_layout(): parent=geometric_representation_context, ) - alignment = ifcopenshell.api.alignment.create(file,"") + alignment = ifcopenshell.api.alignment.create(file, "") horizontal_alignment = ifcopenshell.api.alignment.get_horizontal_layout(alignment) design_parameters = file.create_entity( @@ -66,6 +67,10 @@ def test_add_segment_to_layout(): _add_segment_to_layout(file, horizontal_alignment, alignment_segment) assert len(horizontal_alignment.IsNestedBy) == 1 - assert len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 2 # The the segment we added and the automatically created zero length segment + assert ( + len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 2 + ) # The the segment we added and the automatically created zero length segment assert horizontal_alignment.IsNestedBy[0].RelatedObjects[0] == alignment_segment - assert alignment_segment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent") # a referent is automatically added at the start of the segment + assert ( + alignment_segment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent") + ) # a referent is automatically added at the start of the segment diff --git a/src/ifcopenshell-python/test/api/alignment/test_add_stationing_to_alignment.py b/src/ifcopenshell-python/test/api/alignment/test_add_stationing_to_alignment.py index 70d60290a6..5849f2f1c9 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_add_stationing_to_alignment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_add_stationing_to_alignment.py @@ -21,11 +21,12 @@ import ifcopenshell.api.alignment import ifcopenshell.api.context import ifcopenshell.util.element + def test_add_stationing_to_alignment(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -35,9 +36,7 @@ def test_add_stationing_to_alignment(): parent=geometric_representation_context, ) - alignment = ifcopenshell.api.alignment.create( - file, "TestAlignment", start_station=2000. - ) + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", start_station=2000.0) for rel in alignment.IsNestedBy: for referent in rel.RelatedObjects: diff --git a/src/ifcopenshell-python/test/api/alignment/test_add_vertical_alignment.py b/src/ifcopenshell-python/test/api/alignment/test_add_vertical_alignment.py index baad99ab1c..957379abee 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_add_vertical_alignment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_add_vertical_alignment.py @@ -23,9 +23,9 @@ import ifcopenshell.api.context def test_add_vertical_alignment(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -35,7 +35,7 @@ def test_add_vertical_alignment(): parent=geometric_representation_context, ) - alignment = ifcopenshell.api.alignment.create(file,"A1",include_vertical=False) + alignment = ifcopenshell.api.alignment.create(file, "A1", include_vertical=False) assert len(alignment.IsDecomposedBy) == 0 # no child alignments assert len(alignment.IsNestedBy) == 1 # one nest @@ -45,11 +45,13 @@ def test_add_vertical_alignment(): curve = ifcopenshell.api.alignment.get_curve(alignment) assert curve.is_a("IfcCompositeCurve") - vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file,alignment) + vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file, alignment) assert len(alignment.IsDecomposedBy) == 0 # no child alignments assert len(alignment.IsNestedBy) == 1 # one nest - assert len(alignment.IsNestedBy[0].RelatedObjects) == 3 # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical + assert ( + len(alignment.IsNestedBy[0].RelatedObjects) == 3 + ) # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent") assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal") assert alignment.IsNestedBy[0].RelatedObjects[2].is_a("IfcAlignmentVertical") @@ -57,7 +59,7 @@ def test_add_vertical_alignment(): assert curve.is_a("IfcGradientCurve") # add a second vertical alignment - vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file,alignment) + vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file, alignment) assert len(alignment.IsDecomposedBy) == 1 # 1 IfcRelAggreates relationship for the child algiments assert ( @@ -75,4 +77,5 @@ def test_add_vertical_alignment(): assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent") assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal") -test_add_vertical_alignment() \ No newline at end of file + +test_add_vertical_alignment() diff --git a/src/ifcopenshell-python/test/api/alignment/test_create_alignment.py b/src/ifcopenshell-python/test/api/alignment/test_create_alignment.py index ee49d235b9..2e5ec28f4d 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_create_alignment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_create_alignment.py @@ -24,9 +24,9 @@ import ifcopenshell.api.context def test_create_alignment(): file = ifcopenshell.file(schema="IFC4X3_ADD2") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -36,34 +36,36 @@ def test_create_alignment(): parent=geometric_representation_context, ) - include_vertical = [False,True,True] + include_vertical = [False, True, True] include_cant = [False, False, True] - expected_curve_type = ["IfcCompositeCurve","IfcGradientCurve","IfcSegmentedReferenceCurve"] + expected_curve_type = ["IfcCompositeCurve", "IfcGradientCurve", "IfcSegmentedReferenceCurve"] - for i in range(0,3) : - ali = ifcopenshell.api.alignment.create(file,"A1",include_vertical[i],include_cant[i]) + for i in range(0, 3): + ali = ifcopenshell.api.alignment.create(file, "A1", include_vertical[i], include_cant[i]) assert ali != None # verify the geometric representation was created curve = ifcopenshell.api.alignment.get_curve(ali) - assert(curve.is_a() == expected_curve_type[i]) + assert curve.is_a() == expected_curve_type[i] assert len(curve.Segments) == 1 horiz = ifcopenshell.api.alignment.get_horizontal_layout(ali) vert = ifcopenshell.api.alignment.get_vertical_layout(ali) cant = ifcopenshell.api.alignment.get_cant_layout(ali) - + assert horiz != None if include_vertical[i]: assert vert != None - + if include_cant[i]: assert cant != None # verify each layout has a zero length segment (which also tests if the geometry curve has a zero length segment) - alignments = [horiz,vert,cant] + alignments = [horiz, vert, cant] for a in alignments: if a != None: segments = ifcopenshell.api.alignment.get_layout_segments(a) assert len(segments) == 1 - assert ifcopenshell.api.alignment.has_zero_length_segment(a) # there is a check in this function for the geometry curve + assert ifcopenshell.api.alignment.has_zero_length_segment( + a + ) # there is a check in this function for the geometry curve diff --git a/src/ifcopenshell-python/test/api/alignment/test_create_alignment_by_pi_method.py b/src/ifcopenshell-python/test/api/alignment/test_create_alignment_by_pi_method.py index d1a9fb6aaf..17f37ded98 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_create_alignment_by_pi_method.py +++ b/src/ifcopenshell-python/test/api/alignment/test_create_alignment_by_pi_method.py @@ -23,9 +23,9 @@ import ifcopenshell.api.context def test_create_alignment_pi_method(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -40,18 +40,27 @@ def test_create_alignment_pi_method(): vpoints = [(0.0, 100.0), (2000.0, 135.0), (5000.0, 105.0), (7400.0, 153.0), (9800.0, 105.0), (12800.0, 90.0)] lengths = [(1600.0), (1200.0), (2000.0), (800.0)] - alignment = ifcopenshell.api.alignment.create_by_pi_method(file, "TestAlignment", coordinates, radii, vpoints, lengths) + alignment = ifcopenshell.api.alignment.create_by_pi_method( + file, "TestAlignment", coordinates, radii, vpoints, lengths + ) assert len(alignment.IsDecomposedBy) == 0 # no child alignments assert len(alignment.IsNestedBy) == 1 # one nest - assert len(alignment.IsNestedBy[0].RelatedObjects) == 3 # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical + assert ( + len(alignment.IsNestedBy[0].RelatedObjects) == 3 + ) # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent") assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal") assert alignment.IsNestedBy[0].RelatedObjects[2].is_a("IfcAlignmentVertical") assert ( len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy) == 1 ) # nesting of segments beneath IfcAlignmentHorizontal - assert len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 8 # segments in horizontal layout - assert len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 10 # segments in vertical layout + assert ( + len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 8 + ) # segments in horizontal layout + assert ( + len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 10 + ) # segments in vertical layout -test_create_alignment_pi_method() \ No newline at end of file + +test_create_alignment_pi_method() diff --git a/src/ifcopenshell-python/test/api/alignment/test_create_layout_segment.py b/src/ifcopenshell-python/test/api/alignment/test_create_layout_segment.py index ab80f37bc3..f7d8f98432 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_create_layout_segment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_create_layout_segment.py @@ -22,11 +22,12 @@ import ifcopenshell.api.context from ifcopenshell import entity_instance import math + def _test_horizontal() -> ifcopenshell.file: file = ifcopenshell.file(schema="IFC4X3_ADD2") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -37,13 +38,13 @@ def _test_horizontal() -> ifcopenshell.file: ) # creates an IfcAlignment with an IfcAlignmentHorizontal layout containing only the zero length segment - ali = ifcopenshell.api.alignment.create(file,"A1") + ali = ifcopenshell.api.alignment.create(file, "A1") # append a segment to the horizontal layout horizontal_alignment = ifcopenshell.api.alignment.get_horizontal_layout(ali) curve = ifcopenshell.api.alignment.get_curve(horizontal_alignment) - assert curve == None # for single horizontal, geometric representation is on IfcAlignment + assert curve == None # for single horizontal, geometric representation is on IfcAlignment curve = ifcopenshell.api.alignment.get_curve(ali) assert curve.is_a("IfcCompositeCurve") assert len(curve.Segments) == 1 @@ -60,14 +61,14 @@ def _test_horizontal() -> ifcopenshell.file: GravityCenterLineHeight=None, PredefinedType="LINE", ) - end = ifcopenshell.api.alignment.create_layout_segment(file,horizontal_alignment,design_parameters) + end = ifcopenshell.api.alignment.create_layout_segment(file, horizontal_alignment, design_parameters) assert len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 2 - x = end[0,3] - y = end[1,3] - z = end[2,3] - + x = end[0, 3] + y = end[1, 3] + z = end[2, 3] + assert x == 100.0 assert y == 0.0 assert z == 0.0 @@ -76,13 +77,12 @@ def _test_horizontal() -> ifcopenshell.file: assert curve.is_a("IfcCompositeCurve") assert len(curve.Segments) == 2 - design_parameters = file.create_entity( type="IfcAlignmentHorizontalSegment", StartTag=None, EndTag=None, StartPoint=file.createIfcCartesianPoint(Coordinates=((x.item(), y.item()))), - StartDirection=math.pi/6, + StartDirection=math.pi / 6, StartRadiusOfCurvature=0.0, EndRadiusOfCurvature=0.0, SegmentLength=50.0, @@ -90,15 +90,15 @@ def _test_horizontal() -> ifcopenshell.file: PredefinedType="LINE", ) - end = ifcopenshell.api.alignment.create_layout_segment(file,horizontal_alignment,design_parameters) + end = ifcopenshell.api.alignment.create_layout_segment(file, horizontal_alignment, design_parameters) assert len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 3 - x = end[0,3] - y = end[1,3] - z = end[2,3] - - assert x == 100.0 + 50.0*math.cos(math.pi/6) - assert y == 50.0*math.sin(math.pi/6) + x = end[0, 3] + y = end[1, 3] + z = end[2, 3] + + assert x == 100.0 + 50.0 * math.cos(math.pi / 6) + assert y == 50.0 * math.sin(math.pi / 6) assert z == 0.0 curve = ifcopenshell.api.alignment.get_curve(ali) @@ -110,9 +110,9 @@ def _test_horizontal() -> ifcopenshell.file: def _test_horizontal_vertical(): file = ifcopenshell.file(schema="IFC4X3_ADD2") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -123,7 +123,7 @@ def _test_horizontal_vertical(): ) # creates an IfcAlignment with an IfcAlignmentHorizontal layout containing only the zero length segment - ali = ifcopenshell.api.alignment.create(file,"A1",True) + ali = ifcopenshell.api.alignment.create(file, "A1", True) # append a segment to the horizontal layout horizontal_alignment = ifcopenshell.api.alignment.get_horizontal_layout(ali) @@ -154,53 +154,53 @@ def _test_horizontal_vertical(): GravityCenterLineHeight=None, PredefinedType="LINE", ) - end = ifcopenshell.api.alignment.create_layout_segment(file,horizontal_alignment,design_parameters) + end = ifcopenshell.api.alignment.create_layout_segment(file, horizontal_alignment, design_parameters) basis_curve = ifcopenshell.api.alignment.get_basis_curve(ali) assert basis_curve.is_a("IfcCompositeCurve") assert len(basis_curve.Segments) == 2 - + design_parameters = file.createIfcAlignmentVerticalSegment( StartDistAlong=0.0, HorizontalLength=50.0, StartHeight=20.0, - StartGradient = 1./100., - EndGradient = 1./100., - PredefinedType="CONSTANTGRADIENT" - ) - end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters) + StartGradient=1.0 / 100.0, + EndGradient=1.0 / 100.0, + PredefinedType="CONSTANTGRADIENT", + ) + end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters) assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 2 - x = end[0,3] - y = end[1,3] - z = end[2,3] - - assert x == 50. + x = end[0, 3] + y = end[1, 3] + z = end[2, 3] + + assert x == 50.0 assert y == 20.5 assert z == 0.0 - dx = end[0,0] - dy = end[1,0] - gradient = dy/dx + dx = end[0, 0] + dy = end[1, 0] + gradient = dy / dx design_parameters = file.createIfcAlignmentVerticalSegment( StartDistAlong=50.0, HorizontalLength=50.0, StartHeight=y.item(), - StartGradient = -gradient, - EndGradient = -gradient, - PredefinedType="CONSTANTGRADIENT" - ) - end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters) + StartGradient=-gradient, + EndGradient=-gradient, + PredefinedType="CONSTANTGRADIENT", + ) + end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters) assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 3 - x = end[0,3] - y = end[1,3] - z = end[2,3] - - assert x == 100. - assert y == 20. + x = end[0, 3] + y = end[1, 3] + z = end[2, 3] + + assert x == 100.0 + assert y == 20.0 assert z == 0.0 basis_curve = ifcopenshell.api.alignment.get_basis_curve(ali) @@ -216,60 +216,62 @@ def _test_horizontal_vertical2(file: ifcopenshell.file): vertical_alignment = ifcopenshell.api.alignment.get_vertical_layout(ali) assert vertical_alignment == None - - vertical_alignment = ifcopenshell.api.alignment.add_vertical_layout(file,ali) + + vertical_alignment = ifcopenshell.api.alignment.add_vertical_layout(file, ali) design_parameters = file.createIfcAlignmentVerticalSegment( StartDistAlong=0.0, HorizontalLength=50.0, StartHeight=20.0, - StartGradient = 1./100., - EndGradient = 1./100., - PredefinedType="CONSTANTGRADIENT" - ) - end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters) + StartGradient=1.0 / 100.0, + EndGradient=1.0 / 100.0, + PredefinedType="CONSTANTGRADIENT", + ) + end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters) assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 2 - x = end[0,3] - y = end[1,3] - z = end[2,3] - - assert x == 50. + x = end[0, 3] + y = end[1, 3] + z = end[2, 3] + + assert x == 50.0 assert y == 20.5 assert z == 0.0 - dx = end[0,0] - dy = end[1,0] - gradient = dy/dx + dx = end[0, 0] + dy = end[1, 0] + gradient = dy / dx design_parameters = file.createIfcAlignmentVerticalSegment( StartDistAlong=50.0, HorizontalLength=50.0, StartHeight=y.item(), - StartGradient = -gradient, - EndGradient = -gradient, - PredefinedType="CONSTANTGRADIENT" - ) - end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters) + StartGradient=-gradient, + EndGradient=-gradient, + PredefinedType="CONSTANTGRADIENT", + ) + end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters) assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 3 - x = end[0,3] - y = end[1,3] - z = end[2,3] - - assert x == 100. - assert y == 20. + x = end[0, 3] + y = end[1, 3] + z = end[2, 3] + + assert x == 100.0 + assert y == 20.0 assert z == 0.0 curve = ifcopenshell.api.alignment.get_curve(ali) assert curve.is_a("IfcGradientCurve") assert len(curve.Segments) == 3 + def test_append_segment(): file = _test_horizontal() _test_horizontal_vertical() _test_horizontal_vertical2(file) -test_append_segment() \ No newline at end of file + +test_append_segment() diff --git a/src/ifcopenshell-python/test/api/alignment/test_distance_along_from_station.py b/src/ifcopenshell-python/test/api/alignment/test_distance_along_from_station.py index 4232b406dc..28d2216a9f 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_distance_along_from_station.py +++ b/src/ifcopenshell-python/test/api/alignment/test_distance_along_from_station.py @@ -20,11 +20,12 @@ import pytest import ifcopenshell.api.alignment import ifcopenshell.api.context + def test_distance_along_from_station(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -40,7 +41,7 @@ def test_distance_along_from_station(): lengths = [(1600.0), (1200.0), (2000.0), (800.0)] alignment = ifcopenshell.api.alignment.create_by_pi_method( - file, "TestAlignment", coordinates, radii, vpoints, lengths,start_station=10000.0 + file, "TestAlignment", coordinates, radii, vpoints, lengths, start_station=10000.0 ) # Station 138+83.96 @@ -50,4 +51,4 @@ def test_distance_along_from_station(): assert ifcopenshell.api.alignment.distance_along_from_station(file, alignment, 17525.36) == pytest.approx(7525.36) -test_distance_along_from_station() \ No newline at end of file +test_distance_along_from_station() diff --git a/src/ifcopenshell-python/test/api/alignment/test_get_alignment.py b/src/ifcopenshell-python/test/api/alignment/test_get_alignment.py index d7d1a68a23..ed9a1d2d33 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_get_alignment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_get_alignment.py @@ -23,9 +23,9 @@ import ifcopenshell.api.context def test_get_alignment(): file = ifcopenshell.file(schema="IFC4X3_ADD2") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -35,11 +35,11 @@ def test_get_alignment(): parent=geometric_representation_context, ) - include_vertical = [False,True,True] + include_vertical = [False, True, True] include_cant = [False, False, True] - for i in range(0,3) : - ali = ifcopenshell.api.alignment.create(file,"A1",include_vertical[i],include_cant[i]) + for i in range(0, 3): + ali = ifcopenshell.api.alignment.create(file, "A1", include_vertical[i], include_cant[i]) assert ali != None horiz = ifcopenshell.api.alignment.get_horizontal_layout(ali) @@ -49,6 +49,6 @@ def test_get_alignment(): assert ali == ifcopenshell.api.alignment.get_alignment(horiz) if include_vertical[i]: assert ali == ifcopenshell.api.alignment.get_alignment(vert) - + if include_cant[i]: assert ali == ifcopenshell.api.alignment.get_alignment(cant) diff --git a/src/ifcopenshell-python/test/api/alignment/test_get_basis_curve.py b/src/ifcopenshell-python/test/api/alignment/test_get_basis_curve.py index 65fe9d6f62..8541212291 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_get_basis_curve.py +++ b/src/ifcopenshell-python/test/api/alignment/test_get_basis_curve.py @@ -24,9 +24,9 @@ import ifcopenshell.api.context def _test_horizontal(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -43,9 +43,9 @@ def _test_horizontal(): def _test_horizontal_and_vertical(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -55,17 +55,16 @@ def _test_horizontal_and_vertical(): parent=geometric_representation_context, ) - alignment = ifcopenshell.api.alignment.create( - file, "TestAlignment", include_vertical=True - ) + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True) basis_curve = ifcopenshell.api.alignment.get_basis_curve(alignment) assert basis_curve.is_a("IfcCompositeCurve") + def _test_horizontal_and_vertical_and_cant(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -75,12 +74,11 @@ def _test_horizontal_and_vertical_and_cant(): parent=geometric_representation_context, ) - alignment = ifcopenshell.api.alignment.create( - file, "TestAlignment", include_vertical=True,include_cant=True - ) + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True) basis_curve = ifcopenshell.api.alignment.get_basis_curve(alignment) assert basis_curve.is_a("IfcCompositeCurve") + def test_get_basis_curve(): _test_horizontal() _test_horizontal_and_vertical() diff --git a/src/ifcopenshell-python/test/api/alignment/test_get_curve.py b/src/ifcopenshell-python/test/api/alignment/test_get_curve.py index 478c0c4e38..e74de3458f 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_get_curve.py +++ b/src/ifcopenshell-python/test/api/alignment/test_get_curve.py @@ -18,11 +18,12 @@ import ifcopenshell.api.alignment + def test_get_curve(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -32,14 +33,14 @@ def test_get_curve(): parent=geometric_representation_context, ) - alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=False,include_cant=False) + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=False, include_cant=False) curve = ifcopenshell.api.alignment.get_curve(alignment) assert curve.is_a("IfcCompositeCurve") - alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=False) + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=False) curve = ifcopenshell.api.alignment.get_curve(alignment) assert curve.is_a("IfcGradientCurve") - alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=True) + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True) curve = ifcopenshell.api.alignment.get_curve(alignment) assert curve.is_a("IfcSegmentedReferenceCurve") diff --git a/src/ifcopenshell-python/test/api/alignment/test_get_layout_curve.py b/src/ifcopenshell-python/test/api/alignment/test_get_layout_curve.py index 97d63a62ab..0c457988c1 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_get_layout_curve.py +++ b/src/ifcopenshell-python/test/api/alignment/test_get_layout_curve.py @@ -18,11 +18,12 @@ import ifcopenshell.api.alignment + def test_get_layout_curve(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -32,12 +33,12 @@ def test_get_layout_curve(): parent=geometric_representation_context, ) - alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=False,include_cant=False) + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=False, include_cant=False) layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) curve = ifcopenshell.api.alignment.get_layout_curve(layout) assert curve.is_a("IfcCompositeCurve") - alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=False) + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=False) layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) curve = ifcopenshell.api.alignment.get_layout_curve(layout) assert curve.is_a("IfcCompositeCurve") @@ -45,7 +46,7 @@ def test_get_layout_curve(): curve = ifcopenshell.api.alignment.get_layout_curve(layout) assert curve.is_a("IfcGradientCurve") - alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=True) + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True) layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) curve = ifcopenshell.api.alignment.get_layout_curve(layout) assert curve.is_a("IfcCompositeCurve") diff --git a/src/ifcopenshell-python/test/api/alignment/test_has_zero_length_segment.py b/src/ifcopenshell-python/test/api/alignment/test_has_zero_length_segment.py index 51d8c86326..370101ad14 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_has_zero_length_segment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_has_zero_length_segment.py @@ -20,11 +20,12 @@ import ifcopenshell.api.alignment import ifcopenshell.api.alignment.has_zero_length_segment import ifcopenshell.api.context + def _test_horizontal(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -34,15 +35,16 @@ def _test_horizontal(): parent=geometric_representation_context, ) - alignment = ifcopenshell.api.alignment.create(file,"TestAlignment") + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment") horizontal = ifcopenshell.api.alignment.get_horizontal_layout(alignment) assert True == ifcopenshell.api.alignment.has_zero_length_segment(horizontal) + def _test_horizontal_vertical(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -52,17 +54,18 @@ def _test_horizontal_vertical(): parent=geometric_representation_context, ) - alignment = ifcopenshell.api.alignment.create(file,"TestAlignment",include_vertical=True) + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True) horizontal = ifcopenshell.api.alignment.get_horizontal_layout(alignment) assert True == ifcopenshell.api.alignment.has_zero_length_segment(horizontal) vertical = ifcopenshell.api.alignment.get_vertical_layout(alignment) assert True == ifcopenshell.api.alignment.has_zero_length_segment(vertical) + def _test_horizontal_vertical_cant(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -72,7 +75,7 @@ def _test_horizontal_vertical_cant(): parent=geometric_representation_context, ) - alignment = ifcopenshell.api.alignment.create(file,"TestAlignment",include_vertical=True,include_cant=True) + alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True) horizontal = ifcopenshell.api.alignment.get_horizontal_layout(alignment) assert True == ifcopenshell.api.alignment.has_zero_length_segment(horizontal) vertical = ifcopenshell.api.alignment.get_vertical_layout(alignment) @@ -80,10 +83,11 @@ def _test_horizontal_vertical_cant(): cant = ifcopenshell.api.alignment.get_cant_layout(alignment) assert True == ifcopenshell.api.alignment.has_zero_length_segment(cant) + def test_has_zero_length_segment(): _test_horizontal() _test_horizontal_vertical() _test_horizontal_vertical_cant() -test_has_zero_length_segment() \ No newline at end of file +test_has_zero_length_segment() diff --git a/src/ifcopenshell-python/test/api/alignment/test_horizontal_layout_by_pi_method.py b/src/ifcopenshell-python/test/api/alignment/test_horizontal_layout_by_pi_method.py index abde22e606..61b1ba20ca 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_horizontal_layout_by_pi_method.py +++ b/src/ifcopenshell-python/test/api/alignment/test_horizontal_layout_by_pi_method.py @@ -20,14 +20,15 @@ import pytest import ifcopenshell.api.alignment import ifcopenshell.api.context + # other test cases cover the typical vertical by PI method (test_create_alignment_by_pi_method) # this test will focus on the edge cases of no initial tangent run, no final tangent run, and # compound curve (no tangent between curves) def test_horizontal_layout_by_pi_method(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -50,6 +51,9 @@ def test_horizontal_layout_by_pi_method(): assert ( len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy) == 1 ) # nesting of segments beneath IfcAlignmentHorizontal - assert len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 3 # segments in horizontal layout + assert ( + len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 3 + ) # segments in horizontal layout -test_horizontal_layout_by_pi_method() \ No newline at end of file + +test_horizontal_layout_by_pi_method() diff --git a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py index 6caaf930f2..483e7b977c 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py @@ -21,6 +21,7 @@ import ifcopenshell.api.alignment import ifcopenshell.api.context from ifcopenshell.api.alignment._map_alignment_cant_segment import _map_alignment_cant_segment + def _BlossCurve_100_0_300_1000_1_Meter(file): design_parameters = file.createIfcAlignmentCantSegment( StartDistAlong=0.0, diff --git a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py index c6e9e831c2..58c98980ba 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py @@ -23,6 +23,7 @@ import pytest import ifcopenshell.api.alignment from ifcopenshell.api.alignment._map_alignment_horizontal_segment import __map_alignment_horizontal_segment + def _BlossCurve_100_0_300_1000_1_Meter(file): design_parameters = file.createIfcAlignmentHorizontalSegment( StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), diff --git a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_vertical_segment.py b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_vertical_segment.py index ff2bcdbbc1..c7f4cb3348 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_vertical_segment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_vertical_segment.py @@ -23,6 +23,7 @@ import pytest import ifcopenshell.api.alignment from ifcopenshell.api.alignment._map_alignment_vertical_segment import _map_alignment_vertical_segment + def _CircularArc_100_0_10_0_0_0_0_5_1_Meter(file): design_parameters = file.createIfcAlignmentVerticalSegment( StartDistAlong=0.0, diff --git a/src/ifcopenshell-python/test/api/alignment/test_name_segments.py b/src/ifcopenshell-python/test/api/alignment/test_name_segments.py index c5461f80a4..0a95d0dfec 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_name_segments.py +++ b/src/ifcopenshell-python/test/api/alignment/test_name_segments.py @@ -23,9 +23,9 @@ import ifcopenshell.api.context def test_name_segments(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, diff --git a/src/ifcopenshell-python/test/api/alignment/test_referent_names.py b/src/ifcopenshell-python/test/api/alignment/test_referent_names.py index d271dfb924..d48a82c697 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_referent_names.py +++ b/src/ifcopenshell-python/test/api/alignment/test_referent_names.py @@ -42,8 +42,9 @@ def default_names_alignment(): vpoints = [(0.0, 100.0), (2000.0, 135.0), (5000.0, 105.0), (7400.0, 153.0), (9800.0, 105.0), (12800.0, 90.0)] lengths = [(1600.0), (1200.0), (2000.0), (800.0)] - alignment = ifcopenshell.api.alignment.create_by_pi_method(file, "TestAlignment", coordinates, radii, vpoints, - lengths) + alignment = ifcopenshell.api.alignment.create_by_pi_method( + file, "TestAlignment", coordinates, radii, vpoints, lengths + ) yield alignment @@ -88,8 +89,9 @@ def callback_alignment(): vpoints = [(0.0, 100.0), (2000.0, 135.0), (5000.0, 105.0), (7400.0, 153.0), (9800.0, 105.0), (12800.0, 90.0)] lengths = [(1600.0), (1200.0), (2000.0), (800.0)] - alignment = ifcopenshell.api.alignment.create_by_pi_method(file, "TestAlignment", coordinates, radii, vpoints, - lengths) + alignment = ifcopenshell.api.alignment.create_by_pi_method( + file, "TestAlignment", coordinates, radii, vpoints, lengths + ) yield alignment @@ -108,6 +110,7 @@ def test_with_default_names(default_names_alignment): assert "P.V.T." in vlayout.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects[0].Name assert "V.P.O.E." in vlayout.IsNestedBy[0].RelatedObjects[-1].IsNestedBy[0].RelatedObjects[0].Name + def test_with_callbacks(callback_alignment): hlayout = ifcopenshell.api.alignment.get_horizontal_layout(callback_alignment) diff --git a/src/ifcopenshell-python/test/api/alignment/test_update_curve_segment_transition_code.py b/src/ifcopenshell-python/test/api/alignment/test_update_curve_segment_transition_code.py index 4d47d4aec7..778bf2d69c 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_update_curve_segment_transition_code.py +++ b/src/ifcopenshell-python/test/api/alignment/test_update_curve_segment_transition_code.py @@ -17,15 +17,15 @@ # along with IfcOpenShell. If not, see . import pytest -from ifcopenshell.api.alignment._update_curve_segment_transition_code import _update_curve_segment_transition_code +from ifcopenshell.api.alignment._update_curve_segment_transition_code import _update_curve_segment_transition_code import ifcopenshell.api.context def _test1(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -223,18 +223,20 @@ def _test2(): ), ) - composite_curve = file.createIfcCompositeCurve(Segments=[line1,clothoid1,circular_arc,clothoid2,line2], SelfIntersect=False) + composite_curve = file.createIfcCompositeCurve( + Segments=[line1, clothoid1, circular_arc, clothoid2, line2], SelfIntersect=False + ) - _update_curve_segment_transition_code(line1,clothoid1) + _update_curve_segment_transition_code(line1, clothoid1) assert line1.Transition == "CONTSAMEGRADIENTSAMECURVATURE" - _update_curve_segment_transition_code(clothoid1,circular_arc) + _update_curve_segment_transition_code(clothoid1, circular_arc) assert clothoid1.Transition == "CONTSAMEGRADIENTSAMECURVATURE" - _update_curve_segment_transition_code(circular_arc,clothoid2) + _update_curve_segment_transition_code(circular_arc, clothoid2) assert circular_arc.Transition == "CONTSAMEGRADIENTSAMECURVATURE" - _update_curve_segment_transition_code(clothoid2,line2) + _update_curve_segment_transition_code(clothoid2, line2) assert clothoid2.Transition == "CONTSAMEGRADIENTSAMECURVATURE" @@ -242,4 +244,5 @@ def test_update_curve_segment_transition_code(): _test1() _test2() -test_update_curve_segment_transition_code() \ No newline at end of file + +test_update_curve_segment_transition_code() diff --git a/src/ifcopenshell-python/test/api/alignment/test_vertical_layout_by_pi_method.py b/src/ifcopenshell-python/test/api/alignment/test_vertical_layout_by_pi_method.py index 53bf39c212..65a5de4642 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_vertical_layout_by_pi_method.py +++ b/src/ifcopenshell-python/test/api/alignment/test_vertical_layout_by_pi_method.py @@ -20,14 +20,15 @@ import pytest import ifcopenshell.api.alignment import ifcopenshell.api.context + # other test cases cover the typical vertical by PI method (test_create_alignment_by_pi_method) # this test will focus on the edge cases of no initial gradient, no final gradient, and # compound vertical curve (no gradient between curves) def test_vertical_layout_by_pi_method(): file = ifcopenshell.file(schema="IFC4X3") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot") + ifcopenshell.api.unit.assign_unit(file, units=[length]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -37,35 +38,41 @@ def test_vertical_layout_by_pi_method(): parent=geometric_representation_context, ) - alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True) hlayout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) segment1 = file.createIfcAlignmentHorizontalSegment( - StartPoint=file.createIfcCartesianPoint(Coordinates=((0.,0.))), # Actual coordinate unknown + StartPoint=file.createIfcCartesianPoint(Coordinates=((0.0, 0.0))), # Actual coordinate unknown StartDirection=0.0, StartRadiusOfCurvature=0.0, EndRadiusOfCurvature=0.0, SegmentLength=10000.0, - PredefinedType = "LINE" + PredefinedType="LINE", ) - ifcopenshell.api.alignment.create_layout_segment(file,hlayout,segment1) + ifcopenshell.api.alignment.create_layout_segment(file, hlayout, segment1) vpoints = [(0.0, 110.0), (400.0, 100.0), (800.0, 115.0), (1300.0, 125.0), (1800.0, 105.0)] lengths = [(800.0), (0.0), (1000.0)] vlayout = ifcopenshell.api.alignment.get_vertical_layout(alignment) - ifcopenshell.api.alignment.layout_vertical_alignment_by_pi_method(file,vlayout,vpoints,lengths) + ifcopenshell.api.alignment.layout_vertical_alignment_by_pi_method(file, vlayout, vpoints, lengths) assert len(alignment.IsDecomposedBy) == 0 # no child alignments assert len(alignment.IsNestedBy) == 1 # one nest - assert len(alignment.IsNestedBy[0].RelatedObjects) == 3 # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical + assert ( + len(alignment.IsNestedBy[0].RelatedObjects) == 3 + ) # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent") assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal") assert alignment.IsNestedBy[0].RelatedObjects[2].is_a("IfcAlignmentVertical") assert ( len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy) == 1 ) # nesting of segments beneath IfcAlignmentHorizontal - assert len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 2 # segments in horizontal layout - assert len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 3 # segments in vertical layout + assert ( + len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 2 + ) # segments in horizontal layout + assert ( + len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 3 + ) # segments in vertical layout -test_vertical_layout_by_pi_method() \ No newline at end of file + +test_vertical_layout_by_pi_method() diff --git a/src/ifcopenshell-python/test/api/cogo/test_add_survey_point.py b/src/ifcopenshell-python/test/api/cogo/test_add_survey_point.py index f142f4318f..c5fe9e195c 100644 --- a/src/ifcopenshell-python/test/api/cogo/test_add_survey_point.py +++ b/src/ifcopenshell-python/test/api/cogo/test_add_survey_point.py @@ -25,8 +25,8 @@ import ifcopenshell.api.cogo def test_add_survey_point(): file = ifcopenshell.file(schema="IFC4X3_ADD2") project = file.createIfcProject(Name="Test") - site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(),Name="MySite") - ifcopenshell.api.aggregate.assign_object(file,relating_object=project,products=[site]) + site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite") + ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -36,10 +36,9 @@ def test_add_survey_point(): parent=geometric_representation_context, ) - annotation = ifcopenshell.api.cogo.add_survey_point(file,file.createIfcCartesianPoint((50.0,10.0))) + annotation = ifcopenshell.api.cogo.add_survey_point(file, file.createIfcCartesianPoint((50.0, 10.0))) assert annotation assert annotation.PredefinedType == "SURVEY" assert annotation.Representation.Representations[0].RepresentationIdentifier == "Annotation" assert annotation.Representation.Representations[0].RepresentationType == "Point" - assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0,10.0)) - + assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0, 10.0)) diff --git a/src/ifcopenshell-python/test/api/cogo/test_assign_survey_point.py b/src/ifcopenshell-python/test/api/cogo/test_assign_survey_point.py index 83e7fd5fac..0f957eb98d 100644 --- a/src/ifcopenshell-python/test/api/cogo/test_assign_survey_point.py +++ b/src/ifcopenshell-python/test/api/cogo/test_assign_survey_point.py @@ -25,8 +25,8 @@ import ifcopenshell.api.cogo def test_assign_survey_point(): file = ifcopenshell.file(schema="IFC4X3_ADD2") project = file.createIfcProject(Name="Test") - site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(),Name="MySite") - ifcopenshell.api.aggregate.assign_object(file,relating_object=project,products=[site]) + site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite") + ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -36,13 +36,12 @@ def test_assign_survey_point(): parent=geometric_representation_context, ) - annotation = ifcopenshell.api.cogo.add_survey_point(file,file.createIfcCartesianPoint((50.0,10.0))) + annotation = ifcopenshell.api.cogo.add_survey_point(file, file.createIfcCartesianPoint((50.0, 10.0))) assert annotation assert annotation.PredefinedType == "SURVEY" assert annotation.Representation.Representations[0].RepresentationIdentifier == "Annotation" assert annotation.Representation.Representations[0].RepresentationType == "Point" - assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0,10.0)) - - ifcopenshell.api.cogo.assign_survey_point(annotation,file.createIfcCartesianPoint((20.0,30.0,40.0))) - assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0,30.0,40.0)) + assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0, 10.0)) + ifcopenshell.api.cogo.assign_survey_point(annotation, file.createIfcCartesianPoint((20.0, 30.0, 40.0))) + assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0, 30.0, 40.0)) diff --git a/src/ifcopenshell-python/test/api/cogo/test_bearing2dd.py b/src/ifcopenshell-python/test/api/cogo/test_bearing2dd.py index 41a23c2779..657c0a65a8 100644 --- a/src/ifcopenshell-python/test/api/cogo/test_bearing2dd.py +++ b/src/ifcopenshell-python/test/api/cogo/test_bearing2dd.py @@ -35,39 +35,39 @@ def test_bearing2dd(): assert 0.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 90 E")) assert 0.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("S 90 E")) - assert 180. == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 90 W")) - assert 180. == pytest.approx(ifcopenshell.api.cogo.bearing2dd("S 90 W")) - - assert 120. == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 30 W")) + assert 180.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 90 W")) + assert 180.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("S 90 W")) + + assert 120.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 30 W")) assert 120.16666666666667 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 30 10 W")) assert 89.999722222222228 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 00 00 1 E")) assert 89.99972222222222 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 0 0 1 E")) assert 89.99972222222222 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 00 00 1.0 E")) - with pytest.raises(ValueError,match="Invalid bearing string"): + with pytest.raises(ValueError, match="Invalid bearing string"): ifcopenshell.api.cogo.bearing2dd("Bad String") - with pytest.raises(ValueError,match="Invalid bearing string"): + with pytest.raises(ValueError, match="Invalid bearing string"): ifcopenshell.api.cogo.bearing2dd("Very Bad String") - with pytest.raises(ValueError,match="Invalid bearing string"): + with pytest.raises(ValueError, match="Invalid bearing string"): ifcopenshell.api.cogo.bearing2dd("N 100 15 22.5 E") - with pytest.raises(ValueError,match="Invalid bearing string"): + with pytest.raises(ValueError, match="Invalid bearing string"): ifcopenshell.api.cogo.bearing2dd("N -45 15 22.5 E") - with pytest.raises(ValueError,match="Invalid bearing string"): + with pytest.raises(ValueError, match="Invalid bearing string"): ifcopenshell.api.cogo.bearing2dd("N 45 -15 22.5 E") - with pytest.raises(ValueError,match="Invalid bearing string"): + with pytest.raises(ValueError, match="Invalid bearing string"): ifcopenshell.api.cogo.bearing2dd("N 45 88 22.5 E") - with pytest.raises(ValueError,match="Invalid bearing string"): + with pytest.raises(ValueError, match="Invalid bearing string"): ifcopenshell.api.cogo.bearing2dd("N 45 15 -22.5 E") - with pytest.raises(ValueError,match="Invalid bearing string"): + with pytest.raises(ValueError, match="Invalid bearing string"): ifcopenshell.api.cogo.bearing2dd("N 45 15 99.5 E") -test_bearing2dd() +test_bearing2dd() diff --git a/src/ifcopenshell-python/test/api/cogo/test_edit_survey_point.py b/src/ifcopenshell-python/test/api/cogo/test_edit_survey_point.py index 59426acae7..5a8b1b3a75 100644 --- a/src/ifcopenshell-python/test/api/cogo/test_edit_survey_point.py +++ b/src/ifcopenshell-python/test/api/cogo/test_edit_survey_point.py @@ -25,8 +25,8 @@ import ifcopenshell.api.cogo def test_edit_survey_point(): file = ifcopenshell.file(schema="IFC4X3_ADD2") project = file.createIfcProject(Name="Test") - site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(),Name="MySite") - ifcopenshell.api.aggregate.assign_object(file,relating_object=project,products=[site]) + site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite") + ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site]) geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model") axis_model_representation_subcontext = ifcopenshell.api.context.add_context( file, @@ -36,13 +36,12 @@ def test_edit_survey_point(): parent=geometric_representation_context, ) - annotation = ifcopenshell.api.cogo.add_survey_point(file,file.createIfcCartesianPoint((50.0,10.0))) + annotation = ifcopenshell.api.cogo.add_survey_point(file, file.createIfcCartesianPoint((50.0, 10.0))) assert annotation assert annotation.PredefinedType == "SURVEY" assert annotation.Representation.Representations[0].RepresentationIdentifier == "Annotation" assert annotation.Representation.Representations[0].RepresentationType == "Point" - assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0,10.0)) - - ifcopenshell.api.cogo.edit_survey_point(annotation,20.0,30.0) - assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0,30.0)) + assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0, 10.0)) + ifcopenshell.api.cogo.edit_survey_point(annotation, 20.0, 30.0) + assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0, 30.0)) diff --git a/src/ifcopenshell-python/test/util/test_stationing.py b/src/ifcopenshell-python/test/util/test_stationing.py index 0cc6a9d27f..931db5d33b 100644 --- a/src/ifcopenshell-python/test/util/test_stationing.py +++ b/src/ifcopenshell-python/test/util/test_stationing.py @@ -19,57 +19,60 @@ import ifcopenshell import ifcopenshell.util.stationing as sta + def _test_si_stations(): file = ifcopenshell.file(schema="IFC4X3_ADD2") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") # meter - ifcopenshell.api.unit.assign_unit(file,units=[length]) - - s = sta.station_as_string(file,0.0) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") # meter + ifcopenshell.api.unit.assign_unit(file, units=[length]) + + s = sta.station_as_string(file, 0.0) assert s == "0+000.000" - s = sta.station_as_string(file,100.00) + s = sta.station_as_string(file, 100.00) assert s == "0+100.000" - s = sta.station_as_string(file,-100.00) + s = sta.station_as_string(file, -100.00) assert s == "-0+100.000" - s = sta.station_as_string(file,123456.789) + s = sta.station_as_string(file, 123456.789) assert s == "123+456.789" - s = sta.station_as_string(file,-123456.789) + s = sta.station_as_string(file, -123456.789) assert s == "-123+456.789" + def _test_si_stations_millimeter(): file = ifcopenshell.file(schema="IFC4X3_ADD2") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") ifcopenshell.api.unit.assign_unit(file) - s = sta.station_as_string(file,100.00) + s = sta.station_as_string(file, 100.00) assert s == "0+000.100" - s = sta.station_as_string(file,1000.00) + s = sta.station_as_string(file, 1000.00) assert s == "0+001.000" + def _test_us_stations(): file = ifcopenshell.file(schema="IFC4X3_ADD2") - project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test") - length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot") - ifcopenshell.api.unit.assign_unit(file,units=[length]) - - s = sta.station_as_string(file,0.0) + project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test") + length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot") + ifcopenshell.api.unit.assign_unit(file, units=[length]) + + s = sta.station_as_string(file, 0.0) assert s == "0+00.00" - s = sta.station_as_string(file,100.00) + s = sta.station_as_string(file, 100.00) assert s == "1+00.00" - s = sta.station_as_string(file,-100.00) + s = sta.station_as_string(file, -100.00) assert s == "-1+00.00" - s = sta.station_as_string(file,123456.789) + s = sta.station_as_string(file, 123456.789) assert s == "1234+56.79" - s = sta.station_as_string(file,-123456.789) + s = sta.station_as_string(file, -123456.789) assert s == "-1234+56.79" @@ -79,4 +82,4 @@ def test_station_as_string(): _test_us_stations() -test_station_as_string() \ No newline at end of file +test_station_as_string()