Skip to content

Commit 355349c

Browse files
representation context + colors
1 parent 8edadb0 commit 355349c

20 files changed

Lines changed: 860 additions & 161 deletions

energyml-utils/example/attic/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
validate_epc,
9292
correct_dor,
9393
)
94-
from energyml.utils.xml import (
94+
from energyml.utils.xml_utils import (
9595
find_schema_version_in_element,
9696
get_class_name_from_xml,
9797
get_root_namespace,

energyml-utils/example/attic/main_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
read_energyml_xml_tree,
4040
)
4141
from energyml.utils.validation import validate_epc
42-
from energyml.utils.xml import get_tree
42+
from energyml.utils.xml_utils import get_tree
4343
from energyml.utils.data.datasets_io import (
4444
HDF5FileReader,
4545
get_path_in_external_with_path,

energyml-utils/src/energyml/utils/data/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
Contains functions to help the read of specific entities like Grid2DRepresentation, TriangulatedSetRepresentation etc.
77
It also contains functions to export data into OFF/OBJ format.
88
"""
9-
from .crs import CrsInfo, extract_crs_info, apply_from_crs_info, apply_axis_order_swap # noqa: F401
9+
from energyml.utils.data.crs import CrsInfo, extract_crs_info, apply_from_crs_info, apply_axis_order_swap # noqa: F401

energyml-utils/src/energyml/utils/data/crs.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def _resolve_dor(
181181
**and** the object has a ``uuid``/``uid`` attribute (i.e. it is a pointer,
182182
not a value type).
183183
"""
184-
184+
185185
if obj is None or workspace is None:
186186
return obj
187187
type_lower = type(obj).__name__.lower()
@@ -321,7 +321,9 @@ def _extract_vertical_crs_details(vertical_crs_obj: Any) -> dict:
321321
**must not** override a parent-level ``ZIncreasingDownward`` when this
322322
value is ``None``.
323323
"""
324-
logging.debug(f"Extracting vertical CRS details from object of type {type(vertical_crs_obj).__name__} with URI {get_obj_uri(vertical_crs_obj)}")
324+
logging.debug(
325+
f"Extracting vertical CRS details from object of type {type(vertical_crs_obj).__name__} with URI {get_obj_uri(vertical_crs_obj)}"
326+
)
325327
result: dict = {
326328
"epsg_code": None,
327329
"wkt": None,
@@ -437,14 +439,10 @@ def _from_abstract_local3dcrs(
437439
z_increasing_downward = str(zid_raw).lower() in ("true", "1", "yes")
438440

439441
# --- Projected UOM -----------------------------------------------------
440-
projected_uom: Optional[str] = _uom_to_str(
441-
get_object_attribute_no_verif(crs_obj, "projected_uom")
442-
)
442+
projected_uom: Optional[str] = _uom_to_str(get_object_attribute_no_verif(crs_obj, "projected_uom"))
443443

444444
# --- Vertical UOM (length or time) ------------------------------------
445-
vertical_uom: Optional[str] = _uom_to_str(
446-
get_object_attribute_no_verif(crs_obj, "vertical_uom")
447-
)
445+
vertical_uom: Optional[str] = _uom_to_str(get_object_attribute_no_verif(crs_obj, "vertical_uom"))
448446
if vertical_uom is None:
449447
# time_uom only present on LocalTime3dCrs
450448
vertical_uom = _uom_to_str(getattr(crs_obj, "time_uom", None))
@@ -459,9 +457,7 @@ def _from_abstract_local3dcrs(
459457
projected_axis_order = ao.replace("_", " ").lower()
460458

461459
# --- Projected CRS -----------------------------------------------------
462-
projected_crs_obj = _resolve_dor(
463-
get_object_attribute_no_verif(crs_obj, "projected_crs"), workspace
464-
)
460+
projected_crs_obj = _resolve_dor(get_object_attribute_no_verif(crs_obj, "projected_crs"), workspace)
465461
projected_details = _extract_projected_crs_details(projected_crs_obj)
466462

467463
# Projected UOM from inline ProjectedCrs takes precedence if present
@@ -471,20 +467,20 @@ def _from_abstract_local3dcrs(
471467
projected_axis_order = projected_details["axis_order"]
472468

473469
# --- Vertical CRS ------------------------------------------------------
474-
vertical_crs_obj = _resolve_dor(
475-
get_object_attribute_no_verif(crs_obj, "vertical_crs"), workspace
476-
)
470+
vertical_crs_obj = _resolve_dor(get_object_attribute_no_verif(crs_obj, "vertical_crs"), workspace)
477471
vertical_details = _extract_vertical_crs_details(vertical_crs_obj)
478472

479473
# Direction from VerticalCrs overrides the top-level ZIncreasingDownward
480474
# only when explicitly set.
481475
logging.debug("z_increasing_downward before vertical CRS details: %s", z_increasing_downward)
482-
logging.debug(f"Vertical CRS details: {vertical_details} -- vertical_crs_obj type: {type(vertical_crs_obj).__name__ if vertical_crs_obj else 'None'}")
476+
logging.debug(
477+
f"Vertical CRS details: {vertical_details} -- vertical_crs_obj type: {type(vertical_crs_obj).__name__ if vertical_crs_obj else 'None'}"
478+
)
483479
if vertical_crs_obj is not None and vertical_details.get("z_increasing_downward") is not None:
484480
z_increasing_downward = vertical_details["z_increasing_downward"]
485481
if vertical_details.get("uom"):
486482
vertical_uom = vertical_details["uom"]
487-
483+
488484
logging.debug("z_increasing_downward after vertical CRS details: %s", z_increasing_downward)
489485

490486
return CrsInfo(
@@ -547,9 +543,7 @@ def _from_local_engineering2d_crs(
547543
azimuth_reference = ar.replace("_", " ").lower()
548544

549545
# --- Horizontal UOM (HorizontalAxes.projected_uom or uom on ProjectedCrs) ---
550-
projected_uom: Optional[str] = _uom_to_str(
551-
get_object_attribute(crs_obj, "horizontal_axes.projected_uom")
552-
)
546+
projected_uom: Optional[str] = _uom_to_str(get_object_attribute(crs_obj, "horizontal_axes.projected_uom"))
553547

554548
# --- ProjectedCrs — may be an inline object OR a DOR ------------------
555549
projected_crs_raw = get_object_attribute_no_verif(crs_obj, "origin_projected_crs")
@@ -920,10 +914,7 @@ def extract_crs_info(
920914
# ------------------------------------------------------------------
921915
# v2.0.1 types (LocalDepth3dCrs, LocalTime3dCrs, AbstractLocal3dCrs)
922916
# ------------------------------------------------------------------
923-
if any(
924-
kw in type_name_lower
925-
for kw in ("localdepth3dcrs", "localtime3dcrs", "abstractlocal3dcrs", "local3dcrs")
926-
):
917+
if any(kw in type_name_lower for kw in ("localdepth3dcrs", "localtime3dcrs", "abstractlocal3dcrs", "local3dcrs")):
927918
return _from_abstract_local3dcrs(crs_obj, workspace)
928919

929920
# ------------------------------------------------------------------

energyml-utils/src/energyml/utils/data/datasets_io.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ def extract_h5_datasets(
158158

159159
@dataclass
160160
class HDF5FileWriter:
161-
162161
def write_array(
163162
self,
164163
target: Union[str, BytesIO, bytes, "h5py.File"],
@@ -209,7 +208,6 @@ def extract_h5_datasets(
209208
raise MissingExtraInstallation(extra_name="hdf5")
210209

211210
class HDF5FileWriter:
212-
213211
def write_array(
214212
self,
215213
target: Union[str, BytesIO, bytes, Any],
@@ -631,9 +629,7 @@ def read_external_dataset_array(
631629
for s in sources:
632630
try:
633631
if result_array is None:
634-
result_array = read_dataset(
635-
source=s, path_in_external_file=path_in_external, mimetype=mimetype
636-
)
632+
result_array = read_dataset(source=s, path_in_external_file=path_in_external, mimetype=mimetype)
637633
else:
638634
# TODO: take care of the "Counts" and "Starts" list in ExternalDataArrayPart to fill array correctly
639635
result_array = result_array + read_dataset(
@@ -908,9 +904,7 @@ def read_array_view(
908904
d_group = source[path_in_external_file]
909905
if start_indices is not None and counts is not None:
910906
# h5py reads only the required chunks/slabs from disk
911-
slices = tuple(
912-
slice(start, start + count) for start, count in zip(start_indices, counts)
913-
)
907+
slices = tuple(slice(start, start + count) for start, count in zip(start_indices, counts))
914908
return d_group[slices] # type: ignore
915909
# np.array with copy=False returns a view for contiguous datasets
916910
# Note: copy= kwarg on np.asarray requires numpy >=2.0;

energyml-utils/src/energyml/utils/data/export.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import numpy as np
1515

1616
if TYPE_CHECKING:
17-
from .mesh import AbstractMesh
17+
from energyml.utils.mesh import AbstractMesh
1818

1919

2020
class ExportFormat(Enum):
@@ -97,7 +97,7 @@ def export_obj(mesh_list: List["AbstractMesh"], out: BinaryIO, obj_name: Optiona
9797
:param obj_name: Optional object name for the OBJ file
9898
"""
9999
# Lazy import to avoid circular dependency
100-
from .mesh import PolylineSetMesh
100+
from energyml.utils.mesh import PolylineSetMesh
101101

102102
# Write header
103103
out.write(b"# Generated by energyml-utils a Geosiris python module\n\n")
@@ -142,7 +142,7 @@ def export_geojson(
142142
:param options: GeoJSON export options
143143
"""
144144
# Lazy import to avoid circular dependency
145-
from .mesh import PolylineSetMesh, SurfaceMesh
145+
from energyml.utils.mesh import PolylineSetMesh, SurfaceMesh
146146

147147
if options is None:
148148
options = GeoJSONExportOptions()
@@ -195,7 +195,7 @@ def export_vtk(mesh_list: List["AbstractMesh"], out: BinaryIO, options: Optional
195195
:param options: VTK export options
196196
"""
197197
# Lazy import to avoid circular dependency
198-
from .mesh import PolylineSetMesh, SurfaceMesh
198+
from energyml.utils.mesh import PolylineSetMesh, SurfaceMesh
199199

200200
if options is None:
201201
options = VTKExportOptions()
@@ -260,7 +260,7 @@ def export_stl(mesh_list: List["AbstractMesh"], out: BinaryIO, options: Optional
260260
:param options: STL export options
261261
"""
262262
# Lazy import to avoid circular dependency
263-
from .mesh import SurfaceMesh
263+
from energyml.utils.mesh import SurfaceMesh
264264

265265
if options is None:
266266
options = STLExportOptions(binary=True)

0 commit comments

Comments
 (0)