Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/gumyr/build123d into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
gumyr committed Jan 13, 2025
2 parents 953019a + cc9409f commit 99639ce
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jobs:
python-version: [
"3.10",
# "3.11",
"3.12",
# "3.12",
"3.13",
]

runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
python-version: [
"3.10",
# "3.11",
"3.12",
# "3.12",
"3.13",
]
os: [macos-13, macos-14, ubuntu-latest, windows-latest]

Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ authors = [
]
description = "A python CAD programming library"
readme = "README.md"
requires-python = ">= 3.10, < 3.13"
requires-python = ">= 3.10, < 3.14"
keywords = [
"3d models",
"3d printing",
Expand All @@ -35,16 +35,16 @@ classifiers = [
]

dependencies = [
"cadquery-ocp >= 7.7.0, < 7.8.0",
"cadquery-ocp >= 7.8.0, < 7.9.0",
"typing_extensions >= 4.6.0, < 5",
"numpy >= 2, < 3",
"svgpathtools >= 1.5.1, < 2",
"anytree >= 2.8.0, < 3",
"ezdxf >= 1.1.0, < 2",
"ipython >= 8.0.0, < 9",
"py-lib3mf >= 2.3.1",
"ocpsvg < 0.4",
"trianglesolver"
"ocpsvg >= 0.4",
"trianglesolver",
]

[project.urls]
Expand All @@ -61,5 +61,5 @@ exclude = ["build123d._dev"]
write_to = "src/build123d/_version.py"

[tool.black]
target-version = ["py310", "py311", "py312"]
target-version = ["py310", "py311", "py312", "py313"]
line-length = 88
22 changes: 5 additions & 17 deletions src/build123d/topology/shape_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@
from .composite import Compound # pylint: disable=R0801
from build123d.build_part import BuildPart # pylint: disable=R0801

HASH_CODE_MAX = 2147483647
Shapes = Literal["Vertex", "Edge", "Wire", "Face", "Shell", "Solid", "Compound"]
TrimmingTool = Union[Plane, "Shell", "Face"]
TOPODS = TypeVar("TOPODS", bound=TopoDS_Shape)
Expand Down Expand Up @@ -805,8 +804,10 @@ def __eq__(self, other) -> bool:
return NotImplemented

def __hash__(self) -> int:
"""Return has code"""
return self.hash_code()
"""Return hash code"""
if self.wrapped is None:
return 0
return hash(self.wrapped)

def __rmul__(self, other):
"""right multiply for positioning operator *"""
Expand Down Expand Up @@ -1181,19 +1182,6 @@ def get_top_level_shapes(self) -> ShapeList[Shape]:
self.__class__.cast(s) for s in get_top_level_topods_shapes(self.wrapped)
)

def hash_code(self) -> int:
"""Returns a hashed value denoting this shape. It is computed from the
TShape and the Location. The Orientation is not used.
Args:
Returns:
"""
if self.wrapped is None:
return 0
return self.wrapped.HashCode(HASH_CODE_MAX)

def intersect(
self, *to_intersect: Shape | Axis | Plane
) -> None | Self | ShapeList[Self]:
Expand Down Expand Up @@ -2852,7 +2840,7 @@ def _topods_entities(shape: TopoDS_Shape, topo_type: Shapes) -> list[TopoDS_Shap

while explorer.More():
item = explorer.Current()
out[item.HashCode(HASH_CODE_MAX)] = (
out[hash(item)] = (
item # needed to avoid pseudo-duplicate entities
)
explorer.Next()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_direct_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3559,7 +3559,7 @@ def test_empty_shape(self):
with self.assertRaises(ValueError):
empty.geom_type
self.assertIs(empty, empty.fix())
self.assertEqual(empty.hash_code(), 0)
self.assertEqual(hash(empty), 0)
self.assertFalse(empty.is_same(Solid()))
self.assertFalse(empty.is_equal(Solid()))
self.assertTrue(empty.is_valid())
Expand Down

0 comments on commit 99639ce

Please sign in to comment.