Skip to content

Commit

Permalink
Implement hashing and ordering for Visit class
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGensollen committed Nov 29, 2024
1 parent 445ce8b commit 9eed12f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion clinica/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,21 @@
BIDS_VERSION = Version("1.7.0")


@dataclass
@dataclass(frozen=True)
class Visit:
subject: str
session: str

def __lt__(self, obj):
return (self.subject < obj.subject) or (
self.subject == obj.subject and self.session < obj.session
)

def __gt__(self, obj):
return (self.subject > obj.subject) or (
self.subject == obj.subject and self.session > obj.session
)

def __str__(self) -> str:
return f"{self.subject} {self.session}"

Expand Down

0 comments on commit 9eed12f

Please sign in to comment.