formatting to pass tests
This commit is contained in:
@@ -61,13 +61,15 @@ def _parse_input_data(
|
||||
def execute_automate_function(
|
||||
automate_function: AutomateFunction[T],
|
||||
input_schema: type[T],
|
||||
) -> None: ...
|
||||
) -> None:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def execute_automate_function(
|
||||
automate_function: AutomateFunctionWithoutInputs,
|
||||
) -> None: ...
|
||||
) -> None:
|
||||
...
|
||||
|
||||
|
||||
class AutomateGenerateJsonSchema(GenerateJsonSchema):
|
||||
@@ -144,14 +146,16 @@ def run_function(
|
||||
automation_context: AutomationContext,
|
||||
automate_function: AutomateFunction[T],
|
||||
inputs: T,
|
||||
) -> AutomationContext: ...
|
||||
) -> AutomationContext:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def run_function(
|
||||
automation_context: AutomationContext,
|
||||
automate_function: AutomateFunctionWithoutInputs,
|
||||
) -> AutomationContext: ...
|
||||
) -> AutomationContext:
|
||||
...
|
||||
|
||||
|
||||
def run_function(
|
||||
|
||||
@@ -43,10 +43,12 @@ class ActiveUserResource(CoreResource):
|
||||
company: Optional[str] = None,
|
||||
bio: Optional[str] = None,
|
||||
avatar: Optional[str] = None,
|
||||
) -> User: ...
|
||||
) -> User:
|
||||
...
|
||||
|
||||
@overload
|
||||
def update(self, *, input: UserUpdateInput) -> User: ...
|
||||
def update(self, *, input: UserUpdateInput) -> User:
|
||||
...
|
||||
|
||||
def update(
|
||||
self,
|
||||
|
||||
@@ -99,10 +99,12 @@ class ActiveUserResource(ResourceBase):
|
||||
company: Optional[str] = None,
|
||||
bio: Optional[str] = None,
|
||||
avatar: Optional[str] = None,
|
||||
) -> User: ...
|
||||
) -> User:
|
||||
...
|
||||
|
||||
@overload
|
||||
def update(self, *, input: UserUpdateInput) -> User: ...
|
||||
def update(self, *, input: UserUpdateInput) -> User:
|
||||
...
|
||||
|
||||
def update(
|
||||
self,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import List, Tuple
|
||||
|
||||
from specklepy.objects.base import Base
|
||||
from specklepy.objects.interfaces import ICurve, IHasArea, IHasUnits, IHasVolume
|
||||
from specklepy.objects.models.units import Units
|
||||
@@ -71,8 +72,7 @@ class Line(Base, IHasUnits, ICurve, speckle_type="Objects.Geometry.Line"):
|
||||
@classmethod
|
||||
def from_list(cls, coords: List[float], units: str) -> "Line":
|
||||
if len(coords) < 6:
|
||||
raise ValueError(
|
||||
"Line from coordinate array requires 6 coordinates.")
|
||||
raise ValueError("Line from coordinate array requires 6 coordinates.")
|
||||
|
||||
start = Point(x=coords[0], y=coords[1], z=coords[2], units=units)
|
||||
end = Point(x=coords[3], y=coords[4], z=coords[5], units=units)
|
||||
@@ -128,7 +128,8 @@ class Polyline(Base, IHasUnits, ICurve, speckle_type="Objects.Geometry.Polyline"
|
||||
"""
|
||||
if len(self.value) % 3 != 0:
|
||||
raise ValueError(
|
||||
"Polyline value list is malformed: expected length to be multiple of 3")
|
||||
"Polyline value list is malformed: expected length to be multiple of 3"
|
||||
)
|
||||
|
||||
points = []
|
||||
for i in range(0, len(self.value), 3):
|
||||
@@ -137,7 +138,7 @@ class Polyline(Base, IHasUnits, ICurve, speckle_type="Objects.Geometry.Polyline"
|
||||
x=self.value[i],
|
||||
y=self.value[i + 1],
|
||||
z=self.value[i + 2],
|
||||
units=self.units
|
||||
units=self.units,
|
||||
)
|
||||
)
|
||||
return points
|
||||
@@ -167,17 +168,26 @@ class Polyline(Base, IHasUnits, ICurve, speckle_type="Objects.Geometry.Polyline"
|
||||
return cls(
|
||||
closed=(int(coords[2]) == 1),
|
||||
domain=Interval(start=coords[3], end=coords[4]),
|
||||
value=coords[6:6 + point_count],
|
||||
units=units
|
||||
value=coords[6 : 6 + point_count],
|
||||
units=units,
|
||||
)
|
||||
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
class Mesh(Base, IHasArea, IHasVolume, IHasUnits,
|
||||
speckle_type="Objects.Geometry.Mesh",
|
||||
detachable={"vertices", "faces", "colors", "textureCoordinates"},
|
||||
chunkable={"vertices": 31250, "faces": 62500, "colors": 62500, "textureCoordinates": 31250}):
|
||||
|
||||
class Mesh(
|
||||
Base,
|
||||
IHasArea,
|
||||
IHasVolume,
|
||||
IHasUnits,
|
||||
speckle_type="Objects.Geometry.Mesh",
|
||||
detachable={"vertices", "faces", "colors", "textureCoordinates"},
|
||||
chunkable={
|
||||
"vertices": 31250,
|
||||
"faces": 62500,
|
||||
"colors": 62500,
|
||||
"textureCoordinates": 31250,
|
||||
},
|
||||
):
|
||||
vertices: List[float] = field(default_factory=list)
|
||||
faces: List[int] = field(default_factory=list)
|
||||
colors: List[int] = field(default_factory=list)
|
||||
@@ -192,17 +202,15 @@ class Mesh(Base, IHasArea, IHasVolume, IHasUnits,
|
||||
return len(self.textureCoordinates) // 2
|
||||
|
||||
def get_point(self, index: int) -> Point:
|
||||
|
||||
index *= 3
|
||||
return Point(
|
||||
x=self.vertices[index],
|
||||
y=self.vertices[index + 1],
|
||||
z=self.vertices[index + 2],
|
||||
units=self.units
|
||||
units=self.units,
|
||||
)
|
||||
|
||||
def get_points(self) -> List[Point]:
|
||||
|
||||
if len(self.vertices) % 3 != 0:
|
||||
raise ValueError(
|
||||
"Mesh vertices list is malformed: expected length to be multiple of 3"
|
||||
@@ -215,21 +223,16 @@ class Mesh(Base, IHasArea, IHasVolume, IHasUnits,
|
||||
x=self.vertices[i],
|
||||
y=self.vertices[i + 1],
|
||||
z=self.vertices[i + 2],
|
||||
units=self.units
|
||||
units=self.units,
|
||||
)
|
||||
)
|
||||
return points
|
||||
|
||||
def get_texture_coordinate(self, index: int) -> Tuple[float, float]:
|
||||
|
||||
index *= 2
|
||||
return (
|
||||
self.textureCoordinates[index],
|
||||
self.textureCoordinates[index + 1]
|
||||
)
|
||||
return (self.textureCoordinates[index], self.textureCoordinates[index + 1])
|
||||
|
||||
def align_vertices_with_texcoords_by_index(self) -> None:
|
||||
|
||||
if not self.textureCoordinates:
|
||||
return
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Generic, TypeVar, List
|
||||
from typing import Generic, List, TypeVar
|
||||
|
||||
from specklepy.logging.exceptions import SpeckleInvalidUnitException
|
||||
from specklepy.objects.base import Base
|
||||
from specklepy.objects.models.units import Units
|
||||
@@ -36,7 +37,6 @@ class IDisplayValue(Generic[T], metaclass=ABCMeta):
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
class IHasUnits(metaclass=ABCMeta):
|
||||
|
||||
units: str | Units
|
||||
_units: str = field(repr=False, init=False)
|
||||
|
||||
@@ -58,7 +58,6 @@ class IHasUnits(metaclass=ABCMeta):
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
class IHasArea(metaclass=ABCMeta):
|
||||
|
||||
area: float
|
||||
_area: float = field(init=False, repr=False)
|
||||
|
||||
@@ -75,7 +74,6 @@ class IHasArea(metaclass=ABCMeta):
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
class IHasVolume(metaclass=ABCMeta):
|
||||
|
||||
volume: float
|
||||
_volume: float = field(init=False, repr=False)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
from specklepy.objects.base import Base
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import List, Optional
|
||||
|
||||
from specklepy.objects.base import Base
|
||||
from specklepy.objects.interfaces import IHasUnits
|
||||
|
||||
@@ -21,7 +22,6 @@ class GroupProxy(
|
||||
speckle_type="Models.Proxies.GroupProxy",
|
||||
detachable={"objects"},
|
||||
):
|
||||
|
||||
objects: List[str] = field(default_factory=list)
|
||||
name: str = field(default="Unnamed Group")
|
||||
|
||||
@@ -32,7 +32,6 @@ class InstanceProxy(
|
||||
IHasUnits,
|
||||
speckle_type="Models.Proxies.InstanceProxy",
|
||||
):
|
||||
|
||||
definition_id: str
|
||||
transform: List[float] = field(default_factory=list)
|
||||
max_depth: int = 50
|
||||
@@ -44,7 +43,6 @@ class InstanceDefinitionProxy(
|
||||
speckle_type="Models.Proxies.InstanceDefinitionProxy",
|
||||
detachable={"objects"},
|
||||
):
|
||||
|
||||
objects: List[str] = field(default_factory=list)
|
||||
max_depth: int = 50
|
||||
name: str = field(default="Unnamed Instance")
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
from devtools import debug
|
||||
|
||||
from specklepy.api.operations import deserialize, serialize
|
||||
from specklepy.objects.geometry import Line, Point
|
||||
from specklepy.objects.models.units import Units
|
||||
from specklepy.objects.primitive import Interval
|
||||
|
||||
|
||||
# points
|
||||
p1 = Point(x=1.0, y=2.0, z=3.0, units=Units.m)
|
||||
p2 = Point(x=4.0, y=6.0, z=8.0, units=Units.m, applicationId="asdf")
|
||||
|
||||
|
||||
# test Line
|
||||
line = Line(start=p1, end=p2, units=Units.m,
|
||||
domain=Interval(start=0.0, end=1.0))
|
||||
line = Line(start=p1, end=p2, units=Units.m, domain=Interval(start=0.0, end=1.0))
|
||||
|
||||
print(f"\nLine length: {line.length}")
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from devtools import debug
|
||||
|
||||
from specklepy.api.operations import deserialize, serialize
|
||||
from specklepy.objects.geometry import Mesh
|
||||
|
||||
|
||||
# create a speckle cube mesh (but more colorful)
|
||||
vertices = [
|
||||
0.0, 0.0, 0.0,
|
||||
@@ -64,7 +64,7 @@ cube_mesh = Mesh(
|
||||
area=0.0,
|
||||
volume=0.0)
|
||||
|
||||
print(f"\nMesh Details:")
|
||||
print("\nMesh Details:")
|
||||
print(f"Number of vertices: {cube_mesh.vertices_count}")
|
||||
print(f"Number of texture coordinates: {cube_mesh.texture_coordinates_count}")
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from devtools import debug
|
||||
|
||||
from specklepy.api.operations import deserialize, serialize
|
||||
from specklepy.objects.geometry import Point
|
||||
from specklepy.objects.models.units import Units
|
||||
|
||||
@@ -1,32 +1,22 @@
|
||||
from devtools import debug
|
||||
|
||||
from specklepy.api.operations import deserialize, serialize
|
||||
from specklepy.objects.geometry import Polyline
|
||||
from specklepy.objects.models.units import Units
|
||||
from specklepy.objects.primitive import Interval
|
||||
|
||||
|
||||
# create points for first polyline - not closed, in meters
|
||||
points1_coords = [
|
||||
1.0, 1.0, 0.0,
|
||||
2.0, 1.0, 0.0,
|
||||
2.0, 2.0, 0.0,
|
||||
1.0, 2.0, 0.0
|
||||
]
|
||||
points1_coords = [1.0, 1.0, 0.0, 2.0, 1.0, 0.0, 2.0, 2.0, 0.0, 1.0, 2.0, 0.0]
|
||||
|
||||
# Create points for second polyline - closed, in ft
|
||||
points2_coords = [
|
||||
0.0, 0.0, 0.0,
|
||||
3.0, 0.0, 0.0,
|
||||
3.0, 3.0, 0.0,
|
||||
0.0, 3.0, 0.0
|
||||
]
|
||||
points2_coords = [0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 3.0, 0.0, 0.0, 3.0, 0.0]
|
||||
|
||||
# create polylines
|
||||
polyline1 = Polyline(
|
||||
value=points1_coords,
|
||||
closed=False,
|
||||
units=Units.m,
|
||||
domain=Interval(start=0.0, end=1.0)
|
||||
domain=Interval(start=0.0, end=1.0),
|
||||
)
|
||||
|
||||
polyline2 = Polyline(
|
||||
@@ -34,7 +24,7 @@ polyline2 = Polyline(
|
||||
closed=True,
|
||||
units=Units.feet,
|
||||
domain=Interval(start=0.0, end=1.0),
|
||||
applicationId="polyllllineeee"
|
||||
applicationId="polyllllineeee",
|
||||
)
|
||||
|
||||
print("Polyline 1 length (meters):", polyline1.length)
|
||||
|
||||
@@ -295,9 +295,9 @@ class RevitParameter(Base, speckle_type="Objects.BuiltElements.Revit.Parameter")
|
||||
value: Any = None
|
||||
applicationUnitType: Optional[str] = None # eg UnitType UT_Length
|
||||
applicationUnit: Optional[str] = None # DisplayUnitType eg DUT_MILLIMITERS
|
||||
applicationInternalName: Optional[str] = (
|
||||
None # BuiltInParameterName or GUID for shared parameter
|
||||
)
|
||||
applicationInternalName: Optional[
|
||||
str
|
||||
] = None # BuiltInParameterName or GUID for shared parameter
|
||||
isShared: bool = False
|
||||
isReadOnly: bool = False
|
||||
isTypeParameter: bool = False
|
||||
|
||||
Reference in New Issue
Block a user