fairyfly-core 0.2.6__py3-none-any.whl → 0.2.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fairyfly/model.py CHANGED
@@ -4,6 +4,7 @@ from __future__ import division
4
4
  import os
5
5
  import io
6
6
  import json
7
+ import math
7
8
  try: # check if we are in IronPython
8
9
  import cPickle as pickle
9
10
  except ImportError: # wea are in cPython
@@ -12,7 +13,8 @@ except ImportError: # wea are in cPython
12
13
  from ladybug_geometry.geometry3d import Vector3D, Point3D, LineSegment3D, Plane, Face3D
13
14
 
14
15
  from ._base import _Base
15
- from .units import conversion_factor_to_meters, UNITS, UNITS_TOLERANCES
16
+ from .units import conversion_factor_to_meters, parse_distance_string, \
17
+ UNITS, UNITS_TOLERANCES
16
18
  from .checkdup import check_duplicate_identifiers, check_duplicate_identifiers_parent
17
19
  from .properties import ModelProperties
18
20
  from .shape import Shape
@@ -899,6 +901,52 @@ class Model(_Base):
899
901
  pickle.dump(hb_dict, fp)
900
902
  return hb_file
901
903
 
904
+ @staticmethod
905
+ def check_reasonable_tolerance(units, tolerance):
906
+ """Get a message with a recommended tolerance if it is not reasonable.
907
+
908
+ This method is particularly useful to ensure that users have set a
909
+ tolerance that works for representing construction details and it is
910
+ not only for full-building simulation.
911
+
912
+ When the input tolerance and units are reasonable, the output of this
913
+ method will simply be None:
914
+
915
+ Args:
916
+ units: Text for the units system in which the model geometry
917
+ exists. Choose from the following:
918
+
919
+ * Millimeters
920
+ * Inches
921
+ * Centimeters
922
+ * Meters
923
+ * Feet
924
+
925
+ tolerance: The maximum difference between x, y, and z values at which
926
+ vertices are considered equivalent.
927
+ """
928
+ max_tol = parse_distance_string('1mm', units)
929
+ if tolerance > max_tol:
930
+ return 'The model tolerance is currently set to {} {}.\n' \
931
+ 'This is too coarse to correctly represent construction details.\n' \
932
+ 'It is recommended that the tolerance be dropped to below {} {}\n' \
933
+ 'for an accurate representation of the geometry.'.format(
934
+ tolerance, units, Model._round_to_sig_figs(max_tol, 1), units
935
+ )
936
+
937
+ @staticmethod
938
+ def _round_to_sig_figs(x, sigfigs):
939
+ """Round a number to a specified number of significant figures."""
940
+ if x == 0:
941
+ return 0.0 # Handle zero as a special case
942
+ # calculate the number of decimal places needed
943
+ # by finding the magnitude and adjusting for the desired significant figures
944
+ digits = sigfigs - int(math.floor(math.log10(abs(x)))) - 1
945
+ if digits == 0:
946
+ return math.floor(x)
947
+ multiplier = 10**digits
948
+ return math.floor(x * multiplier) / multiplier
949
+
902
950
  @staticmethod
903
951
  def validate(model, check_function='check_all', check_args=None, json_output=False):
