Skip to content

Commit

Permalink
allowed string seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed May 29, 2024
1 parent 867cd72 commit 7e7deb7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion fileformats/core/fileset.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,10 @@ def mock(cls, *fspaths: ty.Tuple[ty.Union[Path, str]]) -> "FileSet":

@classmethod
def sample(
cls, dest_dir: ty.Optional[Path] = None, seed: int = 0, stem: str = None
cls,
dest_dir: ty.Optional[Path] = None,
seed: ty.Union[int, str] = 0,
stem: str = None,
) -> Self:
"""Return an sample instance of the file-set type for classes where the
`test_data` extra has been implemented
Expand Down
12 changes: 6 additions & 6 deletions fileformats/core/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,13 +659,13 @@ def namespace(cls): # pylint: disable=no-self-argument
namespace = super().namespace
return namespace

@property
def type_name(self):
@classproperty
def type_name(cls):
"""Name of type including classifiers to be used in __repr__"""
if self.is_classified:
unclassified = self.unclassified.__name__
if cls.is_classified:
unclassified = cls.unclassified.__name__
else:
unclassified = type(self).__name__
unclassified = type(cls).__name__
return (
unclassified + "[" + ", ".join(t.type_name for t in self.classifiers) + "]"
unclassified + "[" + ", ".join(t.type_name for t in cls.classifiers) + "]"
)
2 changes: 1 addition & 1 deletion fileformats/core/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SampleFileGenerator:
"""

dest_dir: Path
seed: int
seed: ty.Union[int, str]
fname_stem: str

FNAME_STEM_LENGTH = 24
Expand Down

0 comments on commit 7e7deb7

Please sign in to comment.