Skip to content

Commit 8c8cc28

Browse files
committed
Fix a bug with collapsed grading specification
1 parent 0b328bd commit 8c8cc28

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

examples/advanced/collapsed.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
loft = cb.Loft(bottom_face, top_face)
1111
extrude = cb.Extrude(top_face, 1)
1212

13+
14+
revolve_face = cb.Face([[2, 0, 0], [3, 0, 0], [3, 1, 0], [2, 1, 0]])
15+
revolve = cb.Revolve(revolve_face, 1, [1, 0, 0], [0, 0, 0])
16+
1317
mesh.add(loft)
1418
mesh.add(extrude)
15-
19+
mesh.add(revolve)
1620
mesh.assemble()
1721

1822
# grader = cb.FixedCountGrader(mesh)
@@ -22,5 +26,6 @@
2226
for i in (0, 1, 2):
2327
loft.chop(i, count=5)
2428
extrude.chop(i, count=5)
29+
revolve.chop(i, count=5)
2530

2631
mesh.write(os.path.join("..", "case", "system", "blockMeshDict"), debug_path="debug.vtk")

src/classy_blocks/grading/define/grading.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,9 @@ def clear(self) -> None:
6767
"""Removes all added grading data"""
6868

6969
@property
70+
@abc.abstractmethod
7071
def chop_data(self) -> list[ChopData]:
71-
if len(self._chop_data) < len(self.chops):
72-
# Chops haven't been calculated yet
73-
self._chop_data: list[ChopData] = []
74-
75-
for chop in self.chops:
76-
self._chop_data.append(chop.calculate(self.length))
77-
78-
return self._chop_data
72+
pass
7973

8074
def get_specification(self, inverted: bool) -> list[GradingSpecType]:
8175
if inverted:
@@ -173,6 +167,17 @@ def __init__(self, length: float):
173167
# results from chop.calculate():
174168
self._chop_data: list[ChopData] = []
175169

170+
@property
171+
def chop_data(self):
172+
if len(self._chop_data) < len(self.chops):
173+
# Chops haven't been calculated yet
174+
self._chop_data: list[ChopData] = []
175+
176+
for chop in self.chops:
177+
self._chop_data.append(chop.calculate(self.length))
178+
179+
return self._chop_data
180+
176181
def add_chop(self, chop: Chop):
177182
super().add_chop(chop)
178183

@@ -255,6 +260,10 @@ def add_chop(self, chop: Chop):
255260

256261
self._count += chop.count
257262

263+
@property
264+
def chop_data(self):
265+
return [ChopData(1, 1, 1, self.count, 1, 1)]
266+
258267
@property
259268
def count(self):
260269
return self._count
@@ -268,14 +277,7 @@ def clear(self):
268277

269278
@property
270279
def description(self):
271-
return str(self.count)
272-
273-
@classmethod
274-
def from_grading(cls, source: GradingBase) -> "CollapsedGrading":
275-
grading = cls()
276-
grading.add_chop(Chop(count=source.count))
277-
278-
return grading
280+
return "1"
279281

280282
def __eq__(self, other):
281283
return self.count == other.count

tests/test_grading/test_grading.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,5 @@ def test_clear(self):
301301
def test_description(self):
302302
g = CollapsedGrading()
303303
g.add_chop(Chop(count=10))
304-
g.add_chop(Chop(count=20))
305304

306-
self.assertEqual(g.description, "30")
305+
self.assertEqual(g.description, "1")

0 commit comments

Comments
 (0)