-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite InflationGrader: get_count()
- Loading branch information
1 parent
559ad0b
commit b303c71
Showing
9 changed files
with
487 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import abc | ||
from typing import List, Optional | ||
|
||
from classy_blocks.grading.autograding.probe import WireInfo | ||
from classy_blocks.grading.chop import Chop | ||
|
||
CellSizeType = Optional[float] | ||
|
||
|
||
def sum_length(start_size: float, count: int, c2c_expansion: float) -> float: | ||
"""Returns absolute length of the chop""" | ||
length = 0.0 | ||
size = start_size | ||
|
||
for _ in range(count): | ||
length += size | ||
size *= c2c_expansion | ||
|
||
return length | ||
|
||
|
||
class ChopParams(abc.ABC): | ||
@abc.abstractmethod | ||
def get_count(self, length: float, start_at_wall: bool, end_at_wall: bool) -> int: | ||
"""Calculates count based on given length and position""" | ||
|
||
@abc.abstractmethod | ||
def is_squeezed(self, count: int, info: WireInfo) -> bool: | ||
"""Returns True if cells have to be 'squished' together (thinner than prescribed in params)""" | ||
|
||
@abc.abstractmethod | ||
def get_chops(self, count: int, info: WireInfo) -> List[Chop]: | ||
"""Fixes cell count but modifies chops so that proper cell sizing will be obeyed""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import dataclasses | ||
from typing import List | ||
|
||
from classy_blocks.grading.autograding.params.base import ChopParams | ||
from classy_blocks.grading.chop import Chop | ||
|
||
|
||
@dataclasses.dataclass | ||
class FixedCountGraderParams(ChopParams): | ||
count: int = 8 | ||
|
||
def get_count(self, _length, _start_at_wall, _end_at_wall): | ||
return self.count | ||
|
||
def is_squeezed(self, _count, _info) -> bool: | ||
return True # grade everything in first pass | ||
|
||
def get_chops(self, count, _info) -> List[Chop]: | ||
return [Chop(count=count)] |
Oops, something went wrong.