From d0119479a4ab4f1036f9ca4428c1dce75f5dbf00 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 31 Aug 2026 15:00:26 +0500 Subject: [PATCH] black, ruff --- src/bonsai/bonsai/bim/prop.py | 3 +-- src/bonsai/test/bim/test_prop.py | 8 ++------ src/bonsai/test/tool/test_pset.py | 8 ++------ .../ifcopenshell/util/unit.py | 6 +++++- .../test/api/pset/test_edit_qto.py | 1 - .../test/util/test_unit.py | 20 +++++++++++++------ 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/bonsai/bonsai/bim/prop.py b/src/bonsai/bonsai/bim/prop.py index e951331f15..4c8f56fdba 100644 --- a/src/bonsai/bonsai/bim/prop.py +++ b/src/bonsai/bonsai/bim/prop.py @@ -21,6 +21,7 @@ import os from typing import TYPE_CHECKING, Any, Literal, Union, assert_never, get_args import bpy +import ifcopenshell.util.unit from bpy.props import ( BoolProperty, CollectionProperty, @@ -33,8 +34,6 @@ from bpy.props import ( ) from bpy.types import PropertyGroup -import ifcopenshell.util.unit - import bonsai.bim import bonsai.bim.handler import bonsai.tool as tool diff --git a/src/bonsai/test/bim/test_prop.py b/src/bonsai/test/bim/test_prop.py index be377d551b..29195c6c46 100644 --- a/src/bonsai/test/bim/test_prop.py +++ b/src/bonsai/test/bim/test_prop.py @@ -263,9 +263,7 @@ class TestImportPsetFromExistingWithAGenericNumericValueAndAnExplicitUnit(NewFil length_mm = ifcopenshell.api.unit.add_si_unit(ifc, unit_type="LENGTHUNIT", prefix="MILLI") element = ifc.createIfcWall() - prop = ifc.createIfcPropertySingleValue( - Name="Foo", NominalValue=ifc.createIfcReal(150.0), Unit=length_mm - ) + prop = ifc.createIfcPropertySingleValue(Name="Foo", NominalValue=ifc.createIfcReal(150.0), Unit=length_mm) metadata = import_single_property(ifc, element, prop) assert metadata.special_type == "LENGTH" @@ -291,9 +289,7 @@ class TestImportPsetFromExistingWithAStrayUnitOnANonMeasureProperty(NewFile): length_m = ifcopenshell.api.unit.add_si_unit(ifc, unit_type="LENGTHUNIT") element = ifc.createIfcWall() - prop = ifc.createIfcPropertySingleValue( - Name="Foo", NominalValue=ifc.createIfcLabel("Bar"), Unit=length_m - ) + prop = ifc.createIfcPropertySingleValue(Name="Foo", NominalValue=ifc.createIfcLabel("Bar"), Unit=length_m) metadata = import_single_property(ifc, element, prop) # must not raise assert metadata.special_type == "" diff --git a/src/bonsai/test/tool/test_pset.py b/src/bonsai/test/tool/test_pset.py index 230574bee4..f8f6afc585 100644 --- a/src/bonsai/test/tool/test_pset.py +++ b/src/bonsai/test/tool/test_pset.py @@ -69,9 +69,7 @@ class TestEditingAnOverriddenUnitPropertyRoundTrips(NewFile): element = ifc.createIfcWall() pset = ifcopenshell.api.pset.add_pset(ifc, product=element, name="Pset_Test") - prop = ifc.createIfcPropertySingleValue( - Name="Foo", NominalValue=ifc.createIfcLengthMeasure(2.5), Unit=length_m - ) + prop = ifc.createIfcPropertySingleValue(Name="Foo", NominalValue=ifc.createIfcLengthMeasure(2.5), Unit=length_m) pset.HasProperties = [prop] obj = bpy.data.objects.new("Wall", None) @@ -308,9 +306,7 @@ class TestEditPsetWithUnitOverridePicker(NewFile): element = ifc.createIfcWall() pset = ifcopenshell.api.pset.add_pset(ifc, product=element, name="Pset_Test") - prop = ifc.createIfcPropertySingleValue( - Name="Foo", NominalValue=ifc.createIfcLengthMeasure(2.5), Unit=length_m - ) + prop = ifc.createIfcPropertySingleValue(Name="Foo", NominalValue=ifc.createIfcLengthMeasure(2.5), Unit=length_m) pset.HasProperties = [prop] obj = bpy.data.objects.new("Wall", None) diff --git a/src/ifcopenshell-python/ifcopenshell/util/unit.py b/src/ifcopenshell-python/ifcopenshell/util/unit.py index 9ced450cfb..c7761b9b48 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/unit.py +++ b/src/ifcopenshell-python/ifcopenshell/util/unit.py @@ -510,7 +510,11 @@ def get_project_unit( for unit in unit_assignment.Units or []: if getattr(unit, "UnitType", None) == unit_type: return unit - if dimensional_match is None and unit.is_a("IfcDerivedUnit") and identify_unit_dimensions(unit) == unit_type: + if ( + dimensional_match is None + and unit.is_a("IfcDerivedUnit") + and identify_unit_dimensions(unit) == unit_type + ): dimensional_match = unit return dimensional_match diff --git a/src/ifcopenshell-python/test/api/pset/test_edit_qto.py b/src/ifcopenshell-python/test/api/pset/test_edit_qto.py index 30e838d49a..e90eb7a9b9 100644 --- a/src/ifcopenshell-python/test/api/pset/test_edit_qto.py +++ b/src/ifcopenshell-python/test/api/pset/test_edit_qto.py @@ -18,7 +18,6 @@ import ifcopenshell.api.pset import ifcopenshell.api.root -import ifcopenshell.api.unit import test.bootstrap diff --git a/src/ifcopenshell-python/test/util/test_unit.py b/src/ifcopenshell-python/test/util/test_unit.py index 703eb21489..c1e902583f 100644 --- a/src/ifcopenshell-python/test/util/test_unit.py +++ b/src/ifcopenshell-python/test/util/test_unit.py @@ -20,8 +20,10 @@ import tempfile from math import pi from pathlib import Path +import ifcpatch import numpy as np import pytest +from ifcpatch.recipes import Ifc2Sql import ifcopenshell.api.context import ifcopenshell.api.georeference @@ -31,10 +33,8 @@ import ifcopenshell.api.unit import ifcopenshell.util.element import ifcopenshell.util.geolocation import ifcopenshell.util.unit as subject -import ifcpatch import test.bootstrap from ifcopenshell.util.shape_builder import ShapeBuilder -from ifcpatch.recipes import Ifc2Sql class TestMmToM: @@ -149,7 +149,9 @@ class TestGetCandidateUnits(test.bootstrap.IFC4): ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject") force = ifcopenshell.api.unit.add_si_unit(self.file, unit_type="FORCEUNIT") area = ifcopenshell.api.unit.add_si_unit(self.file, unit_type="AREAUNIT") - modulus = ifcopenshell.api.unit.add_derived_unit(self.file, "MODULUSOFELASTICITYUNIT", None, {force: 1, area: -1}) + modulus = ifcopenshell.api.unit.add_derived_unit( + self.file, "MODULUSOFELASTICITYUNIT", None, {force: 1, area: -1} + ) assert subject.get_candidate_units(self.file, "MODULUSOFELASTICITYUNIT") == [modulus] def test_userdefined_derived_unit_matched_by_dimensional_fallback(self): @@ -288,7 +290,9 @@ class TestCalculateUnitScale(test.bootstrap.IFC4): ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject") force = ifcopenshell.api.unit.add_si_unit(self.file, unit_type="FORCEUNIT") area = ifcopenshell.api.unit.add_si_unit(self.file, unit_type="AREAUNIT", prefix="MILLI") - modulus = ifcopenshell.api.unit.add_derived_unit(self.file, "MODULUSOFELASTICITYUNIT", None, {force: 1, area: -1}) + modulus = ifcopenshell.api.unit.add_derived_unit( + self.file, "MODULUSOFELASTICITYUNIT", None, {force: 1, area: -1} + ) ifcopenshell.api.unit.assign_unit(self.file, units=[modulus]) # AREAUNIT is a pure power of length, so its MILLI prefix is raised to # the length exponent (2) per #9278: (1e-3)**2 = 1e-6, inverted by the @@ -397,7 +401,9 @@ class TestGetUnitSymbol(test.bootstrap.IFC4): ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject") force = ifcopenshell.api.unit.add_si_unit(self.file, unit_type="FORCEUNIT") area = ifcopenshell.api.unit.add_si_unit(self.file, unit_type="AREAUNIT") - modulus = ifcopenshell.api.unit.add_derived_unit(self.file, "MODULUSOFELASTICITYUNIT", None, {force: 1, area: -1}) + modulus = ifcopenshell.api.unit.add_derived_unit( + self.file, "MODULUSOFELASTICITYUNIT", None, {force: 1, area: -1} + ) assert subject.get_unit_symbol(modulus) == "N/m2" def test_unnamed_derived_unit_still_composes_a_symbol_without_crashing(self): @@ -420,7 +426,9 @@ class TestIdentifyUnitDimensions(test.bootstrap.IFC4): ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject") force = ifcopenshell.api.unit.add_si_unit(self.file, unit_type="FORCEUNIT") area = ifcopenshell.api.unit.add_si_unit(self.file, unit_type="AREAUNIT") - modulus = ifcopenshell.api.unit.add_derived_unit(self.file, "MODULUSOFELASTICITYUNIT", None, {force: 1, area: -1}) + modulus = ifcopenshell.api.unit.add_derived_unit( + self.file, "MODULUSOFELASTICITYUNIT", None, {force: 1, area: -1} + ) assert subject.identify_unit_dimensions(modulus) == "PRESSUREUNIT" def test_returns_none_for_no_match(self):