904
952
  """Get a string of a validation report given a specific check_function.
fairyfly/shape.py CHANGED
@@ -283,7 +283,7 @@ class Shape(_Base):
283
283
  break
284
284
  if insert_i is not None:
285
285
  new_bound = list(self.geometry.boundary)
286
- new_bound.insert(insert_i, point)
286
+ new_bound.insert(insert_i + 1, point)
287
287
  self._geometry = Face3D(new_bound, self._geometry.plane, self._geometry.holes)
288
288
  return None
289
289
  # evaluate the holes if they exist
@@ -292,7 +292,7 @@ class Shape(_Base):
292
292
  for i, seg in enumerate(h_segs):
293
293
  if seg.distance_to_point(point) <= tolerance:
294
294
  new_holes = list(self.geometry.holes)
295
- new_holes[hi].insert(i, point)
295
+ new_holes[hi].insert(i + 1, point)
296
296
  self._geometry = Face3D(self._geometry.boundary,
297
297
  self._geometry.plane, new_holes)
298
298
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fairyfly-core
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: A library to represent construction detail geometry for environmental simulation.
5
5
  Home-page: https://github.com/ladybug-tools/fairyfly-core
6
6
  Author: Ladybug Tools
@@ -10,10 +10,10 @@ fairyfly/config.py,sha256=VfQ-vRX-q1CLja4xFMGVte-FpdFStdMXj98WKpmMOFA,10633
10
10
  fairyfly/dictutil.py,sha256=nVwoWG4FsoV9nYjQxI3jBxVeZcdy2TQd1FKhEquVLR8,1469
11
11
  fairyfly/extensionutil.py,sha256=5MQV0gZBc6_vfbVr4j8l_8JslMsj4bBbsZ4yqZ2VPG4,2716
12
12
  fairyfly/logutil.py,sha256=Urxl0U14-qffIt6NiGLT6pV-796oAGUvnnf2ypj1j9Q,2564
13
- fairyfly/model.py,sha256=2S7yGWZCNa7To1CyAhZ44IgIgBcMveu1t6hTfSo4czk,44282
13
+ fairyfly/model.py,sha256=R3BXbVgICTM-5K0O1HAnyODqDYrOXXQjZpkT73PGMos,46274
14
14
  fairyfly/properties.py,sha256=uGBA8YY0Sr_dp3NUCAx-XvXhctoBBwDlqsCiyNU_TTo,21402
15
15
  fairyfly/search.py,sha256=-DapYpzfX3nwZx1eF2elcmYG7vxitsvAiv_e3TGlTJ0,4806
16
- fairyfly/shape.py,sha256=1cQCxJMEuBOJ3AEYIEWScFI8ZxX4pUJ7LQX-exxYJXI,22306
16
+ fairyfly/shape.py,sha256=UaG-CWt2w_h513MpY3sIdr6XNCyQUk6VaI2lTHrQ_94,22314
17
17
  fairyfly/typing.py,sha256=1djGuUI0Ui-96EjBKPKw6rrMF7dPUq97q24Pg6NNfTM,7219
18
18
  fairyfly/units.py,sha256=wM3TEAF_ir8VWHFJYSbAKYrLU7VHzBGTtRTw6Tbh4Aw,3216
19
19
  fairyfly/cli/__init__.py,sha256=1qvLWWmJtYVDdTTQHVtoCNTMKyeAq_VWZ4tp-ap-Ajk,3187
@@ -22,9 +22,9 @@ fairyfly/writer/__init__.py,sha256=D4FdE2LUVCMvfud3qL2UquH1uCz3EGlKOEMgstMjtXc,2
22
22
  fairyfly/writer/boundary.py,sha256=skpfcFyxWLvjTSStbCh5f4wehSHeI-eKMgoeSCzvO7Q,190
23
23
  fairyfly/writer/model.py,sha256=6Y15NVGCjmYcBdimxyQWnE8AAhQAJi6A7QfMi4P49M4,181
24
24
  fairyfly/writer/shape.py,sha256=pMlLbk3WkrNPbNvowDQ_JFgNkhHNOlqL52TMZKB7zKo,181
25
- fairyfly_core-0.2.6.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
26
- fairyfly_core-0.2.6.dist-info/METADATA,sha256=Sho9baISD_xgjf2fmYKUIvWaZDh2h7RfANTRoMnVWTU,3291
27
- fairyfly_core-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
- fairyfly_core-0.2.6.dist-info/entry_points.txt,sha256=KM3hAPV0ivux3CUx1-pDT0BL1WSUFt2jmT4i_MFbdzc,47
29
- fairyfly_core-0.2.6.dist-info/top_level.txt,sha256=8ZUsvZOSB3g5enmv1R0vxJilNeW8Uft5KrTL0rUNj7k,9
30
- fairyfly_core-0.2.6.dist-info/RECORD,,
25
+ fairyfly_core-0.2.8.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
26
+ fairyfly_core-0.2.8.dist-info/METADATA,sha256=m4J4gL2Hb3I_WIUrjmkAhVvN8aUWbsG9PWe_eQ8C6hI,3291
27
+ fairyfly_core-0.2.8.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
28
+ fairyfly_core-0.2.8.dist-info/entry_points.txt,sha256=KM3hAPV0ivux3CUx1-pDT0BL1WSUFt2jmT4i_MFbdzc,47
29
+ fairyfly_core-0.2.8.dist-info/top_level.txt,sha256=8ZUsvZOSB3g5enmv1R0vxJilNeW8Uft5KrTL0rUNj7k,9
30
+ fairyfly_core-0.2.8.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5