-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
dict is too opaque, pls add data class support
can devs do something??
here sample
from dataclasses import dataclass
from typing import List
from datetime import datetime, timedelta
import numpy as np
# The current data structure is:
# bigdict[time_idx][conc_nr][well_nr]['droplet geometry']
# Flattened into a dataclass:
# --------------------------
@dataclass
class ImageData:
raw_image: str
droplet_geometry: str
droplet_status: bool
conc_idx: int
well_idx: int
def gray_image(self) -> str:
return "gray_image"
@dataclass
class Wells:
image_data: ImageData
@dataclass
class Concentrations:
wells: List[Wells]
@dataclass
class Images:
concentrations: List[Concentrations]
# Sample code for testing:
# ------------------------
TOTAL_WELLS = 2
TOTAL_CONCS = 3
dates = np.arange(
datetime(2022, 4, 1),
datetime(2022, 4, 6),
timedelta(days=1)
).astype(datetime)
images = dict()
for date in dates:
concentrations = []
for conc_idx, conc in enumerate(range(TOTAL_CONCS)):
wells = []
for well_idx, well in enumerate(range(TOTAL_WELLS)):
image_data = ImageData(
raw_image="an_image.png",
droplet_geometry="round",
droplet_status=True,
conc_idx=conc_idx,
well_idx=well_idx
)
wells.append(Wells(image_data))
concentrations.append(Concentrations(wells))
images[date] = Images(concentrations=concentrations)
images[datetime(2022, 4, 2, 0, 0)].concentrations[2].wells[1].image_data
# Which returns:
# ImageData(raw_image='an_image.png', droplet_geometry='round', droplet_status=True, conc_idx=2, well_idx=1)Metadata
Metadata
Assignees
Labels
No labels