diff --git a/coconut/astar.coco b/coconut/astar.coco new file mode 100644 index 0000000..2e12109 --- /dev/null +++ b/coconut/astar.coco @@ -0,0 +1,346 @@ +import heapq +from loguru import logger +from pprint import pformat +from data_tree.coconut.monad import try_monad,Try,Success,Failure +import dill # for pickling inner lambda... +from tqdm.autonotebook import tqdm +from loguru import logger +from itertools import chain +from os.path import expanduser +from data_tree.util import DefaultShelveCache +import shelve +import os +from itertools import chain +data Edge(src,dst,f,cost,name="unnamed") +class NoRouteException(Exception) +class ConversionError(Exception) +class Conversion: + def __init__(self,edges): + self.edges = edges + + def __call__(self,x): + init_x = x + for e in self.edges: + try: + x = e.f(x) + except Exception as ex: + import inspect + import pickle + logger.error(f"caught an exception. inspecting..{ex}") + logger.warning(f"saving erroneous conversion for debug") + info= dict( + start = self.edges[0].src, + end = self.edges[-1].dst, + x = init_x + ) + logger.debug(f"conversion info = start:{info['start']},x:{info['x']}") + with open("last_erroneous_conversion.pkl","wb") as f: + pickle.dump(info,f) + source = inspect.getsource(e.f) + logger.warning("saved last conversion error cause") + raise ConversionError(f"exception in edge:{e.name} \n paths:{[e.name for e in self.edges]} \n x:{x} \n edge source:{source}") from ex + return x + + def __getitem__(self,item): + if isinstance(item,int): + edges = [(self.edges[item])] + else: + edges = self.edges[item] + return Conversion(edges) + + def __repr__(self): + if len(self.edges): + start = self.edges[0].src + end = self.edges[-1].dst + else: + start = "None" + end = "None" + info = dict( + name="Conversion", + start = start, + end = end, + path = [e.name for e in self.edges], + cost = sum([e.cost for e in self.edges]) + ) + return pformat(info) + def trace(self,tgt): + x = tgt + for e in self.edges: + x = e.f(x) + yield dict(edge= e,x=x) + +def new_conversion(edges): + return Conversion(edges) +class _HeapContainer: + def __init__(self,score,data): + self.score = score + self.data = data + def __lt__(self,other): + return self.score < other.score + +def _astar( + start, + matcher, + neighbors, + max_depth = 100): + """ + neighbors: node->[(mapper,next_node,cost,name)] + """ + to_visit = [] + scores = dict() + scores[start] = 0#heuristics(start,None) + heapq.heappush(to_visit, + _HeapContainer(scores[start],(start,[]))) + visited = 0 + bar = tqdm(desc="solving with astar") + while to_visit: + bar.update(1) + hc = heapq.heappop(to_visit) + score = hc.score + (pos,trace) = hc.data + visited += 1 + #print(f"visit:{pos}") + #print(f"{((trace[-1].a,trace[-1].name) if trace else 'no trace')}") + #print(f"visit:{trace[-1] if trace else 'no trace'}") + if len(trace) >= max_depth: # terminate search on max_depth + continue + if matcher(pos): # reached a goal + logger.debug(f"found after {visited} visits.") + logger.debug(f"search result:\n{new_conversion(trace)}") + bar.close() + return trace + for mapper,next_node,cost,name in neighbors(pos): + assert isinstance(cost,int),f"cost is not a number. cost:{cost},name:{name},pos:{pos}" + new_trace = trace + [Edge(pos,next_node,mapper,cost,name)] + try: + new_score = scores[pos] + cost #+ heuristics(next_node,end) + except Exception as e: + logger.error(f"pos:{pos},cost:{cost},next_node:{next_node}") + raise e + if next_node in scores and scores[next_node] <= new_score: + continue + + else: + scores[next_node] = new_score + heapq.heappush(to_visit,_HeapContainer(new_score,(next_node,new_trace))) + + raise NoRouteException(f"no route found from {start} matching {matcher}") + + + +def _astar_direct( + start, + end, + neighbors, + smart_neighbors, + heuristics, + edge_cutter, + max_depth = 100, + silent=False + ): + """ + neighbors: node->[(mapper,next_node,cost,name)] + """ + to_visit = [] + scores = dict() + scores[start] = heuristics(start,end) + heapq.heappush(to_visit, + _HeapContainer(scores[start],(start,[]))) + visited = 0 + bar = tqdm(desc="solving with astar_direct") + last_bar_update = visited + while to_visit: + if visited - last_bar_update > 1000: + bar.update(visited-last_bar_update) + last_bar_update = visited + hc = heapq.heappop(to_visit) + score = hc.score + (pos,trace) = hc.data + if not silent: + #logger.info(f"{score}:{pos}") + #bar.write(f"score:{score}") + pass + + #logger.debug(f"visiting:{pos}") + visited += 1 + #print(f"visit:{pos}") + #print(f"{((trace[-1].a,trace[-1].name) if trace else 'no trace')}") + #print(f"visit:{trace[-1] if trace else 'no trace'}") + if len(trace) >= max_depth: # terminate search on max_depth + continue + if pos == end: # reached a goal + if not silent: + logger.debug(f"found after {visited} visits.") + logger.debug(f"search result:\n{new_conversion(trace)}") + bar.close() + return trace + normal_nodes = list(neighbors(pos)) + smart_nodes = list(smart_neighbors(pos,end)) + #logger.debug(f"{normal_nodes},{smart_nodes}") + if visited % 10000 == 0: + msg = str(pos)[:50] + bar.set_description(f"""pos:{msg:<50}""") + for i,(mapper,next_node,cost,name) in enumerate(chain(normal_nodes,smart_nodes)): + assert isinstance(cost,int),f"cost is not a number:{pos}" + new_trace = trace + [Edge(pos,next_node,mapper,cost,name)] + try: + new_score = scores[pos] + cost + heuristics(next_node,end) + except Exception as e: + logger.error(f"pos:{pos},cost:{cost},next_node:{next_node}") + raise e + if next_node in scores and scores[next_node] <= new_score: + continue + elif(edge_cutter(pos,next_node,end)): + continue + else: + scores[next_node] = new_score + heapq.heappush(to_visit,_HeapContainer(new_score,(next_node,new_trace))) + + raise NoRouteException(f"no route found from {start} matching {end}. searched {visited} nodes.") + +astar = (_astar ..> new_conversion) |> try_monad +astar_direct = (_astar_direct ..> new_conversion) |> try_monad + +def _zero_heuristics(x,y): + return 0 + +def _no_cutter(x,y,end): + return False + +MAX_MEMO = 2**(20) + +class AStarSolver: + """ + to make this picklable, you have to have these caches on global variable. + use getstate and setstate + actually, having to pickle this solver every time you pass auto_data is not feasible. + so, lets have auto_data to hold solver in global variable and never pickle AStarSolver!. + so forget about lru_cache pickling issues. + """ + def __init__(self, + rules=None, + smart_rules=None, + heuristics = _zero_heuristics, + edge_cutter=_no_cutter, + cache_path=os.path.join(expanduser("~"),".cache/autodata.shelve") + ): + """ + rules: List[Rule] + Rule: (state)->List[(converter:(data)->data,new_state,cost,conversion_name)] + """ + from lru import LRU + self.rules = rules if rules is not None else [] + self.smart_rules = smart_rules if smart_rules is not None else [] + self.heuristics = heuristics + self.edge_cutter = edge_cutter + self.neighbors_memo = LRU(MAX_MEMO) # you cannot pickle a lru.LRU object, thus you cannot pickle this class for multiprocessing. + self.search_memo = LRU(MAX_MEMO) + self.smart_neighbors_memo = LRU(MAX_MEMO) + self.direct_search_cache = DefaultShelveCache(self._search_direct,cache_path) + self.direct_search_memo = LRU(MAX_MEMO) + + def neighbors(self,node): + if node in self.neighbors_memo: + return self.neighbors_memo[node] + + res = [] + for rule in self.rules: + edges = rule(node) + if edges is not None: + res += edges + self.neighbors_memo[node] = res + return res + def smart_neighbors(self,node,end): + if (node,end) in self.smart_neighbors_memo: + return self.smart_neighbors_memo[(node,end)] + res = [] + for rule in self.smart_rules: + edges = rule(node,end) + if edges is not None: + res += edges + self.smart_neighbors_memo[(node,end)] = res + #logger.debug(res) + return res + + def invalidate_cache(self): + self.neighbors_memo.clear() + self.search_memo.clear() + self.direct_search_memo.clear() + + def add_rule(self,f): + self.rules.append(f) + self.invalidate_cache() + + def search(self,start,matcher): + #problem is that you can't hash matcher + #let's use id of matcher for now. + q = (start,id(matcher)) + if q in self.search_memo: + res = self.search_memo[q] + else: + logger.debug(f"searching from {start} for matching {matcher}") + res = astar( + start=start, + matcher=matcher, + neighbors=self.neighbors, + ) + self.search_memo[q] = res + + case res: + match Success(res): + return res + match Failure(e,trc): + raise e + def _research_from_edges(self,edges): + searched_edges = list(chain(*[self._search_direct((src,dst,True)).edges for src,dst in edges])) + #logger.info(f"searched_edges:{searched_edges}") + return Conversion(searched_edges) + + def _search_direct(self,q): + # you cannot directly save the function. + # so you need to save the paths and re-search it + start,end,silent = q + if not silent: + logger.debug(f"searching {start} to {end}") + res = astar_direct( + start=start, + end=end, + neighbors=self.neighbors, + smart_neighbors=self.smart_neighbors, + heuristics=self.heuristics, + edge_cutter=self.edge_cutter, + silent=silent + ) + case res: + match Success(res): + return res + match Failure(e,trc): + raise e + def search_direct(self,start,end,silent=False): + key = (start,end,silent) + if key in self.direct_search_memo: + return self.direct_search_memo[key] + elif key in self.direct_search_cache: + edges = self.direct_search_cache[key] + conversion = self._research_from_edges(edges) + self.direct_search_memo[key] = conversion + logger.debug(f"researched_conversion:\n{conversion}") + return conversion + else: + conversion = self._search_direct(key) + self.direct_search_cache[key] = [(e.src,e.dst) for e in conversion.edges] + self.direct_search_memo[key] = conversion + # I can memo every path in conversion actually. + # however since the states are in a different space than a query, no speedups can be done. + # if this astar knows about casting, it can first search for a cache though.. + + return conversion + + def search_direct_any(self,start,ends): + for cand in ends: + try: + res = self.search_direct(start,cand) + return res + except Exception as e: + pass + raise NoRouteException(f"no route found from {start} to any of {ends}") \ No newline at end of file diff --git a/coconut/auto_data.coco b/coconut/auto_data.coco new file mode 100644 index 0000000..4e37f10 --- /dev/null +++ b/coconut/auto_data.coco @@ -0,0 +1,279 @@ +from typing import Mapping +from data_tree.coconut.astar import AStarSolver +from IPython.display import display +import dill # to make the lambda functions picklable +from loguru import logger +""" +What I want to achieve is to generate a class. +I want to generate a AutoImage class form AutoData +well the solution is to just use partially applied constructor. that's it. +""" +def identity(a): + return a + +class _CastLambda: + def __init__(self,rule,name,swap,cost=1): + self.rule = rule + self.name = name + self.swap = swap + self.cost = cost + def __call__(self,state): + new_states = self.rule(state) + if new_states is not None: + if self.name is None: + cast_name = f"{self.rule.__name__}" + else: + cast_name=self.name + if self.swap: + return [(identity,new_state,cast_name,self.cost) for new_state in new_states] + else: + return [(identity,new_state,self.cost,cast_name) for new_state in new_states] + else: + return None +class _ConversionLambda: + def __init__(self,rule,cost=1): + self.rule = rule + self.cost = cost + def __call__(self,state): + edges = self.rule(state) + if edges is None: + return [] + result = [] + for edge in edges: + case edge: + match (converter,new_state): + result.append((converter,new_state,self.cost,converter.__name__)) + match (converter,new_state,name): + result.append((converter,new_state,self.cost,name)) + match (converter,new_state,name,score): + result.append((converter,new_state,score,name)) + match _: + raise RuntimeError(f"rule:{self.rule} returned invalid edge:{edge}.") + return result +class _SmartConversionLambda: + def __init__(self,rule,cost=1): + self.rule = rule + self.cost = cost + def __call__(self,state,end): + edges = self.rule(state,end) + if edges is None: + return [] + result = [] + for edge in edges: + case edge: + match (converter,new_state): + result.append((converter,new_state,self.cost,converter.__name__)) + match (converter,new_state,name): + result.append((converter,new_state,self.cost,name)) + match (converter,new_state,name,score): + result.append((converter,new_state,score,name)) + match _: + raise RuntimeError(f"rule:{self.rule} returned invalid edge:{edge}.") + return result +class AutoSolver: + """ + TODO stop using local lambda in order to make this class picklable + Factory for an AutoData class + """ + def __init__(self,rules,smart_rules,heuristics=lambda x,y:0,edge_cutter=lambda x,y,end:False): + self.initial_rules = rules + self.smart_rules = smart_rules + self.solver = AStarSolver( + rules = self.initial_rules.copy(), + smart_rules = self.smart_rules.copy(), + heuristics = heuristics, + edge_cutter =edge_cutter + ) + + @staticmethod + def create_cast_rule(rule,name=None,_swap=False,cost=1): + """ + rule: State->List[State] # should return list of possible casts without data conversion. + """ + return _CastLambda(rule,name,_swap,cost=cost) + + def add_cast(self,rule,name=None): + """ + rule: State->List[State] # should return list of possible casts without data conversion. + """ + + self.add_conversion(AutoSolver.create_cast_rule(rule,name=name,_swap=True)) + + def add_alias(self,a,b): + self.add_cast(state->[b] if state == a else None,name=f"alias: {a}->{b}") + self.add_cast(state->[a] if state == b else None,name=f"alias: {b}->{a}") + + @staticmethod + def create_alias_rule(a,b): + def caster(state): + if state == a: + return [b] + elif state == b: + return [a] + return AutoSolver.create_cast_rule(caster,f"alias:{a}=={b}") + + @staticmethod + def create_conversion_rule(rule): + return _ConversionLambda(rule) + @staticmethod + def create_smart_conversion_rule(rule): + return _SmartConversionLambda(rule) + + def add_conversion(self,rule): + """ + rule: State->List[(converter,new_state,name(optional),cost(optional))] + """ + self.solver.add_rule(AutoSolver.create_conversion_rule(rule)) + + def reset_solver(self,): + self.solver = AStarSolver( + rules = self.initial_rules.copy(), + smart_rules = self.smart_rules.copy(), + heuristics = heuristics, + edge_cutter =edge_cutter + ) + + def debug_conversion(self,a,b,samples): + x = samples + edges = self.solver.search_direct(a,b).edges + for edge in edges: + print(edge) + print(edge.f) + x = edge.f(x) + print(f"converted to type:{type(x)}") + if x `isinstance` np.ndarray: + print(x.shape) + print(f"converted:{x}") + return x + + + +class TagMatcher: + def __init__(self,**kwargs): + self.kwargs = kwargs + + def __call__(self,state): + if isinstance(state,Mapping): + for k,v in self.kwargs.items(): + if not k in state or not state[k] == v: + return False + return True #every item matched. + else: + return False + @property + def __name__(self): + return f"TagMatcher|{self.kwargs}" + + def __str__(self): + return self.__name__ + + +@memoize(1024) +def tag_matcher(**kwargs): + return TagMatcher(**kwargs) + +SOLVERS = dict() + +class AutoData: + """ + Interface class for a user + """ + def to_debug(self,format): + format = parse_def(format) + return AutoData.debug_conversion(self.format,format,self.value) + + def __init__(self,value,format,solver): + self.value = value + self.format = format + self.solver_id = id(solver) # do not hold solver, but hold solver's id. in order to make this picklable. + if self.solver_id not in SOLVERS: + SOLVERS[self.solver_id] = solver + + @property + def solver(self): + return SOLVERS[self.solver_id] + + def converter(self,format=None,**kwargs): + if format is not None: + return self.solver.solver.search_direct(self.format,format) + else: + return self.solver.solver.search(self.format,tag_matcher(**kwargs)) + + def convert(self,format=None,**kwargs) -> AutoData: + """converts internal data to specified format.""" + conversion = self.converter(format,**kwargs) + if conversion.edges: + return self.__class__(conversion(self.value),conversion.edges[-1].dst,self.solver) + else: + return self + def search_converter(self,f): + return self.solver.solver.search(self.format,f) + + def search(self,matcher,ignore_error=True) -> AutoData: + if ignore_error: + def _matcher(state): + try: + return matcher(state) + except Exception as e: + pass + conversion = self.search_converter(_matcher) + else: + conversion = self.search_converter(matcher) + if conversion.edges: + return self.__class__(conversion(self.value),conversion.edges[-1].dst,self.solver) + else: + return self + + def to(self,format=None,**kwargs): # I want 'to' to accept format string too + # if format is given, use direct matching. + # else use tag matching + # format can be of any type, but you need to have a conversion rule to tag_dict, otherwise you won't get any result + # so, ask user to provide any state and state->tag_dict rule. + # That's it. + converted = self.convert(format=format,**kwargs) + return converted.value + + def map(self,f,new_format=None): + if new_format is not None: + format = new_format + else: + format = self.format + return self.__class__(f(self.value),format,self.solver) + + def map_in(self,start_format,f,new_format=None): + return self.__class__(f(self.to(start_format)),new_format??self.format,self.solver) + + def neighbors(self): + return self.solver.solver.neighbors(self.format) + + def to_widget(self): + return self.to("widget") + + def _repr_html_(self): + self.format |> display + self.to("widget") |> display + + def __repr__(self): + return f"<{self.__class__} {self.format}>" + + def _repr_png_(self): + try: + return self.to(type="image")._repr_png_() + except Exception as e: + logger.warning(f"cannot convert data to an image:{self.format}") + return None + + def cast(self,format): + return self.__class__(self.value,format,self.solver) + + def show(self): + from matplotlib.pyplot import imshow,show + imshow(self.to("numpy_rgb")) + show() + + +# def __getstate__(self): + + +def AutoData.call(self,name,*args,**kwargs): + return self.to(name)(*args,**kwargs) diff --git a/coconut/convert.coco b/coconut/convert.coco new file mode 100644 index 0000000..8688222 --- /dev/null +++ b/coconut/convert.coco @@ -0,0 +1,899 @@ +from PIL import Image +import numpy as np +import heapq +from data_tree.coconut.visualization import infer_widget +from loguru import logger +from data_tree.coconut.astar import new_conversion,AStarSolver,NoRouteException +from math import sqrt +from PIL import Image +import torch +import re +VR_0_1 = "0_1" +VR_0_255 = "0_255" +VR_None = "None" +VR_XYZ_Normalized = "XYZ_Normalized" +ch_splitter = re.compile("[A-Z][a-z]*").findall + +data DataType +#TODO add shape information to tensorlike +#TODO add shape information to PILImage + +data TensorLike( + dtype is str, + arrange is str, + channel_repr is str, + value_range is str) from DataType: + def __repr__(self): + return f"Tensor({self.data_type}|{self.dtype}|{self.arrange}|{self.channel_repr}|{self.value_range})" + +data Numpy(dtype,arrange,channel_repr,value_range) from TensorLike: + def __new__(cls,*args): + return makedata(cls,*args) + def __repr__(self): + return f"Numpy({self.dtype},{self.arrange},{self.channel_repr},{self.value_range})" + +data Torch(dtype,arrange,channel_repr,value_range) from TensorLike: + def __new__(cls,*args): + return makedata(cls,*args) + def __repr__(self): + return f"Torch({self.dtype},{self.arrange},{self.channel_repr},{self.value_range})" + +data Hdf5(dtype,arrange,channel_repr,value_range) from TensorLike: + def __new__(cls,*args): + return makedata(cls,*args) + def __repr__(self): + return f"Hdf5({self.dtype},{self.arrange},{self.channel_repr},{self.value_range})" + +data PILImages(mode,channel_repr) from DataType: # represents iterable of PIL.Images + def __repr__(self): + return f"PILImages({self.mode},{self.channel_repr})" +data PILImage(mode,channel_repr) from DataType: + def __repr__(self): + return f"PILImage({self.mode},{self.channel_repr})" + +data ImageDef(data_type is DataType,tags is frozenset): + def __repr__(self): + return f"ImageDef({self.data_type}|{list(self.tags)})" + + +DTYPES={"float32","float64","int32","int64","uint8","bool"} +data Edge(a:ImageDef,b:ImageDef,f,cost:int,name="undefined"): + def __repr__(self): + return f"{self.a} \t-> {self.name}\t-> {self.b}" +from typing import List + +#純粋にエッジだけを考えると、どうしても組み合わせ爆発になる。目的地を知っていれば削減できる。 + +# 各imdefのNodeベースでエッジを定義するのか。それとも。エッジのルールを網羅するのか。 +# オペレーターのほうが数が少ないので、オペレーターだけ定義したい。 +# List up operators. +# operator definition: ImageDef->List[Edge] +# 1. change data_type +# 2. change dtype +# 3. change arrange +# 4. change ch_repr +# 5. select channel +def to_imagedef(f): + def _inner(imdef:ImageDef): + try: + #logger.debug(type(imdef)) + if imdef `isinstance` ImageDef and len(imdef) >= 1 and imdef `hasattr` "data_type": + #if imdef `isinstance` ImageDef: + edges = f(imdef.data_type) + if edges is not None: + return [Edge(imdef,ImageDef(e.b,imdef.tags),e.f,e.cost,e.name) for e in edges] + else: + return [] + else: + return [] + except Exception as e: + logger.warning(f"unknown error...imdef:{imdef}") + logger.warning(f"{imdef} has attr causes exception?") + logger.warning(f"{hasattr(imdef,'data_type')}") + raise e + return _inner + + + +@to_imagedef +def to_PILImages(imdef:ImageDef)->Edge[]: + #TODO fix pattern match on data class + case imdef: + match Numpy("uint8","BHWC", c_repr, =VR_0_255) if len(ch_splitter(c_repr)) in (3,4): + return [Edge(imdef,PILImages(c_repr,c_repr),ary -> [(Image.fromarray)(img) for img in ary],2,name=f"numpy batch {ch_repr} to Images")] + match Numpy("uint8","BHW",c_repr,=VR_0_255): + return [Edge(imdef,PILImages("L",c_repr),ary -> [(Image.fromarray ..> .convert("L"))(img) for img in ary],2,name="numpy batch to images")] + match Numpy("uint8","HW",c_repr,=VR_0_255): + return [Edge(imdef,PILImage("L",c_repr), Image.fromarray ..> .convert("L"),2,name="numpy HW to PIL Image")] + return [] +@to_imagedef +def to_numpy(imdef:ImageDef)->List[Edge]: + case imdef: + match Torch(dtype,arng,ch_repr,vr): # torch tensor can always become numpy + return [Edge(imdef, + Numpy(dtype ,arng ,ch_repr,vr), + (.detach() ..> .cpu() ..> .numpy()), + 1, + name="torch_to_numpy")] + match PILImage("RGB",ch_repr): + return [Edge(imdef, + Numpy("uint8","HWC",ch_repr,VR_0_255), + np.array, + 1, + name="image_to_numpy")] + match PILImage("L",ch_repr): + return [Edge(imdef, + Numpy("uint8","HW",ch_repr,VR_0_255), + np.array, + 1, + name="image_to_numpy")] + match PILImage("YCbCr",ch_repr): + return [Edge(imdef, + Numpy("uint8","HWC",ch_repr,VR_0_255), + np.array, + 1, + name="YCbCr image to numpy" + )] + + match PILImages("L",ch_repr): # A grayscale Image becomes a numpy array + return [Edge(imdef, + Numpy("uint8","BHW",ch_repr,VR_0_255), + (fmap$(np.array) ..> np.array), + 1, + name="image_to_numpy")] + match PILImages(mode,ch_repr):# A multi-channel Image becomes a numpy array + return [Edge(imdef, + Numpy("uint8","BHWC",ch_repr,VR_0_255), + (fmap$(np.array) ..> np.array), + 1, + name="image_to_numpy")] + return [] +@to_imagedef +def to_torch(imdef:ImageDef): + import torch + case imdef: + match Numpy(dtype,arng,ch_repr,vr): # only numpy can directly become a torch tensor + return [Edge(imdef,Torch(dtype,arng,ch_repr,vr),torch.from_numpy,2,name="to_torch")] + return [] +@to_imagedef +def change_dtype(imdef:ImageDef):# TODO match value range to dtype with bool type + case imdef: + match Numpy(dtype,arng,ch_repr,vr): + return [Edge( + imdef, + imdef.__class__(_dtype,arng,ch_repr,vr), + .astype(_dtype), + 1, + name=f"{dtype} to {_dtype}" + ) for _dtype in DTYPES if _dtype != dtype] + return [] + + +def change_arng(imdef): + case imdef: + match Numpy(_,"BCHW",_,_): + return [(.transpose(0,2,3,1),"BHWC")] + match Numpy(_,"BHWC",_,_): + return [(.transpose(0,3,1,2),"BCHW")] + match Torch(_,"BCHW",_,_): + return [(.transpose(1,2) ..> .transpose(2,3),"BHWC")] + match Torch(_,"BHWC",_,_): + return [(.transpose(2,3) ..> .transpose(1,2),"BCHW")] + return [] + +@to_imagedef +def drop_alpha(imdef): + case imdef: + match TensorLike(dtype,"BHWC","RGBA",vr): + return [Edge(a=imdef, + b=imdef.__class__(dtype,"BHWC","RGB",vr), + f=a->a[:,:,:,:3], + cost=1, + name=f"select rgb channel")] + match TensorLike(dtype,"BCHW","RGBA",vr): + return [Edge(a=imdef, + b=imdef.__class__(dtype,"BCHW","RGB",vr), + f=a->a[:,:3], + cost=1, + name=f"select rgb channel")] +@to_imagedef +def change_arrange(imdef:ImageDef): + match TensorLike(dtype,arng,ch_repr,vr) in imdef: + return [Edge(imdef,imdef.__class__(dtype,_arng,ch_repr,vr),f,1,name=f"{arng} to {_arng}") for f,_arng in change_arng(imdef)] + return [] + + + +@to_imagedef +def select_channel(imdef:ImageDef): + case imdef: + match TensorLike(dtype,"BHWC",ch_repr,vr) if len(ch_repr) >= 1: + selector = i->a->a[:,:,:,[i]] + return [Edge(a=imdef, + b=imdef.__class__(dtype,"BHWC",c,vr), + f=selector(i), + cost=10, + name=f"select {c} channel") for i,c in enumerate(ch_splitter(ch_repr))] + match TensorLike(dtype,"BCHW",ch_repr,vr) if len(ch_repr) >= 1: + selector = i->a->a[:,[i]] + return [Edge(a=imdef, + b=imdef.__class__(dtype,"BCHW",c,vr), + f=selector(i), + cost=10, + name=f"select {c} channel") for i,c in enumerate(ch_splitter(ch_repr))] + return [] +@to_imagedef +def drop_channel(imdef:ImageDef): + case imdef: + match TensorLike(dtype,="BHWC",ch_repr,vr) if len(ch_splitter(ch_repr)) == 1: + return [Edge(a=imdef, + b=imdef.__class__(dtype,"BHW",ch_repr,vr), + f=a->a[:,:,:,0], + cost = 1, + name=f"BHWC to BHW" + )] + match TensorLike(dtype,"BCHW",ch_repr,vr) if len(ch_splitter(ch_repr)) == 1: + return [Edge(a=imdef, + b=imdef.__class__(dtype,"BHW",ch_repr,vr), + f=a->a[:,0], + cost = 1, + name=f"BCHW to BHW" + )] + match TensorLike(dtype,"CHW",ch_repr,vr) if len(ch_splitter(ch_repr)) == 1: + return [Edge(a = imdef,b=imdef.__class__(dtype,"HW",ch_repr,vr), + f = a->a[0],cost=1,name="CHW to HW" + )] + match TensorLike(dtype,"HWC",ch_repr,vr) if len(ch_splitter(ch_repr)) == 1: + return [Edge(a = imdef,b=imdef.__class__(dtype,"HW",ch_repr,vr), + f = a->a[:,:,0], cost=1,name="HWC to HW" + )] + + return [] +def enforce_mode(img,mode): + return Image.fromarray(np.array(img),mode) +""" +@to_imagedef +def RGB_to_YCbCr(state): + case state: + match PILImage("RGB","RGB"): + return [Edge( + a=state, + b=PILImage("YCbCr","YCbCr"), + f= enforce_mode$(mode="RGB") ..> .convert("YCbCr"), + cost=1, + name="RGB to YCbCr" + )] + match PILImage("YCbCr","YCbCr"): + return [Edge( + a=state, + b=PILImage("RGB","RGB"), + f= enforce_mode$(mode="YCbCr") ..> .convert("RGB"), + cost=1, + name="YCbCr to RGB" + )] +""" +def rgb_to_ycbcr(image: torch.Tensor) -> torch.Tensor: + r"""Convert an RGB image to YCbCr. + + Args: + image (torch.Tensor): RGB Image to be converted to YCbCr with shape :math:`(*, 3, H, W)`. + + Returns: + torch.Tensor: YCbCr version of the image with shape :math:`(*, 3, H, W)`. + + Examples: + >>> input = torch.rand(2, 3, 4, 5) + >>> output = rgb_to_ycbcr(input) # 2x3x4x5 + """ + if not isinstance(image, torch.Tensor): + raise TypeError("Input type is not a torch.Tensor. Got {}".format( + type(image))) + + if len(image.shape) < 3 or image.shape[-3] != 3: + raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}" + .format(image.shape)) + + r: torch.Tensor = image[..., 0, :, :] + g: torch.Tensor = image[..., 1, :, :] + b: torch.Tensor = image[..., 2, :, :] + + delta: float = 0.5 + y: torch.Tensor = 0.299 * r + 0.587 * g + 0.114 * b + cb: torch.Tensor = (b - y) * 0.564 + delta + cr: torch.Tensor = (r - y) * 0.713 + delta + return torch.stack([y, cb, cr], -3) + + +def ycbcr_to_rgb(image: torch.Tensor) -> torch.Tensor: + r"""Convert an YCbCr image to RGB. + + The image data is assumed to be in the range of (0, 1). + + Args: + image (torch.Tensor): YCbCr Image to be converted to RGB with shape :math:`(*, 3, H, W)`. + + Returns: + torch.Tensor: RGB version of the image with shape :math:`(*, 3, H, W)`. + + Examples: + >>> input = torch.rand(2, 3, 4, 5) + >>> output = ycbcr_to_rgb(input) # 2x3x4x5 + """ + if not isinstance(image, torch.Tensor): + raise TypeError("Input type is not a torch.Tensor. Got {}".format( + type(image))) + + if len(image.shape) < 3 or image.shape[-3] != 3: + raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}" + .format(image.shape)) + + y: torch.Tensor = image[..., 0, :, :] + cb: torch.Tensor = image[..., 1, :, :] + cr: torch.Tensor = image[..., 2, :, :] + + delta: float = 0.5 + cb_shifted: torch.Tensor = cb - delta + cr_shifted: torch.Tensor = cr - delta + + r: torch.Tensor = y + 1.403 * cr_shifted + g: torch.Tensor = y - 0.714 * cr_shifted - 0.344 * cb_shifted + b: torch.Tensor = y + 1.773 * cb_shifted + return torch.stack([r, g, b], -3) + + +@to_imagedef +def RGB_to_YCbCr(state): + case state: + match Torch("float32","BCHW","RGB",=VR_0_1): + return [Edge(a=state, + b=Torch("float32","BCHW","RGB",VR_0_1), + f=rgb_to_ycbcr, + cost=1, + name="RGB_to_YCbCr(torch)" + )] + match Torch("float32","BCHW","YCbCr",=VR_0_1): + return [Edge(a=state, + b=Torch("float32","BCHW","RGB",VR_0_1), + f=ycbcr_to_rgb, + cost=1, + name="YCbCr_to_RGB(torch)" + )] + match Torch("float32","CHW","RGB",=VR_0_1): + return [Edge(a=state, + b=Torch("float32","CHW","YCbCr",VR_0_1), + f=rgb_to_ycbcr, + cost=1, + name="RGB_to_YCbCr(torch)" + )] + match Torch("float32","CHW","YCbCr",=VR_0_1): + return [Edge(a=state, + b=Torch("float32","CHW","RGB",VR_0_1), + f=ycbcr_to_rgb, + cost=1, + name="YCbCr_to_RGB(torch)" + )] + + + + +def en_batch(imdef:ImageDef): + case imdef: + match ImageDef(TensorLike(dtype,"HWC" or "CHW" or "HW",ch_repr,vr),tags): + new_arng = "B"+imdef.data_type.arrange + return [Edge(a=imdef, + b=ImageDef(imdef.data_type.__class__(dtype,new_arng,ch_repr,vr),tags|frozenset(("en_batched",))), + f=a->a[None], + cost=10, + name=f"{imdef.data_type.arrange} to {new_arng} (en_batch)" + )] + match ImageDef(PILImage(mode,channel_repr),tags): + return [Edge(a=imdef, + b=ImageDef(PILImages(mode,channel_repr),tags|frozenset(("en_batched",))), + f=a->[a], + cost=10, + name=f"wrap image with list (en_batch)" + )] + return [] +def de_batch(imdef:ImageDef): + case imdef: + match ImageDef(TensorLike(dtype,arng,ch,vr),tags) if "en_batched" in tags and "B" in arng: + return [Edge( + a=imdef, + b=ImageDef(imdef.data_type.__class__(dtype,arng[1:],ch,vr),tags-frozenset(["en_batched"])), + f=a->a[0], + cost=1, + name=f"de_batch en_batched image" + )] + match ImageDef(PILImages(mode,ch),tags) if "en_batched" in tags: + return [Edge( + a=imdef, + b=ImageDef(PILImage(mode,ch),tags-frozenset(["en_batched"])), + f=a->a[0], + cost=1, + name=f"de_batch en_batched image" + )] + +def drop_batch_tag(imdef:ImageDef): + case imdef: + match ImageDef(data_type,tags) if "en_batched" in tags: + return [Edge(imdef, + ImageDef(data_type,tags-frozenset(("en_batched",))), + f=a->a, + cost=1, + name="drop en_batched tag" + )] + +@to_imagedef +def to_rgba(imdef:ImageDef): + case imdef: + match TensorLike(dtype,arng,ch_repr,"0_1") if len(ch_repr) == 4: + return [Edge(a=imdef, + b=imdef.__class__(dtype,arng,"RGBA","0_1"), + f=a->a, + cost=10, + name=f"view {ch_repr} as RGBA " + )] + match TensorLike(dtype,arng,ch_repr,"0_1") if len(ch_repr) == 3: + return [Edge(a=imdef, + b=imdef.__class__(dtype,arng,"RGB","0_1"), + f=a->a, + cost=10, + name=f"view {ch_repr} as RGB " + )] +@to_imagedef +def change_value_range(imdef:ImageDef): + case imdef: + match TensorLike("float32" or "float64",arng,ch_repr,=VR_0_255): + return [Edge(a=imdef, + b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_1), + f=a->a/255.0, + cost=len(ch_repr), + name="0-255 to 0-1" + )] + match TensorLike("float32" or "float64",arng,ch_repr,=VR_0_1): + return [Edge(a=imdef, + b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_255), + f=a->a*255.0, + cost=len(ch_repr), + name="0-1 to 0-255" + )] + return [] + +def xyza_to_rgba(xyza): + xyz = xyza[:3] + a = xyza[[3]] + rgb = (xyz+1)/2 + return np.concatenate((rgb,a),axis=0) +def xyz_to_rgb(xyz): + return (xyz+1)/2 +def rgb_to_xyz(rgb): + return (rgb*2)-1 +def rgba_to_xyza(rgba): + rgb = rgba[:3] + a = rgba[[3]] + xyz = (rgb*2)-1 + return np.concatenate((xyz,a),axis=0) + +def rule_xyz_to_rgb(imdef): + case imdef: + match ImageDef(Numpy(dtype,"CHW","XYZA","-1_1"),tags): + return [ + (xyza_to_rgba,ImageDef(Numpy(dtype,"CHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba") + ] + match ImageDef(Numpy(dtype,"CHW","XYZ","-1_1"),tags): + return [ + (xyz_to_rgb,ImageDef(Numpy(dtype,"CHW","RGB",VR_0_1),tags),2,"xyz_to_rgb") + ] + match ImageDef(Numpy(dtype,"CHW","RGBA",=VR_0_1),tags): + return [ + (rgba_to_xyza,ImageDef(Numpy(dtype,"CHW","XYZA","-1_1"),tags),2,"rgba_to_xyza") + ] + match ImageDef(Numpy(dtype,"CHW","RGB",=VR_0_1),tags): + return [ + (rgb_to_xyz,ImageDef(Numpy(dtype,"CHW","XYZ","-1_1"),tags),2,"rgb_to_xyz") + ] + +def b_xyza_to_rgba(xyza): + xyz = xyza[:,:3] + a = xyza[:,[3]] + rgb = (xyz+1)/2 + return np.concatenate((rgb,a),axis=1) +def b_xyz_to_rgb(xyz): + return (xyz+1)/2 +def b_rgb_to_xyz(rgb): + return (rgb*2)-1 +def b_rgba_to_xyza(rgba): + rgb = rgba[:,:3] + a = rgba[:,[3]] + xyz = (rgb*2)-1 + return np.concatenate((xyz,a),axis=1) + +def rule_batch_xyz_to_rgb(imdef): + case imdef: + match ImageDef(Numpy(dtype,"BCHW","XYZA","-1_1"),tags): + return [ + (b_xyza_to_rgba,ImageDef(Numpy(dtype,"BCHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba(batch)") + ] + match ImageDef(Numpy(dtype,"BCHW","XYZ","-1_1"),tags): + return [ + (b_xyz_to_rgb,ImageDef(Numpy(dtype,"BCHW","RGB",VR_0_1),tags),2,"xyz_to_rgb(batch)") + ] + match ImageDef(Numpy(dtype,"BCHW","RGBA",=VR_0_1),tags): + return [ + (b_rgba_to_xyza,ImageDef(Numpy(dtype,"BCHW","XYZA","-1_1"),tags),2,"rgba_to_xyza(batch)") + ] + match ImageDef(Numpy(dtype,"BCHW","RGB",=VR_0_1),tags): + return [ + (b_rgb_to_xyz,ImageDef(Numpy(dtype,"BCHW","XYZ","-1_1"),tags),2,"rgb_to_xyz(batch)") + ] + + + +_conversions =[ + to_PILImages, + to_numpy, + to_torch, + change_dtype, + change_arrange, + select_channel, + drop_channel, + en_batch, + change_value_range, + drop_alpha, + to_rgba, + drop_batch_tag, + de_batch, + RGB_to_YCbCr, +] + + +@memoize(1024) +def _edges(imdef): + res = [] + for f in _conversions: + edges = f(imdef) + if edges is not None: + res += edges + return res + + + + +@memoize(1024) +def str_to_img_def(query): + """ + ex1: 'numpy,float32,BCHW,RGB,0_255 | hello,world' + ex2: 'torch,float32,BCHW,RGBA,0_1' + ex3: 'image,RGBA,RGBA' + ex4: 'images,RGB,RGB|tag1,tag2...' + """ + vrs = { + "0_255":VR_0_255, + "0_1":VR_0_1, + "None":VR_None + } + query = query.replace(" ","") + def query_to_data_type(query): + case query.split(","): + match ["numpy",dtype,arng,ch,vr]: + return Numpy(dtype,arng,ch,vrs[vr] if vr in vrs else vr) + match ["torch",dtype,arng,ch,vr]: + return Torch(dtype,arng,ch,vrs[vr] if vr in vrs else vr) + match ["image",mode,ch]: + return PILImage(mode,ch) + match ["images",mode,ch]: + return PILImages(mode,ch) + case query.split("|"): + match [data_type]: + return ImageDef(query_to_data_type(data_type),frozenset()) + match [data_type,tags]: + return ImageDef(query_to_data_type(data_type),frozenset(tags.split(","))) + else: + raise RuntimeError(f"could not parse image def string!:{query}") + +def parse_def(img_def): + try: + return str_to_img_def(img_def) if img_def `isinstance` str else img_def + except Exception as e: + return img_def + + + +accept_def_str = f -> parse_def ..> f +def imdef_neighbors(imdef): + return [(e.f,e.b,e.cost,e.name) for e in _edges(imdef)] + +#from data_tree.coconut.convert import AutoImage,PILImage,str_to_img_def,PILImages +#from data_tree.coconut.convert import ImageDef,Torch,Numpy,TensorLike,VR_0_1,VR_None,VR_0_255 + +def normalize_numpy_img(ary): + _min = ary.min() + _max = ary.max() + return ((ary-_min)/(_max-_min)) + +def rule_VR_None_to_normalized(imdef): + case imdef: + match ImageDef(Numpy(dtype,("CHW" or "HW") as arng,ch,=VR_None),tags): + return [( + normalize_numpy_img, + ImageDef(Numpy(dtype,arng,ch,VR_0_1),tags), + 1, + "minmax_0_1_numpy_img" + )] + match ImageDef(Numpy(dtype,"BCHW",ch,=VR_None),tags): + return [( + batch->np.array([normalize_numpy_img(img) for img in batch]), + ImageDef(Numpy(dtype,"BCHW",ch,VR_0_1),tags), + 1, + "batch_minmax_0_1_numpy_img" + )] +def rule_add_channel(imdef): + case imdef: + match ImageDef(Numpy(dtype,"HW",ch,vr),tags): + return [( + a->a[None], + ImageDef(Numpy(dtype,"CHW",ch,vr),tags), + 1, + "add_channel_dim" + )] + match ImageDef(Numpy(dtype,"BHW",ch,vr),tags): + return [( + a->a[:,None], + ImageDef(Numpy(dtype,"BCHW",ch,vr),tags), + 1, + "add_channel_dim" + )] +def rule_swap_RGB_BGR(imdef): + case imdef: + match ImageDef(TensorLike(dtype,"BHWC",("RGB" or "BGR") as rgb_order,vr) as tl,tags): + return [( + a->a[:,:,:,[2,1,0]], + ImageDef(tl.__class__(dtype,"BHWC","RGB" if rgb_order.startswith("B") else "BGR",vr),tags), + 1, + "swap rgb or bgr" + )] +def rule_BGR_to_LAB(imdef): + from skimage import color + case imdef: + match ImageDef(Numpy("float32","HWC","BGR",=VR_0_1),tags): + return[( + color.rgb2lab, + ImageDef(Numpy("float32","HWC","LAB","VR_LAB"),tags), + 1, + "bgr_0_1 to lab" + )] + match ImageDef(Numpy("float32","HWC","LAB","VR_LAB"),tags): + return [( + color.lab2rgb, + ImageDef(Numpy("float32","HWC","BGR",VR_0_1),tags), + 1, + "lab to bgr_0_1" + )] + + + + +class AutoImage: + default_rules = [ + imdef_neighbors, + rule_xyz_to_rgb, + rule_batch_xyz_to_rgb, + rule_VR_None_to_normalized, + rule_add_channel, + rule_swap_RGB_BGR, + rule_BGR_to_LAB + ] + solver = AStarSolver(rules=default_rules.copy()) + + @staticmethod + def reset_solver(): + AutoImage.solver = AStarSolver(rules = AutoImage.default_rules.copy()) + + @staticmethod + def debug_conversion(a,b,samples): + x = samples + edges = AutoImage.solver.search_direct(a,b).edges + for edge in edges: + print(edge) + print(edge.f) + x = edge.f(x) + print(f"converted to type:{type(x)}") + if x `isinstance` np.ndarray: + print(x.shape) + print(f"converted:{x}") + return x + + def to_debug(self,img_def): + img_def = parse_def(img_def) + return AutoImage.debug_conversion(self.img_def,img_def,self.data) + + def __init__(self,data,img_def): + img_def = parse_def(img_def) + self.data = data + self.img_def = img_def + + def converter(self,img_def): + img_def = parse_def(img_def) + return AutoImage.solver.search_direct(self.img_def,img_def) + + def any_converter(self,img_defs): + imdefs = [parse_def(imdef) for imdef in img_defs] + return AutoImage.solver.search_direct_any(self.img_def,imdefs) + + def convert(self,img_def): + convert = self.converter(img_def) + if convert.edges: + return AutoImage(convert(self.data),convert.edges[-1].dst) + else: + return self + + def any_convert(self,imdefs): + converter = self.any_converter(imdefs) + if converter.edges: + return AutoImage(converter(self.data),converter.edges[-1].dst) + else: + return self + + def to(self,img_def is (str,ImageDef),log_trace=False): + return self.convert(img_def).data + + def any_to(self,imdefs): + return self.any_convert(imdefs).data + + def to_widget(self): + case self.img_def.data_type: + match item is PILImages: + return self.tile_image().to_widget() + match TensorLike(_,arng,*_) if "B" in arng: + return self.tile_image().to_widget() + else: + convert = self.converter(self.to_images_def()) + return convert(self.data) |> infer_widget + + def _repr_html_(self): + return self.to_widget() |> display + + def to_images_def(self): + """ + you have to add en_batched tag when data is not batch. + """ + tag_opt=frozenset() + img_cls = PILImages + case self.img_def: + match ImageDef(TensorLike(_,arng,_,_),tags) if "B" not in arng: + tag_opt = frozenset(("en_batched",)) + match ImageDef(PILImage(mode,ch),tags): + tag_opt = frozenset(("en_batched",)) + + case self.img_def.data_type: + match PILImage(mode,chrepr): + return ImageDef(PILImages(mode,chrepr),self.img_def.tags | tag_opt) + match PILImages(mode,chrepr): + return self.img_def + match TensorLike(dtype,arng,c,vr) if len(c) == 1: + return ImageDef(img_cls("L",c),self.img_def.tags | tag_opt) + match TensorLike(dtype,arng,"RGBA",vr): + return ImageDef(img_cls("RGBA","RGBA"),self.img_def.tags | tag_opt) + match TensorLike(dtype,arng,"RGB",vr): + return ImageDef(img_cls("RGB","RGB"),self.img_def.tags | tag_opt) + match TensorLike(dtype,arng,ch,vr) if "A" in ch and ch != "LAB": + return ImageDef(img_cls("RGBA","RGBA"),self.img_def.tags | tag_opt) + else: + attempts=[ + "image,RGBA,RGBA", + "images,RGBA,RGBA", + "image,RGB,RGB", + "images,RGB,RGB", + "image,L,L", + "images,L,L" + ] + for tgt in attempts: + imdef = str_to_img_def(tgt) + try: + converter = self.converter(imdef) + return imdef + except NoRouteException as e: + #logger.warning(f"no route for:{imdef}. trying next imdef.") + pass + raise RuntimeError(f"cannot convert to image:{self.img_def} to any image_like imdef}") + + + def image_op(self,f:Image->Image): + images_def = self.to_images_def() + images = self.to(images_def) + new_images=[f(i) for i in images ] # do some resizing or something + new_ai = AutoImage(new_images,images_def) + return new_ai.convert(self.img_def) # go back to last state. + + def visdom(self,visdom=None,**kwargs): + if visdom is None: + from data_tree.visdom import VISDOM + visdom = VISDOM + candidates = [ + "numpy,float32,CHW,RGB,0_1", + "numpy,float32,CHW,L,0_1", + "numpy,float32,BCHW,RGB,0_1", + "numpy,float32,BCHW,L,0_1" + ] + img = self.any_convert(candidates) + data_type = img.img_def.data_type + case data_type: + match Numpy(_,"CHW",_,_): + res = visdom.image(img.data,**kwargs) + match Numpy(_,"BCHW",_,_): + res = visdom.images(img.data,**kwargs) + return res + + +@property +def AutoImage.images(self): + return self.to(self.to_images_def()) + +@property +def AutoImage.image_size(self): + return self.images[0].size + +def make_grid(imgs, nrow, padding=0): + """Numpy配列の複数枚の画像を、1枚の画像にタイルします + + Arguments: + imgs {np.ndarray} -- 複数枚の画像からなるテンソル + nrow {int} -- 1行あたりにタイルする枚数 + + Keyword Arguments: + padding {int} -- グリッドの間隔 (default: {0}) + + Returns: + [np.ndarray] -- 3階テンソル。1枚の画像 + """ + assert imgs.ndim == 4 and nrow > 0 + batch, height, width, ch = imgs.shape + n = nrow * (batch // nrow + np.sign(batch % nrow)) + ncol = n // nrow + pad = np.zeros((n - batch, height, width, ch), imgs.dtype) + x = np.concatenate([imgs, pad], axis=0) + # border padding if required + if padding > 0: + x = np.pad(x, ((0, 0), (0, padding), (0, padding), (0, 0)), + "constant", constant_values=(0, 0)) # 下と右だけにpaddingを入れる + height += padding + width += padding + x = x.reshape(ncol, nrow, height, width, ch) + x = x.transpose([0, 2, 1, 3, 4]) # (ncol, height, nrow, width, ch) + x = x.reshape(height * ncol, width * nrow, ch) + if padding > 0: + x = x[:(height * ncol - padding),:(width * nrow - padding),:] # 右端と下端のpaddingを削除 + return x + + +def AutoImage.tile_image(self,w=1024,h=1024,max_image=100,padding=1): + ch = self.to_images_def().data_type.channel_repr + if len(ch) == 1: + codec = f"numpy,uint8,BHW,{ch},0_255" + else: + codec = f"numpy,uint8,BHWC,{ch},0_255" + imgs = self.to(codec)[:max_image] + nrow = int(sqrt(len(imgs))+0.5) + r = int((w-((nrow+1)*padding))/nrow) + imgs = np.array([(Image.fromarray(img).resize((r,r)) |> np.array) for img in imgs]) + if len(ch) == 1: + imgs = imgs[:,:,:,None] + return AutoImage(make_grid(imgs,nrow,padding=1),f"numpy,uint8,HWC,{ch},0_255") + +img_to_shifting_grids = img->make_grids(*img.image_size)|> shifting_grids +def auto_to_3res(img:"AutoImage",cx,cy,r=256)->"AutoImage": + img = img.to("image,L,L") + #img = img.resize((2048,2048)) + chs = [crop_square(img,cx,cy,_r).resize((r,r)) for _r in [r*4,r*2,r]] + return AutoImage(np.concatenate([np.array(i)[:,:,None] for i in chs],axis=2),"numpy,float32,HWC,RGB,0_255") + +def img_to_grid_batch(img:AutoImage): + grids = img_to_shifting_grids(img) |> .astype("int32") |> series + batch = grids.map((xy)->auto_to_3res(img,xy[0]+128,xy[1]+128,r=256).to("numpy,float32,HWC,RGB,0_1")).values |> array |> .astype("float32") + return grids.values,AutoImage(batch,"numpy,float32,BHWC,RGB,0_1") + + +def AutoImage.cast(self,imgdef): + return AutoImage(self.data,imgdef) + + diff --git a/coconut/omni_converter.coco b/coconut/omni_converter.coco new file mode 100644 index 0000000..9a2e5f6 --- /dev/null +++ b/coconut/omni_converter.coco @@ -0,0 +1,681 @@ +from data_tree.coconut.convert import * +from data_tree.coconut.auto_data import AutoSolver,AutoData +from data_tree.coconut.monad import try_monad,Try,Success,Failure +from frozendict import frozendict +from typing import Mapping +from ipywidgets import Text +import ipywidgets as widgets +from itertools import product +from loguru import logger +from collections import namedtuple +import numpy as np +# actually, this kind of pattern matches are too hard to write in pure python. what do I do??? +# wait for pep622,pep642, to be implemented in python 3.10 + +def imagedef2dict(imdef:ImageDef): + case imdef: + match ImageDef(data_type,tags): + case data_type: + match Numpy(dtype,arrange,ch_rpr,v_range): + info = dict(type="numpy",dtype=dtype,arrange=arrange,ch_rpr=ch_rpr,v_range=str(v_range)) + match Torch(dtype,arrange,ch_rpr,v_range): + info = dict(type="torch",dtype=dtype,arrange=arrange,ch_rpr=ch_rpr,v_range=str(v_range)) + match PILImages(mode,ch_rpr): + info = dict(type="images",ch_rpr=ch_rpr,mode=mode) + match PILImage(mode,ch_rpr): + info = dict(type="image",ch_rpr=ch_rpr,mode=mode) + else: + raise RuntimeError(f"cannot convert unknown imagedef:{imdef} to dict.") + return frozendict( + **info, + **{t:True for t in tags} + ) + else: + raise RuntimeError(f"cannot convert unknown imdef:{imdef} to dict.") + +def cast_imdef_to_dict(state): + if isinstance(state,ImageDef): + return [imagedef2dict(state)] + +def cast_imdef_str_to_imdef(state): + if isinstance(state,str): + try: + res = str_to_img_def(state) + return [res] + except Exception as e: + pass +def imdef2imdef_str(imdef): + case imdef: + match ImageDef(data_type,tags): + case data_type: + match Numpy(dtype,arrange,ch_rpr,v_range): + base = f"numpy,{dtype},{arrange},{ch_rpr},{v_range}" + match Torch(dtype,arrange,ch_rpr,v_range): + base = f"torch,{dtype},{arrange},{ch_rpr},{v_range}" + match PILImages(mode,ch_rpr): + base = f"images,{mode},{ch_rpr}" + match PILImage(mode,ch_rpr): + base = f"image,{mode},{ch_rpr}" + else: + raise RuntimeError(f"cannot convert unknown imagedef:{imdef} to str.") + if tags: + return base+f"|{','.join(tags)}" + else: + return base + else: + raise RuntimeError(f"cannot convert unknown imdef:{imdef} to str.") +def cast_imdef_to_imdef_str(imdef): + case imdef: + match ImageDef(_,_): + res = [imdef2imdef_str(imdef)] + return res + else: + return None + +def imgs2tile(imgs,w=1024,h=1024,max_image=100,padding=1): + mode = imgs[0].mode + ch = len(mode) + #nrow = int(sqrt(len(imgs[:max_image]))+0.5) + n_imgs = len(imgs[:max_image]) + nrow = int(sqrt(n_imgs)) + if (nrow*nrow < n_imgs): + nrow += 1 + r = int((w-((nrow+1)*padding))/nrow) + + imgs = np.array([(img.resize((r,r)) |> np.array) for img in imgs[:max_image]]) + if ch == 1: + imgs = imgs[:,:,:,None] + return make_grid(imgs,nrow,padding=padding) + +def rule_imgs2tile(state): + case state: + match ImageDef(PILImages(mode,chrpr),tags): + return [( + imgs2tile, + ImageDef(Numpy("uint8","HWC",chrpr,VR_0_255),tags), + "imgs2tile", + 10 + )] + + +def rule_img2widget(state): + case state: + match ImageDef(PILImage(_,_),tags): + return [( + infer_widget, + "widget", + "infer_widget", + 1 + )] + +def dict2imdef(state): + if isinstance(state,Mapping): + case state: + match {"type":"numpy","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + return [ImageDef(Numpy(_dtype,_arng,_ch_rpr,_v_range),frozenset(tags.keys()))] + match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + return [ImageDef(Torch(_dtype,_arng,_ch_rpr,_v_range),frozenset(tags.keys()))] + match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + return [ImageDef(PILImage(_mode,_ch_rpr),frozenset(tags.keys()))] + match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + return [ImageDef(PILImages(_mode,_ch_rpr),frozenset(tags.keys()))] + +def rule_numpy2img(state): + if isinstance(state,Mapping): + case state: + match {"type":"numpy","dtype":"uint8","ch_rpr":"RGB","arrange":"HWC","v_range":"0_255",**tags}: + return [( + Image.fromarray, + ImageDef(PILImage("RGB","RGB"),frozenset(tags.keys())), + "Image.fromarray", + 1 + )] + match {"type":"numpy","dtype":"uint8","ch_rpr":"L","arrange":"HW","v_range":"0_255",**tags}: + return [( + Image.fromarray, + ImageDef(PILImage("L","L"),frozenset(tags.keys())), + "Image.fromarray", + 1 + )] + +def rule_image2gray(state): + case state: + match ImageDef(PILImage(ch_rpr,ch_rpr2),tags): + return [ + (.convert("L"),ImageDef(PILImage("L","L"),tags),"image2gray",10), + (.convert("LA"),ImageDef(PILImage("LA","LA"),tags),"image2gray-alpha",10), + ] + +def rule_image2lab(state): + from skimage import color + case state: + match ImageDef(Numpy("float64","HWC","RGB","0_1"),tags): + return [ + (color.rgb2lab,ImageDef(Numpy("float64","HWC","LAB","LAB"),tags),"sklearn.color.rgb2lab") + ] + match ImageDef(Numpy("float64","HWC","LAB","LAB"),tags): + return [ + (color.lab2rgb,ImageDef(Numpy("float64","HWC","RGB","0_1"),tags),"sklearn.color.lab2rgb") + ] + +def convert_ignore_channel(ary,f): + """ + shape:(H,W,C) + """ + ignored = ary[:,:,[-1]] + tgt = ary[:,:,:-1] + converted = f(tgt) + result = np.concatenate((tgt,ignored),axis=-1) + return result + +def rule_rgba2laba(state): + from skimage import color + case state: + match ImageDef(Numpy("float64","HWC","RGBA","0_1"),tags): + return [ + (a->convert_ignore_channel(a,color.rgb2lab),ImageDef(Numpy("float64","HWC","LABA","LABA"),tags),"rgba2laba (ignores alpha)") + ] + match ImageDef(Numpy("float64","HWC","LABA","LABA"),tags): + return [ + (a->convert_ignore_channel(a,color.lab2rgb),ImageDef(Numpy("float64","HWC","RGBA","0_1"),tags),"laba2rgba (ignores alpha)") + ] + + +def rule_lab_value_conversion(state): + case state: + match ImageDef(Numpy("float64","HWC","LAB","LAB"),tags): + return [((_vr_lab_to_0_1,ImageDef(Numpy("float64","HWC","LAB","0_1"),tags),"vr_lab_to_0_1"))] + match ImageDef(Numpy("float64","HWC","LABA","LABA"),tags): + return [((a->convert_ignore_channel(a,_vr_lab_to_0_1),ImageDef(Numpy("float64","HWC","LABA","0_1"),tags),"vr_laba_to_0_1"))] + match ImageDef(Numpy("float64","HWC","LAB","0_1"),tags): + return [((_0_1_to_vr_lab,ImageDef(Numpy("float64","HWC","LAB","LAB"),tags),"0_1_to_vr_lab"))] + match ImageDef(Numpy("float64","HWC","LABA","0_1"),tags): + return [((a->convert_ignore_channel(a,_0_1_to_vr_lab),ImageDef(Numpy("float64","HWC","LABA","LABA"),tags),"vr_0_1_to_laba"))] + +def _vr_lab_to_0_1(ary): + r = ary.copy() + r[:,:,0] = ary[:,:,0] * 0.01 + r[:,:,1] = (ary[:,:,1] + 128.0) / 255.0 + r[:,:,2] = (ary[:,:,2] + 128.0) / 255.0 + return r + +def _0_1_to_vr_lab(ary): + r = ary.copy() + r[:,:,0] = ary[:,:,0] * 100 + r[:,:,1] = (ary[:,:,1] * 255) - 128.0 + r[:,:,2] = (ary[:,:,2] * 255) - 128.0 + return r + +""" +def dict2visdomable(state): + case state: + match {"type":"numpy","dtype":"float32","arrange":"CHW" or "BCHW","ch_rpr":"RGB" or "L",**others} if "visdomable" not in state: + return [frozendict( + **state, + visdomable=True + )] +""" +def to_visdom_function(state): + case state: + match {"type":"numpy","dtype":"float32","arrange":"CHW","ch_rpr":"RGB" or "L","v_range":"0_255",**others}: + return [ + (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + ] + match {"type":"numpy","dtype":"float32","arrange":"BCHW","ch_rpr":"RGB" or "L","v_range":"0_255",**others}: + return [ + (ary->visdom->visdom.images$(ary),"visdom_function","to_visdom_function") + ] +def any2widget(state): + return [(ary->Text(str(ary)),"widget","anything_to_text_widget",1000)] +data AutoTuple(formats is tuple) + +def auto_tuple2widget(state): + case state: + match AutoTuple(items) if all(i == "widget" for i in items): + return [ + ( + values-> widgets.VBox(values), + "widget", + "auto_tuple of widgets to a widget", + 1 + ) + ] + +def isnamedtuple(x): + t = type(x) + b = t.__bases__ + if hasattr(x,"__slots__"): return True + if len(b) != 1 or b[0] != tuple: return False + f = getattr(t, '_fields', None) + if not isinstance(f, tuple): return False + return all(type(n)==str for n in f) + +def cast_tuple2auto_tuple(state): + if isinstance(state,str): + return None + if isinstance(state,AutoTuple): + res = [state.formats] + return res + elif type(state) == tuple: + res = [AutoTuple(state)] + return res + +def map_tuple_i(t,i,f): + res = list(t) + res[i] = f(res[i]) + return tuple(res) + +def map_state(states,i,new_state): + res = list(states) + res[i] = new_state + return tuple(res) + +def intra_tuple_conversions(state): + case state: + match AutoTuple(items): + # I think I should only change a part of state. + res = [] + for i in range(len(items)): + ith_state = items[i] + res += [ + ((f,new_state,cost,name)->( + values->map_tuple_i(values,i,f), + AutoTuple(map_state(items,i,new_state)), + f"map {i}th element with {name}", + cost + ))(f,new_state,cost,name) for f,new_state,cost,name in SOLVER.solver.neighbors(ith_state)] + return res + + +def map_each(t,mappers): + #logger.warning(f"items:{t}") + #logger.warning(f"mappers:{mappers}") + return tuple([f(item) for f,item in zip(mappers,t)]) + +def smart_tuple_conversion(state,end): + case (state,end): + match (AutoTuple(formats),t) if type(t) == tuple and len(formats) == len(t): + cs = [] + cost = 0 + for i in range(len(formats)): + c = SOLVER.solver.search_direct(formats[i],end[i]) + cost += sum(e.cost for e in c.edges) + cs.append(c) + res = [ + (t->map_each(t,cs), + end, + f"{state}->{end}", + cost) + ] + logger.debug(res) + return res + match (AutoTuple(formats),"widget"): + f,new_state,name,cost = smart_tuple_conversion(state,("widget",)*len(state.formats))[0] + logger.debug(f"cost:{cost}") + return [( + t-> widgets.VBox(f(t)), + end, + f"{state}->{end}", + cost+1 + )] + +data AutoList(state): + def __str__(self): + return f"[{self.state}]" + + +def unlist(items): + return SOLVER.new_auto_data([i.value for i in items],AutoList(items[0].format)) + +def cast_ary_str_to_ary_type(state): + case state: + match "[" + element_state + "]": + return [AutoList(element_state)] + match AutoList(es is str): + return [f"[{es}]"] + +def intra_list_conversions(state): + case state: + match AutoList(es): + return [((f,new_state,cost,name)->( + items -> [f(i) for i in items], + AutoList(new_state), + f"[{name}]", + cost+1 + ))(f,new_state,cost,name) for f,new_state,cost,name in SOLVER.solver.neighbors(es)] + +def img_list_is_imgs(state): + case state: + match AutoList("image,"+formats): + return [f"images,{formats}"] + match "images,"+formats: + return [AutoList("image,"+formats)] +def numpys_to_numpy(state): + case state: + match AutoList({"type":"numpy","arrange":arng,**kwargs}) if "B" not in arng: + return [ + (numpys->np.array(numpys), + frozendict({"type":"numpy","arrange":"B"+arng,**kwargs}), + f"merge arrays to array", + 10) + ] +def tensor_to_list(state): + case state: + match {"arrange":arng,**kwargs} if len(arng) > 1: + + return [ + (tensor->[t for t in tensor], + AutoList(frozendict(arrange=arng[1:],**kwargs)), + f"tensor to list of tensor", + 2) + ] + +def pil_convert(state): + case state: + match {"type":"image",**kwargs}: + new_state = dict(**state) + return [ + (img -> mode -> SOLVER.new_auto_data(img.convert(mode),f"image,{mode},{mode}"), + "pil_convert", + "image_to_pil_converter", + 1) + ] + +def rgb_to_rgba(state): + if state == "numpy,uint8,HWC,RGB,0_255": + return [( + a->np.concatenate((a,np.ones((*a.shape[:2],1),dtype="uint8")*255),axis=2), + "numpy,uint8,HWC,RGBA,0_255", + "add 255 as alpha channel", + 10 + )] + elif state == "numpy,uint8,BHWC,RGB,0_255": + return [( + a->np.concatenate((a,np.ones((*a.shape[:3],1),dtype="uint8")*255),axis=3), + "numpy,uint8,BHWC,RGBA,0_255", + "add 255 as alpha channel to batch", + 10 + )] + +@memoize() +def pix2pix_normalizer(nc): + import torchvision.transforms as transforms + return transforms.Normalize((0.5,)*nc,(0.5,)*nc) + + +def torch_img_to_pixpix_input(state): + import torch + case state: + match {"type":"torch","dtype":"float32","arrange":"CHW","v_range":"0_1","ch_rpr":("RGB" or "RGBA" or "L") as rpr,**kwargs}: + return [( + pix2pix_normalizer(len(rpr)), + f"pix2pix,nc={len(rpr)}", + "convert to pixpix normalized input", + 1 + )] + match {"type":"torch","dtype":"float32","arrange":"BCHW","v_range":"0_1","ch_rpr":("RGB" or "RGBA" or "L") as rpr,**kwargs}: + return [( + t->torch.cat([pix2pix_normalizer(len(rpr))(i)[None] for i in t],dim=0), + f"pix2pix_batch,nc={len(rpr)}", + "convert to pixpix normalized input", + 1 + )] + match "pix2pix_laba": + return [( + a -> a*0.5+0.5, + f"torch,float32,CHW,LABA,0_1", + "inverse pix2pix_laba to img ", + 1 + )] + match "pix2pix_lab": + return [( + a -> a*0.5+0.5, + f"torch,float32,CHW,LAB,0_1", + "inverse pix2pix_lab to img ", + 1 + )] + match "pix2pix_laba_batch": + return [( + a -> a*0.5+0.5, + f"torch,float32,BCHW,LABA,0_1", + "inverse pix2pix_laba batch to img", + 1 + )] + match "pix2pix_lab_batch": + return [( + a -> a*0.5+0.5, + f"torch,float32,BCHW,LAB,0_1", + "inverse pix2pix_laba batch to img", + 1 + )] + match "pix2pix,nc=4": + return [( + a -> a*0.5+0.5, + f"torch,float32,CHW,RGBA,0_1", + "inverse pix2pix to img", + 1 + )] + match "pix2pix_batch,nc=4": + return [( + a -> a*0.5+0.5, + f"torch,float32,BCHW,RGBA,0_1", + "inverse pix2pix batch nc=4 to img", + 1 + )] + match "pix2pix_batch,nc=3": + return [( + a -> a*0.5+0.5, + f"torch,float32,BCHW,RGB,0_1", + "inverse pix2pix batch nc=3 to img", + 1 + )] + match "pix2pix,nc=3": + return [( + a -> a*0.5+0.5, + f"torch,float32,CHW,RGB,0_1", + "inverse pix2pix to img", + 1 + )] + match "pix2pix_batch,nc=1": + return [( + a -> a*0.5+0.5, + f"torch,float32,BCHW,L,0_1", + "inverse pix2pix_batch,nc=1 to img", + 1 + )] + match "pix2pix,nc=1": + return [( + a -> a*0.5+0.5, + f"torch,float32,CHW,L,0_1", + "inverse pix2pix,nc=1 to img", + 1 + )] + +@memoize() +def _VGG_NORMALIZER(): + import torchvision.transforms as transforms + nrm = transforms.Normalize(mean=[0.485,0.456,0.406],std=[0.229,0.224,0.225]) + return nrm +def inverse_vgg_prep(tensor): + return tensor * torch.tensor([0.229,0.224,0.225])[:,None,None] + torch.tensor([0.485,0.456,0.406])[:,None,None] +def inverse_vgg_prep_batch(tensor): + return tensor * torch.tensor([0.229,0.224,0.225])[None,:,None,None] + torch.tensor([0.485,0.456,0.406])[None,:,None,None] +def torch_img_to_vgg_prep(state): + VGG_NORMALIZER = _VGG_NORMALIZER() + case state: + match "vgg_prep": + return [( + inverse_vgg_prep, + "torch,float32,CHW,RGB,0_1", + "inverse from vgg_prep", + 1) + ] + match "vgg_prep_batch": + return [( + inverse_vgg_prep_batch, + "torch,float32,BCHW,RGB,0_1", + "inverse from vgg_prep_batch", + 1) + ] + match {"type":"torch","dtype":"float32","arrange":"CHW","v_range":"0_1","ch_rpr":"RGB",**kwargs}: + return [( + VGG_NORMALIZER, + f"vgg_prep", + "convert to vgg normalized input", + 1 + )] + match {"type":"torch","dtype":"float32","arrange":"BCHW","v_range":"0_1","ch_rpr":"RGB",**kwargs}: + return [( + t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + f"vgg_prep_batch", + "convert to vgg normalized input batch", + 1 + )] + match {"type":"torch","dtype":"float32","arrange":"BCHW","v_range":"0_1","ch_rpr":"RGBA",**kwargs}: + return [( + t->torch.cat([ + torch.cat((VGG_NORMALIZER(i[:3])[None],i[[3]][None]),dim=1) for i in t + ],dim=0), + f"vgg_prep_batch_masked", + "convert to vgg normalized input batch", + 1 + )] +def repeat_ch(state): + case state: + match {"type":"image","mode":"L","ch_rpr":ch,**kwargs} if len(ch) == 1: + return [ + (a->np.repeat(np.array(a)[:,:,None],3,axis=2), + frozendict(type="numpy",dtype="uint8",arrange="HWC",ch_rpr=ch*3,v_range="0_255"), + "repeat_channel_3", + 50) + ] + + + +def lll_is_rgb(state): + case state: + match {"ch_rpr":"LLL",**kwargs}: + return [frozendict(ch_rpr="RGB",**kwargs)] + + + +DEFAULT_RULES = AutoImage.default_rules.copy() + [ + AutoSolver.create_cast_rule(cast_imdef_to_dict,"cast_imdef_to_dict"), + AutoSolver.create_cast_rule(cast_imdef_str_to_imdef,"cast_imdef_str_to_imdef"), + AutoSolver.create_cast_rule(cast_imdef_to_imdef_str,"cast_imdef_to_imdef_str"), + AutoSolver.create_cast_rule(dict2imdef,"dict2imdef"), + AutoSolver.create_cast_rule(cast_ary_str_to_ary_type,"cast_ary_str_to_ary_type"), + AutoSolver.create_cast_rule(img_list_is_imgs,"img_list_is_imgs"), + AutoSolver.create_cast_rule(lll_is_rgb,"lll_is_rgb",cost=10), + AutoSolver.create_cast_rule(cast_tuple2auto_tuple,"tuple <--> auto_tuple"), + #AutoSolver.create_cast_rule(dict2visdomable), + AutoSolver.create_conversion_rule(any2widget), + AutoSolver.create_conversion_rule(to_visdom_function), + AutoSolver.create_conversion_rule(rule_imgs2tile), + AutoSolver.create_conversion_rule(rule_img2widget), + AutoSolver.create_conversion_rule(rule_numpy2img), + AutoSolver.create_conversion_rule(rule_image2gray), + AutoSolver.create_conversion_rule(rule_image2lab), + AutoSolver.create_conversion_rule(rule_rgba2laba), + AutoSolver.create_conversion_rule(rule_lab_value_conversion), + AutoSolver.create_conversion_rule(intra_list_conversions), + AutoSolver.create_conversion_rule(numpys_to_numpy), + AutoSolver.create_conversion_rule(tensor_to_list), + AutoSolver.create_conversion_rule(pil_convert), + AutoSolver.create_conversion_rule(rgb_to_rgba), + AutoSolver.create_conversion_rule(repeat_ch), + AutoSolver.create_conversion_rule(torch_img_to_pixpix_input), + AutoSolver.create_conversion_rule(torch_img_to_vgg_prep), + #AutoSolver.create_conversion_rule(intra_tuple_conversions), + + AutoSolver.create_conversion_rule(auto_tuple2widget), + AutoSolver.create_alias_rule("numpy_rgb","numpy,uint8,HWC,RGB,0_255"), + AutoSolver.create_alias_rule("numpy_rgba","numpy,uint8,HWC,RGBA,0_255"), +] + +SMART_RULES =[ + AutoSolver.create_smart_conversion_rule(smart_tuple_conversion), +] + +try: + import wandb + def img_to_wandb_img(state): + case state: + match ImageDef(PILImage(_,_),_): + return [( + img->wandb.Image(img), + "wandb.Image", + "image to wandb image", + 1 + )] + DEFAULT_RULES.append(AutoSolver.create_conversion_rule(img_to_wandb_img)) + logger.warning(f"added wandb related conversions") +except Exception as e: + logger.warning(f"could not add wandb related conversions since wandb could not be imported") + + +def tuple_distance(x,y): + assert len(x) == len(y),"cannot compare two tuples with different length" + return len(x) - sum(tuple([i==j for i,j in zip(x,y)])) + + +@memoize() +def state_distance(x,y): + conversion = SOLVER.solver.search_direct(x,y,silent=True) + d = len(conversion.edges) + #logger.info(f"heuristic conversion:{conversion}") + #logger.info(f"{x} to {y}:{d}") + return d + +@memoize() +def tuple_state_distance(x,y): + return sum([state_distance(i,j) for i,j in zip(x,y)]) + +@memoize() +def tuple_widget_heuristics(x,y): + """ + you have to make the solver solve one by one. + """ + res = 0 + return 0 + if type(x) == tuple and type(y) == tuple: + if len(x) == len(y): + res = tuple_distance(x,y) + if isinstance(x,AutoTuple) and type(y) == tuple: + if len(x.formats) == len(y): + xs = x.formats + ys = y + res = tuple_distance(xs,ys) + elif isinstance(x,AutoTuple) and y == "widget": + xs = x.formats + ys = ("widget",)*len(x.formats) + res = tuple_distance(xs,ys) + #if res == 0: + # logger.info(f"{x}->{y}:{res}") + # pass + return res + +def tuple_edge_cutter(x,y,end): + return False + if isinstance(x,AutoTuple) and type(y) == tuple and type(end) == tuple: + n = len(x.formats) + if n == len(y) and n == len(end): + x2end = tuple_distance(x.formats,end) + y2end = tuple_distance(y,end) + x_matching = n - x2end + y_matching = n - y2end + if y_matching < x_matching: + logger.debug(f"cut {x} to {y} for {end}") + return True + return False + + + + +SOLVER = AutoSolver( + rules=DEFAULT_RULES.copy(), + smart_rules=SMART_RULES.copy(), + heuristics=tuple_widget_heuristics, + edge_cutter=tuple_edge_cutter, + ) +auto_img = format->value->AutoData(value,format,SOLVER) diff --git a/data_tree/__init__.py b/data_tree/__init__.py index ebc54ef..87c42e1 100644 --- a/data_tree/__init__.py +++ b/data_tree/__init__.py @@ -1,3 +1,36 @@ +<<<<<<< HEAD + + + +def managed_cache(root_dir): + from data_tree.cache import ConditionedFilePathProvider + return ConditionedFilePathProvider(root_dir) + +def series(iterable): + from data_tree._series import Series + return Series.from_iterable(iterable) + +def unlist_auto(items): + from data_tree.coconut.omni_converter import unlist + return unlist(items) + +def auto(format): + from data_tree.coconut.omni_converter import auto_img as omni_auto_img + return omni_auto_img(format) + +def auto_image(format): + from data_tree.auto_data.auto_image import AutoImage + from data_tree.coconut.omni_converter import SOLVER as omni_solver + + def _gen_ai(value): + return AutoImage(value,format,solver) + + +def auto_img(codec): + def _l(img): + return AutoImage(img, codec,solver) + return _l +======= from omni_converter.auto_data.auto_v2 import RuledData from omni_converter.solver.rules import AutoRuleBook @@ -69,3 +102,4 @@ def __init__(self): logger = PicklableLogger() +>>>>>>> master diff --git a/data_tree/_series.py b/data_tree/_series.py index eb3e277..4f5cbbe 100644 --- a/data_tree/_series.py +++ b/data_tree/_series.py @@ -14,6 +14,19 @@ from typing import Iterable, NamedTuple, Union, Mapping, Callable, List, TypeVar, Generic, Generator, Iterator, Dict import h5py +<<<<<<< HEAD + +import numpy as np + +from frozendict import frozendict + +from lazy import lazy as en_lazy +from loguru import logger +from pyvis.network import Network +from sklearn.preprocessing import MinMaxScaler +from tqdm.autonotebook import tqdm +======= +>>>>>>> master import numpy as np from IPython import embed @@ -35,9 +48,14 @@ from omni_cv_rules.coconut.visualization import infer_widget from data_tree.indexer import Indexer, IdentityIndexer from data_tree.mp_util import GlobalHolder, SequentialTaskParallel2, get_global_holder +<<<<<<< HEAD +from data_tree.resource import Resource +from data_tree.util import batch_index_generator, load_or_save, prefetch_generator, Pickled +======= from data_tree.custom_resource import Resource from data_tree.util import batch_index_generator, load_or_save, prefetch_generator, Pickled from omni_converter import IAutoData +>>>>>>> master def en_numpy(data): diff --git a/data_tree/auto_data/__init__.py b/data_tree/auto_data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/data_tree/auto_data/auto_image.py b/data_tree/auto_data/auto_image.py new file mode 100644 index 0000000..8080751 --- /dev/null +++ b/data_tree/auto_data/auto_image.py @@ -0,0 +1,22 @@ +from data_tree.coconut.auto_data import AutoData +from data_tree.coconut.convert import ch_splitter +from loguru import logger + + +class AutoImage(AutoData): + def __init__(self, value, format, solver): + super().__init__(value, format, solver) + # TODO add some assertions + + def histogram(self): + from matplotlib import pyplot as plt + plt.figure() + aim = self.convert(type="numpy", arrange="BHWC") + ary = aim.value + chs = ch_splitter(aim.format["ch_rpr"]) + logger.info(f"histogram src shape:{ary.shape}") + logger.info(f"src channels:{','.join(chs)}") + for i, ch in enumerate(chs): + plt.hist(ary[:, :, :, i].flatten(), bins=100, label=ch) + plt.legend() + plt.show() diff --git a/data_tree/coconut/astar.py b/data_tree/coconut/astar.py new file mode 100644 index 0000000..4fc5340 --- /dev/null +++ b/data_tree/coconut/astar.py @@ -0,0 +1,350 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# __coconut_hash__ = 0xd59c3d3f + +# Compiled with Coconut version 1.4.3 [Ernest Scribbler] + +# Coconut Header: ------------------------------------------------------------- + +from __future__ import generator_stop +import sys as _coconut_sys, os.path as _coconut_os_path +_coconut_file_path = _coconut_os_path.dirname(_coconut_os_path.abspath(__file__)) +_coconut_cached_module = _coconut_sys.modules.get("__coconut__") +if _coconut_cached_module is not None and _coconut_os_path.dirname(_coconut_cached_module.__file__) != _coconut_file_path: + del _coconut_sys.modules["__coconut__"] +_coconut_sys.path.insert(0, _coconut_file_path) +from __coconut__ import * +from __coconut__ import _coconut, _coconut_MatchError, _coconut_igetitem, _coconut_base_compose, _coconut_forward_compose, _coconut_back_compose, _coconut_forward_star_compose, _coconut_back_star_compose, _coconut_forward_dubstar_compose, _coconut_back_dubstar_compose, _coconut_pipe, _coconut_back_pipe, _coconut_star_pipe, _coconut_back_star_pipe, _coconut_dubstar_pipe, _coconut_back_dubstar_pipe, _coconut_bool_and, _coconut_bool_or, _coconut_none_coalesce, _coconut_minus, _coconut_map, _coconut_partial, _coconut_get_function_match_error, _coconut_base_pattern_func, _coconut_addpattern, _coconut_sentinel, _coconut_assert, _coconut_mark_as_match +_coconut_sys.path.pop(0) + +# Compiled Coconut: ----------------------------------------------------------- + +import heapq # import heapq +from loguru import logger # from loguru import logger +from pprint import pformat # from pprint import pformat +from data_tree.coconut.monad import try_monad # from data_tree.coconut.monad import try_monad,Try,Success,Failure +from data_tree.coconut.monad import Try # from data_tree.coconut.monad import try_monad,Try,Success,Failure +from data_tree.coconut.monad import Success # from data_tree.coconut.monad import try_monad,Try,Success,Failure +from data_tree.coconut.monad import Failure # from data_tree.coconut.monad import try_monad,Try,Success,Failure +import dill # for pickling inner lambda... # import dill # for pickling inner lambda... +from tqdm.autonotebook import tqdm # from tqdm.autonotebook import tqdm +from loguru import logger # from loguru import logger +from itertools import chain # from itertools import chain +from os.path import expanduser # from os.path import expanduser +from data_tree.util import DefaultShelveCache # from data_tree.util import DefaultShelveCache +import shelve # import shelve +import os # import os +from itertools import chain # from itertools import chain +class Edge(_coconut.collections.namedtuple("Edge", "src dst f cost name")): # data Edge(src,dst,f,cost,name="unnamed") + __slots__ = () # data Edge(src,dst,f,cost,name="unnamed") + __ne__ = _coconut.object.__ne__ # data Edge(src,dst,f,cost,name="unnamed") + def __eq__(self, other): # data Edge(src,dst,f,cost,name="unnamed") + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # data Edge(src,dst,f,cost,name="unnamed") + def __hash__(self): # data Edge(src,dst,f,cost,name="unnamed") + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # data Edge(src,dst,f,cost,name="unnamed") + def __new__(_cls, src, dst, f, cost, name="unnamed"): # data Edge(src,dst,f,cost,name="unnamed") + return _coconut.tuple.__new__(_cls, (src, dst, f, cost, name)) # data Edge(src,dst,f,cost,name="unnamed") + +class NoRouteException(Exception): pass # class NoRouteException(Exception) +class ConversionError(Exception): pass # class ConversionError(Exception) +class Conversion: # class Conversion: + def __init__(self, edges): # def __init__(self,edges): + self.edges = edges # self.edges = edges + + def __call__(self, x): # def __call__(self,x): + init_x = x # init_x = x + for e in self.edges: # for e in self.edges: + try: # try: + x = e.f(x) # x = e.f(x) + except Exception as ex: # except Exception as ex: + import inspect # import inspect + import pickle # import pickle + logger.error("caught an exception. inspecting..{_coconut_format_0}".format(_coconut_format_0=(ex))) # logger.error(f"caught an exception. inspecting..{ex}") + logger.warning("saving erroneous conversion for debug".format()) # logger.warning(f"saving erroneous conversion for debug") + info = dict(start=self.edges[0].src, end=self.edges[-1].dst, x=init_x) # info= dict( + logger.debug("conversion info = start:{_coconut_format_0},x:{_coconut_format_1}".format(_coconut_format_0=(info['start']), _coconut_format_1=(info['x']))) # logger.debug(f"conversion info = start:{info['start']},x:{info['x']}") + with open("last_erroneous_conversion.pkl", "wb") as f: # with open("last_erroneous_conversion.pkl","wb") as f: + pickle.dump(info, f) # pickle.dump(info,f) + source = inspect.getsource(e.f) # source = inspect.getsource(e.f) + logger.warning("saved last conversion error cause") # logger.warning("saved last conversion error cause") + raise ConversionError("exception in edge:{_coconut_format_0} \n paths:{_coconut_format_1} \n x:{_coconut_format_2} \n edge source:{_coconut_format_3}".format(_coconut_format_0=(e.name), _coconut_format_1=([e.name for e in self.edges]), _coconut_format_2=(x), _coconut_format_3=(source))) from ex # raise ConversionError(f"exception in edge:{e.name} \n paths:{[e.name for e in self.edges]} \n x:{x} \n edge source:{source}") from ex + return x # return x + + def __getitem__(self, item): # def __getitem__(self,item): + if isinstance(item, int): # if isinstance(item,int): + edges = [(self.edges[item])] # edges = [(self.edges[item])] + else: # else: + edges = self.edges[item] # edges = self.edges[item] + return Conversion(edges) # return Conversion(edges) + + def __repr__(self): # def __repr__(self): + if len(self.edges): # if len(self.edges): + start = self.edges[0].src # start = self.edges[0].src + end = self.edges[-1].dst # end = self.edges[-1].dst + else: # else: + start = "None" # start = "None" + end = "None" # end = "None" + info = dict(name="Conversion", start=start, end=end, path=[e.name for e in self.edges], cost=sum([e.cost for e in self.edges])) # info = dict( + return pformat(info) # return pformat(info) + def trace(self, tgt): # def trace(self,tgt): + x = tgt # x = tgt + for e in self.edges: # for e in self.edges: + x = e.f(x) # x = e.f(x) + yield dict(edge=e, x=x) # yield dict(edge= e,x=x) + +def new_conversion(edges): # def new_conversion(edges): + return Conversion(edges) # return Conversion(edges) +class _HeapContainer: # class _HeapContainer: + def __init__(self, score, data): # def __init__(self,score,data): + self.score = score # self.score = score + self.data = data # self.data = data + def __lt__(self, other): # def __lt__(self,other): + return self.score < other.score # return self.score < other.score + +def _astar(start, matcher, neighbors, max_depth=100): # def _astar( + """ + neighbors: node->[(mapper,next_node,cost,name)] + """ # """ + to_visit = [] # to_visit = [] + scores = dict() # scores = dict() + scores[start] = 0 #heuristics(start,None) # scores[start] = 0#heuristics(start,None) + heapq.heappush(to_visit, _HeapContainer(scores[start], (start, []))) # heapq.heappush(to_visit, + visited = 0 # visited = 0 + bar = tqdm(desc="solving with astar") # bar = tqdm(desc="solving with astar") + while to_visit: # while to_visit: + bar.update(1) # bar.update(1) + hc = heapq.heappop(to_visit) # hc = heapq.heappop(to_visit) + score = hc.score # score = hc.score + (pos, trace) = hc.data # (pos,trace) = hc.data + visited += 1 # visited += 1 +#print(f"visit:{pos}") +#print(f"{((trace[-1].a,trace[-1].name) if trace else 'no trace')}") +#print(f"visit:{trace[-1] if trace else 'no trace'}") + if len(trace) >= max_depth: # terminate search on max_depth # if len(trace) >= max_depth: # terminate search on max_depth + continue # continue + if matcher(pos): # reached a goal # if matcher(pos): # reached a goal + logger.debug("found after {_coconut_format_0} visits.".format(_coconut_format_0=(visited))) # logger.debug(f"found after {visited} visits.") + logger.debug("search result:\n{_coconut_format_0}".format(_coconut_format_0=(new_conversion(trace)))) # logger.debug(f"search result:\n{new_conversion(trace)}") + bar.close() # bar.close() + return trace # return trace + for mapper, next_node, cost, name in neighbors(pos): # for mapper,next_node,cost,name in neighbors(pos): + assert isinstance(cost, int), "cost is not a number. cost:{_coconut_format_0},name:{_coconut_format_1},pos:{_coconut_format_2}".format(_coconut_format_0=(cost), _coconut_format_1=(name), _coconut_format_2=(pos)) # assert isinstance(cost,int),f"cost is not a number. cost:{cost},name:{name},pos:{pos}" + new_trace = trace + [Edge(pos, next_node, mapper, cost, name)] # new_trace = trace + [Edge(pos,next_node,mapper,cost,name)] + try: # try: + new_score = scores[pos] + cost #+ heuristics(next_node,end) # new_score = scores[pos] + cost #+ heuristics(next_node,end) + except Exception as e: # except Exception as e: + logger.error("pos:{_coconut_format_0},cost:{_coconut_format_1},next_node:{_coconut_format_2}".format(_coconut_format_0=(pos), _coconut_format_1=(cost), _coconut_format_2=(next_node))) # logger.error(f"pos:{pos},cost:{cost},next_node:{next_node}") + raise e # raise e + if next_node in scores and scores[next_node] <= new_score: # if next_node in scores and scores[next_node] <= new_score: + continue # continue + + else: # else: + scores[next_node] = new_score # scores[next_node] = new_score + heapq.heappush(to_visit, _HeapContainer(new_score, (next_node, new_trace))) # heapq.heappush(to_visit,_HeapContainer(new_score,(next_node,new_trace))) + + raise NoRouteException("no route found from {_coconut_format_0} matching {_coconut_format_1}".format(_coconut_format_0=(start), _coconut_format_1=(matcher))) # raise NoRouteException(f"no route found from {start} matching {matcher}") + + + +def _astar_direct(start, end, neighbors, smart_neighbors, heuristics, edge_cutter, max_depth=100, silent=False): # def _astar_direct( + """ + neighbors: node->[(mapper,next_node,cost,name)] + """ # """ + to_visit = [] # to_visit = [] + scores = dict() # scores = dict() + scores[start] = heuristics(start, end) # scores[start] = heuristics(start,end) + heapq.heappush(to_visit, _HeapContainer(scores[start], (start, []))) # heapq.heappush(to_visit, + visited = 0 # visited = 0 + bar = tqdm(desc="solving with astar_direct") # bar = tqdm(desc="solving with astar_direct") + last_bar_update = visited # last_bar_update = visited + while to_visit: # while to_visit: + if visited - last_bar_update > 1000: # if visited - last_bar_update > 1000: + bar.update(visited - last_bar_update) # bar.update(visited-last_bar_update) + last_bar_update = visited # last_bar_update = visited + hc = heapq.heappop(to_visit) # hc = heapq.heappop(to_visit) + score = hc.score # score = hc.score + (pos, trace) = hc.data # (pos,trace) = hc.data + if not silent: # if not silent: +#logger.info(f"{score}:{pos}") +#bar.write(f"score:{score}") + pass # pass + +#logger.debug(f"visiting:{pos}") + visited += 1 # visited += 1 +#print(f"visit:{pos}") +#print(f"{((trace[-1].a,trace[-1].name) if trace else 'no trace')}") +#print(f"visit:{trace[-1] if trace else 'no trace'}") + if len(trace) >= max_depth: # terminate search on max_depth # if len(trace) >= max_depth: # terminate search on max_depth + continue # continue + if pos == end: # reached a goal # if pos == end: # reached a goal + if not silent: # if not silent: + logger.debug("found after {_coconut_format_0} visits.".format(_coconut_format_0=(visited))) # logger.debug(f"found after {visited} visits.") + logger.debug("search result:\n{_coconut_format_0}".format(_coconut_format_0=(new_conversion(trace)))) # logger.debug(f"search result:\n{new_conversion(trace)}") + bar.close() # bar.close() + return trace # return trace + normal_nodes = list(neighbors(pos)) # normal_nodes = list(neighbors(pos)) + smart_nodes = list(smart_neighbors(pos, end)) # smart_nodes = list(smart_neighbors(pos,end)) +#logger.debug(f"{normal_nodes},{smart_nodes}") + if visited % 10000 == 0: # if visited % 10000 == 0: + msg = str(pos)[:50] # msg = str(pos)[:50] + bar.set_description("""pos:{_coconut_format_0:<50}""".format(_coconut_format_0=(msg))) # bar.set_description(f"""pos:{msg:<50}""") + for i, (mapper, next_node, cost, name) in enumerate(chain(normal_nodes, smart_nodes)): # for i,(mapper,next_node,cost,name) in enumerate(chain(normal_nodes,smart_nodes)): + assert isinstance(cost, int), "cost is not a number:{_coconut_format_0}".format(_coconut_format_0=(pos)) # assert isinstance(cost,int),f"cost is not a number:{pos}" + new_trace = trace + [Edge(pos, next_node, mapper, cost, name)] # new_trace = trace + [Edge(pos,next_node,mapper,cost,name)] + try: # try: + new_score = scores[pos] + cost + heuristics(next_node, end) # new_score = scores[pos] + cost + heuristics(next_node,end) + except Exception as e: # except Exception as e: + logger.error("pos:{_coconut_format_0},cost:{_coconut_format_1},next_node:{_coconut_format_2}".format(_coconut_format_0=(pos), _coconut_format_1=(cost), _coconut_format_2=(next_node))) # logger.error(f"pos:{pos},cost:{cost},next_node:{next_node}") + raise e # raise e + if next_node in scores and scores[next_node] <= new_score: # if next_node in scores and scores[next_node] <= new_score: + continue # continue + elif (edge_cutter(pos, next_node, end)): # elif(edge_cutter(pos,next_node,end)): + continue # continue + else: # else: + scores[next_node] = new_score # scores[next_node] = new_score + heapq.heappush(to_visit, _HeapContainer(new_score, (next_node, new_trace))) # heapq.heappush(to_visit,_HeapContainer(new_score,(next_node,new_trace))) + + raise NoRouteException("no route found from {_coconut_format_0} matching {_coconut_format_1}. searched {_coconut_format_2} nodes.".format(_coconut_format_0=(start), _coconut_format_1=(end), _coconut_format_2=(visited))) # raise NoRouteException(f"no route found from {start} matching {end}. searched {visited} nodes.") + +astar = (try_monad)((_coconut_base_compose(_astar, (new_conversion, 0)))) # astar = (_astar ..> new_conversion) |> try_monad +astar_direct = (try_monad)((_coconut_base_compose(_astar_direct, (new_conversion, 0)))) # astar_direct = (_astar_direct ..> new_conversion) |> try_monad + +def _zero_heuristics(x, y): # def _zero_heuristics(x,y): + return 0 # return 0 + +def _no_cutter(x, y, end): # def _no_cutter(x,y,end): + return False # return False + +MAX_MEMO = 2**(20) # MAX_MEMO = 2**(20) + +class AStarSolver: # class AStarSolver: + """ + to make this picklable, you have to have these caches on global variable. + use getstate and setstate + actually, having to pickle this solver every time you pass auto_data is not feasible. + so, lets have auto_data to hold solver in global variable and never pickle AStarSolver!. + so forget about lru_cache pickling issues. + """ # """ + def __init__(self, rules=None, smart_rules=None, heuristics=_zero_heuristics, edge_cutter=_no_cutter, cache_path=os.path.join(expanduser("~"), ".cache/autodata.shelve")): # def __init__(self, + """ + rules: List[Rule] + Rule: (state)->List[(converter:(data)->data,new_state,cost,conversion_name)] + """ # """ + from lru import LRU # from lru import LRU + self.rules = rules if rules is not None else [] # self.rules = rules if rules is not None else [] + self.smart_rules = smart_rules if smart_rules is not None else [] # self.smart_rules = smart_rules if smart_rules is not None else [] + self.heuristics = heuristics # self.heuristics = heuristics + self.edge_cutter = edge_cutter # self.edge_cutter = edge_cutter + self.neighbors_memo = LRU(MAX_MEMO) # you cannot pickle a lru.LRU object, thus you cannot pickle this class for multiprocessing. # self.neighbors_memo = LRU(MAX_MEMO) # you cannot pickle a lru.LRU object, thus you cannot pickle this class for multiprocessing. + self.search_memo = LRU(MAX_MEMO) # self.search_memo = LRU(MAX_MEMO) + self.smart_neighbors_memo = LRU(MAX_MEMO) # self.smart_neighbors_memo = LRU(MAX_MEMO) + self.direct_search_cache = DefaultShelveCache(self._search_direct, cache_path) # self.direct_search_cache = DefaultShelveCache(self._search_direct,cache_path) + self.direct_search_memo = LRU(MAX_MEMO) # self.direct_search_memo = LRU(MAX_MEMO) + + def neighbors(self, node): # def neighbors(self,node): + if node in self.neighbors_memo: # if node in self.neighbors_memo: + return self.neighbors_memo[node] # return self.neighbors_memo[node] + + res = [] # res = [] + for rule in self.rules: # for rule in self.rules: + edges = rule(node) # edges = rule(node) + if edges is not None: # if edges is not None: + res += edges # res += edges + self.neighbors_memo[node] = res # self.neighbors_memo[node] = res + return res # return res + def smart_neighbors(self, node, end): # def smart_neighbors(self,node,end): + if (node, end) in self.smart_neighbors_memo: # if (node,end) in self.smart_neighbors_memo: + return self.smart_neighbors_memo[(node, end)] # return self.smart_neighbors_memo[(node,end)] + res = [] # res = [] + for rule in self.smart_rules: # for rule in self.smart_rules: + edges = rule(node, end) # edges = rule(node,end) + if edges is not None: # if edges is not None: + res += edges # res += edges + self.smart_neighbors_memo[(node, end)] = res # self.smart_neighbors_memo[(node,end)] = res +#logger.debug(res) + return res # return res + + def invalidate_cache(self): # def invalidate_cache(self): + self.neighbors_memo.clear() # self.neighbors_memo.clear() + self.search_memo.clear() # self.search_memo.clear() + self.direct_search_memo.clear() # self.direct_search_memo.clear() + + def add_rule(self, f): # def add_rule(self,f): + self.rules.append(f) # self.rules.append(f) + self.invalidate_cache() # self.invalidate_cache() + + def search(self, start, matcher): # def search(self,start,matcher): +#problem is that you can't hash matcher +#let's use id of matcher for now. + q = (start, id(matcher)) # q = (start,id(matcher)) + if q in self.search_memo: # if q in self.search_memo: + res = self.search_memo[q] # res = self.search_memo[q] + else: # else: + logger.debug("searching from {_coconut_format_0} for matching {_coconut_format_1}".format(_coconut_format_0=(start), _coconut_format_1=(matcher))) # logger.debug(f"searching from {start} for matching {matcher}") + res = astar(start=start, matcher=matcher, neighbors=self.neighbors) # res = astar( + self.search_memo[q] = res # self.search_memo[q] = res + + _coconut_match_to = res # case res: + _coconut_case_check_0 = False # case res: + if (_coconut.isinstance(_coconut_match_to, Success)) and (_coconut.len(_coconut_match_to) == 1): # case res: + res = _coconut_match_to[0] # case res: + _coconut_case_check_0 = True # case res: + if _coconut_case_check_0: # case res: + return res # return res + if not _coconut_case_check_0: # match Failure(e,trc): + if (_coconut.isinstance(_coconut_match_to, Failure)) and (_coconut.len(_coconut_match_to) == 2): # match Failure(e,trc): + e = _coconut_match_to[0] # match Failure(e,trc): + trc = _coconut_match_to[1] # match Failure(e,trc): + _coconut_case_check_0 = True # match Failure(e,trc): + if _coconut_case_check_0: # match Failure(e,trc): + raise e # raise e + def _research_from_edges(self, edges): # def _research_from_edges(self,edges): + searched_edges = list(chain(*[self._search_direct((src, dst, True)).edges for src, dst in edges])) # searched_edges = list(chain(*[self._search_direct((src,dst,True)).edges for src,dst in edges])) +#logger.info(f"searched_edges:{searched_edges}") + return Conversion(searched_edges) # return Conversion(searched_edges) + + def _search_direct(self, q): # def _search_direct(self,q): +# you cannot directly save the function. +# so you need to save the paths and re-search it + start, end, silent = q # start,end,silent = q + if not silent: # if not silent: + logger.debug("searching {_coconut_format_0} to {_coconut_format_1}".format(_coconut_format_0=(start), _coconut_format_1=(end))) # logger.debug(f"searching {start} to {end}") + res = astar_direct(start=start, end=end, neighbors=self.neighbors, smart_neighbors=self.smart_neighbors, heuristics=self.heuristics, edge_cutter=self.edge_cutter, silent=silent) # res = astar_direct( + _coconut_match_to = res # start=start, + _coconut_case_check_1 = False # start=start, + if (_coconut.isinstance(_coconut_match_to, Success)) and (_coconut.len(_coconut_match_to) == 1): # start=start, + res = _coconut_match_to[0] # start=start, + _coconut_case_check_1 = True # start=start, + if _coconut_case_check_1: # start=start, + return res # return res + if not _coconut_case_check_1: # match Failure(e,trc): + if (_coconut.isinstance(_coconut_match_to, Failure)) and (_coconut.len(_coconut_match_to) == 2): # match Failure(e,trc): + e = _coconut_match_to[0] # match Failure(e,trc): + trc = _coconut_match_to[1] # match Failure(e,trc): + _coconut_case_check_1 = True # match Failure(e,trc): + if _coconut_case_check_1: # match Failure(e,trc): + raise e # raise e + def search_direct(self, start, end, silent=False): # def search_direct(self,start,end,silent=False): + key = (start, end, silent) # key = (start,end,silent) + if key in self.direct_search_memo: # if key in self.direct_search_memo: + return self.direct_search_memo[key] # return self.direct_search_memo[key] + elif key in self.direct_search_cache: # elif key in self.direct_search_cache: + edges = self.direct_search_cache[key] # edges = self.direct_search_cache[key] + conversion = self._research_from_edges(edges) # conversion = self._research_from_edges(edges) + self.direct_search_memo[key] = conversion # self.direct_search_memo[key] = conversion + logger.debug("researched_conversion:\n{_coconut_format_0}".format(_coconut_format_0=(conversion))) # logger.debug(f"researched_conversion:\n{conversion}") + return conversion # return conversion + else: # else: + conversion = self._search_direct(key) # conversion = self._search_direct(key) + self.direct_search_cache[key] = [(e.src, e.dst) for e in conversion.edges] # self.direct_search_cache[key] = [(e.src,e.dst) for e in conversion.edges] + self.direct_search_memo[key] = conversion # self.direct_search_memo[key] = conversion + return conversion # return conversion + + def search_direct_any(self, start, ends): # def search_direct_any(self,start,ends): + for cand in ends: # for cand in ends: + try: # try: + res = self.search_direct(start, cand) # res = self.search_direct(start,cand) + return res # return res + except Exception as e: # except Exception as e: + pass # pass + raise NoRouteException("no route found from {_coconut_format_0} to any of {_coconut_format_1}".format(_coconut_format_0=(start), _coconut_format_1=(ends))) # raise NoRouteException(f"no route found from {start} to any of {ends}") diff --git a/data_tree/coconut/auto_data.py b/data_tree/coconut/auto_data.py new file mode 100644 index 0000000..2085340 --- /dev/null +++ b/data_tree/coconut/auto_data.py @@ -0,0 +1,338 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# __coconut_hash__ = 0xfce0bd37 + +# Compiled with Coconut version 1.4.3 [Ernest Scribbler] + +# Coconut Header: ------------------------------------------------------------- + +from __future__ import generator_stop +import sys as _coconut_sys, os.path as _coconut_os_path +_coconut_file_path = _coconut_os_path.dirname(_coconut_os_path.abspath(__file__)) +_coconut_cached_module = _coconut_sys.modules.get("__coconut__") +if _coconut_cached_module is not None and _coconut_os_path.dirname(_coconut_cached_module.__file__) != _coconut_file_path: + del _coconut_sys.modules["__coconut__"] +_coconut_sys.path.insert(0, _coconut_file_path) +from __coconut__ import * +from __coconut__ import _coconut, _coconut_MatchError, _coconut_igetitem, _coconut_base_compose, _coconut_forward_compose, _coconut_back_compose, _coconut_forward_star_compose, _coconut_back_star_compose, _coconut_forward_dubstar_compose, _coconut_back_dubstar_compose, _coconut_pipe, _coconut_back_pipe, _coconut_star_pipe, _coconut_back_star_pipe, _coconut_dubstar_pipe, _coconut_back_dubstar_pipe, _coconut_bool_and, _coconut_bool_or, _coconut_none_coalesce, _coconut_minus, _coconut_map, _coconut_partial, _coconut_get_function_match_error, _coconut_base_pattern_func, _coconut_addpattern, _coconut_sentinel, _coconut_assert, _coconut_mark_as_match +_coconut_sys.path.pop(0) + +# Compiled Coconut: ----------------------------------------------------------- + +from typing import Mapping # from typing import Mapping +from data_tree.coconut.astar import AStarSolver # from data_tree.coconut.astar import AStarSolver +from IPython.display import display # from IPython.display import display +import dill # to make the lambda functions picklable # import dill # to make the lambda functions picklable +from loguru import logger # from loguru import logger +""" +What I want to achieve is to generate a class. +I want to generate a AutoImage class form AutoData +well the solution is to just use partially applied constructor. that's it. +""" # """ +def identity(a): # def identity(a): + return a # return a + +class _CastLambda: # class _CastLambda: + def __init__(self, rule, name, swap, cost=1): # def __init__(self,rule,name,swap,cost=1): + self.rule = rule # self.rule = rule + self.name = name # self.name = name + self.swap = swap # self.swap = swap + self.cost = cost # self.cost = cost + def __call__(self, state): # def __call__(self,state): + new_states = self.rule(state) # new_states = self.rule(state) + if new_states is not None: # if new_states is not None: + if self.name is None: # if self.name is None: + cast_name = "{_coconut_format_0}".format(_coconut_format_0=(self.rule.__name__)) # cast_name = f"{self.rule.__name__}" + else: # else: + cast_name = self.name # cast_name=self.name + if self.swap: # if self.swap: + return [(identity, new_state, cast_name, self.cost) for new_state in new_states] # return [(identity,new_state,cast_name,self.cost) for new_state in new_states] + else: # else: + return [(identity, new_state, self.cost, cast_name) for new_state in new_states] # return [(identity,new_state,self.cost,cast_name) for new_state in new_states] + else: # else: + return None # return None +class _ConversionLambda: # class _ConversionLambda: + def __init__(self, rule, cost=1): # def __init__(self,rule,cost=1): + self.rule = rule # self.rule = rule + self.cost = cost # self.cost = cost + def __call__(self, state): # def __call__(self,state): + edges = self.rule(state) # edges = self.rule(state) + if edges is None: # if edges is None: + return [] # return [] + result = [] # result = [] + for edge in edges: # for edge in edges: + _coconut_match_to = edge # case edge: + _coconut_case_check_0 = False # case edge: + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 2): # case edge: + converter = _coconut_match_to[0] # case edge: + new_state = _coconut_match_to[1] # case edge: + _coconut_case_check_0 = True # case edge: + if _coconut_case_check_0: # case edge: + result.append((converter, new_state, self.cost, converter.__name__)) # result.append((converter,new_state,self.cost,converter.__name__)) + if not _coconut_case_check_0: # match (converter,new_state,name): + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 3): # match (converter,new_state,name): + converter = _coconut_match_to[0] # match (converter,new_state,name): + new_state = _coconut_match_to[1] # match (converter,new_state,name): + name = _coconut_match_to[2] # match (converter,new_state,name): + _coconut_case_check_0 = True # match (converter,new_state,name): + if _coconut_case_check_0: # match (converter,new_state,name): + result.append((converter, new_state, self.cost, name)) # result.append((converter,new_state,self.cost,name)) + if not _coconut_case_check_0: # match (converter,new_state,name,score): + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 4): # match (converter,new_state,name,score): + converter = _coconut_match_to[0] # match (converter,new_state,name,score): + new_state = _coconut_match_to[1] # match (converter,new_state,name,score): + name = _coconut_match_to[2] # match (converter,new_state,name,score): + score = _coconut_match_to[3] # match (converter,new_state,name,score): + _coconut_case_check_0 = True # match (converter,new_state,name,score): + if _coconut_case_check_0: # match (converter,new_state,name,score): + result.append((converter, new_state, score, name)) # result.append((converter,new_state,score,name)) + if not _coconut_case_check_0: # match _: + _coconut_case_check_0 = True # match _: + if _coconut_case_check_0: # match _: + raise RuntimeError("rule:{_coconut_format_0} returned invalid edge:{_coconut_format_1}.".format(_coconut_format_0=(self.rule), _coconut_format_1=(edge))) # raise RuntimeError(f"rule:{self.rule} returned invalid edge:{edge}.") + return result # return result +class _SmartConversionLambda: # class _SmartConversionLambda: + def __init__(self, rule, cost=1): # def __init__(self,rule,cost=1): + self.rule = rule # self.rule = rule + self.cost = cost # self.cost = cost + def __call__(self, state, end): # def __call__(self,state,end): + edges = self.rule(state, end) # edges = self.rule(state,end) + if edges is None: # if edges is None: + return [] # return [] + result = [] # result = [] + for edge in edges: # for edge in edges: + _coconut_match_to = edge # case edge: + _coconut_case_check_1 = False # case edge: + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 2): # case edge: + converter = _coconut_match_to[0] # case edge: + new_state = _coconut_match_to[1] # case edge: + _coconut_case_check_1 = True # case edge: + if _coconut_case_check_1: # case edge: + result.append((converter, new_state, self.cost, converter.__name__)) # result.append((converter,new_state,self.cost,converter.__name__)) + if not _coconut_case_check_1: # match (converter,new_state,name): + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 3): # match (converter,new_state,name): + converter = _coconut_match_to[0] # match (converter,new_state,name): + new_state = _coconut_match_to[1] # match (converter,new_state,name): + name = _coconut_match_to[2] # match (converter,new_state,name): + _coconut_case_check_1 = True # match (converter,new_state,name): + if _coconut_case_check_1: # match (converter,new_state,name): + result.append((converter, new_state, self.cost, name)) # result.append((converter,new_state,self.cost,name)) + if not _coconut_case_check_1: # match (converter,new_state,name,score): + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 4): # match (converter,new_state,name,score): + converter = _coconut_match_to[0] # match (converter,new_state,name,score): + new_state = _coconut_match_to[1] # match (converter,new_state,name,score): + name = _coconut_match_to[2] # match (converter,new_state,name,score): + score = _coconut_match_to[3] # match (converter,new_state,name,score): + _coconut_case_check_1 = True # match (converter,new_state,name,score): + if _coconut_case_check_1: # match (converter,new_state,name,score): + result.append((converter, new_state, score, name)) # result.append((converter,new_state,score,name)) + if not _coconut_case_check_1: # match _: + _coconut_case_check_1 = True # match _: + if _coconut_case_check_1: # match _: + raise RuntimeError("rule:{_coconut_format_0} returned invalid edge:{_coconut_format_1}.".format(_coconut_format_0=(self.rule), _coconut_format_1=(edge))) # raise RuntimeError(f"rule:{self.rule} returned invalid edge:{edge}.") + return result # return result +class AutoSolver: # class AutoSolver: + """ + TODO stop using local lambda in order to make this class picklable + Factory for an AutoData class + """ # """ + def __init__(self, rules, smart_rules, heuristics=lambda x, y: 0, edge_cutter=lambda x, y, end: False): # def __init__(self,rules,smart_rules,heuristics=lambda x,y:0,edge_cutter=lambda x,y,end:False): + self.initial_rules = rules # self.initial_rules = rules + self.smart_rules = smart_rules # self.smart_rules = smart_rules + self.solver = AStarSolver(rules=self.initial_rules.copy(), smart_rules=self.smart_rules.copy(), heuristics=heuristics, edge_cutter=edge_cutter) # self.solver = AStarSolver( + + @staticmethod # @staticmethod + def create_cast_rule(rule, name=None, _swap=False, cost=1): # def create_cast_rule(rule,name=None,_swap=False,cost=1): + """ + rule: State->List[State] # should return list of possible casts without data conversion. + """ # """ + return _CastLambda(rule, name, _swap, cost=cost) # return _CastLambda(rule,name,_swap,cost=cost) + + def add_cast(self, rule, name=None): # def add_cast(self,rule,name=None): + """ + rule: State->List[State] # should return list of possible casts without data conversion. + """ # """ + + self.add_conversion(AutoSolver.create_cast_rule(rule, name=name, _swap=True)) # self.add_conversion(AutoSolver.create_cast_rule(rule,name=name,_swap=True)) + + def add_alias(self, a, b): # def add_alias(self,a,b): + self.add_cast(lambda state: [b] if state == a else None, name="alias: {_coconut_format_0}->{_coconut_format_1}".format(_coconut_format_0=(a), _coconut_format_1=(b))) # self.add_cast(state->[b] if state == a else None,name=f"alias: {a}->{b}") + self.add_cast(lambda state: [a] if state == b else None, name="alias: {_coconut_format_0}->{_coconut_format_1}".format(_coconut_format_0=(b), _coconut_format_1=(a))) # self.add_cast(state->[a] if state == b else None,name=f"alias: {b}->{a}") + + @staticmethod # @staticmethod + def create_alias_rule(a, b): # def create_alias_rule(a,b): + def caster(state): # def caster(state): + if state == a: # if state == a: + return [b] # return [b] + elif state == b: # elif state == b: + return [a] # return [a] + return AutoSolver.create_cast_rule(caster, "alias:{_coconut_format_0}=={_coconut_format_1}".format(_coconut_format_0=(a), _coconut_format_1=(b))) # return AutoSolver.create_cast_rule(caster,f"alias:{a}=={b}") + + @staticmethod # @staticmethod + def create_conversion_rule(rule): # def create_conversion_rule(rule): + return _ConversionLambda(rule) # return _ConversionLambda(rule) + @staticmethod # @staticmethod + def create_smart_conversion_rule(rule): # def create_smart_conversion_rule(rule): + return _SmartConversionLambda(rule) # return _SmartConversionLambda(rule) + + def add_conversion(self, rule): # def add_conversion(self,rule): + """ + rule: State->List[(converter,new_state,name(optional),cost(optional))] + """ # """ + self.solver.add_rule(AutoSolver.create_conversion_rule(rule)) # self.solver.add_rule(AutoSolver.create_conversion_rule(rule)) + + def reset_solver(self,): # def reset_solver(self,): + self.solver = AStarSolver(rules=self.initial_rules.copy(), smart_rules=self.smart_rules.copy(), heuristics=heuristics, edge_cutter=edge_cutter) # self.solver = AStarSolver( + + def debug_conversion(self, a, b, samples): # def debug_conversion(self,a,b,samples): + x = samples # x = samples + edges = self.solver.search_direct(a, b).edges # edges = self.solver.search_direct(a,b).edges + for edge in edges: # for edge in edges: + print(edge) # print(edge) + print(edge.f) # print(edge.f) + x = edge.f(x) # x = edge.f(x) + print("converted to type:{_coconut_format_0}".format(_coconut_format_0=(type(x)))) # print(f"converted to type:{type(x)}") + if (isinstance)(x, np.ndarray): # if x `isinstance` np.ndarray: + print(x.shape) # print(x.shape) + print("converted:{_coconut_format_0}".format(_coconut_format_0=(x))) # print(f"converted:{x}") + return x # return x + + + +class TagMatcher: # class TagMatcher: + def __init__(self, **kwargs): # def __init__(self,**kwargs): + self.kwargs = kwargs # self.kwargs = kwargs + + def __call__(self, state): # def __call__(self,state): + if isinstance(state, Mapping): # if isinstance(state,Mapping): + for k, v in self.kwargs.items(): # for k,v in self.kwargs.items(): + if not k in state or not state[k] == v: # if not k in state or not state[k] == v: + return False # return False + return True #every item matched. # return True #every item matched. + else: # else: + return False # return False + @property # @property + def __name__(self): # def __name__(self): + return "TagMatcher|{_coconut_format_0}".format(_coconut_format_0=(self.kwargs)) # return f"TagMatcher|{self.kwargs}" + + def __str__(self): # def __str__(self): + return self.__name__ # return self.__name__ + + +@memoize(1024) # @memoize(1024) +def tag_matcher(**kwargs): # def tag_matcher(**kwargs): + return TagMatcher(**kwargs) # return TagMatcher(**kwargs) + +SOLVERS = dict() # SOLVERS = dict() + +class AutoData: # class AutoData: + """ + Interface class for a user + """ # """ + def to_debug(self, format): # def to_debug(self,format): + format = parse_def(format) # format = parse_def(format) + return AutoData.debug_conversion(self.format, format, self.value) # return AutoData.debug_conversion(self.format,format,self.value) + + def __init__(self, value, format, solver): # def __init__(self,value,format,solver): + self.value = value # self.value = value + self.format = format # self.format = format + self.solver_id = id(solver) # do not hold solver, but hold solver's id. in order to make this picklable. # self.solver_id = id(solver) # do not hold solver, but hold solver's id. in order to make this picklable. + if self.solver_id not in SOLVERS: # if self.solver_id not in SOLVERS: + SOLVERS[self.solver_id] = solver # SOLVERS[self.solver_id] = solver + + @property # @property + def solver(self): # def solver(self): + return SOLVERS[self.solver_id] # return SOLVERS[self.solver_id] + + def converter(self, format=None, **kwargs): # def converter(self,format=None,**kwargs): + if format is not None: # if format is not None: + return self.solver.solver.search_direct(self.format, format) # return self.solver.solver.search_direct(self.format,format) + else: # else: + return self.solver.solver.search(self.format, tag_matcher(**kwargs)) # return self.solver.solver.search(self.format,tag_matcher(**kwargs)) + + def convert(self, format=None, **kwargs) -> 'AutoData': # def convert(self,format=None,**kwargs) -> AutoData: + """converts internal data to specified format.""" # """converts internal data to specified format.""" + conversion = self.converter(format, **kwargs) # conversion = self.converter(format,**kwargs) + if conversion.edges: # if conversion.edges: + return self.__class__(conversion(self.value), conversion.edges[-1].dst, self.solver) # return self.__class__(conversion(self.value),conversion.edges[-1].dst,self.solver) + else: # else: + return self # return self + def search_converter(self, f): # def search_converter(self,f): + return self.solver.solver.search(self.format, f) # return self.solver.solver.search(self.format,f) + + def search(self, matcher, ignore_error=True) -> 'AutoData': # def search(self,matcher,ignore_error=True) -> AutoData: + if ignore_error: # if ignore_error: + def _matcher(state): # def _matcher(state): + try: # try: + return matcher(state) # return matcher(state) + except Exception as e: # except Exception as e: + pass # pass + conversion = self.search_converter(_matcher) # conversion = self.search_converter(_matcher) + else: # else: + conversion = self.search_converter(matcher) # conversion = self.search_converter(matcher) + if conversion.edges: # if conversion.edges: + return self.__class__(conversion(self.value), conversion.edges[-1].dst, self.solver) # return self.__class__(conversion(self.value),conversion.edges[-1].dst,self.solver) + else: # else: + return self # return self + + def to(self, format=None, **kwargs): # I want 'to' to accept format string too # def to(self,format=None,**kwargs): # I want 'to' to accept format string too +# if format is given, use direct matching. +# else use tag matching +# format can be of any type, but you need to have a conversion rule to tag_dict, otherwise you won't get any result +# so, ask user to provide any state and state->tag_dict rule. +# That's it. + converted = self.convert(format=format, **kwargs) # converted = self.convert(format=format,**kwargs) + return converted.value # return converted.value + + def map(self, f, new_format=None): # def map(self,f,new_format=None): + if new_format is not None: # if new_format is not None: + format = new_format # format = new_format + else: # else: + format = self.format # format = self.format + return self.__class__(f(self.value), format, self.solver) # return self.__class__(f(self.value),format,self.solver) + + def map_in(self, start_format, f, new_format=None): # def map_in(self,start_format,f,new_format=None): + return self.__class__(f(self.to(start_format)), (lambda _coconut_none_coalesce_item: self.format if _coconut_none_coalesce_item is None else _coconut_none_coalesce_item)(new_format), self.solver) # return self.__class__(f(self.to(start_format)),new_format??self.format,self.solver) + + def neighbors(self): # def neighbors(self): + return self.solver.solver.neighbors(self.format) # return self.solver.solver.neighbors(self.format) + + def to_widget(self): # def to_widget(self): + return self.to("widget") # return self.to("widget") + + def _repr_html_(self): # def _repr_html_(self): + (display)(self.format) # self.format |> display + (display)(self.to("widget")) # self.to("widget") |> display + + def __repr__(self): # def __repr__(self): + return "<{_coconut_format_0} {_coconut_format_1}>".format(_coconut_format_0=(self.__class__), _coconut_format_1=(self.format)) # return f"<{self.__class__} {self.format}>" + + def _repr_png_(self): # def _repr_png_(self): + try: # try: + return self.to(type="image")._repr_png_() # return self.to(type="image")._repr_png_() + except Exception as e: # except Exception as e: + logger.warning("cannot convert data to an image:{_coconut_format_0}".format(_coconut_format_0=(self.format))) # logger.warning(f"cannot convert data to an image:{self.format}") + return None # return None + + def cast(self, format): # def cast(self,format): + return self.__class__(self.value, format, self.solver) # return self.__class__(self.value,format,self.solver) + + def show(self): # def show(self): + from matplotlib.pyplot import imshow # from matplotlib.pyplot import imshow,show + from matplotlib.pyplot import show # from matplotlib.pyplot import imshow,show + imshow(self.to("numpy_rgb")) # imshow(self.to("numpy_rgb")) + show() # show() + + +# def __getstate__(self): + + +try: # def AutoData.call(self,name,*args,**kwargs): + _coconut_dotted_func_name_store_0 = call # def AutoData.call(self,name,*args,**kwargs): +except _coconut.NameError: # def AutoData.call(self,name,*args,**kwargs): + _coconut_dotted_func_name_store_0 = None # def AutoData.call(self,name,*args,**kwargs): +def call(self, name, *args, **kwargs): # def AutoData.call(self,name,*args,**kwargs): + return self.to(name)(*args, **kwargs) # return self.to(name)(*args,**kwargs) + +AutoData.call = call # return self.to(name)(*args,**kwargs) +call = _coconut_dotted_func_name_store_0 # return self.to(name)(*args,**kwargs) diff --git a/data_tree/coconut/convert.py b/data_tree/coconut/convert.py new file mode 100644 index 0000000..a6e8fdb --- /dev/null +++ b/data_tree/coconut/convert.py @@ -0,0 +1,1266 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# __coconut_hash__ = 0x36244153 + +# Compiled with Coconut version 1.4.3 [Ernest Scribbler] + +# Coconut Header: ------------------------------------------------------------- + +from __future__ import generator_stop +import sys as _coconut_sys, os.path as _coconut_os_path +_coconut_file_path = _coconut_os_path.dirname(_coconut_os_path.abspath(__file__)) +_coconut_cached_module = _coconut_sys.modules.get("__coconut__") +if _coconut_cached_module is not None and _coconut_os_path.dirname(_coconut_cached_module.__file__) != _coconut_file_path: + del _coconut_sys.modules["__coconut__"] +_coconut_sys.path.insert(0, _coconut_file_path) +from __coconut__ import * +from __coconut__ import _coconut, _coconut_MatchError, _coconut_igetitem, _coconut_base_compose, _coconut_forward_compose, _coconut_back_compose, _coconut_forward_star_compose, _coconut_back_star_compose, _coconut_forward_dubstar_compose, _coconut_back_dubstar_compose, _coconut_pipe, _coconut_back_pipe, _coconut_star_pipe, _coconut_back_star_pipe, _coconut_dubstar_pipe, _coconut_back_dubstar_pipe, _coconut_bool_and, _coconut_bool_or, _coconut_none_coalesce, _coconut_minus, _coconut_map, _coconut_partial, _coconut_get_function_match_error, _coconut_base_pattern_func, _coconut_addpattern, _coconut_sentinel, _coconut_assert, _coconut_mark_as_match +_coconut_sys.path.pop(0) + +# Compiled Coconut: ----------------------------------------------------------- + +from PIL import Image # from PIL import Image +import numpy as np # import numpy as np +import heapq # import heapq +from data_tree.coconut.visualization import infer_widget # from data_tree.coconut.visualization import infer_widget +from loguru import logger # from loguru import logger +from data_tree.coconut.astar import new_conversion # from data_tree.coconut.astar import new_conversion,AStarSolver,NoRouteException +from data_tree.coconut.astar import AStarSolver # from data_tree.coconut.astar import new_conversion,AStarSolver,NoRouteException +from data_tree.coconut.astar import NoRouteException # from data_tree.coconut.astar import new_conversion,AStarSolver,NoRouteException +from math import sqrt # from math import sqrt +from PIL import Image # from PIL import Image +import torch # import torch +import re # import re +VR_0_1 = "0_1" # VR_0_1 = "0_1" +VR_0_255 = "0_255" # VR_0_255 = "0_255" +VR_None = "None" # VR_None = "None" +VR_XYZ_Normalized = "XYZ_Normalized" # VR_XYZ_Normalized = "XYZ_Normalized" +ch_splitter = re.compile("[A-Z][a-z]*").findall # ch_splitter = re.compile("[A-Z][a-z]*").findall + +class DataType(_coconut.collections.namedtuple("DataType", "")): # data DataType + __slots__ = () # data DataType + __ne__ = _coconut.object.__ne__ # data DataType + def __eq__(self, other): # data DataType + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # data DataType + def __hash__(self): # data DataType + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # data DataType + +#TODO add shape information to tensorlike +#TODO add shape information to PILImage + +class TensorLike(_coconut.collections.namedtuple("TensorLike", "dtype, arrange, channel_repr, value_range"), DataType): # data TensorLike( + __slots__ = () # data TensorLike( + __ne__ = _coconut.object.__ne__ # data TensorLike( + def __eq__(self, other): # data TensorLike( + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # data TensorLike( + def __hash__(self): # data TensorLike( + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # data TensorLike( + def __new__(_cls, *_coconut_match_to_args, **_coconut_match_to_kwargs): # data TensorLike( + _coconut_match_check = False # data TensorLike( + _coconut_FunctionMatchError = _coconut_get_function_match_error() # data TensorLike( + if (_coconut.len(_coconut_match_to_args) <= 4) and (_coconut.sum((_coconut.len(_coconut_match_to_args) > 0, "dtype" in _coconut_match_to_kwargs)) == 1) and (_coconut.sum((_coconut.len(_coconut_match_to_args) > 1, "arrange" in _coconut_match_to_kwargs)) == 1) and (_coconut.sum((_coconut.len(_coconut_match_to_args) > 2, "channel_repr" in _coconut_match_to_kwargs)) == 1) and (_coconut.sum((_coconut.len(_coconut_match_to_args) > 3, "value_range" in _coconut_match_to_kwargs)) == 1): # data TensorLike( + _coconut_match_temp_0 = _coconut_match_to_args[0] if _coconut.len(_coconut_match_to_args) > 0 else _coconut_match_to_kwargs.pop("dtype") # data TensorLike( + _coconut_match_temp_1 = _coconut_match_to_args[1] if _coconut.len(_coconut_match_to_args) > 1 else _coconut_match_to_kwargs.pop("arrange") # data TensorLike( + _coconut_match_temp_2 = _coconut_match_to_args[2] if _coconut.len(_coconut_match_to_args) > 2 else _coconut_match_to_kwargs.pop("channel_repr") # data TensorLike( + _coconut_match_temp_3 = _coconut_match_to_args[3] if _coconut.len(_coconut_match_to_args) > 3 else _coconut_match_to_kwargs.pop("value_range") # data TensorLike( + if (_coconut.isinstance(_coconut_match_temp_0, str)) and (_coconut.isinstance(_coconut_match_temp_1, str)) and (_coconut.isinstance(_coconut_match_temp_2, str)) and (_coconut.isinstance(_coconut_match_temp_3, str)) and (not _coconut_match_to_kwargs): # data TensorLike( + dtype = _coconut_match_temp_0 # data TensorLike( + arrange = _coconut_match_temp_1 # data TensorLike( + channel_repr = _coconut_match_temp_2 # data TensorLike( + value_range = _coconut_match_temp_3 # data TensorLike( + _coconut_match_check = True # data TensorLike( + + if not _coconut_match_check: # data TensorLike( + _coconut_match_val_repr = _coconut.repr(_coconut_match_to_args) # data TensorLike( + _coconut_match_err = _coconut_FunctionMatchError("pattern-matching failed for " "'data TensorLike( dtype is str, arrange is str, channel_repr is str, value_range is str) from DataType:'" " in " + (_coconut_match_val_repr if _coconut.len(_coconut_match_val_repr) <= 500 else _coconut_match_val_repr[:500] + "...")) # data TensorLike( + _coconut_match_err.pattern = 'data TensorLike( dtype is str, arrange is str, channel_repr is str, value_range is str) from DataType:' # data TensorLike( + _coconut_match_err.value = _coconut_match_to_args # data TensorLike( + raise _coconut_match_err # data TensorLike( + + return _coconut.tuple.__new__(_cls, (dtype, arrange, channel_repr, value_range)) # data TensorLike( + def __repr__(self): # def __repr__(self): + return "Tensor({_coconut_format_0}|{_coconut_format_1}|{_coconut_format_2}|{_coconut_format_3}|{_coconut_format_4})".format(_coconut_format_0=(self.data_type), _coconut_format_1=(self.dtype), _coconut_format_2=(self.arrange), _coconut_format_3=(self.channel_repr), _coconut_format_4=(self.value_range)) # return f"Tensor({self.data_type}|{self.dtype}|{self.arrange}|{self.channel_repr}|{self.value_range})" + +class Numpy(_coconut.collections.namedtuple("Numpy", "dtype arrange channel_repr value_range"), TensorLike): # data Numpy(dtype,arrange,channel_repr,value_range) from TensorLike: + __slots__ = () # data Numpy(dtype,arrange,channel_repr,value_range) from TensorLike: + __ne__ = _coconut.object.__ne__ # data Numpy(dtype,arrange,channel_repr,value_range) from TensorLike: + def __eq__(self, other): # data Numpy(dtype,arrange,channel_repr,value_range) from TensorLike: + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # data Numpy(dtype,arrange,channel_repr,value_range) from TensorLike: + def __hash__(self): # data Numpy(dtype,arrange,channel_repr,value_range) from TensorLike: + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # data Numpy(dtype,arrange,channel_repr,value_range) from TensorLike: + def __new__(cls, *args): # def __new__(cls,*args): + return makedata(cls, *args) # return makedata(cls,*args) + def __repr__(self): # def __repr__(self): + return "Numpy({_coconut_format_0},{_coconut_format_1},{_coconut_format_2},{_coconut_format_3})".format(_coconut_format_0=(self.dtype), _coconut_format_1=(self.arrange), _coconut_format_2=(self.channel_repr), _coconut_format_3=(self.value_range)) # return f"Numpy({self.dtype},{self.arrange},{self.channel_repr},{self.value_range})" + +class Torch(_coconut.collections.namedtuple("Torch", "dtype arrange channel_repr value_range"), TensorLike): # data Torch(dtype,arrange,channel_repr,value_range) from TensorLike: + __slots__ = () # data Torch(dtype,arrange,channel_repr,value_range) from TensorLike: + __ne__ = _coconut.object.__ne__ # data Torch(dtype,arrange,channel_repr,value_range) from TensorLike: + def __eq__(self, other): # data Torch(dtype,arrange,channel_repr,value_range) from TensorLike: + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # data Torch(dtype,arrange,channel_repr,value_range) from TensorLike: + def __hash__(self): # data Torch(dtype,arrange,channel_repr,value_range) from TensorLike: + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # data Torch(dtype,arrange,channel_repr,value_range) from TensorLike: + def __new__(cls, *args): # def __new__(cls,*args): + return makedata(cls, *args) # return makedata(cls,*args) + def __repr__(self): # def __repr__(self): + return "Torch({_coconut_format_0},{_coconut_format_1},{_coconut_format_2},{_coconut_format_3})".format(_coconut_format_0=(self.dtype), _coconut_format_1=(self.arrange), _coconut_format_2=(self.channel_repr), _coconut_format_3=(self.value_range)) # return f"Torch({self.dtype},{self.arrange},{self.channel_repr},{self.value_range})" + +class Hdf5(_coconut.collections.namedtuple("Hdf5", "dtype arrange channel_repr value_range"), TensorLike): # data Hdf5(dtype,arrange,channel_repr,value_range) from TensorLike: + __slots__ = () # data Hdf5(dtype,arrange,channel_repr,value_range) from TensorLike: + __ne__ = _coconut.object.__ne__ # data Hdf5(dtype,arrange,channel_repr,value_range) from TensorLike: + def __eq__(self, other): # data Hdf5(dtype,arrange,channel_repr,value_range) from TensorLike: + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # data Hdf5(dtype,arrange,channel_repr,value_range) from TensorLike: + def __hash__(self): # data Hdf5(dtype,arrange,channel_repr,value_range) from TensorLike: + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # data Hdf5(dtype,arrange,channel_repr,value_range) from TensorLike: + def __new__(cls, *args): # def __new__(cls,*args): + return makedata(cls, *args) # return makedata(cls,*args) + def __repr__(self): # def __repr__(self): + return "Hdf5({_coconut_format_0},{_coconut_format_1},{_coconut_format_2},{_coconut_format_3})".format(_coconut_format_0=(self.dtype), _coconut_format_1=(self.arrange), _coconut_format_2=(self.channel_repr), _coconut_format_3=(self.value_range)) # return f"Hdf5({self.dtype},{self.arrange},{self.channel_repr},{self.value_range})" + +class PILImages(_coconut.collections.namedtuple("PILImages", "mode channel_repr"), DataType): # represents iterable of PIL.Images # data PILImages(mode,channel_repr) from DataType: # represents iterable of PIL.Images + __slots__ = () # represents iterable of PIL.Images # data PILImages(mode,channel_repr) from DataType: # represents iterable of PIL.Images + __ne__ = _coconut.object.__ne__ # represents iterable of PIL.Images # data PILImages(mode,channel_repr) from DataType: # represents iterable of PIL.Images + def __eq__(self, other): # represents iterable of PIL.Images # data PILImages(mode,channel_repr) from DataType: # represents iterable of PIL.Images + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # represents iterable of PIL.Images # data PILImages(mode,channel_repr) from DataType: # represents iterable of PIL.Images + def __hash__(self): # represents iterable of PIL.Images # data PILImages(mode,channel_repr) from DataType: # represents iterable of PIL.Images + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # represents iterable of PIL.Images # data PILImages(mode,channel_repr) from DataType: # represents iterable of PIL.Images + def __repr__(self): # def __repr__(self): + return "PILImages({_coconut_format_0},{_coconut_format_1})".format(_coconut_format_0=(self.mode), _coconut_format_1=(self.channel_repr)) # return f"PILImages({self.mode},{self.channel_repr})" +class PILImage(_coconut.collections.namedtuple("PILImage", "mode channel_repr"), DataType): # data PILImage(mode,channel_repr) from DataType: + __slots__ = () # data PILImage(mode,channel_repr) from DataType: + __ne__ = _coconut.object.__ne__ # data PILImage(mode,channel_repr) from DataType: + def __eq__(self, other): # data PILImage(mode,channel_repr) from DataType: + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # data PILImage(mode,channel_repr) from DataType: + def __hash__(self): # data PILImage(mode,channel_repr) from DataType: + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # data PILImage(mode,channel_repr) from DataType: + def __repr__(self): # def __repr__(self): + return "PILImage({_coconut_format_0},{_coconut_format_1})".format(_coconut_format_0=(self.mode), _coconut_format_1=(self.channel_repr)) # return f"PILImage({self.mode},{self.channel_repr})" + +class ImageDef(_coconut.collections.namedtuple("ImageDef", "data_type, tags")): # data ImageDef(data_type is DataType,tags is frozenset): + __slots__ = () # data ImageDef(data_type is DataType,tags is frozenset): + __ne__ = _coconut.object.__ne__ # data ImageDef(data_type is DataType,tags is frozenset): + def __eq__(self, other): # data ImageDef(data_type is DataType,tags is frozenset): + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # data ImageDef(data_type is DataType,tags is frozenset): + def __hash__(self): # data ImageDef(data_type is DataType,tags is frozenset): + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # data ImageDef(data_type is DataType,tags is frozenset): + def __new__(_cls, *_coconut_match_to_args, **_coconut_match_to_kwargs): # data ImageDef(data_type is DataType,tags is frozenset): + _coconut_match_check = False # data ImageDef(data_type is DataType,tags is frozenset): + _coconut_FunctionMatchError = _coconut_get_function_match_error() # data ImageDef(data_type is DataType,tags is frozenset): + if (_coconut.len(_coconut_match_to_args) <= 2) and (_coconut.sum((_coconut.len(_coconut_match_to_args) > 0, "data_type" in _coconut_match_to_kwargs)) == 1) and (_coconut.sum((_coconut.len(_coconut_match_to_args) > 1, "tags" in _coconut_match_to_kwargs)) == 1): # data ImageDef(data_type is DataType,tags is frozenset): + _coconut_match_temp_0 = _coconut_match_to_args[0] if _coconut.len(_coconut_match_to_args) > 0 else _coconut_match_to_kwargs.pop("data_type") # data ImageDef(data_type is DataType,tags is frozenset): + _coconut_match_temp_1 = _coconut_match_to_args[1] if _coconut.len(_coconut_match_to_args) > 1 else _coconut_match_to_kwargs.pop("tags") # data ImageDef(data_type is DataType,tags is frozenset): + if (_coconut.isinstance(_coconut_match_temp_0, DataType)) and (_coconut.isinstance(_coconut_match_temp_1, frozenset)) and (not _coconut_match_to_kwargs): # data ImageDef(data_type is DataType,tags is frozenset): + data_type = _coconut_match_temp_0 # data ImageDef(data_type is DataType,tags is frozenset): + tags = _coconut_match_temp_1 # data ImageDef(data_type is DataType,tags is frozenset): + _coconut_match_check = True # data ImageDef(data_type is DataType,tags is frozenset): + + if not _coconut_match_check: # data ImageDef(data_type is DataType,tags is frozenset): + _coconut_match_val_repr = _coconut.repr(_coconut_match_to_args) # data ImageDef(data_type is DataType,tags is frozenset): + _coconut_match_err = _coconut_FunctionMatchError("pattern-matching failed for " "'data ImageDef(data_type is DataType,tags is frozenset):'" " in " + (_coconut_match_val_repr if _coconut.len(_coconut_match_val_repr) <= 500 else _coconut_match_val_repr[:500] + "...")) # data ImageDef(data_type is DataType,tags is frozenset): + _coconut_match_err.pattern = 'data ImageDef(data_type is DataType,tags is frozenset):' # data ImageDef(data_type is DataType,tags is frozenset): + _coconut_match_err.value = _coconut_match_to_args # data ImageDef(data_type is DataType,tags is frozenset): + raise _coconut_match_err # data ImageDef(data_type is DataType,tags is frozenset): + + return _coconut.tuple.__new__(_cls, (data_type, tags)) # data ImageDef(data_type is DataType,tags is frozenset): + def __repr__(self): # def __repr__(self): + return "ImageDef({_coconut_format_0}|{_coconut_format_1})".format(_coconut_format_0=(self.data_type), _coconut_format_1=(list(self.tags))) # return f"ImageDef({self.data_type}|{list(self.tags)})" + + +DTYPES = {"float32", "float64", "int32", "int64", "uint8", "bool"} # DTYPES={"float32","float64","int32","int64","uint8","bool"} +class Edge(_coconut.typing.NamedTuple("Edge", [("a", 'ImageDef'), ("b", 'ImageDef'), ("f", '_coconut.typing.Any'), ("cost", 'int'), ("name", '_coconut.typing.Any')])): # data Edge(a:ImageDef,b:ImageDef,f,cost:int,name="undefined"): + __slots__ = () # data Edge(a:ImageDef,b:ImageDef,f,cost:int,name="undefined"): + __ne__ = _coconut.object.__ne__ # data Edge(a:ImageDef,b:ImageDef,f,cost:int,name="undefined"): + def __eq__(self, other): # data Edge(a:ImageDef,b:ImageDef,f,cost:int,name="undefined"): + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # data Edge(a:ImageDef,b:ImageDef,f,cost:int,name="undefined"): + def __hash__(self): # data Edge(a:ImageDef,b:ImageDef,f,cost:int,name="undefined"): + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # data Edge(a:ImageDef,b:ImageDef,f,cost:int,name="undefined"): + def __new__(_cls, a, b, f, cost, name="undefined"): # data Edge(a:ImageDef,b:ImageDef,f,cost:int,name="undefined"): + return _coconut.tuple.__new__(_cls, (a, b, f, cost, name)) # data Edge(a:ImageDef,b:ImageDef,f,cost:int,name="undefined"): + def __repr__(self): # def __repr__(self): + return "{_coconut_format_0} \t-> {_coconut_format_1}\t-> {_coconut_format_2}".format(_coconut_format_0=(self.a), _coconut_format_1=(self.name), _coconut_format_2=(self.b)) # return f"{self.a} \t-> {self.name}\t-> {self.b}" +from typing import List # from typing import List + +#純粋にエッジだけを考えると、どうしても組み合わせ爆発になる。目的地を知っていれば削減できる。 + +# 各imdefのNodeベースでエッジを定義するのか。それとも。エッジのルールを網羅するのか。 +# オペレーターのほうが数が少ないので、オペレーターだけ定義したい。 +# List up operators. +# operator definition: ImageDef->List[Edge] +# 1. change data_type +# 2. change dtype +# 3. change arrange +# 4. change ch_repr +# 5. select channel +def to_imagedef(f): # def to_imagedef(f): + def _inner(imdef: 'ImageDef'): # def _inner(imdef:ImageDef): + try: # try: +#logger.debug(type(imdef)) + if (isinstance)(imdef, ImageDef) and len(imdef) >= 1 and (hasattr)(imdef, "data_type"): # if imdef `isinstance` ImageDef and len(imdef) >= 1 and imdef `hasattr` "data_type": +#if imdef `isinstance` ImageDef: + edges = f(imdef.data_type) # edges = f(imdef.data_type) + if edges is not None: # if edges is not None: + return [Edge(imdef, ImageDef(e.b, imdef.tags), e.f, e.cost, e.name) for e in edges] # return [Edge(imdef,ImageDef(e.b,imdef.tags),e.f,e.cost,e.name) for e in edges] + else: # else: + return [] # return [] + else: # else: + return [] # return [] + except Exception as e: # except Exception as e: + logger.warning("unknown error...imdef:{_coconut_format_0}".format(_coconut_format_0=(imdef))) # logger.warning(f"unknown error...imdef:{imdef}") + logger.warning("{_coconut_format_0} has attr causes exception?".format(_coconut_format_0=(imdef))) # logger.warning(f"{imdef} has attr causes exception?") + logger.warning("{_coconut_format_0}".format(_coconut_format_0=(hasattr(imdef, 'data_type')))) # logger.warning(f"{hasattr(imdef,'data_type')}") + raise e # raise e + return _inner # return _inner + + + +@to_imagedef # @to_imagedef +def to_PILImages(imdef: 'ImageDef') -> '_coconut.typing.Sequence[Edge]': # def to_PILImages(imdef:ImageDef)->Edge[]: +#TODO fix pattern match on data class + _coconut_match_to = imdef # case imdef: + _coconut_case_check_0 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, Numpy)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[0] == "uint8") and (_coconut_match_to[1] == "BHWC") and (_coconut_match_to[3] == VR_0_255): # case imdef: + c_repr = _coconut_match_to[2] # case imdef: + _coconut_case_check_0 = True # case imdef: + if _coconut_case_check_0 and not (len(ch_splitter(c_repr)) in (3, 4)): # case imdef: + _coconut_case_check_0 = False # case imdef: + if _coconut_case_check_0: # case imdef: + return [Edge(imdef, PILImages(c_repr, c_repr), lambda ary: [(Image.fromarray)(img) for img in ary], 2, name="numpy batch {_coconut_format_0} to Images".format(_coconut_format_0=(c_repr)))] # return [Edge(imdef,PILImages(c_repr,c_repr),ary -> [(Image.fromarray)(img) for img in ary],2,name=f"numpy batch {c_repr} to Images")] + if not _coconut_case_check_0: # match Numpy("uint8","BHW",c_repr,=VR_0_255): + if (_coconut.isinstance(_coconut_match_to, Numpy)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[0] == "uint8") and (_coconut_match_to[1] == "BHW") and (_coconut_match_to[3] == VR_0_255): # match Numpy("uint8","BHW",c_repr,=VR_0_255): + c_repr = _coconut_match_to[2] # match Numpy("uint8","BHW",c_repr,=VR_0_255): + _coconut_case_check_0 = True # match Numpy("uint8","BHW",c_repr,=VR_0_255): + if _coconut_case_check_0: # match Numpy("uint8","BHW",c_repr,=VR_0_255): + return [Edge(imdef, PILImages("L", c_repr), lambda ary: [(_coconut_base_compose(Image.fromarray, (_coconut.operator.methodcaller("convert", "L"), 0)))(img) for img in ary], 2, name="numpy batch to images")] # return [Edge(imdef,PILImages("L",c_repr),ary -> [(Image.fromarray ..> .convert("L"))(img) for img in ary],2,name="numpy batch to images")] + if not _coconut_case_check_0: # match Numpy("uint8","HW",c_repr,=VR_0_255): + if (_coconut.isinstance(_coconut_match_to, Numpy)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[0] == "uint8") and (_coconut_match_to[1] == "HW") and (_coconut_match_to[3] == VR_0_255): # match Numpy("uint8","HW",c_repr,=VR_0_255): + c_repr = _coconut_match_to[2] # match Numpy("uint8","HW",c_repr,=VR_0_255): + _coconut_case_check_0 = True # match Numpy("uint8","HW",c_repr,=VR_0_255): + if _coconut_case_check_0: # match Numpy("uint8","HW",c_repr,=VR_0_255): + return [Edge(imdef, PILImage("L", c_repr), _coconut_base_compose(Image.fromarray, (_coconut.operator.methodcaller("convert", "L"), 0)), 2, name="numpy HW to PIL Image")] # return [Edge(imdef,PILImage("L",c_repr), Image.fromarray ..> .convert("L"),2,name="numpy HW to PIL Image")] + return [] # return [] +@to_imagedef # @to_imagedef +def to_numpy(imdef: 'ImageDef') -> 'List[Edge]': # def to_numpy(imdef:ImageDef)->List[Edge]: + _coconut_match_to = imdef # case imdef: + _coconut_case_check_1 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, Torch)) and (_coconut.len(_coconut_match_to) == 4): # case imdef: + dtype = _coconut_match_to[0] # case imdef: + arng = _coconut_match_to[1] # case imdef: + ch_repr = _coconut_match_to[2] # case imdef: + vr = _coconut_match_to[3] # case imdef: + _coconut_case_check_1 = True # case imdef: + if _coconut_case_check_1: # case imdef: + return [Edge(imdef, Numpy(dtype, arng, ch_repr, vr), (_coconut_base_compose(_coconut.operator.methodcaller("detach"), (_coconut.operator.methodcaller("cpu"), 0), (_coconut.operator.methodcaller("numpy"), 0))), 1, name="torch_to_numpy")] # return [Edge(imdef, + if not _coconut_case_check_1: # Numpy(dtype ,arng ,ch_repr,vr), + if (_coconut.isinstance(_coconut_match_to, PILImage)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut_match_to[0] == "RGB"): # Numpy(dtype ,arng ,ch_repr,vr), + ch_repr = _coconut_match_to[1] # Numpy(dtype ,arng ,ch_repr,vr), + _coconut_case_check_1 = True # Numpy(dtype ,arng ,ch_repr,vr), + if _coconut_case_check_1: # Numpy(dtype ,arng ,ch_repr,vr), + return [Edge(imdef, Numpy("uint8", "HWC", ch_repr, VR_0_255), np.array, 1, name="image_to_numpy")] # return [Edge(imdef, + if not _coconut_case_check_1: # Numpy("uint8","HWC",ch_repr,VR_0_255), + if (_coconut.isinstance(_coconut_match_to, PILImage)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut_match_to[0] == "L"): # Numpy("uint8","HWC",ch_repr,VR_0_255), + ch_repr = _coconut_match_to[1] # Numpy("uint8","HWC",ch_repr,VR_0_255), + _coconut_case_check_1 = True # Numpy("uint8","HWC",ch_repr,VR_0_255), + if _coconut_case_check_1: # Numpy("uint8","HWC",ch_repr,VR_0_255), + return [Edge(imdef, Numpy("uint8", "HW", ch_repr, VR_0_255), np.array, 1, name="image_to_numpy")] # return [Edge(imdef, + if not _coconut_case_check_1: # Numpy("uint8","HW",ch_repr,VR_0_255), + if (_coconut.isinstance(_coconut_match_to, PILImage)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut_match_to[0] == "YCbCr"): # Numpy("uint8","HW",ch_repr,VR_0_255), + ch_repr = _coconut_match_to[1] # Numpy("uint8","HW",ch_repr,VR_0_255), + _coconut_case_check_1 = True # Numpy("uint8","HW",ch_repr,VR_0_255), + if _coconut_case_check_1: # Numpy("uint8","HW",ch_repr,VR_0_255), + return [Edge(imdef, Numpy("uint8", "HWC", ch_repr, VR_0_255), np.array, 1, name="YCbCr image to numpy")] # return [Edge(imdef, + + if not _coconut_case_check_1: # A grayscale Image becomes a numpy array # match PILImages("L",ch_repr): # A grayscale Image becomes a numpy array + if (_coconut.isinstance(_coconut_match_to, PILImages)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut_match_to[0] == "L"): # A grayscale Image becomes a numpy array # match PILImages("L",ch_repr): # A grayscale Image becomes a numpy array + ch_repr = _coconut_match_to[1] # A grayscale Image becomes a numpy array # match PILImages("L",ch_repr): # A grayscale Image becomes a numpy array + _coconut_case_check_1 = True # A grayscale Image becomes a numpy array # match PILImages("L",ch_repr): # A grayscale Image becomes a numpy array + if _coconut_case_check_1: # A grayscale Image becomes a numpy array # match PILImages("L",ch_repr): # A grayscale Image becomes a numpy array + return [Edge(imdef, Numpy("uint8", "BHW", ch_repr, VR_0_255), (_coconut_base_compose(_coconut.functools.partial(fmap, np.array), (np.array, 0))), 1, name="image_to_numpy")] # return [Edge(imdef, + if not _coconut_case_check_1: # Numpy("uint8","BHW",ch_repr,VR_0_255), + if (_coconut.isinstance(_coconut_match_to, PILImages)) and (_coconut.len(_coconut_match_to) == 2): # Numpy("uint8","BHW",ch_repr,VR_0_255), + mode = _coconut_match_to[0] # Numpy("uint8","BHW",ch_repr,VR_0_255), + ch_repr = _coconut_match_to[1] # Numpy("uint8","BHW",ch_repr,VR_0_255), + _coconut_case_check_1 = True # Numpy("uint8","BHW",ch_repr,VR_0_255), + if _coconut_case_check_1: # Numpy("uint8","BHW",ch_repr,VR_0_255), + return [Edge(imdef, Numpy("uint8", "BHWC", ch_repr, VR_0_255), (_coconut_base_compose(_coconut.functools.partial(fmap, np.array), (np.array, 0))), 1, name="image_to_numpy")] # return [Edge(imdef, + return [] # return [] +@to_imagedef # @to_imagedef +def to_torch(imdef: 'ImageDef'): # def to_torch(imdef:ImageDef): + import torch # import torch + _coconut_match_to = imdef # case imdef: + _coconut_case_check_2 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, Numpy)) and (_coconut.len(_coconut_match_to) == 4): # case imdef: + dtype = _coconut_match_to[0] # case imdef: + arng = _coconut_match_to[1] # case imdef: + ch_repr = _coconut_match_to[2] # case imdef: + vr = _coconut_match_to[3] # case imdef: + _coconut_case_check_2 = True # case imdef: + if _coconut_case_check_2: # case imdef: + return [Edge(imdef, Torch(dtype, arng, ch_repr, vr), torch.from_numpy, 2, name="to_torch")] # return [Edge(imdef,Torch(dtype,arng,ch_repr,vr),torch.from_numpy,2,name="to_torch")] + return [] # return [] +@to_imagedef # @to_imagedef +def change_dtype(imdef: 'ImageDef'): # TODO match value range to dtype with bool type # def change_dtype(imdef:ImageDef):# TODO match value range to dtype with bool type + _coconut_match_to = imdef # case imdef: + _coconut_case_check_3 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, Numpy)) and (_coconut.len(_coconut_match_to) == 4): # case imdef: + dtype = _coconut_match_to[0] # case imdef: + arng = _coconut_match_to[1] # case imdef: + ch_repr = _coconut_match_to[2] # case imdef: + vr = _coconut_match_to[3] # case imdef: + _coconut_case_check_3 = True # case imdef: + if _coconut_case_check_3: # case imdef: + return [Edge(imdef, imdef.__class__(_dtype, arng, ch_repr, vr), _coconut.operator.methodcaller("astype", _dtype), 1, name="{_coconut_format_0} to {_coconut_format_1}".format(_coconut_format_0=(dtype), _coconut_format_1=(_dtype))) for _dtype in DTYPES if _dtype != dtype] # return [Edge( + return [] # return [] + + +def change_arng(imdef): # def change_arng(imdef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_4 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, Numpy)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "BCHW"): # case imdef: + _coconut_case_check_4 = True # case imdef: + if _coconut_case_check_4: # case imdef: + return [(_coconut.operator.methodcaller("transpose", 0, 2, 3, 1), "BHWC")] # return [(.transpose(0,2,3,1),"BHWC")] + if not _coconut_case_check_4: # match Numpy(_,"BHWC",_,_): + if (_coconut.isinstance(_coconut_match_to, Numpy)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "BHWC"): # match Numpy(_,"BHWC",_,_): + _coconut_case_check_4 = True # match Numpy(_,"BHWC",_,_): + if _coconut_case_check_4: # match Numpy(_,"BHWC",_,_): + return [(_coconut.operator.methodcaller("transpose", 0, 3, 1, 2), "BCHW")] # return [(.transpose(0,3,1,2),"BCHW")] + if not _coconut_case_check_4: # match Torch(_,"BCHW",_,_): + if (_coconut.isinstance(_coconut_match_to, Torch)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "BCHW"): # match Torch(_,"BCHW",_,_): + _coconut_case_check_4 = True # match Torch(_,"BCHW",_,_): + if _coconut_case_check_4: # match Torch(_,"BCHW",_,_): + return [(_coconut_base_compose(_coconut.operator.methodcaller("transpose", 1, 2), (_coconut.operator.methodcaller("transpose", 2, 3), 0)), "BHWC")] # return [(.transpose(1,2) ..> .transpose(2,3),"BHWC")] + if not _coconut_case_check_4: # match Torch(_,"BHWC",_,_): + if (_coconut.isinstance(_coconut_match_to, Torch)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "BHWC"): # match Torch(_,"BHWC",_,_): + _coconut_case_check_4 = True # match Torch(_,"BHWC",_,_): + if _coconut_case_check_4: # match Torch(_,"BHWC",_,_): + return [(_coconut_base_compose(_coconut.operator.methodcaller("transpose", 2, 3), (_coconut.operator.methodcaller("transpose", 1, 2), 0)), "BCHW")] # return [(.transpose(2,3) ..> .transpose(1,2),"BCHW")] + return [] # return [] + +@to_imagedef # @to_imagedef +def drop_alpha(imdef): # def drop_alpha(imdef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_5 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "BHWC") and (_coconut_match_to[2] == "RGBA"): # case imdef: + dtype = _coconut_match_to[0] # case imdef: + vr = _coconut_match_to[3] # case imdef: + _coconut_case_check_5 = True # case imdef: + if _coconut_case_check_5: # case imdef: + return [Edge(a=imdef, b=imdef.__class__(dtype, "BHWC", "RGB", vr), f=lambda a: a[:, :, :, :3], cost=1, name="select rgb channel".format())] # return [Edge(a=imdef, + if not _coconut_case_check_5: # b=imdef.__class__(dtype,"BHWC","RGB",vr), + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "BCHW") and (_coconut_match_to[2] == "RGBA"): # b=imdef.__class__(dtype,"BHWC","RGB",vr), + dtype = _coconut_match_to[0] # b=imdef.__class__(dtype,"BHWC","RGB",vr), + vr = _coconut_match_to[3] # b=imdef.__class__(dtype,"BHWC","RGB",vr), + _coconut_case_check_5 = True # b=imdef.__class__(dtype,"BHWC","RGB",vr), + if _coconut_case_check_5: # b=imdef.__class__(dtype,"BHWC","RGB",vr), + return [Edge(a=imdef, b=imdef.__class__(dtype, "BCHW", "RGB", vr), f=lambda a: a[:, :3], cost=1, name="select rgb channel".format())] # return [Edge(a=imdef, +@to_imagedef # b=imdef.__class__(dtype,"BCHW","RGB",vr), +def change_arrange(imdef: 'ImageDef'): # def change_arrange(imdef:ImageDef): + _coconut_match_to = imdef # match TensorLike(dtype,arng,ch_repr,vr) in imdef: + _coconut_match_check = False # match TensorLike(dtype,arng,ch_repr,vr) in imdef: + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4): # match TensorLike(dtype,arng,ch_repr,vr) in imdef: + dtype = _coconut_match_to[0] # match TensorLike(dtype,arng,ch_repr,vr) in imdef: + arng = _coconut_match_to[1] # match TensorLike(dtype,arng,ch_repr,vr) in imdef: + ch_repr = _coconut_match_to[2] # match TensorLike(dtype,arng,ch_repr,vr) in imdef: + vr = _coconut_match_to[3] # match TensorLike(dtype,arng,ch_repr,vr) in imdef: + _coconut_match_check = True # match TensorLike(dtype,arng,ch_repr,vr) in imdef: + if _coconut_match_check: # match TensorLike(dtype,arng,ch_repr,vr) in imdef: + return [Edge(imdef, imdef.__class__(dtype, _arng, ch_repr, vr), f, 1, name="{_coconut_format_0} to {_coconut_format_1}".format(_coconut_format_0=(arng), _coconut_format_1=(_arng))) for f, _arng in change_arng(imdef)] # return [Edge(imdef,imdef.__class__(dtype,_arng,ch_repr,vr),f,1,name=f"{arng} to {_arng}") for f,_arng in change_arng(imdef)] + return [] # return [] + + + +@to_imagedef # @to_imagedef +def select_channel(imdef: 'ImageDef'): # def select_channel(imdef:ImageDef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_6 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "BHWC"): # case imdef: + dtype = _coconut_match_to[0] # case imdef: + ch_repr = _coconut_match_to[2] # case imdef: + vr = _coconut_match_to[3] # case imdef: + _coconut_case_check_6 = True # case imdef: + if _coconut_case_check_6 and not (len(ch_repr) >= 1): # case imdef: + _coconut_case_check_6 = False # case imdef: + if _coconut_case_check_6: # case imdef: + selector = lambda i: lambda a: a[:, :, :, [i]] # selector = i->a->a[:,:,:,[i]] + return [Edge(a=imdef, b=imdef.__class__(dtype, "BHWC", c, vr), f=selector(i), cost=10, name="select {_coconut_format_0} channel".format(_coconut_format_0=(c))) for i, c in enumerate(ch_splitter(ch_repr))] # return [Edge(a=imdef, + if not _coconut_case_check_6: # b=imdef.__class__(dtype,"BHWC",c,vr), + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "BCHW"): # b=imdef.__class__(dtype,"BHWC",c,vr), + dtype = _coconut_match_to[0] # b=imdef.__class__(dtype,"BHWC",c,vr), + ch_repr = _coconut_match_to[2] # b=imdef.__class__(dtype,"BHWC",c,vr), + vr = _coconut_match_to[3] # b=imdef.__class__(dtype,"BHWC",c,vr), + _coconut_case_check_6 = True # b=imdef.__class__(dtype,"BHWC",c,vr), + if _coconut_case_check_6 and not (len(ch_repr) >= 1): # b=imdef.__class__(dtype,"BHWC",c,vr), + _coconut_case_check_6 = False # b=imdef.__class__(dtype,"BHWC",c,vr), + if _coconut_case_check_6: # b=imdef.__class__(dtype,"BHWC",c,vr), + selector = lambda i: lambda a: a[:, [i]] # selector = i->a->a[:,[i]] + return [Edge(a=imdef, b=imdef.__class__(dtype, "BCHW", c, vr), f=selector(i), cost=10, name="select {_coconut_format_0} channel".format(_coconut_format_0=(c))) for i, c in enumerate(ch_splitter(ch_repr))] # return [Edge(a=imdef, + return [] # return [] +@to_imagedef # @to_imagedef +def drop_channel(imdef: 'ImageDef'): # def drop_channel(imdef:ImageDef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_7 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "BHWC"): # case imdef: + dtype = _coconut_match_to[0] # case imdef: + ch_repr = _coconut_match_to[2] # case imdef: + vr = _coconut_match_to[3] # case imdef: + _coconut_case_check_7 = True # case imdef: + if _coconut_case_check_7 and not (len(ch_splitter(ch_repr)) == 1): # case imdef: + _coconut_case_check_7 = False # case imdef: + if _coconut_case_check_7: # case imdef: + return [Edge(a=imdef, b=imdef.__class__(dtype, "BHW", ch_repr, vr), f=lambda a: a[:, :, :, 0], cost=1, name="BHWC to BHW".format())] # return [Edge(a=imdef, + if not _coconut_case_check_7: # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "BCHW"): # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + dtype = _coconut_match_to[0] # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + ch_repr = _coconut_match_to[2] # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + vr = _coconut_match_to[3] # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + _coconut_case_check_7 = True # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + if _coconut_case_check_7 and not (len(ch_splitter(ch_repr)) == 1): # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + _coconut_case_check_7 = False # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + if _coconut_case_check_7: # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + return [Edge(a=imdef, b=imdef.__class__(dtype, "BHW", ch_repr, vr), f=lambda a: a[:, 0], cost=1, name="BCHW to BHW".format())] # return [Edge(a=imdef, + if not _coconut_case_check_7: # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "CHW"): # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + dtype = _coconut_match_to[0] # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + ch_repr = _coconut_match_to[2] # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + vr = _coconut_match_to[3] # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + _coconut_case_check_7 = True # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + if _coconut_case_check_7 and not (len(ch_splitter(ch_repr)) == 1): # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + _coconut_case_check_7 = False # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + if _coconut_case_check_7: # b=imdef.__class__(dtype,"BHW",ch_repr,vr), + return [Edge(a=imdef, b=imdef.__class__(dtype, "HW", ch_repr, vr), f=lambda a: a[0], cost=1, name="CHW to HW")] # return [Edge(a = imdef,b=imdef.__class__(dtype,"HW",ch_repr,vr), + if not _coconut_case_check_7: # f = a->a[0],cost=1,name="CHW to HW" + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "HWC"): # f = a->a[0],cost=1,name="CHW to HW" + dtype = _coconut_match_to[0] # f = a->a[0],cost=1,name="CHW to HW" + ch_repr = _coconut_match_to[2] # f = a->a[0],cost=1,name="CHW to HW" + vr = _coconut_match_to[3] # f = a->a[0],cost=1,name="CHW to HW" + _coconut_case_check_7 = True # f = a->a[0],cost=1,name="CHW to HW" + if _coconut_case_check_7 and not (len(ch_splitter(ch_repr)) == 1): # f = a->a[0],cost=1,name="CHW to HW" + _coconut_case_check_7 = False # f = a->a[0],cost=1,name="CHW to HW" + if _coconut_case_check_7: # f = a->a[0],cost=1,name="CHW to HW" + return [Edge(a=imdef, b=imdef.__class__(dtype, "HW", ch_repr, vr), f=lambda a: a[:, :, 0], cost=1, name="HWC to HW")] # return [Edge(a = imdef,b=imdef.__class__(dtype,"HW",ch_repr,vr), + + return [] # return [] +def enforce_mode(img, mode): # def enforce_mode(img,mode): + return Image.fromarray(np.array(img), mode) # return Image.fromarray(np.array(img),mode) +""" +@to_imagedef +def RGB_to_YCbCr(state): + case state: + match PILImage("RGB","RGB"): + return [Edge( + a=state, + b=PILImage("YCbCr","YCbCr"), + f= enforce_mode$(mode="RGB") ..> .convert("YCbCr"), + cost=1, + name="RGB to YCbCr" + )] + match PILImage("YCbCr","YCbCr"): + return [Edge( + a=state, + b=PILImage("RGB","RGB"), + f= enforce_mode$(mode="YCbCr") ..> .convert("RGB"), + cost=1, + name="YCbCr to RGB" + )] +""" # """ +def rgb_to_ycbcr(image: 'torch.Tensor') -> 'torch.Tensor': # def rgb_to_ycbcr(image: torch.Tensor) -> torch.Tensor: + r"""Convert an RGB image to YCbCr. + + Args: + image (torch.Tensor): RGB Image to be converted to YCbCr with shape :math:`(*, 3, H, W)`. + + Returns: + torch.Tensor: YCbCr version of the image with shape :math:`(*, 3, H, W)`. + + Examples: + >>> input = torch.rand(2, 3, 4, 5) + >>> output = rgb_to_ycbcr(input) # 2x3x4x5 + """ # """ + if not isinstance(image, torch.Tensor): # if not isinstance(image, torch.Tensor): + raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image))) # raise TypeError("Input type is not a torch.Tensor. Got {}".format( + + if len(image.shape) < 3 or image.shape[-3] != 3: # if len(image.shape) < 3 or image.shape[-3] != 3: + raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape)) # raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}" + + r = image[..., 0, :, :] # type: torch.Tensor # r: torch.Tensor = image[..., 0, :, :] + g = image[..., 1, :, :] # type: torch.Tensor # g: torch.Tensor = image[..., 1, :, :] + b = image[..., 2, :, :] # type: torch.Tensor # b: torch.Tensor = image[..., 2, :, :] + + delta = 0.5 # type: float # delta: float = 0.5 + y = 0.299 * r + 0.587 * g + 0.114 * b # type: torch.Tensor # y: torch.Tensor = 0.299 * r + 0.587 * g + 0.114 * b + cb = (b - y) * 0.564 + delta # type: torch.Tensor # cb: torch.Tensor = (b - y) * 0.564 + delta + cr = (r - y) * 0.713 + delta # type: torch.Tensor # cr: torch.Tensor = (r - y) * 0.713 + delta + return torch.stack([y, cb, cr], -3) # return torch.stack([y, cb, cr], -3) + + +def ycbcr_to_rgb(image: 'torch.Tensor') -> 'torch.Tensor': # def ycbcr_to_rgb(image: torch.Tensor) -> torch.Tensor: + r"""Convert an YCbCr image to RGB. + + The image data is assumed to be in the range of (0, 1). + + Args: + image (torch.Tensor): YCbCr Image to be converted to RGB with shape :math:`(*, 3, H, W)`. + + Returns: + torch.Tensor: RGB version of the image with shape :math:`(*, 3, H, W)`. + + Examples: + >>> input = torch.rand(2, 3, 4, 5) + >>> output = ycbcr_to_rgb(input) # 2x3x4x5 + """ # """ + if not isinstance(image, torch.Tensor): # if not isinstance(image, torch.Tensor): + raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image))) # raise TypeError("Input type is not a torch.Tensor. Got {}".format( + + if len(image.shape) < 3 or image.shape[-3] != 3: # if len(image.shape) < 3 or image.shape[-3] != 3: + raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape)) # raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}" + + y = image[..., 0, :, :] # type: torch.Tensor # y: torch.Tensor = image[..., 0, :, :] + cb = image[..., 1, :, :] # type: torch.Tensor # cb: torch.Tensor = image[..., 1, :, :] + cr = image[..., 2, :, :] # type: torch.Tensor # cr: torch.Tensor = image[..., 2, :, :] + + delta = 0.5 # type: float # delta: float = 0.5 + cb_shifted = cb - delta # type: torch.Tensor # cb_shifted: torch.Tensor = cb - delta + cr_shifted = cr - delta # type: torch.Tensor # cr_shifted: torch.Tensor = cr - delta + + r = y + 1.403 * cr_shifted # type: torch.Tensor # r: torch.Tensor = y + 1.403 * cr_shifted + g = y - 0.714 * cr_shifted - 0.344 * cb_shifted # type: torch.Tensor # g: torch.Tensor = y - 0.714 * cr_shifted - 0.344 * cb_shifted + b = y + 1.773 * cb_shifted # type: torch.Tensor # b: torch.Tensor = y + 1.773 * cb_shifted + return torch.stack([r, g, b], -3) # return torch.stack([r, g, b], -3) + + +@to_imagedef # @to_imagedef +def RGB_to_YCbCr(state): # def RGB_to_YCbCr(state): + _coconut_match_to = state # case state: + _coconut_case_check_8 = False # case state: + if (_coconut.isinstance(_coconut_match_to, Torch)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[0] == "float32") and (_coconut_match_to[1] == "BCHW") and (_coconut_match_to[2] == "RGB") and (_coconut_match_to[3] == VR_0_1): # case state: + _coconut_case_check_8 = True # case state: + if _coconut_case_check_8: # case state: + return [Edge(a=state, b=Torch("float32", "BCHW", "RGB", VR_0_1), f=rgb_to_ycbcr, cost=1, name="RGB_to_YCbCr(torch)")] # return [Edge(a=state, + if not _coconut_case_check_8: # b=Torch("float32","BCHW","RGB",VR_0_1), + if (_coconut.isinstance(_coconut_match_to, Torch)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[0] == "float32") and (_coconut_match_to[1] == "BCHW") and (_coconut_match_to[2] == "YCbCr") and (_coconut_match_to[3] == VR_0_1): # b=Torch("float32","BCHW","RGB",VR_0_1), + _coconut_case_check_8 = True # b=Torch("float32","BCHW","RGB",VR_0_1), + if _coconut_case_check_8: # b=Torch("float32","BCHW","RGB",VR_0_1), + return [Edge(a=state, b=Torch("float32", "BCHW", "RGB", VR_0_1), f=ycbcr_to_rgb, cost=1, name="YCbCr_to_RGB(torch)")] # return [Edge(a=state, + if not _coconut_case_check_8: # b=Torch("float32","BCHW","RGB",VR_0_1), + if (_coconut.isinstance(_coconut_match_to, Torch)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[0] == "float32") and (_coconut_match_to[1] == "CHW") and (_coconut_match_to[2] == "RGB") and (_coconut_match_to[3] == VR_0_1): # b=Torch("float32","BCHW","RGB",VR_0_1), + _coconut_case_check_8 = True # b=Torch("float32","BCHW","RGB",VR_0_1), + if _coconut_case_check_8: # b=Torch("float32","BCHW","RGB",VR_0_1), + return [Edge(a=state, b=Torch("float32", "CHW", "YCbCr", VR_0_1), f=rgb_to_ycbcr, cost=1, name="RGB_to_YCbCr(torch)")] # return [Edge(a=state, + if not _coconut_case_check_8: # b=Torch("float32","CHW","YCbCr",VR_0_1), + if (_coconut.isinstance(_coconut_match_to, Torch)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[0] == "float32") and (_coconut_match_to[1] == "CHW") and (_coconut_match_to[2] == "YCbCr") and (_coconut_match_to[3] == VR_0_1): # b=Torch("float32","CHW","YCbCr",VR_0_1), + _coconut_case_check_8 = True # b=Torch("float32","CHW","YCbCr",VR_0_1), + if _coconut_case_check_8: # b=Torch("float32","CHW","YCbCr",VR_0_1), + return [Edge(a=state, b=Torch("float32", "CHW", "RGB", VR_0_1), f=ycbcr_to_rgb, cost=1, name="YCbCr_to_RGB(torch)")] # return [Edge(a=state, + + + + +def en_batch(imdef: 'ImageDef'): # def en_batch(imdef:ImageDef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_9 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], TensorLike)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "HWC"): # case imdef: + dtype = _coconut_match_to[0][0] # case imdef: + ch_repr = _coconut_match_to[0][2] # case imdef: + vr = _coconut_match_to[0][3] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_9 = True # case imdef: + if (not _coconut_case_check_9) and (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], TensorLike)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "CHW"): # case imdef: + dtype = _coconut_match_to[0][0] # case imdef: + ch_repr = _coconut_match_to[0][2] # case imdef: + vr = _coconut_match_to[0][3] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_9 = True # case imdef: + if (not _coconut_case_check_9) and (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], TensorLike)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "HW"): # case imdef: + dtype = _coconut_match_to[0][0] # case imdef: + ch_repr = _coconut_match_to[0][2] # case imdef: + vr = _coconut_match_to[0][3] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_9 = True # case imdef: + if _coconut_case_check_9: # case imdef: + new_arng = "B" + imdef.data_type.arrange # new_arng = "B"+imdef.data_type.arrange + return [Edge(a=imdef, b=ImageDef(imdef.data_type.__class__(dtype, new_arng, ch_repr, vr), tags | frozenset(("en_batched",))), f=lambda a: a[None], cost=10, name="{_coconut_format_0} to {_coconut_format_1} (en_batch)".format(_coconut_format_0=(imdef.data_type.arrange), _coconut_format_1=(new_arng)))] # return [Edge(a=imdef, + if not _coconut_case_check_9: # b=ImageDef(imdef.data_type.__class__(dtype,new_arng,ch_repr,vr),tags|frozenset(("en_batched",))), + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], PILImage)) and (_coconut.len(_coconut_match_to[0]) == 2): # b=ImageDef(imdef.data_type.__class__(dtype,new_arng,ch_repr,vr),tags|frozenset(("en_batched",))), + mode = _coconut_match_to[0][0] # b=ImageDef(imdef.data_type.__class__(dtype,new_arng,ch_repr,vr),tags|frozenset(("en_batched",))), + channel_repr = _coconut_match_to[0][1] # b=ImageDef(imdef.data_type.__class__(dtype,new_arng,ch_repr,vr),tags|frozenset(("en_batched",))), + tags = _coconut_match_to[1] # b=ImageDef(imdef.data_type.__class__(dtype,new_arng,ch_repr,vr),tags|frozenset(("en_batched",))), + _coconut_case_check_9 = True # b=ImageDef(imdef.data_type.__class__(dtype,new_arng,ch_repr,vr),tags|frozenset(("en_batched",))), + if _coconut_case_check_9: # b=ImageDef(imdef.data_type.__class__(dtype,new_arng,ch_repr,vr),tags|frozenset(("en_batched",))), + return [Edge(a=imdef, b=ImageDef(PILImages(mode, channel_repr), tags | frozenset(("en_batched",))), f=lambda a: [a], cost=10, name="wrap image with list (en_batch)".format())] # return [Edge(a=imdef, + return [] # return [] +def de_batch(imdef: 'ImageDef'): # def de_batch(imdef:ImageDef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_10 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], TensorLike)) and (_coconut.len(_coconut_match_to[0]) == 4): # case imdef: + dtype = _coconut_match_to[0][0] # case imdef: + arng = _coconut_match_to[0][1] # case imdef: + ch = _coconut_match_to[0][2] # case imdef: + vr = _coconut_match_to[0][3] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_10 = True # case imdef: + if _coconut_case_check_10 and not ("en_batched" in tags and "B" in arng): # case imdef: + _coconut_case_check_10 = False # case imdef: + if _coconut_case_check_10: # case imdef: + return [Edge(a=imdef, b=ImageDef(imdef.data_type.__class__(dtype, arng[1:], ch, vr), tags - frozenset(["en_batched"])), f=lambda a: a[0], cost=1, name="de_batch en_batched image".format())] # return [Edge( + if not _coconut_case_check_10: # a=imdef, + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], PILImages)) and (_coconut.len(_coconut_match_to[0]) == 2): # a=imdef, + mode = _coconut_match_to[0][0] # a=imdef, + ch = _coconut_match_to[0][1] # a=imdef, + tags = _coconut_match_to[1] # a=imdef, + _coconut_case_check_10 = True # a=imdef, + if _coconut_case_check_10 and not ("en_batched" in tags): # a=imdef, + _coconut_case_check_10 = False # a=imdef, + if _coconut_case_check_10: # a=imdef, + return [Edge(a=imdef, b=ImageDef(PILImage(mode, ch), tags - frozenset(["en_batched"])), f=lambda a: a[0], cost=1, name="de_batch en_batched image".format())] # return [Edge( + +def drop_batch_tag(imdef: 'ImageDef'): # def drop_batch_tag(imdef:ImageDef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_11 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2): # case imdef: + data_type = _coconut_match_to[0] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_11 = True # case imdef: + if _coconut_case_check_11 and not ("en_batched" in tags): # case imdef: + _coconut_case_check_11 = False # case imdef: + if _coconut_case_check_11: # case imdef: + return [Edge(imdef, ImageDef(data_type, tags - frozenset(("en_batched",))), f=lambda a: a, cost=1, name="drop en_batched tag")] # return [Edge(imdef, + +@to_imagedef # @to_imagedef +def to_rgba(imdef: 'ImageDef'): # def to_rgba(imdef:ImageDef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_12 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[3] == "0_1"): # case imdef: + dtype = _coconut_match_to[0] # case imdef: + arng = _coconut_match_to[1] # case imdef: + ch_repr = _coconut_match_to[2] # case imdef: + _coconut_case_check_12 = True # case imdef: + if _coconut_case_check_12 and not (len(ch_repr) == 4): # case imdef: + _coconut_case_check_12 = False # case imdef: + if _coconut_case_check_12: # case imdef: + return [Edge(a=imdef, b=imdef.__class__(dtype, arng, "RGBA", "0_1"), f=lambda a: a, cost=10, name="view {_coconut_format_0} as RGBA ".format(_coconut_format_0=(ch_repr)))] # return [Edge(a=imdef, + if not _coconut_case_check_12: # b=imdef.__class__(dtype,arng,"RGBA","0_1"), + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[3] == "0_1"): # b=imdef.__class__(dtype,arng,"RGBA","0_1"), + dtype = _coconut_match_to[0] # b=imdef.__class__(dtype,arng,"RGBA","0_1"), + arng = _coconut_match_to[1] # b=imdef.__class__(dtype,arng,"RGBA","0_1"), + ch_repr = _coconut_match_to[2] # b=imdef.__class__(dtype,arng,"RGBA","0_1"), + _coconut_case_check_12 = True # b=imdef.__class__(dtype,arng,"RGBA","0_1"), + if _coconut_case_check_12 and not (len(ch_repr) == 3): # b=imdef.__class__(dtype,arng,"RGBA","0_1"), + _coconut_case_check_12 = False # b=imdef.__class__(dtype,arng,"RGBA","0_1"), + if _coconut_case_check_12: # b=imdef.__class__(dtype,arng,"RGBA","0_1"), + return [Edge(a=imdef, b=imdef.__class__(dtype, arng, "RGB", "0_1"), f=lambda a: a, cost=10, name="view {_coconut_format_0} as RGB ".format(_coconut_format_0=(ch_repr)))] # return [Edge(a=imdef, +@to_imagedef # b=imdef.__class__(dtype,arng,"RGB","0_1"), +def change_value_range(imdef: 'ImageDef'): # def change_value_range(imdef:ImageDef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_13 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[0] == "float32") and (_coconut_match_to[3] == VR_0_255): # case imdef: + arng = _coconut_match_to[1] # case imdef: + ch_repr = _coconut_match_to[2] # case imdef: + _coconut_case_check_13 = True # case imdef: + if (not _coconut_case_check_13) and (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[0] == "float64") and (_coconut_match_to[3] == VR_0_255): # case imdef: + arng = _coconut_match_to[1] # case imdef: + ch_repr = _coconut_match_to[2] # case imdef: + _coconut_case_check_13 = True # case imdef: + if _coconut_case_check_13: # case imdef: + return [Edge(a=imdef, b=imdef.__class__(imdef.dtype, arng, ch_repr, VR_0_1), f=lambda a: a / 255.0, cost=len(ch_repr), name="0-255 to 0-1")] # return [Edge(a=imdef, + if not _coconut_case_check_13: # b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_1), + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[0] == "float32") and (_coconut_match_to[3] == VR_0_1): # b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_1), + arng = _coconut_match_to[1] # b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_1), + ch_repr = _coconut_match_to[2] # b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_1), + _coconut_case_check_13 = True # b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_1), + if (not _coconut_case_check_13) and (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[0] == "float64") and (_coconut_match_to[3] == VR_0_1): # b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_1), + arng = _coconut_match_to[1] # b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_1), + ch_repr = _coconut_match_to[2] # b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_1), + _coconut_case_check_13 = True # b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_1), + if _coconut_case_check_13: # b=imdef.__class__(imdef.dtype,arng,ch_repr,VR_0_1), + return [Edge(a=imdef, b=imdef.__class__(imdef.dtype, arng, ch_repr, VR_0_255), f=lambda a: a * 255.0, cost=len(ch_repr), name="0-1 to 0-255")] # return [Edge(a=imdef, + return [] # return [] + +def xyza_to_rgba(xyza): # def xyza_to_rgba(xyza): + xyz = xyza[:3] # xyz = xyza[:3] + a = xyza[[3]] # a = xyza[[3]] + rgb = (xyz + 1) / 2 # rgb = (xyz+1)/2 + return np.concatenate((rgb, a), axis=0) # return np.concatenate((rgb,a),axis=0) +def xyz_to_rgb(xyz): # def xyz_to_rgb(xyz): + return (xyz + 1) / 2 # return (xyz+1)/2 +def rgb_to_xyz(rgb): # def rgb_to_xyz(rgb): + return (rgb * 2) - 1 # return (rgb*2)-1 +def rgba_to_xyza(rgba): # def rgba_to_xyza(rgba): + rgb = rgba[:3] # rgb = rgba[:3] + a = rgba[[3]] # a = rgba[[3]] + xyz = (rgb * 2) - 1 # xyz = (rgb*2)-1 + return np.concatenate((xyz, a), axis=0) # return np.concatenate((xyz,a),axis=0) + +def rule_xyz_to_rgb(imdef): # def rule_xyz_to_rgb(imdef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_14 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "CHW") and (_coconut_match_to[0][2] == "XYZA") and (_coconut_match_to[0][3] == "-1_1"): # case imdef: + dtype = _coconut_match_to[0][0] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_14 = True # case imdef: + if _coconut_case_check_14: # case imdef: + return [(xyza_to_rgba, ImageDef(Numpy(dtype, "CHW", "RGBA", VR_0_1), tags), 2, "xyza_to_rgba")] # return [ + if not _coconut_case_check_14: # (xyza_to_rgba,ImageDef(Numpy(dtype,"CHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba") + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "CHW") and (_coconut_match_to[0][2] == "XYZ") and (_coconut_match_to[0][3] == "-1_1"): # (xyza_to_rgba,ImageDef(Numpy(dtype,"CHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba") + dtype = _coconut_match_to[0][0] # (xyza_to_rgba,ImageDef(Numpy(dtype,"CHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba") + tags = _coconut_match_to[1] # (xyza_to_rgba,ImageDef(Numpy(dtype,"CHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba") + _coconut_case_check_14 = True # (xyza_to_rgba,ImageDef(Numpy(dtype,"CHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba") + if _coconut_case_check_14: # (xyza_to_rgba,ImageDef(Numpy(dtype,"CHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba") + return [(xyz_to_rgb, ImageDef(Numpy(dtype, "CHW", "RGB", VR_0_1), tags), 2, "xyz_to_rgb")] # return [ + if not _coconut_case_check_14: # (xyz_to_rgb,ImageDef(Numpy(dtype,"CHW","RGB",VR_0_1),tags),2,"xyz_to_rgb") + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "CHW") and (_coconut_match_to[0][2] == "RGBA") and (_coconut_match_to[0][3] == VR_0_1): # (xyz_to_rgb,ImageDef(Numpy(dtype,"CHW","RGB",VR_0_1),tags),2,"xyz_to_rgb") + dtype = _coconut_match_to[0][0] # (xyz_to_rgb,ImageDef(Numpy(dtype,"CHW","RGB",VR_0_1),tags),2,"xyz_to_rgb") + tags = _coconut_match_to[1] # (xyz_to_rgb,ImageDef(Numpy(dtype,"CHW","RGB",VR_0_1),tags),2,"xyz_to_rgb") + _coconut_case_check_14 = True # (xyz_to_rgb,ImageDef(Numpy(dtype,"CHW","RGB",VR_0_1),tags),2,"xyz_to_rgb") + if _coconut_case_check_14: # (xyz_to_rgb,ImageDef(Numpy(dtype,"CHW","RGB",VR_0_1),tags),2,"xyz_to_rgb") + return [(rgba_to_xyza, ImageDef(Numpy(dtype, "CHW", "XYZA", "-1_1"), tags), 2, "rgba_to_xyza")] # return [ + if not _coconut_case_check_14: # (rgba_to_xyza,ImageDef(Numpy(dtype,"CHW","XYZA","-1_1"),tags),2,"rgba_to_xyza") + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "CHW") and (_coconut_match_to[0][2] == "RGB") and (_coconut_match_to[0][3] == VR_0_1): # (rgba_to_xyza,ImageDef(Numpy(dtype,"CHW","XYZA","-1_1"),tags),2,"rgba_to_xyza") + dtype = _coconut_match_to[0][0] # (rgba_to_xyza,ImageDef(Numpy(dtype,"CHW","XYZA","-1_1"),tags),2,"rgba_to_xyza") + tags = _coconut_match_to[1] # (rgba_to_xyza,ImageDef(Numpy(dtype,"CHW","XYZA","-1_1"),tags),2,"rgba_to_xyza") + _coconut_case_check_14 = True # (rgba_to_xyza,ImageDef(Numpy(dtype,"CHW","XYZA","-1_1"),tags),2,"rgba_to_xyza") + if _coconut_case_check_14: # (rgba_to_xyza,ImageDef(Numpy(dtype,"CHW","XYZA","-1_1"),tags),2,"rgba_to_xyza") + return [(rgb_to_xyz, ImageDef(Numpy(dtype, "CHW", "XYZ", "-1_1"), tags), 2, "rgb_to_xyz")] # return [ + +def b_xyza_to_rgba(xyza): # def b_xyza_to_rgba(xyza): + xyz = xyza[:, :3] # xyz = xyza[:,:3] + a = xyza[:, [3]] # a = xyza[:,[3]] + rgb = (xyz + 1) / 2 # rgb = (xyz+1)/2 + return np.concatenate((rgb, a), axis=1) # return np.concatenate((rgb,a),axis=1) +def b_xyz_to_rgb(xyz): # def b_xyz_to_rgb(xyz): + return (xyz + 1) / 2 # return (xyz+1)/2 +def b_rgb_to_xyz(rgb): # def b_rgb_to_xyz(rgb): + return (rgb * 2) - 1 # return (rgb*2)-1 +def b_rgba_to_xyza(rgba): # def b_rgba_to_xyza(rgba): + rgb = rgba[:, :3] # rgb = rgba[:,:3] + a = rgba[:, [3]] # a = rgba[:,[3]] + xyz = (rgb * 2) - 1 # xyz = (rgb*2)-1 + return np.concatenate((xyz, a), axis=1) # return np.concatenate((xyz,a),axis=1) + +def rule_batch_xyz_to_rgb(imdef): # def rule_batch_xyz_to_rgb(imdef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_15 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "BCHW") and (_coconut_match_to[0][2] == "XYZA") and (_coconut_match_to[0][3] == "-1_1"): # case imdef: + dtype = _coconut_match_to[0][0] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_15 = True # case imdef: + if _coconut_case_check_15: # case imdef: + return [(b_xyza_to_rgba, ImageDef(Numpy(dtype, "BCHW", "RGBA", VR_0_1), tags), 2, "xyza_to_rgba(batch)")] # return [ + if not _coconut_case_check_15: # (b_xyza_to_rgba,ImageDef(Numpy(dtype,"BCHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba(batch)") + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "BCHW") and (_coconut_match_to[0][2] == "XYZ") and (_coconut_match_to[0][3] == "-1_1"): # (b_xyza_to_rgba,ImageDef(Numpy(dtype,"BCHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba(batch)") + dtype = _coconut_match_to[0][0] # (b_xyza_to_rgba,ImageDef(Numpy(dtype,"BCHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba(batch)") + tags = _coconut_match_to[1] # (b_xyza_to_rgba,ImageDef(Numpy(dtype,"BCHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba(batch)") + _coconut_case_check_15 = True # (b_xyza_to_rgba,ImageDef(Numpy(dtype,"BCHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba(batch)") + if _coconut_case_check_15: # (b_xyza_to_rgba,ImageDef(Numpy(dtype,"BCHW","RGBA",VR_0_1),tags),2,"xyza_to_rgba(batch)") + return [(b_xyz_to_rgb, ImageDef(Numpy(dtype, "BCHW", "RGB", VR_0_1), tags), 2, "xyz_to_rgb(batch)")] # return [ + if not _coconut_case_check_15: # (b_xyz_to_rgb,ImageDef(Numpy(dtype,"BCHW","RGB",VR_0_1),tags),2,"xyz_to_rgb(batch)") + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "BCHW") and (_coconut_match_to[0][2] == "RGBA") and (_coconut_match_to[0][3] == VR_0_1): # (b_xyz_to_rgb,ImageDef(Numpy(dtype,"BCHW","RGB",VR_0_1),tags),2,"xyz_to_rgb(batch)") + dtype = _coconut_match_to[0][0] # (b_xyz_to_rgb,ImageDef(Numpy(dtype,"BCHW","RGB",VR_0_1),tags),2,"xyz_to_rgb(batch)") + tags = _coconut_match_to[1] # (b_xyz_to_rgb,ImageDef(Numpy(dtype,"BCHW","RGB",VR_0_1),tags),2,"xyz_to_rgb(batch)") + _coconut_case_check_15 = True # (b_xyz_to_rgb,ImageDef(Numpy(dtype,"BCHW","RGB",VR_0_1),tags),2,"xyz_to_rgb(batch)") + if _coconut_case_check_15: # (b_xyz_to_rgb,ImageDef(Numpy(dtype,"BCHW","RGB",VR_0_1),tags),2,"xyz_to_rgb(batch)") + return [(b_rgba_to_xyza, ImageDef(Numpy(dtype, "BCHW", "XYZA", "-1_1"), tags), 2, "rgba_to_xyza(batch)")] # return [ + if not _coconut_case_check_15: # (b_rgba_to_xyza,ImageDef(Numpy(dtype,"BCHW","XYZA","-1_1"),tags),2,"rgba_to_xyza(batch)") + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "BCHW") and (_coconut_match_to[0][2] == "RGB") and (_coconut_match_to[0][3] == VR_0_1): # (b_rgba_to_xyza,ImageDef(Numpy(dtype,"BCHW","XYZA","-1_1"),tags),2,"rgba_to_xyza(batch)") + dtype = _coconut_match_to[0][0] # (b_rgba_to_xyza,ImageDef(Numpy(dtype,"BCHW","XYZA","-1_1"),tags),2,"rgba_to_xyza(batch)") + tags = _coconut_match_to[1] # (b_rgba_to_xyza,ImageDef(Numpy(dtype,"BCHW","XYZA","-1_1"),tags),2,"rgba_to_xyza(batch)") + _coconut_case_check_15 = True # (b_rgba_to_xyza,ImageDef(Numpy(dtype,"BCHW","XYZA","-1_1"),tags),2,"rgba_to_xyza(batch)") + if _coconut_case_check_15: # (b_rgba_to_xyza,ImageDef(Numpy(dtype,"BCHW","XYZA","-1_1"),tags),2,"rgba_to_xyza(batch)") + return [(b_rgb_to_xyz, ImageDef(Numpy(dtype, "BCHW", "XYZ", "-1_1"), tags), 2, "rgb_to_xyz(batch)")] # return [ + + + +_conversions = [to_PILImages, to_numpy, to_torch, change_dtype, change_arrange, select_channel, drop_channel, en_batch, change_value_range, drop_alpha, to_rgba, drop_batch_tag, de_batch, RGB_to_YCbCr,] # _conversions =[ + + +@memoize(1024) # @memoize(1024) +def _edges(imdef): # def _edges(imdef): + res = [] # res = [] + for f in _conversions: # for f in _conversions: + edges = f(imdef) # edges = f(imdef) + if edges is not None: # if edges is not None: + res += edges # res += edges + return res # return res + + + + +@memoize(1024) # @memoize(1024) +def str_to_img_def(query): # def str_to_img_def(query): + """ + ex1: 'numpy,float32,BCHW,RGB,0_255 | hello,world' + ex2: 'torch,float32,BCHW,RGBA,0_1' + ex3: 'image,RGBA,RGBA' + ex4: 'images,RGB,RGB|tag1,tag2...' + """ # """ + vrs = {"0_255": VR_0_255, "0_1": VR_0_1, "None": VR_None} # vrs = { + query = query.replace(" ", "") # query = query.replace(" ","") + def query_to_data_type(query): # def query_to_data_type(query): + _coconut_match_to = query.split(",") # case query.split(","): + _coconut_case_check_16 = False # case query.split(","): + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 5) and (_coconut_match_to[0] == "numpy"): # case query.split(","): + dtype = _coconut_match_to[1] # case query.split(","): + arng = _coconut_match_to[2] # case query.split(","): + ch = _coconut_match_to[3] # case query.split(","): + vr = _coconut_match_to[4] # case query.split(","): + _coconut_case_check_16 = True # case query.split(","): + if _coconut_case_check_16: # case query.split(","): + return Numpy(dtype, arng, ch, vrs[vr] if vr in vrs else vr) # return Numpy(dtype,arng,ch,vrs[vr] if vr in vrs else vr) + if not _coconut_case_check_16: # match ["torch",dtype,arng,ch,vr]: + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 5) and (_coconut_match_to[0] == "torch"): # match ["torch",dtype,arng,ch,vr]: + dtype = _coconut_match_to[1] # match ["torch",dtype,arng,ch,vr]: + arng = _coconut_match_to[2] # match ["torch",dtype,arng,ch,vr]: + ch = _coconut_match_to[3] # match ["torch",dtype,arng,ch,vr]: + vr = _coconut_match_to[4] # match ["torch",dtype,arng,ch,vr]: + _coconut_case_check_16 = True # match ["torch",dtype,arng,ch,vr]: + if _coconut_case_check_16: # match ["torch",dtype,arng,ch,vr]: + return Torch(dtype, arng, ch, vrs[vr] if vr in vrs else vr) # return Torch(dtype,arng,ch,vrs[vr] if vr in vrs else vr) + if not _coconut_case_check_16: # match ["image",mode,ch]: + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 3) and (_coconut_match_to[0] == "image"): # match ["image",mode,ch]: + mode = _coconut_match_to[1] # match ["image",mode,ch]: + ch = _coconut_match_to[2] # match ["image",mode,ch]: + _coconut_case_check_16 = True # match ["image",mode,ch]: + if _coconut_case_check_16: # match ["image",mode,ch]: + return PILImage(mode, ch) # return PILImage(mode,ch) + if not _coconut_case_check_16: # match ["images",mode,ch]: + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 3) and (_coconut_match_to[0] == "images"): # match ["images",mode,ch]: + mode = _coconut_match_to[1] # match ["images",mode,ch]: + ch = _coconut_match_to[2] # match ["images",mode,ch]: + _coconut_case_check_16 = True # match ["images",mode,ch]: + if _coconut_case_check_16: # match ["images",mode,ch]: + return PILImages(mode, ch) # return PILImages(mode,ch) + _coconut_match_to = query.split("|") # case query.split("|"): + _coconut_case_check_17 = False # case query.split("|"): + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 1): # case query.split("|"): + data_type = _coconut_match_to[0] # case query.split("|"): + _coconut_case_check_17 = True # case query.split("|"): + if _coconut_case_check_17: # case query.split("|"): + return ImageDef(query_to_data_type(data_type), frozenset()) # return ImageDef(query_to_data_type(data_type),frozenset()) + if not _coconut_case_check_17: # match [data_type,tags]: + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 2): # match [data_type,tags]: + data_type = _coconut_match_to[0] # match [data_type,tags]: + tags = _coconut_match_to[1] # match [data_type,tags]: + _coconut_case_check_17 = True # match [data_type,tags]: + if _coconut_case_check_17: # match [data_type,tags]: + return ImageDef(query_to_data_type(data_type), frozenset(tags.split(","))) # return ImageDef(query_to_data_type(data_type),frozenset(tags.split(","))) + if not _coconut_case_check_17: # else: + raise RuntimeError("could not parse image def string!:{_coconut_format_0}".format(_coconut_format_0=(query))) # raise RuntimeError(f"could not parse image def string!:{query}") + +def parse_def(img_def): # def parse_def(img_def): + try: # try: + return str_to_img_def(img_def) if (isinstance)(img_def, str) else img_def # return str_to_img_def(img_def) if img_def `isinstance` str else img_def + except Exception as e: # except Exception as e: + return img_def # return img_def + + + +accept_def_str = lambda f: _coconut_base_compose(parse_def, (f, 0)) # accept_def_str = f -> parse_def ..> f +def imdef_neighbors(imdef): # def imdef_neighbors(imdef): + return [(e.f, e.b, e.cost, e.name) for e in _edges(imdef)] # return [(e.f,e.b,e.cost,e.name) for e in _edges(imdef)] + +#from data_tree.coconut.convert import AutoImage,PILImage,str_to_img_def,PILImages +#from data_tree.coconut.convert import ImageDef,Torch,Numpy,TensorLike,VR_0_1,VR_None,VR_0_255 + +def normalize_numpy_img(ary): # def normalize_numpy_img(ary): + _min = ary.min() # _min = ary.min() + _max = ary.max() # _max = ary.max() + return ((ary - _min) / (_max - _min)) # return ((ary-_min)/(_max-_min)) + +def rule_VR_None_to_normalized(imdef): # def rule_VR_None_to_normalized(imdef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_18 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "CHW") and (_coconut_match_to[0][3] == VR_None): # case imdef: + dtype = _coconut_match_to[0][0] # case imdef: + arng = _coconut_match_to[0][1] # case imdef: + ch = _coconut_match_to[0][2] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_18 = True # case imdef: + if (not _coconut_case_check_18) and (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "HW") and (_coconut_match_to[0][3] == VR_None): # case imdef: + dtype = _coconut_match_to[0][0] # case imdef: + arng = _coconut_match_to[0][1] # case imdef: + ch = _coconut_match_to[0][2] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_18 = True # case imdef: + if _coconut_case_check_18: # case imdef: + return [(normalize_numpy_img, ImageDef(Numpy(dtype, arng, ch, VR_0_1), tags), 1, "minmax_0_1_numpy_img")] # return [( + if not _coconut_case_check_18: # normalize_numpy_img, + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "BCHW") and (_coconut_match_to[0][3] == VR_None): # normalize_numpy_img, + dtype = _coconut_match_to[0][0] # normalize_numpy_img, + ch = _coconut_match_to[0][2] # normalize_numpy_img, + tags = _coconut_match_to[1] # normalize_numpy_img, + _coconut_case_check_18 = True # normalize_numpy_img, + if _coconut_case_check_18: # normalize_numpy_img, + return [(lambda batch: np.array([normalize_numpy_img(img) for img in batch]), ImageDef(Numpy(dtype, "BCHW", ch, VR_0_1), tags), 1, "batch_minmax_0_1_numpy_img")] # return [( +def rule_add_channel(imdef): # def rule_add_channel(imdef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_19 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "HW"): # case imdef: + dtype = _coconut_match_to[0][0] # case imdef: + ch = _coconut_match_to[0][2] # case imdef: + vr = _coconut_match_to[0][3] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_19 = True # case imdef: + if _coconut_case_check_19: # case imdef: + return [(lambda a: a[None], ImageDef(Numpy(dtype, "CHW", ch, vr), tags), 1, "add_channel_dim")] # return [( + if not _coconut_case_check_19: # a->a[None], + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "BHW"): # a->a[None], + dtype = _coconut_match_to[0][0] # a->a[None], + ch = _coconut_match_to[0][2] # a->a[None], + vr = _coconut_match_to[0][3] # a->a[None], + tags = _coconut_match_to[1] # a->a[None], + _coconut_case_check_19 = True # a->a[None], + if _coconut_case_check_19: # a->a[None], + return [(lambda a: a[:, None], ImageDef(Numpy(dtype, "BCHW", ch, vr), tags), 1, "add_channel_dim")] # return [( +def rule_swap_RGB_BGR(imdef): # def rule_swap_RGB_BGR(imdef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_20 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], TensorLike)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "BHWC") and (_coconut_match_to[0][2] == "RGB"): # case imdef: + tl = _coconut_match_to[0] # case imdef: + dtype = _coconut_match_to[0][0] # case imdef: + rgb_order = _coconut_match_to[0][2] # case imdef: + vr = _coconut_match_to[0][3] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_20 = True # case imdef: + if (not _coconut_case_check_20) and (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], TensorLike)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][1] == "BHWC") and (_coconut_match_to[0][2] == "BGR"): # case imdef: + tl = _coconut_match_to[0] # case imdef: + dtype = _coconut_match_to[0][0] # case imdef: + rgb_order = _coconut_match_to[0][2] # case imdef: + vr = _coconut_match_to[0][3] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_20 = True # case imdef: + if _coconut_case_check_20: # case imdef: + return [(lambda a: a[:, :, :, [2, 1, 0]], ImageDef(tl.__class__(dtype, "BHWC", "RGB" if rgb_order.startswith("B") else "BGR", vr), tags), 1, "swap rgb or bgr")] # return [( +def rule_BGR_to_LAB(imdef): # def rule_BGR_to_LAB(imdef): + from skimage import color # from skimage import color + _coconut_match_to = imdef # case imdef: + _coconut_case_check_21 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][0] == "float32") and (_coconut_match_to[0][1] == "HWC") and (_coconut_match_to[0][2] == "BGR") and (_coconut_match_to[0][3] == VR_0_1): # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_21 = True # case imdef: + if _coconut_case_check_21: # case imdef: + return [(color.rgb2lab, ImageDef(Numpy("float32", "HWC", "LAB", "VR_LAB"), tags), 1, "bgr_0_1 to lab")] # return[( + if not _coconut_case_check_21: # color.rgb2lab, + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][0] == "float32") and (_coconut_match_to[0][1] == "HWC") and (_coconut_match_to[0][2] == "LAB") and (_coconut_match_to[0][3] == "VR_LAB"): # color.rgb2lab, + tags = _coconut_match_to[1] # color.rgb2lab, + _coconut_case_check_21 = True # color.rgb2lab, + if _coconut_case_check_21: # color.rgb2lab, + return [(color.lab2rgb, ImageDef(Numpy("float32", "HWC", "BGR", VR_0_1), tags), 1, "lab to bgr_0_1")] # return [( + + + + +class AutoImage: # class AutoImage: + default_rules = [imdef_neighbors, rule_xyz_to_rgb, rule_batch_xyz_to_rgb, rule_VR_None_to_normalized, rule_add_channel, rule_swap_RGB_BGR, rule_BGR_to_LAB] # default_rules = [ + solver = AStarSolver(rules=default_rules.copy()) # solver = AStarSolver(rules=default_rules.copy()) + + @staticmethod # @staticmethod + def reset_solver(): # def reset_solver(): + AutoImage.solver = AStarSolver(rules=AutoImage.default_rules.copy()) # AutoImage.solver = AStarSolver(rules = AutoImage.default_rules.copy()) + + @staticmethod # @staticmethod + def debug_conversion(a, b, samples): # def debug_conversion(a,b,samples): + x = samples # x = samples + edges = AutoImage.solver.search_direct(a, b).edges # edges = AutoImage.solver.search_direct(a,b).edges + for edge in edges: # for edge in edges: + print(edge) # print(edge) + print(edge.f) # print(edge.f) + x = edge.f(x) # x = edge.f(x) + print("converted to type:{_coconut_format_0}".format(_coconut_format_0=(type(x)))) # print(f"converted to type:{type(x)}") + if (isinstance)(x, np.ndarray): # if x `isinstance` np.ndarray: + print(x.shape) # print(x.shape) + print("converted:{_coconut_format_0}".format(_coconut_format_0=(x))) # print(f"converted:{x}") + return x # return x + + def to_debug(self, img_def): # def to_debug(self,img_def): + img_def = parse_def(img_def) # img_def = parse_def(img_def) + return AutoImage.debug_conversion(self.img_def, img_def, self.data) # return AutoImage.debug_conversion(self.img_def,img_def,self.data) + + def __init__(self, data, img_def): # def __init__(self,data,img_def): + img_def = parse_def(img_def) # img_def = parse_def(img_def) + self.data = data # self.data = data + self.img_def = img_def # self.img_def = img_def + + def converter(self, img_def): # def converter(self,img_def): + img_def = parse_def(img_def) # img_def = parse_def(img_def) + return AutoImage.solver.search_direct(self.img_def, img_def) # return AutoImage.solver.search_direct(self.img_def,img_def) + + def any_converter(self, img_defs): # def any_converter(self,img_defs): + imdefs = [parse_def(imdef) for imdef in img_defs] # imdefs = [parse_def(imdef) for imdef in img_defs] + return AutoImage.solver.search_direct_any(self.img_def, imdefs) # return AutoImage.solver.search_direct_any(self.img_def,imdefs) + + def convert(self, img_def): # def convert(self,img_def): + convert = self.converter(img_def) # convert = self.converter(img_def) + if convert.edges: # if convert.edges: + return AutoImage(convert(self.data), convert.edges[-1].dst) # return AutoImage(convert(self.data),convert.edges[-1].dst) + else: # else: + return self # return self + + def any_convert(self, imdefs): # def any_convert(self,imdefs): + converter = self.any_converter(imdefs) # converter = self.any_converter(imdefs) + if converter.edges: # if converter.edges: + return AutoImage(converter(self.data), converter.edges[-1].dst) # return AutoImage(converter(self.data),converter.edges[-1].dst) + else: # else: + return self # return self + + @_coconut_mark_as_match # def to(self,img_def is (str,ImageDef),log_trace=False): + def to(*_coconut_match_to_args, **_coconut_match_to_kwargs): # def to(self,img_def is (str,ImageDef),log_trace=False): + _coconut_match_check = False # def to(self,img_def is (str,ImageDef),log_trace=False): + _coconut_FunctionMatchError = _coconut_get_function_match_error() # def to(self,img_def is (str,ImageDef),log_trace=False): + if (_coconut.len(_coconut_match_to_args) <= 3) and (_coconut.sum((_coconut.len(_coconut_match_to_args) > 0, "self" in _coconut_match_to_kwargs)) == 1) and (_coconut.sum((_coconut.len(_coconut_match_to_args) > 1, "img_def" in _coconut_match_to_kwargs)) == 1) and (_coconut.sum((_coconut.len(_coconut_match_to_args) > 2, "log_trace" in _coconut_match_to_kwargs)) <= 1): # def to(self,img_def is (str,ImageDef),log_trace=False): + _coconut_match_temp_0 = _coconut_match_to_args[0] if _coconut.len(_coconut_match_to_args) > 0 else _coconut_match_to_kwargs.pop("self") # def to(self,img_def is (str,ImageDef),log_trace=False): + _coconut_match_temp_1 = _coconut_match_to_args[1] if _coconut.len(_coconut_match_to_args) > 1 else _coconut_match_to_kwargs.pop("img_def") # def to(self,img_def is (str,ImageDef),log_trace=False): + _coconut_match_temp_2 = _coconut_match_to_args[2] if _coconut.len(_coconut_match_to_args) > 2 else _coconut_match_to_kwargs.pop("log_trace") if "log_trace" in _coconut_match_to_kwargs else False # def to(self,img_def is (str,ImageDef),log_trace=False): + if (_coconut.isinstance(_coconut_match_temp_1, (str, ImageDef))) and (not _coconut_match_to_kwargs): # def to(self,img_def is (str,ImageDef),log_trace=False): + self = _coconut_match_temp_0 # def to(self,img_def is (str,ImageDef),log_trace=False): + img_def = _coconut_match_temp_1 # def to(self,img_def is (str,ImageDef),log_trace=False): + log_trace = _coconut_match_temp_2 # def to(self,img_def is (str,ImageDef),log_trace=False): + _coconut_match_check = True # def to(self,img_def is (str,ImageDef),log_trace=False): + if not _coconut_match_check: # def to(self,img_def is (str,ImageDef),log_trace=False): + _coconut_match_val_repr = _coconut.repr(_coconut_match_to_args) # def to(self,img_def is (str,ImageDef),log_trace=False): + _coconut_match_err = _coconut_FunctionMatchError("pattern-matching failed for " "'def to(self,img_def is (str,ImageDef),log_trace=False):'" " in " + (_coconut_match_val_repr if _coconut.len(_coconut_match_val_repr) <= 500 else _coconut_match_val_repr[:500] + "...")) # def to(self,img_def is (str,ImageDef),log_trace=False): + _coconut_match_err.pattern = 'def to(self,img_def is (str,ImageDef),log_trace=False):' # def to(self,img_def is (str,ImageDef),log_trace=False): + _coconut_match_err.value = _coconut_match_to_args # def to(self,img_def is (str,ImageDef),log_trace=False): + raise _coconut_match_err # def to(self,img_def is (str,ImageDef),log_trace=False): + + return self.convert(img_def).data # return self.convert(img_def).data + + def any_to(self, imdefs): # def any_to(self,imdefs): + return self.any_convert(imdefs).data # return self.any_convert(imdefs).data + + def to_widget(self): # def to_widget(self): + _coconut_match_to = self.img_def.data_type # case self.img_def.data_type: + _coconut_case_check_22 = False # case self.img_def.data_type: + if _coconut.isinstance(_coconut_match_to, PILImages): # case self.img_def.data_type: + item = _coconut_match_to # case self.img_def.data_type: + _coconut_case_check_22 = True # case self.img_def.data_type: + if _coconut_case_check_22: # case self.img_def.data_type: + return self.tile_image().to_widget() # return self.tile_image().to_widget() + if not _coconut_case_check_22: # match TensorLike(_,arng,*_) if "B" in arng: + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) >= 2): # match TensorLike(_,arng,*_) if "B" in arng: + arng = _coconut_match_to[1] # match TensorLike(_,arng,*_) if "B" in arng: + _coconut_case_check_22 = True # match TensorLike(_,arng,*_) if "B" in arng: + if _coconut_case_check_22 and not ("B" in arng): # match TensorLike(_,arng,*_) if "B" in arng: + _coconut_case_check_22 = False # match TensorLike(_,arng,*_) if "B" in arng: + if _coconut_case_check_22: # match TensorLike(_,arng,*_) if "B" in arng: + return self.tile_image().to_widget() # return self.tile_image().to_widget() + if not _coconut_case_check_22: # else: + convert = self.converter(self.to_images_def()) # convert = self.converter(self.to_images_def()) + return (infer_widget)(convert(self.data)) # return convert(self.data) |> infer_widget + + def _repr_html_(self): # def _repr_html_(self): + return (display)(self.to_widget()) # return self.to_widget() |> display + + def to_images_def(self): # def to_images_def(self): + """ + you have to add en_batched tag when data is not batch. + """ # """ + tag_opt = frozenset() # tag_opt=frozenset() + img_cls = PILImages # img_cls = PILImages + _coconut_match_to = self.img_def # case self.img_def: + _coconut_case_check_23 = False # case self.img_def: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], TensorLike)) and (_coconut.len(_coconut_match_to[0]) == 4): # case self.img_def: + arng = _coconut_match_to[0][1] # case self.img_def: + tags = _coconut_match_to[1] # case self.img_def: + _coconut_case_check_23 = True # case self.img_def: + if _coconut_case_check_23 and not ("B" not in arng): # case self.img_def: + _coconut_case_check_23 = False # case self.img_def: + if _coconut_case_check_23: # case self.img_def: + tag_opt = frozenset(("en_batched",)) # tag_opt = frozenset(("en_batched",)) + if not _coconut_case_check_23: # match ImageDef(PILImage(mode,ch),tags): + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], PILImage)) and (_coconut.len(_coconut_match_to[0]) == 2): # match ImageDef(PILImage(mode,ch),tags): + mode = _coconut_match_to[0][0] # match ImageDef(PILImage(mode,ch),tags): + ch = _coconut_match_to[0][1] # match ImageDef(PILImage(mode,ch),tags): + tags = _coconut_match_to[1] # match ImageDef(PILImage(mode,ch),tags): + _coconut_case_check_23 = True # match ImageDef(PILImage(mode,ch),tags): + if _coconut_case_check_23: # match ImageDef(PILImage(mode,ch),tags): + tag_opt = frozenset(("en_batched",)) # tag_opt = frozenset(("en_batched",)) + + _coconut_match_to = self.img_def.data_type # case self.img_def.data_type: + _coconut_case_check_24 = False # case self.img_def.data_type: + if (_coconut.isinstance(_coconut_match_to, PILImage)) and (_coconut.len(_coconut_match_to) == 2): # case self.img_def.data_type: + mode = _coconut_match_to[0] # case self.img_def.data_type: + chrepr = _coconut_match_to[1] # case self.img_def.data_type: + _coconut_case_check_24 = True # case self.img_def.data_type: + if _coconut_case_check_24: # case self.img_def.data_type: + return ImageDef(PILImages(mode, chrepr), self.img_def.tags | tag_opt) # return ImageDef(PILImages(mode,chrepr),self.img_def.tags | tag_opt) + if not _coconut_case_check_24: # match PILImages(mode,chrepr): + if (_coconut.isinstance(_coconut_match_to, PILImages)) and (_coconut.len(_coconut_match_to) == 2): # match PILImages(mode,chrepr): + mode = _coconut_match_to[0] # match PILImages(mode,chrepr): + chrepr = _coconut_match_to[1] # match PILImages(mode,chrepr): + _coconut_case_check_24 = True # match PILImages(mode,chrepr): + if _coconut_case_check_24: # match PILImages(mode,chrepr): + return self.img_def # return self.img_def + if not _coconut_case_check_24: # match TensorLike(dtype,arng,c,vr) if len(c) == 1: + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4): # match TensorLike(dtype,arng,c,vr) if len(c) == 1: + dtype = _coconut_match_to[0] # match TensorLike(dtype,arng,c,vr) if len(c) == 1: + arng = _coconut_match_to[1] # match TensorLike(dtype,arng,c,vr) if len(c) == 1: + c = _coconut_match_to[2] # match TensorLike(dtype,arng,c,vr) if len(c) == 1: + vr = _coconut_match_to[3] # match TensorLike(dtype,arng,c,vr) if len(c) == 1: + _coconut_case_check_24 = True # match TensorLike(dtype,arng,c,vr) if len(c) == 1: + if _coconut_case_check_24 and not (len(c) == 1): # match TensorLike(dtype,arng,c,vr) if len(c) == 1: + _coconut_case_check_24 = False # match TensorLike(dtype,arng,c,vr) if len(c) == 1: + if _coconut_case_check_24: # match TensorLike(dtype,arng,c,vr) if len(c) == 1: + return ImageDef(img_cls("L", c), self.img_def.tags | tag_opt) # return ImageDef(img_cls("L",c),self.img_def.tags | tag_opt) + if not _coconut_case_check_24: # match TensorLike(dtype,arng,"RGBA",vr): + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[2] == "RGBA"): # match TensorLike(dtype,arng,"RGBA",vr): + dtype = _coconut_match_to[0] # match TensorLike(dtype,arng,"RGBA",vr): + arng = _coconut_match_to[1] # match TensorLike(dtype,arng,"RGBA",vr): + vr = _coconut_match_to[3] # match TensorLike(dtype,arng,"RGBA",vr): + _coconut_case_check_24 = True # match TensorLike(dtype,arng,"RGBA",vr): + if _coconut_case_check_24: # match TensorLike(dtype,arng,"RGBA",vr): + return ImageDef(img_cls("RGBA", "RGBA"), self.img_def.tags | tag_opt) # return ImageDef(img_cls("RGBA","RGBA"),self.img_def.tags | tag_opt) + if not _coconut_case_check_24: # match TensorLike(dtype,arng,"RGB",vr): + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[2] == "RGB"): # match TensorLike(dtype,arng,"RGB",vr): + dtype = _coconut_match_to[0] # match TensorLike(dtype,arng,"RGB",vr): + arng = _coconut_match_to[1] # match TensorLike(dtype,arng,"RGB",vr): + vr = _coconut_match_to[3] # match TensorLike(dtype,arng,"RGB",vr): + _coconut_case_check_24 = True # match TensorLike(dtype,arng,"RGB",vr): + if _coconut_case_check_24: # match TensorLike(dtype,arng,"RGB",vr): + return ImageDef(img_cls("RGB", "RGB"), self.img_def.tags | tag_opt) # return ImageDef(img_cls("RGB","RGB"),self.img_def.tags | tag_opt) + if not _coconut_case_check_24: # match TensorLike(dtype,arng,ch,vr) if "A" in ch and ch != "LAB": + if (_coconut.isinstance(_coconut_match_to, TensorLike)) and (_coconut.len(_coconut_match_to) == 4): # match TensorLike(dtype,arng,ch,vr) if "A" in ch and ch != "LAB": + dtype = _coconut_match_to[0] # match TensorLike(dtype,arng,ch,vr) if "A" in ch and ch != "LAB": + arng = _coconut_match_to[1] # match TensorLike(dtype,arng,ch,vr) if "A" in ch and ch != "LAB": + ch = _coconut_match_to[2] # match TensorLike(dtype,arng,ch,vr) if "A" in ch and ch != "LAB": + vr = _coconut_match_to[3] # match TensorLike(dtype,arng,ch,vr) if "A" in ch and ch != "LAB": + _coconut_case_check_24 = True # match TensorLike(dtype,arng,ch,vr) if "A" in ch and ch != "LAB": + if _coconut_case_check_24 and not ("A" in ch and ch != "LAB"): # match TensorLike(dtype,arng,ch,vr) if "A" in ch and ch != "LAB": + _coconut_case_check_24 = False # match TensorLike(dtype,arng,ch,vr) if "A" in ch and ch != "LAB": + if _coconut_case_check_24: # match TensorLike(dtype,arng,ch,vr) if "A" in ch and ch != "LAB": + return ImageDef(img_cls("RGBA", "RGBA"), self.img_def.tags | tag_opt) # return ImageDef(img_cls("RGBA","RGBA"),self.img_def.tags | tag_opt) + if not _coconut_case_check_24: # else: + attempts = ["image,RGBA,RGBA", "images,RGBA,RGBA", "image,RGB,RGB", "images,RGB,RGB", "image,L,L", "images,L,L"] # attempts=[ + for tgt in attempts: # for tgt in attempts: + imdef = str_to_img_def(tgt) # imdef = str_to_img_def(tgt) + try: # try: + converter = self.converter(imdef) # converter = self.converter(imdef) + return imdef # return imdef + except NoRouteException as e: # except NoRouteException as e: +#logger.warning(f"no route for:{imdef}. trying next imdef.") + pass # pass + raise RuntimeError("cannot convert to image:{_coconut_format_0} to any image_like imdef}".format(_coconut_format_0=(self.img_def))) # raise RuntimeError(f"cannot convert to image:{self.img_def} to any image_like imdef}") + + + def image_op(self, f: '_coconut.typing.Callable[[Image], Image]'): # def image_op(self,f:Image->Image): + images_def = self.to_images_def() # images_def = self.to_images_def() + images = self.to(images_def) # images = self.to(images_def) + new_images = [f(i) for i in images] # do some resizing or something # new_images=[f(i) for i in images ] # do some resizing or something + new_ai = AutoImage(new_images, images_def) # new_ai = AutoImage(new_images,images_def) + return new_ai.convert(self.img_def) # go back to last state. # return new_ai.convert(self.img_def) # go back to last state. + + def visdom(self, visdom=None, **kwargs): # def visdom(self,visdom=None,**kwargs): + if visdom is None: # if visdom is None: + from data_tree.visdom import VISDOM # from data_tree.visdom import VISDOM + visdom = VISDOM # visdom = VISDOM + candidates = ["numpy,float32,CHW,RGB,0_1", "numpy,float32,CHW,L,0_1", "numpy,float32,BCHW,RGB,0_1", "numpy,float32,BCHW,L,0_1"] # candidates = [ + img = self.any_convert(candidates) # img = self.any_convert(candidates) + data_type = img.img_def.data_type # data_type = img.img_def.data_type + _coconut_match_to = data_type # case data_type: + _coconut_case_check_25 = False # case data_type: + if (_coconut.isinstance(_coconut_match_to, Numpy)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "CHW"): # case data_type: + _coconut_case_check_25 = True # case data_type: + if _coconut_case_check_25: # case data_type: + res = visdom.image(img.data, **kwargs) # res = visdom.image(img.data,**kwargs) + if not _coconut_case_check_25: # match Numpy(_,"BCHW",_,_): + if (_coconut.isinstance(_coconut_match_to, Numpy)) and (_coconut.len(_coconut_match_to) == 4) and (_coconut_match_to[1] == "BCHW"): # match Numpy(_,"BCHW",_,_): + _coconut_case_check_25 = True # match Numpy(_,"BCHW",_,_): + if _coconut_case_check_25: # match Numpy(_,"BCHW",_,_): + res = visdom.images(img.data, **kwargs) # res = visdom.images(img.data,**kwargs) + return res # return res + + +try: # @property + _coconut_dotted_func_name_store_0 = images # @property +except _coconut.NameError: # @property + _coconut_dotted_func_name_store_0 = None # @property +@property # @property +def images(self): # def AutoImage.images(self): + return self.to(self.to_images_def()) # return self.to(self.to_images_def()) + +AutoImage.images = images # @property +images = _coconut_dotted_func_name_store_0 # @property +try: # @property + _coconut_dotted_func_name_store_1 = image_size # @property +except _coconut.NameError: # @property + _coconut_dotted_func_name_store_1 = None # @property +@property # @property +def image_size(self): # def AutoImage.image_size(self): + return self.images[0].size # return self.images[0].size + +AutoImage.image_size = image_size # def make_grid(imgs, nrow, padding=0): +image_size = _coconut_dotted_func_name_store_1 # def make_grid(imgs, nrow, padding=0): +def make_grid(imgs, nrow, padding=0): # def make_grid(imgs, nrow, padding=0): + """Numpy配列の複数枚の画像を、1枚の画像にタイルします + + Arguments: + imgs {np.ndarray} -- 複数枚の画像からなるテンソル + nrow {int} -- 1行あたりにタイルする枚数 + + Keyword Arguments: + padding {int} -- グリッドの間隔 (default: {0}) + + Returns: + [np.ndarray] -- 3階テンソル。1枚の画像 + """ # """ + assert imgs.ndim == 4 and nrow > 0 # assert imgs.ndim == 4 and nrow > 0 + batch, height, width, ch = imgs.shape # batch, height, width, ch = imgs.shape + n = nrow * (batch // nrow + np.sign(batch % nrow)) # n = nrow * (batch // nrow + np.sign(batch % nrow)) + ncol = n // nrow # ncol = n // nrow + pad = np.zeros((n - batch, height, width, ch), imgs.dtype) # pad = np.zeros((n - batch, height, width, ch), imgs.dtype) + x = np.concatenate([imgs, pad], axis=0) # x = np.concatenate([imgs, pad], axis=0) +# border padding if required + if padding > 0: # if padding > 0: + x = np.pad(x, ((0, 0), (0, padding), (0, padding), (0, 0)), "constant", constant_values=(0, 0)) # 下と右だけにpaddingを入れる # x = np.pad(x, ((0, 0), (0, padding), (0, padding), (0, 0)), + height += padding # height += padding + width += padding # width += padding + x = x.reshape(ncol, nrow, height, width, ch) # x = x.reshape(ncol, nrow, height, width, ch) + x = x.transpose([0, 2, 1, 3, 4]) # (ncol, height, nrow, width, ch) # x = x.transpose([0, 2, 1, 3, 4]) # (ncol, height, nrow, width, ch) + x = x.reshape(height * ncol, width * nrow, ch) # x = x.reshape(height * ncol, width * nrow, ch) + if padding > 0: # if padding > 0: + x = x[:(height * ncol - padding), :(width * nrow - padding), :] # 右端と下端のpaddingを削除 # x = x[:(height * ncol - padding),:(width * nrow - padding),:] # 右端と下端のpaddingを削除 + return x # return x + + +try: # def AutoImage.tile_image(self,w=1024,h=1024,max_image=100,padding=1): + _coconut_dotted_func_name_store_2 = tile_image # def AutoImage.tile_image(self,w=1024,h=1024,max_image=100,padding=1): +except _coconut.NameError: # def AutoImage.tile_image(self,w=1024,h=1024,max_image=100,padding=1): + _coconut_dotted_func_name_store_2 = None # def AutoImage.tile_image(self,w=1024,h=1024,max_image=100,padding=1): +def tile_image(self, w=1024, h=1024, max_image=100, padding=1): # def AutoImage.tile_image(self,w=1024,h=1024,max_image=100,padding=1): + ch = self.to_images_def().data_type.channel_repr # ch = self.to_images_def().data_type.channel_repr + if len(ch) == 1: # if len(ch) == 1: + codec = "numpy,uint8,BHW,{_coconut_format_0},0_255".format(_coconut_format_0=(ch)) # codec = f"numpy,uint8,BHW,{ch},0_255" + else: # else: + codec = "numpy,uint8,BHWC,{_coconut_format_0},0_255".format(_coconut_format_0=(ch)) # codec = f"numpy,uint8,BHWC,{ch},0_255" + imgs = self.to(codec)[:max_image] # imgs = self.to(codec)[:max_image] + nrow = int(sqrt(len(imgs)) + 0.5) # nrow = int(sqrt(len(imgs))+0.5) + r = int((w - ((nrow + 1) * padding)) / nrow) # r = int((w-((nrow+1)*padding))/nrow) + imgs = np.array([((np.array)(Image.fromarray(img).resize((r, r)))) for img in imgs]) # imgs = np.array([(Image.fromarray(img).resize((r,r)) |> np.array) for img in imgs]) + if len(ch) == 1: # if len(ch) == 1: + imgs = imgs[:, :, :, None] # imgs = imgs[:,:,:,None] + return AutoImage(make_grid(imgs, nrow, padding=1), "numpy,uint8,HWC,{_coconut_format_0},0_255".format(_coconut_format_0=(ch))) # return AutoImage(make_grid(imgs,nrow,padding=1),f"numpy,uint8,HWC,{ch},0_255") + +AutoImage.tile_image = tile_image # img_to_shifting_grids = img->make_grids(*img.image_size)|> shifting_grids +tile_image = _coconut_dotted_func_name_store_2 # img_to_shifting_grids = img->make_grids(*img.image_size)|> shifting_grids +img_to_shifting_grids = lambda img: (shifting_grids)(make_grids(*img.image_size)) # img_to_shifting_grids = img->make_grids(*img.image_size)|> shifting_grids +def auto_to_3res(img: '"AutoImage"', cx, cy, r=256) -> '"AutoImage"': # def auto_to_3res(img:"AutoImage",cx,cy,r=256)->"AutoImage": + img = img.to("image,L,L") # img = img.to("image,L,L") +#img = img.resize((2048,2048)) + chs = [crop_square(img, cx, cy, _r).resize((r, r)) for _r in [r * 4, r * 2, r]] # chs = [crop_square(img,cx,cy,_r).resize((r,r)) for _r in [r*4,r*2,r]] + return AutoImage(np.concatenate([np.array(i)[:, :, None] for i in chs], axis=2), "numpy,float32,HWC,RGB,0_255") # return AutoImage(np.concatenate([np.array(i)[:,:,None] for i in chs],axis=2),"numpy,float32,HWC,RGB,0_255") + +def img_to_grid_batch(img: 'AutoImage'): # def img_to_grid_batch(img:AutoImage): + grids = (series)((img_to_shifting_grids(img)).astype("int32")) # grids = img_to_shifting_grids(img) |> .astype("int32") |> series + batch = ((array)(grids.map(lambda xy: auto_to_3res(img, xy[0] + 128, xy[1] + 128, r=256).to("numpy,float32,HWC,RGB,0_1")).values)).astype("float32") # batch = grids.map((xy)->auto_to_3res(img,xy[0]+128,xy[1]+128,r=256).to("numpy,float32,HWC,RGB,0_1")).values |> array |> .astype("float32") + return grids.values, AutoImage(batch, "numpy,float32,BHWC,RGB,0_1") # return grids.values,AutoImage(batch,"numpy,float32,BHWC,RGB,0_1") + + +try: # def AutoImage.cast(self,imgdef): + _coconut_dotted_func_name_store_3 = cast # def AutoImage.cast(self,imgdef): +except _coconut.NameError: # def AutoImage.cast(self,imgdef): + _coconut_dotted_func_name_store_3 = None # def AutoImage.cast(self,imgdef): +def cast(self, imgdef): # def AutoImage.cast(self,imgdef): + return AutoImage(self.data, imgdef) # return AutoImage(self.data,imgdef) + + + +AutoImage.cast = cast # +cast = _coconut_dotted_func_name_store_3 # diff --git a/data_tree/coconut/omni_converter.py b/data_tree/coconut/omni_converter.py new file mode 100644 index 0000000..b3ce9b8 --- /dev/null +++ b/data_tree/coconut/omni_converter.py @@ -0,0 +1,937 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# __coconut_hash__ = 0x6d9f3c11 + +# Compiled with Coconut version 1.4.3 [Ernest Scribbler] + +# Coconut Header: ------------------------------------------------------------- + +from __future__ import generator_stop +import sys as _coconut_sys, os.path as _coconut_os_path +_coconut_file_path = _coconut_os_path.dirname(_coconut_os_path.abspath(__file__)) +_coconut_cached_module = _coconut_sys.modules.get("__coconut__") +if _coconut_cached_module is not None and _coconut_os_path.dirname(_coconut_cached_module.__file__) != _coconut_file_path: + del _coconut_sys.modules["__coconut__"] +_coconut_sys.path.insert(0, _coconut_file_path) +from __coconut__ import * +from __coconut__ import _coconut, _coconut_MatchError, _coconut_igetitem, _coconut_base_compose, _coconut_forward_compose, _coconut_back_compose, _coconut_forward_star_compose, _coconut_back_star_compose, _coconut_forward_dubstar_compose, _coconut_back_dubstar_compose, _coconut_pipe, _coconut_back_pipe, _coconut_star_pipe, _coconut_back_star_pipe, _coconut_dubstar_pipe, _coconut_back_dubstar_pipe, _coconut_bool_and, _coconut_bool_or, _coconut_none_coalesce, _coconut_minus, _coconut_map, _coconut_partial, _coconut_get_function_match_error, _coconut_base_pattern_func, _coconut_addpattern, _coconut_sentinel, _coconut_assert, _coconut_mark_as_match +_coconut_sys.path.pop(0) + +# Compiled Coconut: ----------------------------------------------------------- + +from data_tree.coconut.convert import * # from data_tree.coconut.convert import * +from data_tree.coconut.auto_data import AutoSolver # from data_tree.coconut.auto_data import AutoSolver,AutoData +from data_tree.coconut.auto_data import AutoData # from data_tree.coconut.auto_data import AutoSolver,AutoData +from data_tree.coconut.monad import try_monad # from data_tree.coconut.monad import try_monad,Try,Success,Failure +from data_tree.coconut.monad import Try # from data_tree.coconut.monad import try_monad,Try,Success,Failure +from data_tree.coconut.monad import Success # from data_tree.coconut.monad import try_monad,Try,Success,Failure +from data_tree.coconut.monad import Failure # from data_tree.coconut.monad import try_monad,Try,Success,Failure +from frozendict import frozendict # from frozendict import frozendict +from typing import Mapping # from typing import Mapping +from ipywidgets import Text # from ipywidgets import Text +import ipywidgets as widgets # import ipywidgets as widgets +from itertools import product # from itertools import product +from loguru import logger # from loguru import logger +from collections import namedtuple # from collections import namedtuple +import numpy as np # import numpy as np + +def imagedef2dict(imdef: 'ImageDef'): # def imagedef2dict(imdef:ImageDef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_1 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2): # case imdef: + data_type = _coconut_match_to[0] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_1 = True # case imdef: + if _coconut_case_check_1: # case imdef: + _coconut_match_to = data_type # case imdef: + _coconut_case_check_0 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, Numpy)) and (_coconut.len(_coconut_match_to) == 4): # case imdef: + dtype = _coconut_match_to[0] # case imdef: + arrange = _coconut_match_to[1] # case imdef: + ch_rpr = _coconut_match_to[2] # case imdef: + v_range = _coconut_match_to[3] # case imdef: + _coconut_case_check_0 = True # case imdef: + if _coconut_case_check_0: # case imdef: + info = dict(type="numpy", dtype=dtype, arrange=arrange, ch_rpr=ch_rpr, v_range=str(v_range)) # info = dict(type="numpy",dtype=dtype,arrange=arrange,ch_rpr=ch_rpr,v_range=str(v_range)) + if not _coconut_case_check_0: # match Torch(dtype,arrange,ch_rpr,v_range): + if (_coconut.isinstance(_coconut_match_to, Torch)) and (_coconut.len(_coconut_match_to) == 4): # match Torch(dtype,arrange,ch_rpr,v_range): + dtype = _coconut_match_to[0] # match Torch(dtype,arrange,ch_rpr,v_range): + arrange = _coconut_match_to[1] # match Torch(dtype,arrange,ch_rpr,v_range): + ch_rpr = _coconut_match_to[2] # match Torch(dtype,arrange,ch_rpr,v_range): + v_range = _coconut_match_to[3] # match Torch(dtype,arrange,ch_rpr,v_range): + _coconut_case_check_0 = True # match Torch(dtype,arrange,ch_rpr,v_range): + if _coconut_case_check_0: # match Torch(dtype,arrange,ch_rpr,v_range): + info = dict(type="torch", dtype=dtype, arrange=arrange, ch_rpr=ch_rpr, v_range=str(v_range)) # info = dict(type="torch",dtype=dtype,arrange=arrange,ch_rpr=ch_rpr,v_range=str(v_range)) + if not _coconut_case_check_0: # match PILImages(mode,ch_rpr): + if (_coconut.isinstance(_coconut_match_to, PILImages)) and (_coconut.len(_coconut_match_to) == 2): # match PILImages(mode,ch_rpr): + mode = _coconut_match_to[0] # match PILImages(mode,ch_rpr): + ch_rpr = _coconut_match_to[1] # match PILImages(mode,ch_rpr): + _coconut_case_check_0 = True # match PILImages(mode,ch_rpr): + if _coconut_case_check_0: # match PILImages(mode,ch_rpr): + info = dict(type="images", ch_rpr=ch_rpr, mode=mode) # info = dict(type="images",ch_rpr=ch_rpr,mode=mode) + if not _coconut_case_check_0: # match PILImage(mode,ch_rpr): + if (_coconut.isinstance(_coconut_match_to, PILImage)) and (_coconut.len(_coconut_match_to) == 2): # match PILImage(mode,ch_rpr): + mode = _coconut_match_to[0] # match PILImage(mode,ch_rpr): + ch_rpr = _coconut_match_to[1] # match PILImage(mode,ch_rpr): + _coconut_case_check_0 = True # match PILImage(mode,ch_rpr): + if _coconut_case_check_0: # match PILImage(mode,ch_rpr): + info = dict(type="image", ch_rpr=ch_rpr, mode=mode) # info = dict(type="image",ch_rpr=ch_rpr,mode=mode) + if not _coconut_case_check_0: # else: + raise RuntimeError("cannot convert unknown imagedef:{_coconut_format_0} to dict.".format(_coconut_format_0=(imdef))) # raise RuntimeError(f"cannot convert unknown imagedef:{imdef} to dict.") + return frozendict(**info, **{t: True for t in tags}) # return frozendict( + if not _coconut_case_check_1: # else: + raise RuntimeError("cannot convert unknown imdef:{_coconut_format_0} to dict.".format(_coconut_format_0=(imdef))) # raise RuntimeError(f"cannot convert unknown imdef:{imdef} to dict.") + +def cast_imdef_to_dict(state): # def cast_imdef_to_dict(state): + if isinstance(state, ImageDef): # if isinstance(state,ImageDef): + return [imagedef2dict(state)] # return [imagedef2dict(state)] + +def cast_imdef_str_to_imdef(state): # def cast_imdef_str_to_imdef(state): + if isinstance(state, str): # if isinstance(state,str): + try: # try: + res = str_to_img_def(state) # res = str_to_img_def(state) + return [res] # return [res] + except Exception as e: # except Exception as e: + pass # pass +def imdef2imdef_str(imdef): # def imdef2imdef_str(imdef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_3 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2): # case imdef: + data_type = _coconut_match_to[0] # case imdef: + tags = _coconut_match_to[1] # case imdef: + _coconut_case_check_3 = True # case imdef: + if _coconut_case_check_3: # case imdef: + _coconut_match_to = data_type # case imdef: + _coconut_case_check_2 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, Numpy)) and (_coconut.len(_coconut_match_to) == 4): # case imdef: + dtype = _coconut_match_to[0] # case imdef: + arrange = _coconut_match_to[1] # case imdef: + ch_rpr = _coconut_match_to[2] # case imdef: + v_range = _coconut_match_to[3] # case imdef: + _coconut_case_check_2 = True # case imdef: + if _coconut_case_check_2: # case imdef: + base = "numpy,{_coconut_format_0},{_coconut_format_1},{_coconut_format_2},{_coconut_format_3}".format(_coconut_format_0=(dtype), _coconut_format_1=(arrange), _coconut_format_2=(ch_rpr), _coconut_format_3=(v_range)) # base = f"numpy,{dtype},{arrange},{ch_rpr},{v_range}" + if not _coconut_case_check_2: # match Torch(dtype,arrange,ch_rpr,v_range): + if (_coconut.isinstance(_coconut_match_to, Torch)) and (_coconut.len(_coconut_match_to) == 4): # match Torch(dtype,arrange,ch_rpr,v_range): + dtype = _coconut_match_to[0] # match Torch(dtype,arrange,ch_rpr,v_range): + arrange = _coconut_match_to[1] # match Torch(dtype,arrange,ch_rpr,v_range): + ch_rpr = _coconut_match_to[2] # match Torch(dtype,arrange,ch_rpr,v_range): + v_range = _coconut_match_to[3] # match Torch(dtype,arrange,ch_rpr,v_range): + _coconut_case_check_2 = True # match Torch(dtype,arrange,ch_rpr,v_range): + if _coconut_case_check_2: # match Torch(dtype,arrange,ch_rpr,v_range): + base = "torch,{_coconut_format_0},{_coconut_format_1},{_coconut_format_2},{_coconut_format_3}".format(_coconut_format_0=(dtype), _coconut_format_1=(arrange), _coconut_format_2=(ch_rpr), _coconut_format_3=(v_range)) # base = f"torch,{dtype},{arrange},{ch_rpr},{v_range}" + if not _coconut_case_check_2: # match PILImages(mode,ch_rpr): + if (_coconut.isinstance(_coconut_match_to, PILImages)) and (_coconut.len(_coconut_match_to) == 2): # match PILImages(mode,ch_rpr): + mode = _coconut_match_to[0] # match PILImages(mode,ch_rpr): + ch_rpr = _coconut_match_to[1] # match PILImages(mode,ch_rpr): + _coconut_case_check_2 = True # match PILImages(mode,ch_rpr): + if _coconut_case_check_2: # match PILImages(mode,ch_rpr): + base = "images,{_coconut_format_0},{_coconut_format_1}".format(_coconut_format_0=(mode), _coconut_format_1=(ch_rpr)) # base = f"images,{mode},{ch_rpr}" + if not _coconut_case_check_2: # match PILImage(mode,ch_rpr): + if (_coconut.isinstance(_coconut_match_to, PILImage)) and (_coconut.len(_coconut_match_to) == 2): # match PILImage(mode,ch_rpr): + mode = _coconut_match_to[0] # match PILImage(mode,ch_rpr): + ch_rpr = _coconut_match_to[1] # match PILImage(mode,ch_rpr): + _coconut_case_check_2 = True # match PILImage(mode,ch_rpr): + if _coconut_case_check_2: # match PILImage(mode,ch_rpr): + base = "image,{_coconut_format_0},{_coconut_format_1}".format(_coconut_format_0=(mode), _coconut_format_1=(ch_rpr)) # base = f"image,{mode},{ch_rpr}" + if not _coconut_case_check_2: # else: + raise RuntimeError("cannot convert unknown imagedef:{_coconut_format_0} to str.".format(_coconut_format_0=(imdef))) # raise RuntimeError(f"cannot convert unknown imagedef:{imdef} to str.") + if tags: # if tags: + return base + "|{_coconut_format_0}".format(_coconut_format_0=(','.join(tags))) # return base+f"|{','.join(tags)}" + else: # else: + return base # return base + if not _coconut_case_check_3: # else: + raise RuntimeError("cannot convert unknown imdef:{_coconut_format_0} to str.".format(_coconut_format_0=(imdef))) # raise RuntimeError(f"cannot convert unknown imdef:{imdef} to str.") +def cast_imdef_to_imdef_str(imdef): # def cast_imdef_to_imdef_str(imdef): + _coconut_match_to = imdef # case imdef: + _coconut_case_check_4 = False # case imdef: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2): # case imdef: + _coconut_case_check_4 = True # case imdef: + if _coconut_case_check_4: # case imdef: + res = [imdef2imdef_str(imdef)] # res = [imdef2imdef_str(imdef)] + return res # return res + if not _coconut_case_check_4: # else: + return None # return None + +def imgs2tile(imgs, w=1024, h=1024, max_image=100, padding=1): # def imgs2tile(imgs,w=1024,h=1024,max_image=100,padding=1): + mode = imgs[0].mode # mode = imgs[0].mode + ch = len(mode) # ch = len(mode) +#nrow = int(sqrt(len(imgs[:max_image]))+0.5) + n_imgs = len(imgs[:max_image]) # n_imgs = len(imgs[:max_image]) + nrow = int(sqrt(n_imgs)) # nrow = int(sqrt(n_imgs)) + if (nrow * nrow < n_imgs): # if (nrow*nrow < n_imgs): + nrow += 1 # nrow += 1 + r = int((w - ((nrow + 1) * padding)) / nrow) # r = int((w-((nrow+1)*padding))/nrow) + + imgs = np.array([((np.array)(img.resize((r, r)))) for img in imgs[:max_image]]) # imgs = np.array([(img.resize((r,r)) |> np.array) for img in imgs[:max_image]]) + if ch == 1: # if ch == 1: + imgs = imgs[:, :, :, None] # imgs = imgs[:,:,:,None] + return make_grid(imgs, nrow, padding=padding) # return make_grid(imgs,nrow,padding=padding) + +def rule_imgs2tile(state): # def rule_imgs2tile(state): + _coconut_match_to = state # case state: + _coconut_case_check_5 = False # case state: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], PILImages)) and (_coconut.len(_coconut_match_to[0]) == 2): # case state: + mode = _coconut_match_to[0][0] # case state: + chrpr = _coconut_match_to[0][1] # case state: + tags = _coconut_match_to[1] # case state: + _coconut_case_check_5 = True # case state: + if _coconut_case_check_5: # case state: + return [(imgs2tile, ImageDef(Numpy("uint8", "HWC", chrpr, VR_0_255), tags), "imgs2tile", 10)] # return [( + + +def rule_img2widget(state): # def rule_img2widget(state): + _coconut_match_to = state # case state: + _coconut_case_check_6 = False # case state: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], PILImage)) and (_coconut.len(_coconut_match_to[0]) == 2): # case state: + tags = _coconut_match_to[1] # case state: + _coconut_case_check_6 = True # case state: + if _coconut_case_check_6: # case state: + return [(infer_widget, "widget", "infer_widget", 1)] # return [( + +def dict2imdef(state): # def dict2imdef(state): + if isinstance(state, Mapping): # if isinstance(state,Mapping): + _coconut_match_to = state # case state: + _coconut_case_check_7 = False # case state: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # case state: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # case state: + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # case state: + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # case state: + _coconut_match_temp_3 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # case state: + _coconut_match_temp_4 = _coconut_match_to.get("v_range", _coconut_sentinel) # case state: + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "numpy") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_4 is not _coconut_sentinel): # case state: + _dtype = _coconut_match_temp_1 # case state: + _arng = _coconut_match_temp_2 # case state: + _ch_rpr = _coconut_match_temp_3 # case state: + _v_range = _coconut_match_temp_4 # case state: + tags = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "ch_rpr", "v_range"))) # case state: + _coconut_case_check_7 = True # case state: + if _coconut_case_check_7: # case state: + return [ImageDef(Numpy(_dtype, _arng, _ch_rpr, _v_range), frozenset(tags.keys()))] # return [ImageDef(Numpy(_dtype,_arng,_ch_rpr,_v_range),frozenset(tags.keys()))] + if not _coconut_case_check_7: # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + _coconut_match_temp_3 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + _coconut_match_temp_4 = _coconut_match_to.get("v_range", _coconut_sentinel) # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "torch") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_4 is not _coconut_sentinel): # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + _dtype = _coconut_match_temp_1 # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + _arng = _coconut_match_temp_2 # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + _ch_rpr = _coconut_match_temp_3 # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + _v_range = _coconut_match_temp_4 # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + tags = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "ch_rpr", "v_range"))) # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + _coconut_case_check_7 = True # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + if _coconut_case_check_7: # match {"type":"torch","dtype":_dtype,"arrange":_arng,"ch_rpr":_ch_rpr,"v_range":_v_range,**tags}: + return [ImageDef(Torch(_dtype, _arng, _ch_rpr, _v_range), frozenset(tags.keys()))] # return [ImageDef(Torch(_dtype,_arng,_ch_rpr,_v_range),frozenset(tags.keys()))] + if not _coconut_case_check_7: # match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _coconut_match_temp_1 = _coconut_match_to.get("mode", _coconut_sentinel) # match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _coconut_match_temp_2 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "image") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_2 is not _coconut_sentinel): # match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _mode = _coconut_match_temp_1 # match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _ch_rpr = _coconut_match_temp_2 # match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + tags = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "mode", "ch_rpr"))) # match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _coconut_case_check_7 = True # match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + if _coconut_case_check_7: # match {"type":"image","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + return [ImageDef(PILImage(_mode, _ch_rpr), frozenset(tags.keys()))] # return [ImageDef(PILImage(_mode,_ch_rpr),frozenset(tags.keys()))] + if not _coconut_case_check_7: # match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _coconut_match_temp_1 = _coconut_match_to.get("mode", _coconut_sentinel) # match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _coconut_match_temp_2 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "images") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_2 is not _coconut_sentinel): # match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _mode = _coconut_match_temp_1 # match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _ch_rpr = _coconut_match_temp_2 # match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + tags = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "mode", "ch_rpr"))) # match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + _coconut_case_check_7 = True # match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + if _coconut_case_check_7: # match {"type":"images","mode":_mode,"ch_rpr":_ch_rpr,**tags}: + return [ImageDef(PILImages(_mode, _ch_rpr), frozenset(tags.keys()))] # return [ImageDef(PILImages(_mode,_ch_rpr),frozenset(tags.keys()))] + +def rule_numpy2img(state): # def rule_numpy2img(state): + if isinstance(state, Mapping): # if isinstance(state,Mapping): + _coconut_match_to = state # case state: + _coconut_case_check_8 = False # case state: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # case state: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # case state: + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # case state: + _coconut_match_temp_2 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # case state: + _coconut_match_temp_3 = _coconut_match_to.get("arrange", _coconut_sentinel) # case state: + _coconut_match_temp_4 = _coconut_match_to.get("v_range", _coconut_sentinel) # case state: + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "numpy") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "uint8") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "RGB") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "HWC") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "0_255"): # case state: + tags = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "ch_rpr", "arrange", "v_range"))) # case state: + _coconut_case_check_8 = True # case state: + if _coconut_case_check_8: # case state: + return [(Image.fromarray, ImageDef(PILImage("RGB", "RGB"), frozenset(tags.keys())), "Image.fromarray", 1)] # return [( + if not _coconut_case_check_8: # Image.fromarray, + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # Image.fromarray, + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # Image.fromarray, + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # Image.fromarray, + _coconut_match_temp_2 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # Image.fromarray, + _coconut_match_temp_3 = _coconut_match_to.get("arrange", _coconut_sentinel) # Image.fromarray, + _coconut_match_temp_4 = _coconut_match_to.get("v_range", _coconut_sentinel) # Image.fromarray, + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "numpy") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "uint8") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "L") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "HW") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "0_255"): # Image.fromarray, + tags = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "ch_rpr", "arrange", "v_range"))) # Image.fromarray, + _coconut_case_check_8 = True # Image.fromarray, + if _coconut_case_check_8: # Image.fromarray, + return [(Image.fromarray, ImageDef(PILImage("L", "L"), frozenset(tags.keys())), "Image.fromarray", 1)] # return [( + +def rule_image2gray(state): # def rule_image2gray(state): + _coconut_match_to = state # case state: + _coconut_case_check_9 = False # case state: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], PILImage)) and (_coconut.len(_coconut_match_to[0]) == 2): # case state: + ch_rpr = _coconut_match_to[0][0] # case state: + ch_rpr2 = _coconut_match_to[0][1] # case state: + tags = _coconut_match_to[1] # case state: + _coconut_case_check_9 = True # case state: + if _coconut_case_check_9: # case state: + return [(_coconut.operator.methodcaller("convert", "L"), ImageDef(PILImage("L", "L"), tags), "image2gray", 10), (_coconut.operator.methodcaller("convert", "LA"), ImageDef(PILImage("LA", "LA"), tags), "image2gray-alpha", 10),] # return [ + +def rule_image2lab(state): # def rule_image2lab(state): + from skimage import color # from skimage import color + _coconut_match_to = state # case state: + _coconut_case_check_10 = False # case state: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][0] == "float64") and (_coconut_match_to[0][1] == "HWC") and (_coconut_match_to[0][2] == "RGB") and (_coconut_match_to[0][3] == "0_1"): # case state: + tags = _coconut_match_to[1] # case state: + _coconut_case_check_10 = True # case state: + if _coconut_case_check_10: # case state: + return [(color.rgb2lab, ImageDef(Numpy("float64", "HWC", "LAB", "LAB"), tags), "sklearn.color.rgb2lab")] # return [ + if not _coconut_case_check_10: # (color.rgb2lab,ImageDef(Numpy("float64","HWC","LAB","LAB"),tags),"sklearn.color.rgb2lab") + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][0] == "float64") and (_coconut_match_to[0][1] == "HWC") and (_coconut_match_to[0][2] == "LAB") and (_coconut_match_to[0][3] == "LAB"): # (color.rgb2lab,ImageDef(Numpy("float64","HWC","LAB","LAB"),tags),"sklearn.color.rgb2lab") + tags = _coconut_match_to[1] # (color.rgb2lab,ImageDef(Numpy("float64","HWC","LAB","LAB"),tags),"sklearn.color.rgb2lab") + _coconut_case_check_10 = True # (color.rgb2lab,ImageDef(Numpy("float64","HWC","LAB","LAB"),tags),"sklearn.color.rgb2lab") + if _coconut_case_check_10: # (color.rgb2lab,ImageDef(Numpy("float64","HWC","LAB","LAB"),tags),"sklearn.color.rgb2lab") + return [(color.lab2rgb, ImageDef(Numpy("float64", "HWC", "RGB", "0_1"), tags), "sklearn.color.lab2rgb")] # return [ + +def convert_ignore_channel(ary, f): # def convert_ignore_channel(ary,f): + """ + shape:(H,W,C) + """ # """ + ignored = ary[:, :, [-1]] # ignored = ary[:,:,[-1]] + tgt = ary[:, :, :-1] # tgt = ary[:,:,:-1] + converted = f(tgt) # converted = f(tgt) + result = np.concatenate((tgt, ignored), axis=-1) # result = np.concatenate((tgt,ignored),axis=-1) + return result # return result + +def rule_rgba2laba(state): # def rule_rgba2laba(state): + from skimage import color # from skimage import color + _coconut_match_to = state # case state: + _coconut_case_check_11 = False # case state: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][0] == "float64") and (_coconut_match_to[0][1] == "HWC") and (_coconut_match_to[0][2] == "RGBA") and (_coconut_match_to[0][3] == "0_1"): # case state: + tags = _coconut_match_to[1] # case state: + _coconut_case_check_11 = True # case state: + if _coconut_case_check_11: # case state: + return [(lambda a: convert_ignore_channel(a, color.rgb2lab), ImageDef(Numpy("float64", "HWC", "LABA", "LABA"), tags), "rgba2laba (ignores alpha)")] # return [ + if not _coconut_case_check_11: # (a->convert_ignore_channel(a,color.rgb2lab),ImageDef(Numpy("float64","HWC","LABA","LABA"),tags),"rgba2laba (ignores alpha)") + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][0] == "float64") and (_coconut_match_to[0][1] == "HWC") and (_coconut_match_to[0][2] == "LABA") and (_coconut_match_to[0][3] == "LABA"): # (a->convert_ignore_channel(a,color.rgb2lab),ImageDef(Numpy("float64","HWC","LABA","LABA"),tags),"rgba2laba (ignores alpha)") + tags = _coconut_match_to[1] # (a->convert_ignore_channel(a,color.rgb2lab),ImageDef(Numpy("float64","HWC","LABA","LABA"),tags),"rgba2laba (ignores alpha)") + _coconut_case_check_11 = True # (a->convert_ignore_channel(a,color.rgb2lab),ImageDef(Numpy("float64","HWC","LABA","LABA"),tags),"rgba2laba (ignores alpha)") + if _coconut_case_check_11: # (a->convert_ignore_channel(a,color.rgb2lab),ImageDef(Numpy("float64","HWC","LABA","LABA"),tags),"rgba2laba (ignores alpha)") + return [(lambda a: convert_ignore_channel(a, color.lab2rgb), ImageDef(Numpy("float64", "HWC", "RGBA", "0_1"), tags), "laba2rgba (ignores alpha)")] # return [ + + +def rule_lab_value_conversion(state): # def rule_lab_value_conversion(state): + _coconut_match_to = state # case state: + _coconut_case_check_12 = False # case state: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][0] == "float64") and (_coconut_match_to[0][1] == "HWC") and (_coconut_match_to[0][2] == "LAB") and (_coconut_match_to[0][3] == "LAB"): # case state: + tags = _coconut_match_to[1] # case state: + _coconut_case_check_12 = True # case state: + if _coconut_case_check_12: # case state: + return [((_vr_lab_to_0_1, ImageDef(Numpy("float64", "HWC", "LAB", "0_1"), tags), "vr_lab_to_0_1"))] # return [((_vr_lab_to_0_1,ImageDef(Numpy("float64","HWC","LAB","0_1"),tags),"vr_lab_to_0_1"))] + if not _coconut_case_check_12: # match ImageDef(Numpy("float64","HWC","LABA","LABA"),tags): + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][0] == "float64") and (_coconut_match_to[0][1] == "HWC") and (_coconut_match_to[0][2] == "LABA") and (_coconut_match_to[0][3] == "LABA"): # match ImageDef(Numpy("float64","HWC","LABA","LABA"),tags): + tags = _coconut_match_to[1] # match ImageDef(Numpy("float64","HWC","LABA","LABA"),tags): + _coconut_case_check_12 = True # match ImageDef(Numpy("float64","HWC","LABA","LABA"),tags): + if _coconut_case_check_12: # match ImageDef(Numpy("float64","HWC","LABA","LABA"),tags): + return [((lambda a: convert_ignore_channel(a, _vr_lab_to_0_1), ImageDef(Numpy("float64", "HWC", "LABA", "0_1"), tags), "vr_laba_to_0_1"))] # return [((a->convert_ignore_channel(a,_vr_lab_to_0_1),ImageDef(Numpy("float64","HWC","LABA","0_1"),tags),"vr_laba_to_0_1"))] + if not _coconut_case_check_12: # match ImageDef(Numpy("float64","HWC","LAB","0_1"),tags): + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][0] == "float64") and (_coconut_match_to[0][1] == "HWC") and (_coconut_match_to[0][2] == "LAB") and (_coconut_match_to[0][3] == "0_1"): # match ImageDef(Numpy("float64","HWC","LAB","0_1"),tags): + tags = _coconut_match_to[1] # match ImageDef(Numpy("float64","HWC","LAB","0_1"),tags): + _coconut_case_check_12 = True # match ImageDef(Numpy("float64","HWC","LAB","0_1"),tags): + if _coconut_case_check_12: # match ImageDef(Numpy("float64","HWC","LAB","0_1"),tags): + return [((_0_1_to_vr_lab, ImageDef(Numpy("float64", "HWC", "LAB", "LAB"), tags), "0_1_to_vr_lab"))] # return [((_0_1_to_vr_lab,ImageDef(Numpy("float64","HWC","LAB","LAB"),tags),"0_1_to_vr_lab"))] + if not _coconut_case_check_12: # match ImageDef(Numpy("float64","HWC","LABA","0_1"),tags): + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], Numpy)) and (_coconut.len(_coconut_match_to[0]) == 4) and (_coconut_match_to[0][0] == "float64") and (_coconut_match_to[0][1] == "HWC") and (_coconut_match_to[0][2] == "LABA") and (_coconut_match_to[0][3] == "0_1"): # match ImageDef(Numpy("float64","HWC","LABA","0_1"),tags): + tags = _coconut_match_to[1] # match ImageDef(Numpy("float64","HWC","LABA","0_1"),tags): + _coconut_case_check_12 = True # match ImageDef(Numpy("float64","HWC","LABA","0_1"),tags): + if _coconut_case_check_12: # match ImageDef(Numpy("float64","HWC","LABA","0_1"),tags): + return [((lambda a: convert_ignore_channel(a, _0_1_to_vr_lab), ImageDef(Numpy("float64", "HWC", "LABA", "LABA"), tags), "vr_0_1_to_laba"))] # return [((a->convert_ignore_channel(a,_0_1_to_vr_lab),ImageDef(Numpy("float64","HWC","LABA","LABA"),tags),"vr_0_1_to_laba"))] + +def _vr_lab_to_0_1(ary): # def _vr_lab_to_0_1(ary): + r = ary.copy() # r = ary.copy() + r[:, :, 0] = ary[:, :, 0] * 0.01 # r[:,:,0] = ary[:,:,0] * 0.01 + r[:, :, 1] = (ary[:, :, 1] + 128.0) / 255.0 # r[:,:,1] = (ary[:,:,1] + 128.0) / 255.0 + r[:, :, 2] = (ary[:, :, 2] + 128.0) / 255.0 # r[:,:,2] = (ary[:,:,2] + 128.0) / 255.0 + return r # return r + +def _0_1_to_vr_lab(ary): # def _0_1_to_vr_lab(ary): + r = ary.copy() # r = ary.copy() + r[:, :, 0] = ary[:, :, 0] * 100 # r[:,:,0] = ary[:,:,0] * 100 + r[:, :, 1] = (ary[:, :, 1] * 255) - 128.0 # r[:,:,1] = (ary[:,:,1] * 255) - 128.0 + r[:, :, 2] = (ary[:, :, 2] * 255) - 128.0 # r[:,:,2] = (ary[:,:,2] * 255) - 128.0 + return r # return r + +""" +def dict2visdomable(state): + case state: + match {"type":"numpy","dtype":"float32","arrange":"CHW" or "BCHW","ch_rpr":"RGB" or "L",**others} if "visdomable" not in state: + return [frozendict( + **state, + visdomable=True + )] +""" # """ +def to_visdom_function(state): # def to_visdom_function(state): + _coconut_match_to = state # case state: + _coconut_case_check_13 = False # case state: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # case state: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # case state: + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # case state: + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # case state: + _coconut_match_temp_3 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # case state: + _coconut_match_temp_4 = _coconut_match_to.get("v_range", _coconut_sentinel) # case state: + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "numpy") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "CHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "RGB") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "0_255"): # case state: + others = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "ch_rpr", "v_range"))) # case state: + _coconut_case_check_13 = True # case state: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # case state: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # case state: + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # case state: + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # case state: + _coconut_match_temp_3 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # case state: + if (not _coconut_case_check_13) and (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "numpy") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "CHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "L") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "0_255"): # case state: + _coconut_match_temp_4 = _coconut_match_to.get("v_range", _coconut_sentinel) # case state: + others = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "ch_rpr", "v_range"))) # case state: + _coconut_case_check_13 = True # case state: + if _coconut_case_check_13: # case state: + return [(lambda ary: lambda visdom: _coconut.functools.partial(visdom.image, ary), "visdom_function", "to_visdom_function")] # return [ + if not _coconut_case_check_13: # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_match_temp_3 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_match_temp_4 = _coconut_match_to.get("v_range", _coconut_sentinel) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "numpy") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "BCHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "RGB") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "0_255"): # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + others = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "ch_rpr", "v_range"))) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_case_check_13 = True # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_match_temp_3 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + if (not _coconut_case_check_13) and (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "numpy") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "BCHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "L") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "0_255"): # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_match_temp_4 = _coconut_match_to.get("v_range", _coconut_sentinel) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + others = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "ch_rpr", "v_range"))) # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + _coconut_case_check_13 = True # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + if _coconut_case_check_13: # (ary->visdom->visdom.image$(ary),"visdom_function","to_visdom_function") + return [(lambda ary: lambda visdom: _coconut.functools.partial(visdom.images, ary), "visdom_function", "to_visdom_function")] # return [ +def any2widget(state): # def any2widget(state): + return [(lambda ary: Text(str(ary)), "widget", "anything_to_text_widget", 1000)] # return [(ary->Text(str(ary)),"widget","anything_to_text_widget",1000)] +class AutoTuple(_coconut.collections.namedtuple("AutoTuple", "formats")): # data AutoTuple(formats is tuple) + __slots__ = () # data AutoTuple(formats is tuple) + __ne__ = _coconut.object.__ne__ # data AutoTuple(formats is tuple) + def __eq__(self, other): # data AutoTuple(formats is tuple) + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # data AutoTuple(formats is tuple) + def __hash__(self): # data AutoTuple(formats is tuple) + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # data AutoTuple(formats is tuple) + def __new__(_cls, *_coconut_match_to_args, **_coconut_match_to_kwargs): # data AutoTuple(formats is tuple) + _coconut_match_check = False # data AutoTuple(formats is tuple) + _coconut_FunctionMatchError = _coconut_get_function_match_error() # data AutoTuple(formats is tuple) + if (_coconut.len(_coconut_match_to_args) <= 1) and (_coconut.sum((_coconut.len(_coconut_match_to_args) > 0, "formats" in _coconut_match_to_kwargs)) == 1): # data AutoTuple(formats is tuple) + _coconut_match_temp_0 = _coconut_match_to_args[0] if _coconut.len(_coconut_match_to_args) > 0 else _coconut_match_to_kwargs.pop("formats") # data AutoTuple(formats is tuple) + if (_coconut.isinstance(_coconut_match_temp_0, tuple)) and (not _coconut_match_to_kwargs): # data AutoTuple(formats is tuple) + formats = _coconut_match_temp_0 # data AutoTuple(formats is tuple) + _coconut_match_check = True # data AutoTuple(formats is tuple) + + if not _coconut_match_check: # data AutoTuple(formats is tuple) + _coconut_match_val_repr = _coconut.repr(_coconut_match_to_args) # data AutoTuple(formats is tuple) + _coconut_match_err = _coconut_FunctionMatchError("pattern-matching failed for " "'data AutoTuple(formats is tuple)'" " in " + (_coconut_match_val_repr if _coconut.len(_coconut_match_val_repr) <= 500 else _coconut_match_val_repr[:500] + "...")) # data AutoTuple(formats is tuple) + _coconut_match_err.pattern = 'data AutoTuple(formats is tuple)' # data AutoTuple(formats is tuple) + _coconut_match_err.value = _coconut_match_to_args # data AutoTuple(formats is tuple) + raise _coconut_match_err # data AutoTuple(formats is tuple) + + return _coconut.tuple.__new__(_cls, (formats,)) # data AutoTuple(formats is tuple) + + +def auto_tuple2widget(state): # def auto_tuple2widget(state): + _coconut_match_to = state # case state: + _coconut_case_check_14 = False # case state: + if (_coconut.isinstance(_coconut_match_to, AutoTuple)) and (_coconut.len(_coconut_match_to) == 1): # case state: + items = _coconut_match_to[0] # case state: + _coconut_case_check_14 = True # case state: + if _coconut_case_check_14 and not (all((i == "widget" for i in items))): # case state: + _coconut_case_check_14 = False # case state: + if _coconut_case_check_14: # case state: + return [(lambda values: widgets.VBox(values), "widget", "auto_tuple of widgets to a widget", 1)] # return [ + +def isnamedtuple(x): # def isnamedtuple(x): + t = type(x) # t = type(x) + b = t.__bases__ # b = t.__bases__ + if hasattr(x, "__slots__"): # if hasattr(x,"__slots__"): return True + return True # if hasattr(x,"__slots__"): return True + if len(b) != 1 or b[0] != tuple: # if len(b) != 1 or b[0] != tuple: return False + return False # if len(b) != 1 or b[0] != tuple: return False + f = getattr(t, '_fields', None) # f = getattr(t, '_fields', None) + if not isinstance(f, tuple): # if not isinstance(f, tuple): return False + return False # if not isinstance(f, tuple): return False + return all((type(n) == str for n in f)) # return all(type(n)==str for n in f) + +def cast_tuple2auto_tuple(state): # def cast_tuple2auto_tuple(state): + if isinstance(state, str): # if isinstance(state,str): + return None # return None + if isinstance(state, AutoTuple): # if isinstance(state,AutoTuple): + res = [state.formats] # res = [state.formats] + return res # return res + elif type(state) == tuple: # elif type(state) == tuple: + res = [AutoTuple(state)] # res = [AutoTuple(state)] + return res # return res + +def map_tuple_i(t, i, f): # def map_tuple_i(t,i,f): + res = list(t) # res = list(t) + res[i] = f(res[i]) # res[i] = f(res[i]) + return tuple(res) # return tuple(res) + +def map_state(states, i, new_state): # def map_state(states,i,new_state): + res = list(states) # res = list(states) + res[i] = new_state # res[i] = new_state + return tuple(res) # return tuple(res) + +def intra_tuple_conversions(state): # def intra_tuple_conversions(state): + _coconut_match_to = state # case state: + _coconut_case_check_15 = False # case state: + if (_coconut.isinstance(_coconut_match_to, AutoTuple)) and (_coconut.len(_coconut_match_to) == 1): # case state: + items = _coconut_match_to[0] # case state: + _coconut_case_check_15 = True # case state: + if _coconut_case_check_15: # case state: + res = [] # res = [] + for i in range(len(items)): # for i in range(len(items)): + ith_state = items[i] # ith_state = items[i] + res += [(lambda f, new_state, cost, name: (lambda values: map_tuple_i(values, i, f), AutoTuple(map_state(items, i, new_state)), "map {_coconut_format_0}th element with {_coconut_format_1}".format(_coconut_format_0=(i), _coconut_format_1=(name)), cost))(f, new_state, cost, name) for f, new_state, cost, name in SOLVER.solver.neighbors(ith_state)] # res += [ + return res # return res + + +def map_each(t, mappers): # def map_each(t,mappers): +#logger.warning(f"items:{t}") +#logger.warning(f"mappers:{mappers}") + return tuple([f(item) for f, item in zip(mappers, t)]) # return tuple([f(item) for f,item in zip(mappers,t)]) + +def smart_tuple_conversion(state, end): # def smart_tuple_conversion(state,end): + _coconut_match_to = (state, end) # case (state,end): + _coconut_case_check_16 = False # case (state,end): + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], AutoTuple)) and (_coconut.len(_coconut_match_to[0]) == 1): # case (state,end): + formats = _coconut_match_to[0][0] # case (state,end): + t = _coconut_match_to[1] # case (state,end): + _coconut_case_check_16 = True # case (state,end): + if _coconut_case_check_16 and not (type(t) == tuple and len(formats) == len(t)): # case (state,end): + _coconut_case_check_16 = False # case (state,end): + if _coconut_case_check_16: # case (state,end): + cs = [] # cs = [] + cost = 0 # cost = 0 + for i in range(len(formats)): # for i in range(len(formats)): + c = SOLVER.solver.search_direct(formats[i], end[i]) # c = SOLVER.solver.search_direct(formats[i],end[i]) + cost += sum((e.cost for e in c.edges)) # cost += sum(e.cost for e in c.edges) + cs.append(c) # cs.append(c) + res = [(lambda t: map_each(t, cs), end, "{_coconut_format_0}->{_coconut_format_1}".format(_coconut_format_0=(state), _coconut_format_1=(end)), cost)] # res = [ + logger.debug(res) # logger.debug(res) + return res # return res + if not _coconut_case_check_16: # match (AutoTuple(formats),"widget"): + if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], AutoTuple)) and (_coconut.len(_coconut_match_to[0]) == 1) and (_coconut_match_to[1] == "widget"): # match (AutoTuple(formats),"widget"): + formats = _coconut_match_to[0][0] # match (AutoTuple(formats),"widget"): + _coconut_case_check_16 = True # match (AutoTuple(formats),"widget"): + if _coconut_case_check_16: # match (AutoTuple(formats),"widget"): + f, new_state, name, cost = smart_tuple_conversion(state, ("widget",) * len(state.formats))[0] # f,new_state,name,cost = smart_tuple_conversion(state,("widget",)*len(state.formats))[0] + logger.debug("cost:{_coconut_format_0}".format(_coconut_format_0=(cost))) # logger.debug(f"cost:{cost}") + return [(lambda t: widgets.VBox(f(t)), end, "{_coconut_format_0}->{_coconut_format_1}".format(_coconut_format_0=(state), _coconut_format_1=(end)), cost + 1)] # return [( + +class AutoList(_coconut.collections.namedtuple("AutoList", "state")): # data AutoList(state): + __slots__ = () # data AutoList(state): + __ne__ = _coconut.object.__ne__ # data AutoList(state): + def __eq__(self, other): # data AutoList(state): + return self.__class__ is other.__class__ and _coconut.tuple.__eq__(self, other) # data AutoList(state): + def __hash__(self): # data AutoList(state): + return _coconut.tuple.__hash__(self) ^ hash(self.__class__) # data AutoList(state): + def __str__(self): # def __str__(self): + return "[{_coconut_format_0}]".format(_coconut_format_0=(self.state)) # return f"[{self.state}]" + + +def unlist(items): # def unlist(items): + return SOLVER.new_auto_data([i.value for i in items], AutoList(items[0].format)) # return SOLVER.new_auto_data([i.value for i in items],AutoList(items[0].format)) + +def cast_ary_str_to_ary_type(state): # def cast_ary_str_to_ary_type(state): + _coconut_match_to = state # case state: + _coconut_case_check_17 = False # case state: + if (_coconut.isinstance(_coconut_match_to, _coconut.str)) and (_coconut_match_to.startswith("[")) and (_coconut_match_to.endswith("]")): # case state: + element_state = _coconut_match_to[_coconut.len("["):-_coconut.len("]")] # case state: + _coconut_case_check_17 = True # case state: + if _coconut_case_check_17: # case state: + return [AutoList(element_state)] # return [AutoList(element_state)] + if not _coconut_case_check_17: # match AutoList(es is str): + if (_coconut.isinstance(_coconut_match_to, AutoList)) and (_coconut.len(_coconut_match_to) == 1) and (_coconut.isinstance(_coconut_match_to[0], str)): # match AutoList(es is str): + es = _coconut_match_to[0] # match AutoList(es is str): + _coconut_case_check_17 = True # match AutoList(es is str): + if _coconut_case_check_17: # match AutoList(es is str): + return ["[{_coconut_format_0}]".format(_coconut_format_0=(es))] # return [f"[{es}]"] + +def intra_list_conversions(state): # def intra_list_conversions(state): + _coconut_match_to = state # case state: + _coconut_case_check_18 = False # case state: + if (_coconut.isinstance(_coconut_match_to, AutoList)) and (_coconut.len(_coconut_match_to) == 1): # case state: + es = _coconut_match_to[0] # case state: + _coconut_case_check_18 = True # case state: + if _coconut_case_check_18: # case state: + return [(lambda f, new_state, cost, name: (lambda items: [f(i) for i in items], AutoList(new_state), "[{_coconut_format_0}]".format(_coconut_format_0=(name)), cost + 1))(f, new_state, cost, name) for f, new_state, cost, name in SOLVER.solver.neighbors(es)] # return [((f,new_state,cost,name)->( + +def img_list_is_imgs(state): # def img_list_is_imgs(state): + _coconut_match_to = state # case state: + _coconut_case_check_19 = False # case state: + if (_coconut.isinstance(_coconut_match_to, AutoList)) and (_coconut.len(_coconut_match_to) == 1) and (_coconut.isinstance(_coconut_match_to[0], _coconut.str)) and (_coconut_match_to[0].startswith("image,")): # case state: + formats = _coconut_match_to[0][_coconut.len("image,"):] # case state: + _coconut_case_check_19 = True # case state: + if _coconut_case_check_19: # case state: + return ["images,{_coconut_format_0}".format(_coconut_format_0=(formats))] # return [f"images,{formats}"] + if not _coconut_case_check_19: # match "images,"+formats: + if (_coconut.isinstance(_coconut_match_to, _coconut.str)) and (_coconut_match_to.startswith("images,")): # match "images,"+formats: + formats = _coconut_match_to[_coconut.len("images,"):] # match "images,"+formats: + _coconut_case_check_19 = True # match "images,"+formats: + if _coconut_case_check_19: # match "images,"+formats: + return [AutoList("image," + formats)] # return [AutoList("image,"+formats)] +def numpys_to_numpy(state): # def numpys_to_numpy(state): + _coconut_match_to = state # case state: + _coconut_case_check_20 = False # case state: + if (_coconut.isinstance(_coconut_match_to, AutoList)) and (_coconut.len(_coconut_match_to) == 1) and (_coconut.isinstance(_coconut_match_to[0], _coconut.abc.Mapping)): # case state: + _coconut_match_temp_0 = _coconut_match_to[0].get("type", _coconut_sentinel) # case state: + _coconut_match_temp_1 = _coconut_match_to[0].get("arrange", _coconut_sentinel) # case state: + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "numpy") and (_coconut_match_temp_1 is not _coconut_sentinel): # case state: + arng = _coconut_match_temp_1 # case state: + kwargs = dict((k, v) for k, v in _coconut_match_to[0].items() if k not in set(("type", "arrange"))) # case state: + _coconut_case_check_20 = True # case state: + if _coconut_case_check_20 and not ("B" not in arng): # case state: + _coconut_case_check_20 = False # case state: + if _coconut_case_check_20: # case state: + return [(lambda numpys: np.array(numpys), frozendict({"type": "numpy", "arrange": "B" + arng, **kwargs}), "merge arrays to array".format(), 10)] # return [ +def tensor_to_list(state): # def tensor_to_list(state): + _coconut_match_to = state # case state: + _coconut_case_check_21 = False # case state: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # case state: + _coconut_match_temp_0 = _coconut_match_to.get("arrange", _coconut_sentinel) # case state: + if _coconut_match_temp_0 is not _coconut_sentinel: # case state: + arng = _coconut_match_temp_0 # case state: + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("arrange",))) # case state: + _coconut_case_check_21 = True # case state: + if _coconut_case_check_21 and not (len(arng) > 1): # case state: + _coconut_case_check_21 = False # case state: + if _coconut_case_check_21: # case state: + return [(lambda tensor: [t for t in tensor], AutoList(frozendict(arrange=arng[1:], **kwargs)), "tensor to list of tensor".format(), 2)] # return [ + +def pil_convert(state): # def pil_convert(state): + _coconut_match_to = state # case state: + _coconut_case_check_22 = False # case state: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # case state: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # case state: + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "image"): # case state: + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type",))) # case state: + _coconut_case_check_22 = True # case state: + if _coconut_case_check_22: # case state: + new_state = dict(**state) # new_state = dict(**state) + return [(lambda img: lambda mode: SOLVER.new_auto_data(img.convert(mode), "image,{_coconut_format_0},{_coconut_format_1}".format(_coconut_format_0=(mode), _coconut_format_1=(mode))), "pil_convert", "image_to_pil_converter", 1)] # return [ + +def rgb_to_rgba(state): # def rgb_to_rgba(state): + if state == "numpy,uint8,HWC,RGB,0_255": # if state == "numpy,uint8,HWC,RGB,0_255": + return [(lambda a: np.concatenate((a, np.ones((*a.shape[:2], 1), dtype="uint8") * 255), axis=2), "numpy,uint8,HWC,RGBA,0_255", "add 255 as alpha channel", 10)] # return [( + elif state == "numpy,uint8,BHWC,RGB,0_255": # elif state == "numpy,uint8,BHWC,RGB,0_255": + return [(lambda a: np.concatenate((a, np.ones((*a.shape[:3], 1), dtype="uint8") * 255), axis=3), "numpy,uint8,BHWC,RGBA,0_255", "add 255 as alpha channel to batch", 10)] # return [( + +@memoize() # @memoize() +def pix2pix_normalizer(nc): # def pix2pix_normalizer(nc): + from torchvision import transforms # import torchvision.transforms as transforms + return transforms.Normalize((0.5,) * nc, (0.5,) * nc) # return transforms.Normalize((0.5,)*nc,(0.5,)*nc) + + +def torch_img_to_pixpix_input(state): # def torch_img_to_pixpix_input(state): + import torch # import torch + _coconut_match_to = state # case state: + _coconut_case_check_23 = False # case state: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # case state: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # case state: + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # case state: + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # case state: + _coconut_match_temp_3 = _coconut_match_to.get("v_range", _coconut_sentinel) # case state: + _coconut_match_temp_4 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # case state: + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "torch") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "CHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "0_1") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "RGB"): # case state: + rpr = _coconut_match_temp_4 # case state: + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "v_range", "ch_rpr"))) # case state: + _coconut_case_check_23 = True # case state: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # case state: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # case state: + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # case state: + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # case state: + _coconut_match_temp_3 = _coconut_match_to.get("v_range", _coconut_sentinel) # case state: + _coconut_match_temp_4 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # case state: + if (not _coconut_case_check_23) and (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "torch") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "CHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "0_1") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "RGBA"): # case state: + rpr = _coconut_match_temp_4 # case state: + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "v_range", "ch_rpr"))) # case state: + _coconut_case_check_23 = True # case state: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # case state: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # case state: + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # case state: + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # case state: + _coconut_match_temp_3 = _coconut_match_to.get("v_range", _coconut_sentinel) # case state: + _coconut_match_temp_4 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # case state: + if (not _coconut_case_check_23) and (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "torch") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "CHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "0_1") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "L"): # case state: + rpr = _coconut_match_temp_4 # case state: + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "v_range", "ch_rpr"))) # case state: + _coconut_case_check_23 = True # case state: + if _coconut_case_check_23: # case state: + return [(pix2pix_normalizer(len(rpr)), "pix2pix,nc={_coconut_format_0}".format(_coconut_format_0=(len(rpr))), "convert to pixpix normalized input", 1)] # return [( + if not _coconut_case_check_23: # pix2pix_normalizer(len(rpr)), + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_3 = _coconut_match_to.get("v_range", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_4 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "torch") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "BCHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "0_1") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "RGB"): # pix2pix_normalizer(len(rpr)), + rpr = _coconut_match_temp_4 # pix2pix_normalizer(len(rpr)), + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "v_range", "ch_rpr"))) # pix2pix_normalizer(len(rpr)), + _coconut_case_check_23 = True # pix2pix_normalizer(len(rpr)), + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_3 = _coconut_match_to.get("v_range", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_4 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + if (not _coconut_case_check_23) and (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "torch") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "BCHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "0_1") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "RGBA"): # pix2pix_normalizer(len(rpr)), + rpr = _coconut_match_temp_4 # pix2pix_normalizer(len(rpr)), + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "v_range", "ch_rpr"))) # pix2pix_normalizer(len(rpr)), + _coconut_case_check_23 = True # pix2pix_normalizer(len(rpr)), + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_3 = _coconut_match_to.get("v_range", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + _coconut_match_temp_4 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # pix2pix_normalizer(len(rpr)), + if (not _coconut_case_check_23) and (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "torch") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "BCHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "0_1") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "L"): # pix2pix_normalizer(len(rpr)), + rpr = _coconut_match_temp_4 # pix2pix_normalizer(len(rpr)), + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "v_range", "ch_rpr"))) # pix2pix_normalizer(len(rpr)), + _coconut_case_check_23 = True # pix2pix_normalizer(len(rpr)), + if _coconut_case_check_23: # pix2pix_normalizer(len(rpr)), + return [(lambda t: torch.cat([pix2pix_normalizer(len(rpr))(i)[None] for i in t], dim=0), "pix2pix_batch,nc={_coconut_format_0}".format(_coconut_format_0=(len(rpr))), "convert to pixpix normalized input", 1)] # return [( + if not _coconut_case_check_23: # t->torch.cat([pix2pix_normalizer(len(rpr))(i)[None] for i in t],dim=0), + if _coconut_match_to == "pix2pix_laba": # t->torch.cat([pix2pix_normalizer(len(rpr))(i)[None] for i in t],dim=0), + _coconut_case_check_23 = True # t->torch.cat([pix2pix_normalizer(len(rpr))(i)[None] for i in t],dim=0), + if _coconut_case_check_23: # t->torch.cat([pix2pix_normalizer(len(rpr))(i)[None] for i in t],dim=0), + return [(lambda a: a * 0.5 + 0.5, "torch,float32,CHW,LABA,0_1".format(), "inverse pix2pix_laba to img ", 1)] # return [( + if not _coconut_case_check_23: # a -> a*0.5+0.5, + if _coconut_match_to == "pix2pix_lab": # a -> a*0.5+0.5, + _coconut_case_check_23 = True # a -> a*0.5+0.5, + if _coconut_case_check_23: # a -> a*0.5+0.5, + return [(lambda a: a * 0.5 + 0.5, "torch,float32,CHW,LAB,0_1".format(), "inverse pix2pix_lab to img ", 1)] # return [( + if not _coconut_case_check_23: # a -> a*0.5+0.5, + if _coconut_match_to == "pix2pix_laba_batch": # a -> a*0.5+0.5, + _coconut_case_check_23 = True # a -> a*0.5+0.5, + if _coconut_case_check_23: # a -> a*0.5+0.5, + return [(lambda a: a * 0.5 + 0.5, "torch,float32,BCHW,LABA,0_1".format(), "inverse pix2pix_laba batch to img", 1)] # return [( + if not _coconut_case_check_23: # a -> a*0.5+0.5, + if _coconut_match_to == "pix2pix_lab_batch": # a -> a*0.5+0.5, + _coconut_case_check_23 = True # a -> a*0.5+0.5, + if _coconut_case_check_23: # a -> a*0.5+0.5, + return [(lambda a: a * 0.5 + 0.5, "torch,float32,BCHW,LAB,0_1".format(), "inverse pix2pix_laba batch to img", 1)] # return [( + if not _coconut_case_check_23: # a -> a*0.5+0.5, + if _coconut_match_to == "pix2pix,nc=4": # a -> a*0.5+0.5, + _coconut_case_check_23 = True # a -> a*0.5+0.5, + if _coconut_case_check_23: # a -> a*0.5+0.5, + return [(lambda a: a * 0.5 + 0.5, "torch,float32,CHW,RGBA,0_1".format(), "inverse pix2pix to img", 1)] # return [( + if not _coconut_case_check_23: # a -> a*0.5+0.5, + if _coconut_match_to == "pix2pix_batch,nc=4": # a -> a*0.5+0.5, + _coconut_case_check_23 = True # a -> a*0.5+0.5, + if _coconut_case_check_23: # a -> a*0.5+0.5, + return [(lambda a: a * 0.5 + 0.5, "torch,float32,BCHW,RGBA,0_1".format(), "inverse pix2pix batch nc=4 to img", 1)] # return [( + if not _coconut_case_check_23: # a -> a*0.5+0.5, + if _coconut_match_to == "pix2pix_batch,nc=3": # a -> a*0.5+0.5, + _coconut_case_check_23 = True # a -> a*0.5+0.5, + if _coconut_case_check_23: # a -> a*0.5+0.5, + return [(lambda a: a * 0.5 + 0.5, "torch,float32,BCHW,RGB,0_1".format(), "inverse pix2pix batch nc=3 to img", 1)] # return [( + if not _coconut_case_check_23: # a -> a*0.5+0.5, + if _coconut_match_to == "pix2pix,nc=3": # a -> a*0.5+0.5, + _coconut_case_check_23 = True # a -> a*0.5+0.5, + if _coconut_case_check_23: # a -> a*0.5+0.5, + return [(lambda a: a * 0.5 + 0.5, "torch,float32,CHW,RGB,0_1".format(), "inverse pix2pix to img", 1)] # return [( + if not _coconut_case_check_23: # a -> a*0.5+0.5, + if _coconut_match_to == "pix2pix_batch,nc=1": # a -> a*0.5+0.5, + _coconut_case_check_23 = True # a -> a*0.5+0.5, + if _coconut_case_check_23: # a -> a*0.5+0.5, + return [(lambda a: a * 0.5 + 0.5, "torch,float32,BCHW,L,0_1".format(), "inverse pix2pix_batch,nc=1 to img", 1)] # return [( + if not _coconut_case_check_23: # a -> a*0.5+0.5, + if _coconut_match_to == "pix2pix,nc=1": # a -> a*0.5+0.5, + _coconut_case_check_23 = True # a -> a*0.5+0.5, + if _coconut_case_check_23: # a -> a*0.5+0.5, + return [(lambda a: a * 0.5 + 0.5, "torch,float32,CHW,L,0_1".format(), "inverse pix2pix,nc=1 to img", 1)] # return [( + +@memoize() # @memoize() +def _VGG_NORMALIZER(): # def _VGG_NORMALIZER(): + from torchvision import transforms # import torchvision.transforms as transforms + nrm = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) # nrm = transforms.Normalize(mean=[0.485,0.456,0.406],std=[0.229,0.224,0.225]) + return nrm # return nrm +def inverse_vgg_prep(tensor): # def inverse_vgg_prep(tensor): + return tensor * torch.tensor([0.229, 0.224, 0.225])[:, None, None] + torch.tensor([0.485, 0.456, 0.406])[:, None, None] # return tensor * torch.tensor([0.229,0.224,0.225])[:,None,None] + torch.tensor([0.485,0.456,0.406])[:,None,None] +def inverse_vgg_prep_batch(tensor): # def inverse_vgg_prep_batch(tensor): + return tensor * torch.tensor([0.229, 0.224, 0.225])[None, :, None, None] + torch.tensor([0.485, 0.456, 0.406])[None, :, None, None] # return tensor * torch.tensor([0.229,0.224,0.225])[None,:,None,None] + torch.tensor([0.485,0.456,0.406])[None,:,None,None] +def torch_img_to_vgg_prep(state): # def torch_img_to_vgg_prep(state): + VGG_NORMALIZER = _VGG_NORMALIZER() # VGG_NORMALIZER = _VGG_NORMALIZER() + _coconut_match_to = state # case state: + _coconut_case_check_24 = False # case state: + if _coconut_match_to == "vgg_prep": # case state: + _coconut_case_check_24 = True # case state: + if _coconut_case_check_24: # case state: + return [(inverse_vgg_prep, "torch,float32,CHW,RGB,0_1", "inverse from vgg_prep", 1)] # return [( + if not _coconut_case_check_24: # inverse_vgg_prep, + if _coconut_match_to == "vgg_prep_batch": # inverse_vgg_prep, + _coconut_case_check_24 = True # inverse_vgg_prep, + if _coconut_case_check_24: # inverse_vgg_prep, + return [(inverse_vgg_prep_batch, "torch,float32,BCHW,RGB,0_1", "inverse from vgg_prep_batch", 1)] # return [( + if not _coconut_case_check_24: # inverse_vgg_prep_batch, + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # inverse_vgg_prep_batch, + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # inverse_vgg_prep_batch, + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # inverse_vgg_prep_batch, + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # inverse_vgg_prep_batch, + _coconut_match_temp_3 = _coconut_match_to.get("v_range", _coconut_sentinel) # inverse_vgg_prep_batch, + _coconut_match_temp_4 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # inverse_vgg_prep_batch, + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "torch") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "CHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "0_1") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "RGB"): # inverse_vgg_prep_batch, + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "v_range", "ch_rpr"))) # inverse_vgg_prep_batch, + _coconut_case_check_24 = True # inverse_vgg_prep_batch, + if _coconut_case_check_24: # inverse_vgg_prep_batch, + return [(VGG_NORMALIZER, "vgg_prep".format(), "convert to vgg normalized input", 1)] # return [( + if not _coconut_case_check_24: # VGG_NORMALIZER, + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # VGG_NORMALIZER, + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # VGG_NORMALIZER, + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # VGG_NORMALIZER, + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # VGG_NORMALIZER, + _coconut_match_temp_3 = _coconut_match_to.get("v_range", _coconut_sentinel) # VGG_NORMALIZER, + _coconut_match_temp_4 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # VGG_NORMALIZER, + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "torch") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "BCHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "0_1") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "RGB"): # VGG_NORMALIZER, + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "v_range", "ch_rpr"))) # VGG_NORMALIZER, + _coconut_case_check_24 = True # VGG_NORMALIZER, + if _coconut_case_check_24: # VGG_NORMALIZER, + return [(lambda t: torch.cat([VGG_NORMALIZER(i)[None] for i in t], dim=0), "vgg_prep_batch".format(), "convert to vgg normalized input batch", 1)] # return [( + if not _coconut_case_check_24: # t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + _coconut_match_temp_1 = _coconut_match_to.get("dtype", _coconut_sentinel) # t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + _coconut_match_temp_2 = _coconut_match_to.get("arrange", _coconut_sentinel) # t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + _coconut_match_temp_3 = _coconut_match_to.get("v_range", _coconut_sentinel) # t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + _coconut_match_temp_4 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "torch") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "float32") and (_coconut_match_temp_2 is not _coconut_sentinel) and (_coconut_match_temp_2 == "BCHW") and (_coconut_match_temp_3 is not _coconut_sentinel) and (_coconut_match_temp_3 == "0_1") and (_coconut_match_temp_4 is not _coconut_sentinel) and (_coconut_match_temp_4 == "RGBA"): # t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "dtype", "arrange", "v_range", "ch_rpr"))) # t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + _coconut_case_check_24 = True # t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + if _coconut_case_check_24: # t->torch.cat([VGG_NORMALIZER(i)[None] for i in t],dim=0), + return [(lambda t: torch.cat([torch.cat((VGG_NORMALIZER(i[:3])[None], i[[3]][None]), dim=1) for i in t], dim=0), "vgg_prep_batch_masked".format(), "convert to vgg normalized input batch", 1)] # return [( +def repeat_ch(state): # def repeat_ch(state): + _coconut_match_to = state # case state: + _coconut_case_check_25 = False # case state: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # case state: + _coconut_match_temp_0 = _coconut_match_to.get("type", _coconut_sentinel) # case state: + _coconut_match_temp_1 = _coconut_match_to.get("mode", _coconut_sentinel) # case state: + _coconut_match_temp_2 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # case state: + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "image") and (_coconut_match_temp_1 is not _coconut_sentinel) and (_coconut_match_temp_1 == "L") and (_coconut_match_temp_2 is not _coconut_sentinel): # case state: + ch = _coconut_match_temp_2 # case state: + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("type", "mode", "ch_rpr"))) # case state: + _coconut_case_check_25 = True # case state: + if _coconut_case_check_25 and not (len(ch) == 1): # case state: + _coconut_case_check_25 = False # case state: + if _coconut_case_check_25: # case state: + return [(lambda a: np.repeat(np.array(a)[:, :, None], 3, axis=2), frozendict(type="numpy", dtype="uint8", arrange="HWC", ch_rpr=ch * 3, v_range="0_255"), "repeat_channel_3", 50)] # return [ + + + +def lll_is_rgb(state): # def lll_is_rgb(state): + _coconut_match_to = state # case state: + _coconut_case_check_26 = False # case state: + if _coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping): # case state: + _coconut_match_temp_0 = _coconut_match_to.get("ch_rpr", _coconut_sentinel) # case state: + if (_coconut_match_temp_0 is not _coconut_sentinel) and (_coconut_match_temp_0 == "LLL"): # case state: + kwargs = dict((k, v) for k, v in _coconut_match_to.items() if k not in set(("ch_rpr",))) # case state: + _coconut_case_check_26 = True # case state: + if _coconut_case_check_26: # case state: + return [frozendict(ch_rpr="RGB", **kwargs)] # return [frozendict(ch_rpr="RGB",**kwargs)] + + + +DEFAULT_RULES = AutoImage.default_rules.copy() + [AutoSolver.create_cast_rule(cast_imdef_to_dict, "cast_imdef_to_dict"), AutoSolver.create_cast_rule(cast_imdef_str_to_imdef, "cast_imdef_str_to_imdef"), AutoSolver.create_cast_rule(cast_imdef_to_imdef_str, "cast_imdef_to_imdef_str"), AutoSolver.create_cast_rule(dict2imdef, "dict2imdef"), AutoSolver.create_cast_rule(cast_ary_str_to_ary_type, "cast_ary_str_to_ary_type"), AutoSolver.create_cast_rule(img_list_is_imgs, "img_list_is_imgs"), AutoSolver.create_cast_rule(lll_is_rgb, "lll_is_rgb", cost=10), AutoSolver.create_cast_rule(cast_tuple2auto_tuple, "tuple <--> auto_tuple"), AutoSolver.create_conversion_rule(any2widget), AutoSolver.create_conversion_rule(to_visdom_function), AutoSolver.create_conversion_rule(rule_imgs2tile), AutoSolver.create_conversion_rule(rule_img2widget), AutoSolver.create_conversion_rule(rule_numpy2img), AutoSolver.create_conversion_rule(rule_image2gray), AutoSolver.create_conversion_rule(rule_image2lab), AutoSolver.create_conversion_rule(rule_rgba2laba), AutoSolver.create_conversion_rule(rule_lab_value_conversion), AutoSolver.create_conversion_rule(intra_list_conversions), AutoSolver.create_conversion_rule(numpys_to_numpy), AutoSolver.create_conversion_rule(tensor_to_list), AutoSolver.create_conversion_rule(pil_convert), AutoSolver.create_conversion_rule(rgb_to_rgba), AutoSolver.create_conversion_rule(repeat_ch), AutoSolver.create_conversion_rule(torch_img_to_pixpix_input), AutoSolver.create_conversion_rule(torch_img_to_vgg_prep), AutoSolver.create_conversion_rule(auto_tuple2widget), AutoSolver.create_alias_rule("numpy_rgb", "numpy,uint8,HWC,RGB,0_255"), AutoSolver.create_alias_rule("numpy_rgba", "numpy,uint8,HWC,RGBA,0_255"),] # DEFAULT_RULES = AutoImage.default_rules.copy() + [ + +SMART_RULES = [AutoSolver.create_smart_conversion_rule(smart_tuple_conversion),] # SMART_RULES =[ + +try: # try: + import wandb # import wandb + def img_to_wandb_img(state): # def img_to_wandb_img(state): + _coconut_match_to = state # case state: + _coconut_case_check_27 = False # case state: + if (_coconut.isinstance(_coconut_match_to, ImageDef)) and (_coconut.len(_coconut_match_to) == 2) and (_coconut.isinstance(_coconut_match_to[0], PILImage)) and (_coconut.len(_coconut_match_to[0]) == 2): # case state: + _coconut_case_check_27 = True # case state: + if _coconut_case_check_27: # case state: + return [(lambda img: wandb.Image(img), "wandb.Image", "image to wandb image", 1)] # return [( + DEFAULT_RULES.append(AutoSolver.create_conversion_rule(img_to_wandb_img)) # DEFAULT_RULES.append(AutoSolver.create_conversion_rule(img_to_wandb_img)) + logger.warning("added wandb related conversions".format()) # logger.warning(f"added wandb related conversions") +except Exception as e: # except Exception as e: + logger.warning("could not add wandb related conversions since wandb could not be imported".format()) # logger.warning(f"could not add wandb related conversions since wandb could not be imported") + + +def tuple_distance(x, y): # def tuple_distance(x,y): + assert len(x) == len(y), "cannot compare two tuples with different length" # assert len(x) == len(y),"cannot compare two tuples with different length" + return len(x) - sum(tuple([i == j for i, j in zip(x, y)])) # return len(x) - sum(tuple([i==j for i,j in zip(x,y)])) + + +@memoize() # @memoize() +def state_distance(x, y): # def state_distance(x,y): + conversion = SOLVER.solver.search_direct(x, y, silent=True) # conversion = SOLVER.solver.search_direct(x,y,silent=True) + d = len(conversion.edges) # d = len(conversion.edges) +#logger.info(f"heuristic conversion:{conversion}") +#logger.info(f"{x} to {y}:{d}") + return d # return d + +@memoize() # @memoize() +def tuple_state_distance(x, y): # def tuple_state_distance(x,y): + return sum([state_distance(i, j) for i, j in zip(x, y)]) # return sum([state_distance(i,j) for i,j in zip(x,y)]) + +@memoize() # @memoize() +def tuple_widget_heuristics(x, y): # def tuple_widget_heuristics(x,y): + """ + you have to make the solver solve one by one. + """ # """ + res = 0 # res = 0 + return 0 # return 0 + if type(x) == tuple and type(y) == tuple: # if type(x) == tuple and type(y) == tuple: + if len(x) == len(y): # if len(x) == len(y): + res = tuple_distance(x, y) # res = tuple_distance(x,y) + if isinstance(x, AutoTuple) and type(y) == tuple: # if isinstance(x,AutoTuple) and type(y) == tuple: + if len(x.formats) == len(y): # if len(x.formats) == len(y): + xs = x.formats # xs = x.formats + ys = y # ys = y + res = tuple_distance(xs, ys) # res = tuple_distance(xs,ys) + elif isinstance(x, AutoTuple) and y == "widget": # elif isinstance(x,AutoTuple) and y == "widget": + xs = x.formats # xs = x.formats + ys = ("widget",) * len(x.formats) # ys = ("widget",)*len(x.formats) + res = tuple_distance(xs, ys) # res = tuple_distance(xs,ys) +#if res == 0: +# logger.info(f"{x}->{y}:{res}") +# pass + return res # return res + +def tuple_edge_cutter(x, y, end): # def tuple_edge_cutter(x,y,end): + return False # return False + if isinstance(x, AutoTuple) and type(y) == tuple and type(end) == tuple: # if isinstance(x,AutoTuple) and type(y) == tuple and type(end) == tuple: + n = len(x.formats) # n = len(x.formats) + if n == len(y) and n == len(end): # if n == len(y) and n == len(end): + x2end = tuple_distance(x.formats, end) # x2end = tuple_distance(x.formats,end) + y2end = tuple_distance(y, end) # y2end = tuple_distance(y,end) + x_matching = n - x2end # x_matching = n - x2end + y_matching = n - y2end # y_matching = n - y2end + if y_matching < x_matching: # if y_matching < x_matching: + logger.debug("cut {_coconut_format_0} to {_coconut_format_1} for {_coconut_format_2}".format(_coconut_format_0=(x), _coconut_format_1=(y), _coconut_format_2=(end))) # logger.debug(f"cut {x} to {y} for {end}") + return True # return True + return False # return False + + + + +SOLVER = AutoSolver(rules=DEFAULT_RULES.copy(), smart_rules=SMART_RULES.copy(), heuristics=tuple_widget_heuristics, edge_cutter=tuple_edge_cutter) # SOLVER = AutoSolver( +auto_img = lambda format: lambda value: AutoData(value, format, SOLVER) # auto_img = format->value->AutoData(value,format,SOLVER) diff --git a/data_tree/ops/cache.py b/data_tree/ops/cache.py index 4216544..3567ea6 100644 --- a/data_tree/ops/cache.py +++ b/data_tree/ops/cache.py @@ -8,15 +8,32 @@ import threading from contextlib import contextmanager # from threading import RLock +<<<<<<< HEAD +from multiprocessing import RLock +======= from datetime import time from multiprocessing import RLock from multiprocessing.dummy import Value +>>>>>>> master import h5py import numpy as np from PIL import Image from filelock import FileLock from lazy import lazy as en_lazy +<<<<<<< HEAD +from loguru import logger +from lru import LRU +from tqdm.autonotebook import tqdm + +from data_tree import auto +from data_tree._series import SourcedSeries, NumpySeries, MappedSeries, Series +from data_tree.coconut.astar import Conversion +from data_tree.indexer import IdentityIndexer, Indexer +from data_tree.resource import ContextResource +from data_tree.util import ensure_path_exists, batch_index_generator, prefetch_generator + +======= from lru import LRU from tqdm import tqdm @@ -30,6 +47,7 @@ from data_tree.custom_resource import ContextResource from data_tree.util import ensure_path_exists, batch_index_generator, prefetch_generator +>>>>>>> master # from loguru import logger diff --git a/data_tree/storage_manager.py b/data_tree/storage_manager.py index f3652a8..af70733 100644 --- a/data_tree/storage_manager.py +++ b/data_tree/storage_manager.py @@ -161,8 +161,29 @@ def find(self, **conditions) -> str: :param conditions: :return: absolute path matching condition """ +<<<<<<< HEAD + import inspect + curframe = inspect.currentframe() + calframe = inspect.getouterframes(curframe, 2) + logger.debug('caller name:', calframe[1][3]) + ... + def find_matching(): + for k, c in self.info_cache.value.items(): + matched = True + for ck, cv in conditions.items(): + if ck in c and c[ck] != cv: + matched = False + break + if matched and k in self.scan_cache.value: + candidates = self.scan_cache.value[k] + if len(candidates) >= 2: + logger.warning(f"multiple candidates found. using {candidates[0]}.") + logger.warning(f"candidates:{candidates}") + return candidates[0] +======= # curframe = inspect.currentframe() # calframe = inspect.getouterframes(curframe, 2) +>>>>>>> master # frame = calframe[1] # logger.debug(f'caller name: {frame.filename}, {frame.index}') diff --git a/data_tree/util.py b/data_tree/util.py index cf63784..42b73cb 100644 --- a/data_tree/util.py +++ b/data_tree/util.py @@ -1,7 +1,10 @@ import abc import os +<<<<<<< HEAD +======= import threading import time +>>>>>>> master from contextlib import contextmanager from datetime import datetime from hashlib import sha1 @@ -12,6 +15,14 @@ import numpy as np import pandas as pd +<<<<<<< HEAD +from easydict import EasyDict as edict +from filelock import FileLock +from frozendict import frozendict +from lazy import lazy +from loguru import logger +from tqdm.autonotebook import tqdm +======= from cytoolz import memoize from easydict import EasyDict as edict from frozendict import frozendict @@ -21,6 +32,7 @@ from data_tree.get_callee import get_callee from data_tree.picklable_file_lock import PicklableFileLock +>>>>>>> master WARN_SLOW_PREFETCH = False import pickle @@ -236,6 +248,66 @@ def sorted_frozendict(_dict): return frozendict(sorted(_dict.items(), key=lambda item: item[0])) +<<<<<<< HEAD +class ShelvedCache: + """ + a cache that uses shelve and memory as backend + """ + + def __init__(self, path): + import filelock + self.path = path + self.lock = filelock.FileLock(path+".lock") + self.mem_cache = dict() + + def get_cache(self): + import shelve + return shelve.open(self.path, writeback=True) + + def __contains__(self, key): + key = pickle.dumps(key,0).decode() + if key in self.mem_cache: + return True + else: + with self.get_cache() as db: + #logger.info(list(db.keys())) + return key in db + + def __setitem__(self, key, value): + key = pickle.dumps(key,0).decode() + self.mem_cache[key] = value + with self.lock, self.get_cache() as db: + db[key] = value + db.sync() + + def __getitem__(self, key): + key = pickle.dumps(key,0).decode() + if key in self.mem_cache: + return self.mem_cache[key] + else: + with self.lock, self.get_cache() as db: + if key in db: + res = db[key] + self.mem_cache[key] = res + return res + else: + return self.__missing__(key) + + def __missing__(self, key): + raise KeyError(key) + + def items(self): + with self.lock, self.get_cache() as db: + for k, v in db.items(): + yield pickle.loads(k.encode()), v + + def clear(self): + with self.lock: + os.remove(self.path + ".db") + + +======= +>>>>>>> master class DefaultDict(dict): def __init__(self, f): super().__init__() diff --git a/poetry.lock b/poetry.lock index be39a55..f9ef0aa 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Poetry and should not be changed by hand. + [[package]] name = "appdirs" version = "1.4.4" @@ -5,6 +7,10 @@ description = "A small Python module for determining appropriate platform-specif category = "main" optional = false python-versions = "*" +files = [ + {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, + {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, +] [[package]] name = "appnope" @@ -13,6 +19,10 @@ description = "Disable App Nap on macOS >= 10.9" category = "main" optional = false python-versions = "*" +files = [ + {file = "appnope-0.1.2-py2.py3-none-any.whl", hash = "sha256:93aa393e9d6c54c5cd570ccadd8edad61ea0c4b9ea7a01409020c9aa019eb442"}, + {file = "appnope-0.1.2.tar.gz", hash = "sha256:dd83cd4b5b460958838f6eb3000c660b1f9caf2a5b1de4264e941512f603258a"}, +] [[package]] name = "argon2-cffi" @@ -21,13 +31,17 @@ description = "The secure Argon2 password hashing algorithm." category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "argon2-cffi-21.3.0.tar.gz", hash = "sha256:d384164d944190a7dd7ef22c6aa3ff197da12962bd04b17f64d4e93d934dba5b"}, + {file = "argon2_cffi-21.3.0-py3-none-any.whl", hash = "sha256:8c976986f2c5c0e5000919e6de187906cfd81fb1c72bf9d88c01177e77da7f80"}, +] [package.dependencies] argon2-cffi-bindings = "*" [package.extras] -dev = ["pre-commit", "cogapp", "tomli", "coverage[toml] (>=5.0.2)", "hypothesis", "pytest", "sphinx", "sphinx-notfound-page", "furo"] -docs = ["sphinx", "sphinx-notfound-page", "furo"] +dev = ["cogapp", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "pre-commit", "pytest", "sphinx", "sphinx-notfound-page", "tomli"] +docs = ["furo", "sphinx", "sphinx-notfound-page"] tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pytest"] [[package]] @@ -37,12 +51,35 @@ description = "Low-level CFFI bindings for Argon2" category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "argon2-cffi-bindings-21.2.0.tar.gz", hash = "sha256:bb89ceffa6c791807d1305ceb77dbfacc5aa499891d2c55661c6459651fc39e3"}, + {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:ccb949252cb2ab3a08c02024acb77cfb179492d5701c7cbdbfd776124d4d2367"}, + {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9524464572e12979364b7d600abf96181d3541da11e23ddf565a32e70bd4dc0d"}, + {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b746dba803a79238e925d9046a63aa26bf86ab2a2fe74ce6b009a1c3f5c8f2ae"}, + {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:58ed19212051f49a523abb1dbe954337dc82d947fb6e5a0da60f7c8471a8476c"}, + {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:bd46088725ef7f58b5a1ef7ca06647ebaf0eb4baff7d1d0d177c6cc8744abd86"}, + {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_i686.whl", hash = "sha256:8cd69c07dd875537a824deec19f978e0f2078fdda07fd5c42ac29668dda5f40f"}, + {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:f1152ac548bd5b8bcecfb0b0371f082037e47128653df2e8ba6e914d384f3c3e"}, + {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-win32.whl", hash = "sha256:603ca0aba86b1349b147cab91ae970c63118a0f30444d4bc80355937c950c082"}, + {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-win_amd64.whl", hash = "sha256:b2ef1c30440dbbcba7a5dc3e319408b59676e2e039e2ae11a8775ecf482b192f"}, + {file = "argon2_cffi_bindings-21.2.0-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:e415e3f62c8d124ee16018e491a009937f8cf7ebf5eb430ffc5de21b900dad93"}, + {file = "argon2_cffi_bindings-21.2.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:3e385d1c39c520c08b53d63300c3ecc28622f076f4c2b0e6d7e796e9f6502194"}, + {file = "argon2_cffi_bindings-21.2.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2c3e3cc67fdb7d82c4718f19b4e7a87123caf8a93fde7e23cf66ac0337d3cb3f"}, + {file = "argon2_cffi_bindings-21.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6a22ad9800121b71099d0fb0a65323810a15f2e292f2ba450810a7316e128ee5"}, + {file = "argon2_cffi_bindings-21.2.0-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f9f8b450ed0547e3d473fdc8612083fd08dd2120d6ac8f73828df9b7d45bb351"}, + {file = "argon2_cffi_bindings-21.2.0-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:93f9bf70084f97245ba10ee36575f0c3f1e7d7724d67d8e5b08e61787c320ed7"}, + {file = "argon2_cffi_bindings-21.2.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:3b9ef65804859d335dc6b31582cad2c5166f0c3e7975f324d9ffaa34ee7e6583"}, + {file = "argon2_cffi_bindings-21.2.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d4966ef5848d820776f5f562a7d45fdd70c2f330c961d0d745b784034bd9f48d"}, + {file = "argon2_cffi_bindings-21.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:20ef543a89dee4db46a1a6e206cd015360e5a75822f76df533845c3cbaf72670"}, + {file = "argon2_cffi_bindings-21.2.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ed2937d286e2ad0cc79a7087d3c272832865f779430e0cc2b4f3718d3159b0cb"}, + {file = "argon2_cffi_bindings-21.2.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:5e00316dabdaea0b2dd82d141cc66889ced0cdcbfa599e8b471cf22c620c329a"}, +] [package.dependencies] cffi = ">=1.0.1" [package.extras] -dev = ["pytest", "cogapp", "pre-commit", "wheel"] +dev = ["cogapp", "pre-commit", "pytest", "wheel"] tests = ["pytest"] [[package]] @@ -52,6 +89,10 @@ description = "Annotate AST trees with source code positions" category = "main" optional = false python-versions = "*" +files = [ + {file = "asttokens-2.0.5-py2.py3-none-any.whl", hash = "sha256:0844691e88552595a6f4a4281a9f7f79b8dd45ca4ccea82e5e05b4bbdb76705c"}, + {file = "asttokens-2.0.5.tar.gz", hash = "sha256:9a54c114f02c7a9480d56550932546a3f1fe71d8a02f1bc7ccd0ee3ee35cf4d5"}, +] [package.dependencies] six = "*" @@ -66,12 +107,16 @@ description = "Classes Without Boilerplate" category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ + {file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"}, + {file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"}, +] [package.extras] -dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"] -docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"] -tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"] -tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"] +dev = ["cloudpickle", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "mypy", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "six", "sphinx", "sphinx-notfound-page", "zope.interface"] +docs = ["furo", "sphinx", "sphinx-notfound-page", "zope.interface"] +tests = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "six", "zope.interface"] +tests-no-zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "six"] [[package]] name = "backcall" @@ -80,6 +125,10 @@ description = "Specifications for callback functions passed in to an API" category = "main" optional = false python-versions = "*" +files = [ + {file = "backcall-0.2.0-py2.py3-none-any.whl", hash = "sha256:fbbce6a29f263178a1f7915c1940bde0ec2b2a967566fe1c65c1dfb7422bd255"}, + {file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"}, +] [[package]] name = "black" @@ -88,6 +137,10 @@ description = "The uncompromising code formatter." category = "main" optional = false python-versions = ">=3.6.2" +files = [ + {file = "black-21.6b0-py3-none-any.whl", hash = "sha256:dfb8c5a069012b2ab1e972e7b908f5fb42b6bbabcba0a788b86dc05067c7d9c7"}, + {file = "black-21.6b0.tar.gz", hash = "sha256:dc132348a88d103016726fe360cb9ede02cecf99b76e3660ce6c596be132ce04"}, +] [package.dependencies] appdirs = "*" @@ -110,6 +163,10 @@ description = "An easy safelist-based HTML-sanitizing tool." category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "bleach-4.1.0-py2.py3-none-any.whl", hash = "sha256:4d2651ab93271d1129ac9cbc679f524565cc8a1b791909c4a51eac4446a15994"}, + {file = "bleach-4.1.0.tar.gz", hash = "sha256:0900d8b37eba61a802ee40ac0061f8c2b5dee29c1927dd1d233e075ebf5a71da"}, +] [package.dependencies] packaging = "*" @@ -123,6 +180,10 @@ description = "Interactive plotting for the Jupyter notebook, using d3.js and ip category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "bqplot-0.12.32-py2.py3-none-any.whl", hash = "sha256:815289a0136615bd0fbe05b851471622c27b4e56bda96e0db947c9a5827b8501"}, + {file = "bqplot-0.12.32.tar.gz", hash = "sha256:6fbfb93955ac15f87b6fa37368b04fd00da1f2d43843d8d9bc3d59116c6f5f00"}, +] [package.dependencies] ipywidgets = ">=7.5.0" @@ -138,6 +199,58 @@ description = "Foreign Function Interface for Python calling C code." category = "main" optional = false python-versions = "*" +files = [ + {file = "cffi-1.15.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:c2502a1a03b6312837279c8c1bd3ebedf6c12c4228ddbad40912d671ccc8a962"}, + {file = "cffi-1.15.0-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:23cfe892bd5dd8941608f93348c0737e369e51c100d03718f108bf1add7bd6d0"}, + {file = "cffi-1.15.0-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:41d45de54cd277a7878919867c0f08b0cf817605e4eb94093e7516505d3c8d14"}, + {file = "cffi-1.15.0-cp27-cp27m-win32.whl", hash = "sha256:4a306fa632e8f0928956a41fa8e1d6243c71e7eb59ffbd165fc0b41e316b2474"}, + {file = "cffi-1.15.0-cp27-cp27m-win_amd64.whl", hash = "sha256:e7022a66d9b55e93e1a845d8c9eba2a1bebd4966cd8bfc25d9cd07d515b33fa6"}, + {file = "cffi-1.15.0-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:14cd121ea63ecdae71efa69c15c5543a4b5fbcd0bbe2aad864baca0063cecf27"}, + {file = "cffi-1.15.0-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:d4d692a89c5cf08a8557fdeb329b82e7bf609aadfaed6c0d79f5a449a3c7c023"}, + {file = "cffi-1.15.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0104fb5ae2391d46a4cb082abdd5c69ea4eab79d8d44eaaf79f1b1fd806ee4c2"}, + {file = "cffi-1.15.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:91ec59c33514b7c7559a6acda53bbfe1b283949c34fe7440bcf917f96ac0723e"}, + {file = "cffi-1.15.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:f5c7150ad32ba43a07c4479f40241756145a1f03b43480e058cfd862bf5041c7"}, + {file = "cffi-1.15.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:00c878c90cb53ccfaae6b8bc18ad05d2036553e6d9d1d9dbcf323bbe83854ca3"}, + {file = "cffi-1.15.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:abb9a20a72ac4e0fdb50dae135ba5e77880518e742077ced47eb1499e29a443c"}, + {file = "cffi-1.15.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a5263e363c27b653a90078143adb3d076c1a748ec9ecc78ea2fb916f9b861962"}, + {file = "cffi-1.15.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f54a64f8b0c8ff0b64d18aa76675262e1700f3995182267998c31ae974fbc382"}, + {file = "cffi-1.15.0-cp310-cp310-win32.whl", hash = "sha256:c21c9e3896c23007803a875460fb786118f0cdd4434359577ea25eb556e34c55"}, + {file = "cffi-1.15.0-cp310-cp310-win_amd64.whl", hash = "sha256:5e069f72d497312b24fcc02073d70cb989045d1c91cbd53979366077959933e0"}, + {file = "cffi-1.15.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:64d4ec9f448dfe041705426000cc13e34e6e5bb13736e9fd62e34a0b0c41566e"}, + {file = "cffi-1.15.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2756c88cbb94231c7a147402476be2c4df2f6078099a6f4a480d239a8817ae39"}, + {file = "cffi-1.15.0-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3b96a311ac60a3f6be21d2572e46ce67f09abcf4d09344c49274eb9e0bf345fc"}, + {file = "cffi-1.15.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:75e4024375654472cc27e91cbe9eaa08567f7fbdf822638be2814ce059f58032"}, + {file = "cffi-1.15.0-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:59888172256cac5629e60e72e86598027aca6bf01fa2465bdb676d37636573e8"}, + {file = "cffi-1.15.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:27c219baf94952ae9d50ec19651a687b826792055353d07648a5695413e0c605"}, + {file = "cffi-1.15.0-cp36-cp36m-win32.whl", hash = "sha256:4958391dbd6249d7ad855b9ca88fae690783a6be9e86df65865058ed81fc860e"}, + {file = "cffi-1.15.0-cp36-cp36m-win_amd64.whl", hash = "sha256:f6f824dc3bce0edab5f427efcfb1d63ee75b6fcb7282900ccaf925be84efb0fc"}, + {file = "cffi-1.15.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:06c48159c1abed75c2e721b1715c379fa3200c7784271b3c46df01383b593636"}, + {file = "cffi-1.15.0-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:c2051981a968d7de9dd2d7b87bcb9c939c74a34626a6e2f8181455dd49ed69e4"}, + {file = "cffi-1.15.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:fd8a250edc26254fe5b33be00402e6d287f562b6a5b2152dec302fa15bb3e997"}, + {file = "cffi-1.15.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:91d77d2a782be4274da750752bb1650a97bfd8f291022b379bb8e01c66b4e96b"}, + {file = "cffi-1.15.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:45db3a33139e9c8f7c09234b5784a5e33d31fd6907800b316decad50af323ff2"}, + {file = "cffi-1.15.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:263cc3d821c4ab2213cbe8cd8b355a7f72a8324577dc865ef98487c1aeee2bc7"}, + {file = "cffi-1.15.0-cp37-cp37m-win32.whl", hash = "sha256:17771976e82e9f94976180f76468546834d22a7cc404b17c22df2a2c81db0c66"}, + {file = "cffi-1.15.0-cp37-cp37m-win_amd64.whl", hash = "sha256:3415c89f9204ee60cd09b235810be700e993e343a408693e80ce7f6a40108029"}, + {file = "cffi-1.15.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4238e6dab5d6a8ba812de994bbb0a79bddbdf80994e4ce802b6f6f3142fcc880"}, + {file = "cffi-1.15.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0808014eb713677ec1292301ea4c81ad277b6cdf2fdd90fd540af98c0b101d20"}, + {file = "cffi-1.15.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:57e9ac9ccc3101fac9d6014fba037473e4358ef4e89f8e181f8951a2c0162024"}, + {file = "cffi-1.15.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8b6c2ea03845c9f501ed1313e78de148cd3f6cad741a75d43a29b43da27f2e1e"}, + {file = "cffi-1.15.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:10dffb601ccfb65262a27233ac273d552ddc4d8ae1bf93b21c94b8511bffe728"}, + {file = "cffi-1.15.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:786902fb9ba7433aae840e0ed609f45c7bcd4e225ebb9c753aa39725bb3e6ad6"}, + {file = "cffi-1.15.0-cp38-cp38-win32.whl", hash = "sha256:da5db4e883f1ce37f55c667e5c0de439df76ac4cb55964655906306918e7363c"}, + {file = "cffi-1.15.0-cp38-cp38-win_amd64.whl", hash = "sha256:181dee03b1170ff1969489acf1c26533710231c58f95534e3edac87fff06c443"}, + {file = "cffi-1.15.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:45e8636704eacc432a206ac7345a5d3d2c62d95a507ec70d62f23cd91770482a"}, + {file = "cffi-1.15.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:31fb708d9d7c3f49a60f04cf5b119aeefe5644daba1cd2a0fe389b674fd1de37"}, + {file = "cffi-1.15.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:6dc2737a3674b3e344847c8686cf29e500584ccad76204efea14f451d4cc669a"}, + {file = "cffi-1.15.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:74fdfdbfdc48d3f47148976f49fab3251e550a8720bebc99bf1483f5bfb5db3e"}, + {file = "cffi-1.15.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ffaa5c925128e29efbde7301d8ecaf35c8c60ffbcd6a1ffd3a552177c8e5e796"}, + {file = "cffi-1.15.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3f7d084648d77af029acb79a0ff49a0ad7e9d09057a9bf46596dac9514dc07df"}, + {file = "cffi-1.15.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ef1f279350da2c586a69d32fc8733092fd32cc8ac95139a00377841f59a3f8d8"}, + {file = "cffi-1.15.0-cp39-cp39-win32.whl", hash = "sha256:2a23af14f408d53d5e6cd4e3d9a24ff9e05906ad574822a10563efcef137979a"}, + {file = "cffi-1.15.0-cp39-cp39-win_amd64.whl", hash = "sha256:3773c4d81e6e818df2efbc7dd77325ca0dcb688116050fb2b3011218eda36139"}, + {file = "cffi-1.15.0.tar.gz", hash = "sha256:920f0d66a896c2d99f0adbb391f990a84091179542c205fa53ce5787aff87954"}, +] [package.dependencies] pycparser = "*" @@ -149,6 +262,10 @@ description = "Composable command line interface toolkit" category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "click-8.0.3-py3-none-any.whl", hash = "sha256:353f466495adaeb40b6b5f592f9f91cb22372351c84caeb068132442a4518ef3"}, + {file = "click-8.0.3.tar.gz", hash = "sha256:410e932b050f5eed773c4cda94de75971c89cdb3155a72a0831139a79e5ecb5b"}, +] [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} @@ -160,6 +277,10 @@ description = "Cross-platform colored terminal text." category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ + {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, + {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, +] [[package]] name = "cycler" @@ -168,6 +289,10 @@ description = "Composable style cycles" category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "cycler-0.11.0-py3-none-any.whl", hash = "sha256:3a27e95f763a428a739d2add979fa7494c912a32c17c4c38c4d5f082cad165a3"}, + {file = "cycler-0.11.0.tar.gz", hash = "sha256:9c87405839a19696e837b3b818fed3f5f69f16f1eec1a1ad77e043dcea9c772f"}, +] [[package]] name = "cytoolz" @@ -176,6 +301,9 @@ description = "Cython implementation of Toolz: High performance functional utili category = "main" optional = false python-versions = ">=3.5" +files = [ + {file = "cytoolz-0.11.2.tar.gz", hash = "sha256:ea23663153806edddce7e4153d1d407d62357c05120a4e8485bddf1bd5ab22b4"}, +] [package.dependencies] toolz = ">=0.8.0" @@ -190,6 +318,29 @@ description = "An implementation of the Debug Adapter Protocol for Python" category = "main" optional = false python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*" +files = [ + {file = "debugpy-1.5.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:70b422c63a833630c33e3f9cdbd9b6971f8c5afd452697e464339a21bbe862ba"}, + {file = "debugpy-1.5.1-cp310-cp310-win32.whl", hash = "sha256:3a457ad9c0059a21a6c7d563c1f18e924f5cf90278c722bd50ede6f56b77c7fe"}, + {file = "debugpy-1.5.1-cp310-cp310-win_amd64.whl", hash = "sha256:5d76a4fd028d8009c3faf1185b4b78ceb2273dd2499447664b03939e0368bb90"}, + {file = "debugpy-1.5.1-cp36-cp36m-macosx_10_15_x86_64.whl", hash = "sha256:16db27b4b91991442f91d73604d32080b30de655aca9ba821b1972ea8171021b"}, + {file = "debugpy-1.5.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2b073ad5e8d8c488fbb6a116986858bab0c9c4558f28deb8832c7a5a27405bd6"}, + {file = "debugpy-1.5.1-cp36-cp36m-win32.whl", hash = "sha256:318f81f37341e4e054b4267d39896b73cddb3612ca13b39d7eea45af65165e1d"}, + {file = "debugpy-1.5.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b5b3157372e0e0a1297a8b6b5280bcf1d35a40f436c7973771c972726d1e32d5"}, + {file = "debugpy-1.5.1-cp37-cp37m-macosx_10_15_x86_64.whl", hash = "sha256:1ec3a086e14bba6c472632025b8fe5bdfbaef2afa1ebd5c6615ce6ed8d89bc67"}, + {file = "debugpy-1.5.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:26fbe53cca45a608679094791ce587b6e2798acd1d4777a8b303b07622e85182"}, + {file = "debugpy-1.5.1-cp37-cp37m-win32.whl", hash = "sha256:d876db8c312eeb02d85611e0f696abe66a2c1515e6405943609e725d5ff36f2a"}, + {file = "debugpy-1.5.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4404a62fb5332ea5c8c9132290eef50b3a0ba38cecacad5529e969a783bcbdd7"}, + {file = "debugpy-1.5.1-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:f3a3dca9104aa14fd4210edcce6d9ce2b65bd9618c0b222135a40b9d6e2a9eeb"}, + {file = "debugpy-1.5.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:b2df2c373e85871086bd55271c929670cd4e1dba63e94a08d442db830646203b"}, + {file = "debugpy-1.5.1-cp38-cp38-win32.whl", hash = "sha256:82f5f9ce93af6861a0713f804e62ab390bb12a17f113153e47fea8bbb1dfbe36"}, + {file = "debugpy-1.5.1-cp38-cp38-win_amd64.whl", hash = "sha256:17a25ce9d7714f92fc97ef00cc06269d7c2b163094990ada30156ed31d9a5030"}, + {file = "debugpy-1.5.1-cp39-cp39-macosx_10_15_x86_64.whl", hash = "sha256:01e98c594b3e66d529e40edf314f849cd1a21f7a013298df58cd8e263bf8e184"}, + {file = "debugpy-1.5.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f73988422b17f071ad3c4383551ace1ba5ed810cbab5f9c362783d22d40a08dc"}, + {file = "debugpy-1.5.1-cp39-cp39-win32.whl", hash = "sha256:23df67fc56d59e386c342428a7953c2c06cc226d8525b11319153e96afb65b0c"}, + {file = "debugpy-1.5.1-cp39-cp39-win_amd64.whl", hash = "sha256:a2aa64f6d2ca7ded8a7e8a4e7cae3bc71866b09876b7b05cecad231779cb9156"}, + {file = "debugpy-1.5.1-py2.py3-none-any.whl", hash = "sha256:194f95dd3e84568b5489aab5689a3a2c044e8fdc06f1890b8b4f70b6b89f2778"}, + {file = "debugpy-1.5.1.zip", hash = "sha256:d2b09e91fbd1efa4f4fda121d49af89501beda50c18ed7499712c71a4bf3452e"}, +] [[package]] name = "decorator" @@ -198,6 +349,10 @@ description = "Decorators for Humans" category = "main" optional = false python-versions = ">=3.5" +files = [ + {file = "decorator-5.1.1-py3-none-any.whl", hash = "sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"}, + {file = "decorator-5.1.1.tar.gz", hash = "sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330"}, +] [[package]] name = "defusedxml" @@ -206,6 +361,10 @@ description = "XML bomb protection for Python stdlib modules" category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ + {file = "defusedxml-0.7.1-py2.py3-none-any.whl", hash = "sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61"}, + {file = "defusedxml-0.7.1.tar.gz", hash = "sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69"}, +] [[package]] name = "dill" @@ -214,6 +373,10 @@ description = "serialize all of python" category = "main" optional = false python-versions = ">=2.7, !=3.0.*" +files = [ + {file = "dill-0.3.4-py2.py3-none-any.whl", hash = "sha256:7e40e4a70304fd9ceab3535d36e58791d9c4a776b38ec7f7ec9afc8d3dca4d4f"}, + {file = "dill-0.3.4.zip", hash = "sha256:9f9734205146b2b353ab3fec9af0070237b6ddae78452af83d2fca84d739e675"}, +] [package.extras] graph = ["objgraph (>=1.7.2)"] @@ -225,6 +388,9 @@ description = "Access dict values as attributes (works recursively)." category = "main" optional = false python-versions = "*" +files = [ + {file = "easydict-1.9.tar.gz", hash = "sha256:3f3f0dab07c299f0f4df032db1f388d985bb57fa4c5be30acd25c5f9a516883b"}, +] [[package]] name = "entrypoints" @@ -233,6 +399,10 @@ description = "Discover and load entry points from installed packages." category = "main" optional = false python-versions = ">=2.7" +files = [ + {file = "entrypoints-0.3-py2.py3-none-any.whl", hash = "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19"}, + {file = "entrypoints-0.3.tar.gz", hash = "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451"}, +] [[package]] name = "executing" @@ -241,6 +411,10 @@ description = "Get the currently executing AST node of a frame, and other inform category = "main" optional = false python-versions = "*" +files = [ + {file = "executing-0.8.2-py2.py3-none-any.whl", hash = "sha256:32fc6077b103bd19e6494a72682d66d5763cf20a106d5aa7c5ccbea4e47b0df7"}, + {file = "executing-0.8.2.tar.gz", hash = "sha256:c23bf42e9a7b9b212f185b1b2c3c91feb895963378887bb10e64a2e612ec0023"}, +] [[package]] name = "expression" @@ -249,6 +423,10 @@ description = "Practical functional programming for Python 3.8+" category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "Expression-1.1.1-py3-none-any.whl", hash = "sha256:909c6f109687e00514183e2fd2483f2942acccfab7bd1ba489baed236d332580"}, + {file = "Expression-1.1.1.tar.gz", hash = "sha256:beb1befd68de2ccb7888c4944e6c3b3113cb6916caba1562dde3bb1991240018"}, +] [[package]] name = "filelock" @@ -257,6 +435,10 @@ description = "A platform independent file lock." category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "filelock-3.4.2-py3-none-any.whl", hash = "sha256:cf0fc6a2f8d26bd900f19bf33915ca70ba4dd8c56903eeb14e1e7a2fd7590146"}, + {file = "filelock-3.4.2.tar.gz", hash = "sha256:38b4f4c989f9d06d44524df1b24bd19e167d851f19b50bf3e3559952dddc5b80"}, +] [package.extras] docs = ["furo (>=2021.8.17b43)", "sphinx (>=4.1)", "sphinx-autodoc-typehints (>=1.12)"] @@ -269,11 +451,15 @@ description = "Tools to manipulate font files" category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "fonttools-4.28.5-py3-none-any.whl", hash = "sha256:edf251d5d2cc0580d5f72de4621c338d8c66c5f61abb50cf486640f73c8194d5"}, + {file = "fonttools-4.28.5.zip", hash = "sha256:545c05d0f7903a863c2020e07b8f0a57517f2c40d940bded77076397872d14ca"}, +] [package.extras] -all = ["fs (>=2.2.0,<3)", "lxml (>=4.0,<5)", "zopfli (>=0.1.4)", "lz4 (>=1.7.4.2)", "matplotlib", "sympy", "skia-pathops (>=0.5.0)", "brotlicffi (>=0.8.0)", "scipy", "brotli (>=1.0.1)", "munkres", "unicodedata2 (>=13.0.0)", "xattr"] +all = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "fs (>=2.2.0,<3)", "lxml (>=4.0,<5)", "lz4 (>=1.7.4.2)", "matplotlib", "munkres", "scipy", "skia-pathops (>=0.5.0)", "sympy", "unicodedata2 (>=13.0.0)", "xattr", "zopfli (>=0.1.4)"] graphite = ["lz4 (>=1.7.4.2)"] -interpolatable = ["scipy", "munkres"] +interpolatable = ["munkres", "scipy"] lxml = ["lxml (>=4.0,<5)"] pathops = ["skia-pathops (>=0.5.0)"] plot = ["matplotlib"] @@ -281,7 +467,7 @@ symfont = ["sympy"] type1 = ["xattr"] ufo = ["fs (>=2.2.0,<3)"] unicode = ["unicodedata2 (>=13.0.0)"] -woff = ["zopfli (>=0.1.4)", "brotlicffi (>=0.8.0)", "brotli (>=1.0.1)"] +woff = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "zopfli (>=0.1.4)"] [[package]] name = "frozendict" @@ -290,6 +476,10 @@ description = "A simple immutable dictionary" category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "frozendict-2.1.3-py3-none-any.whl", hash = "sha256:cfa47860932d549947157d68f246898f60b05da392f67219a913b85d8c36b1b2"}, + {file = "frozendict-2.1.3.tar.gz", hash = "sha256:7a12336ba271066e1261a70d8ba97d5178392f3b317b31c6686e401423e70670"}, +] [[package]] name = "h5py" @@ -298,6 +488,24 @@ description = "Read and write HDF5 files from Python" category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "h5py-3.6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a5320837c60870911645e9a935099bdb2be6a786fcf0dac5c860f3b679e2de55"}, + {file = "h5py-3.6.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98646e659bf8591a2177e12a4461dced2cad72da0ba4247643fd118db88880d2"}, + {file = "h5py-3.6.0-cp310-cp310-win_amd64.whl", hash = "sha256:5996ff5adefd2d68c330a4265b6ef92e51b2fc674834a5990add5033bf109e20"}, + {file = "h5py-3.6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:c9a5529343a619fea777b7caa27d493595b28b5af8b005e8d1817559fcccf493"}, + {file = "h5py-3.6.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:e2b49c48df05e19bb20b400b7ff7dc6f1ee36b84dc717c3771c468b33697b466"}, + {file = "h5py-3.6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cd9447633b0bafaf82190d9a8d56f3cb2e8d30169483aee67d800816e028190a"}, + {file = "h5py-3.6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:1c5acc660c458421e88c4c5fe092ce15923adfac4c732af1ac4fced683a5ea97"}, + {file = "h5py-3.6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:35ab552c6f0a93365b3cb5664a5305f3920daa0a43deb5b2c547c52815ec46b9"}, + {file = "h5py-3.6.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:542781d50e1182b8fb619b1265dfe1c765e18215f818b0ab28b2983c28471325"}, + {file = "h5py-3.6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9f39242960b8d7f86f3056cc2546aa3047ff4835985f6483229af8f029e9c8db"}, + {file = "h5py-3.6.0-cp38-cp38-win_amd64.whl", hash = "sha256:8ecedf16c613973622a334701f67edcc0249469f9daa0576e994fb20ac0405db"}, + {file = "h5py-3.6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d8cacad89aa7daf3626fce106f7f2662ac35b14849df22d252d0d8fab9dc1c0b"}, + {file = "h5py-3.6.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:dbaa1ed9768bf9ff04af0919acc55746e62b28333644f0251f38768313f31745"}, + {file = "h5py-3.6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:954c5c39a09b5302f69f752c3bbf165d368a65c8d200f7d5655e0fa6368a75e6"}, + {file = "h5py-3.6.0-cp39-cp39-win_amd64.whl", hash = "sha256:9fd8a14236fdd092a20c0bdf25c3aba3777718d266fabb0fdded4fcf252d1630"}, + {file = "h5py-3.6.0.tar.gz", hash = "sha256:8752d2814a92aba4e2b2a5922d2782d0029102d99caaf3c201a566bc0b40db29"}, +] [package.dependencies] numpy = ">=1.14.5" @@ -309,13 +517,17 @@ description = "Read resources from Python packages" category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "importlib_resources-5.4.0-py3-none-any.whl", hash = "sha256:33a95faed5fc19b4bc16b29a6eeae248a3fe69dd55d4d229d2b480e23eeaad45"}, + {file = "importlib_resources-5.4.0.tar.gz", hash = "sha256:d756e2f85dd4de2ba89be0b21dba2a3bbec2e871a42a3a16719258a11f87506b"}, +] [package.dependencies] zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} [package.extras] -docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] -testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-black (>=0.3.7)", "pytest-mypy"] +docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] +testing = ["pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy"] [[package]] name = "ipykernel" @@ -324,6 +536,10 @@ description = "IPython Kernel for Jupyter" category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "ipykernel-6.6.1-py3-none-any.whl", hash = "sha256:de99f6c1caa72578305cc96122ee3a19669e9c1958694a2b564ed1be28240ab9"}, + {file = "ipykernel-6.6.1.tar.gz", hash = "sha256:91ff0058b45660aad4a68088041059c0d378cd53fc8aff60e5abc91bcc049353"}, +] [package.dependencies] appnope = {version = "*", markers = "platform_system == \"Darwin\""} @@ -336,7 +552,7 @@ tornado = ">=4.2,<7.0" traitlets = ">=5.1.0,<6.0" [package.extras] -test = ["pytest (!=5.3.4)", "pytest-cov", "flaky", "ipyparallel"] +test = ["flaky", "ipyparallel", "pytest (!=5.3.4)", "pytest-cov"] [[package]] name = "ipython" @@ -345,6 +561,10 @@ description = "IPython: Productive Interactive Computing" category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "ipython-8.0.0-py3-none-any.whl", hash = "sha256:5b58cf977635abad74d76be49dbb2e97fddd825fb8503083d55496aa1160b854"}, + {file = "ipython-8.0.0.tar.gz", hash = "sha256:004a0d05aeecd32adec4841b6e2586d5ca35785b1477db4d8333a39333e0ce98"}, +] [package.dependencies] appnope = {version = "*", markers = "sys_platform == \"darwin\""} @@ -358,6 +578,7 @@ pexpect = {version = ">4.3", markers = "sys_platform != \"win32\""} pickleshare = "*" prompt-toolkit = ">=2.0.0,<3.0.0 || >3.0.0,<3.0.1 || >3.0.1,<3.1.0" pygments = "*" +setuptools = ">=18.5" stack-data = "*" traitlets = ">=5" @@ -367,11 +588,11 @@ doc = ["Sphinx (>=1.3)"] kernel = ["ipykernel"] nbconvert = ["nbconvert"] nbformat = ["nbformat"] -notebook = ["notebook", "ipywidgets"] +notebook = ["ipywidgets", "notebook"] parallel = ["ipyparallel"] qtconsole = ["qtconsole"] -test = ["pytest", "pytest-asyncio", "testpath", "pygments"] -test_extra = ["pytest", "testpath", "curio", "matplotlib (!=3.2.0)", "nbformat", "numpy (>=1.19)", "pandas", "pygments", "trio"] +test = ["pygments", "pytest", "pytest-asyncio", "testpath"] +test-extra = ["curio", "matplotlib (!=3.2.0)", "nbformat", "numpy (>=1.19)", "pandas", "pygments", "pytest", "testpath", "trio"] [[package]] name = "ipython-genutils" @@ -380,6 +601,10 @@ description = "Vestigial utilities from IPython" category = "main" optional = false python-versions = "*" +files = [ + {file = "ipython_genutils-0.2.0-py2.py3-none-any.whl", hash = "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8"}, + {file = "ipython_genutils-0.2.0.tar.gz", hash = "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8"}, +] [[package]] name = "ipywidgets" @@ -388,6 +613,10 @@ description = "IPython HTML widgets for Jupyter" category = "main" optional = false python-versions = "*" +files = [ + {file = "ipywidgets-7.6.5-py2.py3-none-any.whl", hash = "sha256:d258f582f915c62ea91023299603be095de19afb5ee271698f88327b9fe9bf43"}, + {file = "ipywidgets-7.6.5.tar.gz", hash = "sha256:00974f7cb4d5f8d494c19810fedb9fa9b64bffd3cda7c2be23c133a1ad3c99c5"}, +] [package.dependencies] ipykernel = ">=4.5.1" @@ -399,7 +628,7 @@ traitlets = ">=4.3.1" widgetsnbextension = ">=3.5.0,<3.6.0" [package.extras] -test = ["pytest (>=3.6.0)", "pytest-cov", "mock"] +test = ["mock", "pytest (>=3.6.0)", "pytest-cov"] [[package]] name = "jedi" @@ -408,6 +637,10 @@ description = "An autocompletion tool for Python that can be used for text edito category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "jedi-0.18.1-py2.py3-none-any.whl", hash = "sha256:637c9635fcf47945ceb91cd7f320234a7be540ded6f3e99a50cb6febdfd1ba8d"}, + {file = "jedi-0.18.1.tar.gz", hash = "sha256:74137626a64a99c8eb6ae5832d99b3bdd7d29a3850fe2aa80a4126b2a7d949ab"}, +] [package.dependencies] parso = ">=0.8.0,<0.9.0" @@ -423,6 +656,10 @@ description = "A very fast and expressive template engine." category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "Jinja2-3.0.3-py3-none-any.whl", hash = "sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8"}, + {file = "Jinja2-3.0.3.tar.gz", hash = "sha256:611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7"}, +] [package.dependencies] MarkupSafe = ">=2.0" @@ -437,11 +674,15 @@ description = "Python library for serializing any arbitrary object graph into JS category = "main" optional = false python-versions = ">=2.7" +files = [ + {file = "jsonpickle-2.0.0-py2.py3-none-any.whl", hash = "sha256:c1010994c1fbda87a48f8a56698605b598cb0fc6bb7e7927559fc1100e69aeac"}, + {file = "jsonpickle-2.0.0.tar.gz", hash = "sha256:0be49cba80ea6f87a168aa8168d717d00c6ca07ba83df3cec32d3b30bfe6fb9a"}, +] [package.extras] -docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] -testing = ["coverage (<5)", "pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pytest-black-multipy", "pytest-cov", "ecdsa", "feedparser", "numpy", "pandas", "pymongo", "sklearn", "sqlalchemy", "enum34", "jsonlib"] -"testing.libs" = ["demjson", "simplejson", "ujson", "yajl"] +docs = ["jaraco.packaging (>=3.2)", "rst.linker (>=1.9)", "sphinx"] +testing = ["coverage (<5)", "ecdsa", "enum34", "feedparser", "jsonlib", "numpy", "pandas", "pymongo", "pytest (>=3.5,!=3.7.3)", "pytest-black-multipy", "pytest-checkdocs (>=1.2.3)", "pytest-cov", "pytest-flake8", "sklearn", "sqlalchemy"] +testing-libs = ["demjson", "simplejson", "ujson", "yajl"] [[package]] name = "jsonschema" @@ -450,6 +691,10 @@ description = "An implementation of JSON Schema validation for Python" category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "jsonschema-4.4.0-py3-none-any.whl", hash = "sha256:77281a1f71684953ee8b3d488371b162419767973789272434bbc3f29d9c8823"}, + {file = "jsonschema-4.4.0.tar.gz", hash = "sha256:636694eb41b3535ed608fe04129f26542b59ed99808b4f688aa32dcf55317a83"}, +] [package.dependencies] attrs = ">=17.4.0" @@ -458,7 +703,7 @@ pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2" [package.extras] format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"] -format_nongpl = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3986-validator (>0.1.0)", "uri-template", "webcolors (>=1.11)"] +format-nongpl = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3986-validator (>0.1.0)", "uri-template", "webcolors (>=1.11)"] [[package]] name = "jupyter-client" @@ -467,6 +712,10 @@ description = "Jupyter protocol implementation and client libraries" category = "main" optional = false python-versions = ">=3.6.1" +files = [ + {file = "jupyter_client-7.1.0-py3-none-any.whl", hash = "sha256:64d93752d8cbfba0c1030c3335c3f0d9797cd1efac012652a14aac1653db11a3"}, + {file = "jupyter_client-7.1.0.tar.gz", hash = "sha256:a5f995a73cffb314ed262713ae6dfce53c6b8216cea9f332071b8ff44a6e1654"}, +] [package.dependencies] entrypoints = "*" @@ -479,7 +728,7 @@ traitlets = "*" [package.extras] doc = ["myst-parser", "sphinx (>=1.3.6)", "sphinx-rtd-theme", "sphinxcontrib-github-alt"] -test = ["codecov", "coverage", "ipykernel", "ipython", "mock", "mypy", "pre-commit", "pytest", "pytest-asyncio", "pytest-cov", "pytest-timeout", "jedi (<0.18)"] +test = ["codecov", "coverage", "ipykernel", "ipython", "jedi (<0.18)", "mock", "mypy", "pre-commit", "pytest", "pytest-asyncio", "pytest-cov", "pytest-timeout"] [[package]] name = "jupyter-core" @@ -488,6 +737,10 @@ description = "Jupyter core package. A base package on which Jupyter projects re category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "jupyter_core-4.9.1-py3-none-any.whl", hash = "sha256:1c091f3bbefd6f2a8782f2c1db662ca8478ac240e962ae2c66f0b87c818154ea"}, + {file = "jupyter_core-4.9.1.tar.gz", hash = "sha256:dce8a7499da5a53ae3afd5a9f4b02e5df1d57250cf48f3ad79da23b4778cd6fa"}, +] [package.dependencies] pywin32 = {version = ">=1.0", markers = "sys_platform == \"win32\" and platform_python_implementation != \"PyPy\""} @@ -500,6 +753,10 @@ description = "Pygments theme using JupyterLab CSS variables" category = "main" optional = false python-versions = "*" +files = [ + {file = "jupyterlab_pygments-0.1.2-py2.py3-none-any.whl", hash = "sha256:abfb880fd1561987efaefcb2d2ac75145d2a5d0139b1876d5be806e32f630008"}, + {file = "jupyterlab_pygments-0.1.2.tar.gz", hash = "sha256:cfcda0873626150932f438eccf0f8bf22bfa92345b814890ab360d666b254146"}, +] [package.dependencies] pygments = ">=2.4.1,<3" @@ -511,6 +768,10 @@ description = "A JupyterLab extension." category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "jupyterlab_widgets-1.0.2-py3-none-any.whl", hash = "sha256:f5d9efface8ec62941173ba1cffb2edd0ecddc801c11ae2931e30b50492eb8f7"}, + {file = "jupyterlab_widgets-1.0.2.tar.gz", hash = "sha256:7885092b2b96bf189c3a705cc3c412a4472ec5e8382d0b47219a66cccae73cfa"}, +] [[package]] name = "kiwisolver" @@ -519,1016 +780,7 @@ description = "A fast implementation of the Cassowary constraint solver" category = "main" optional = false python-versions = ">=3.7" - -[[package]] -name = "lazy" -version = "1.4" -description = "Lazy attributes for Python objects" -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "lazy-object-proxy" -version = "1.7.1" -description = "A fast and thorough lazy object proxy." -category = "main" -optional = false -python-versions = ">=3.6" - -[[package]] -name = "loguru" -version = "0.5.3" -description = "Python logging made (stupidly) simple" -category = "main" -optional = false -python-versions = ">=3.5" - -[package.dependencies] -colorama = {version = ">=0.3.4", markers = "sys_platform == \"win32\""} -win32-setctime = {version = ">=1.0.0", markers = "sys_platform == \"win32\""} - -[package.extras] -dev = ["codecov (>=2.0.15)", "colorama (>=0.3.4)", "flake8 (>=3.7.7)", "tox (>=3.9.0)", "tox-travis (>=0.12)", "pytest (>=4.6.2)", "pytest-cov (>=2.7.1)", "Sphinx (>=2.2.1)", "sphinx-autobuild (>=0.7.1)", "sphinx-rtd-theme (>=0.4.3)", "black (>=19.10b0)", "isort (>=5.1.1)"] - -[[package]] -name = "logzero" -version = "1.7.0" -description = "Robust and effective logging for Python 2 and 3" -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -colorama = {version = "*", markers = "sys_platform == \"win32\""} - -[[package]] -name = "lru-dict" -version = "1.1.7" -description = "An Dict like LRU container." -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "makefun" -version = "1.13.1" -description = "Small library to dynamically create python functions." -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "markupsafe" -version = "2.0.1" -description = "Safely add untrusted strings to HTML/XML markup." -category = "main" -optional = false -python-versions = ">=3.6" - -[[package]] -name = "matplotlib" -version = "3.5.1" -description = "Python plotting package" -category = "main" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -cycler = ">=0.10" -fonttools = ">=4.22.0" -kiwisolver = ">=1.0.1" -numpy = ">=1.17" -packaging = ">=20.0" -pillow = ">=6.2.0" -pyparsing = ">=2.2.1" -python-dateutil = ">=2.7" -setuptools_scm = ">=4" - -[[package]] -name = "matplotlib-inline" -version = "0.1.3" -description = "Inline Matplotlib backend for Jupyter" -category = "main" -optional = false -python-versions = ">=3.5" - -[package.dependencies] -traitlets = "*" - -[[package]] -name = "mistune" -version = "0.8.4" -description = "The fastest markdown parser in pure Python" -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "mypy-extensions" -version = "0.4.3" -description = "Experimental type system extensions for programs checked with the mypy typechecker." -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "nbclient" -version = "0.5.9" -description = "A client library for executing notebooks. Formerly nbconvert's ExecutePreprocessor." -category = "main" -optional = false -python-versions = ">=3.6.1" - -[package.dependencies] -jupyter-client = ">=6.1.5" -nbformat = ">=5.0" -nest-asyncio = "*" -traitlets = ">=4.2" - -[package.extras] -dev = ["codecov", "coverage", "ipython", "ipykernel", "ipywidgets", "pytest (>=4.1)", "pytest-cov (>=2.6.1)", "check-manifest", "flake8", "mypy", "tox", "xmltodict", "pip (>=18.1)", "wheel (>=0.31.0)", "setuptools (>=38.6.0)", "twine (>=1.11.0)", "black"] -sphinx = ["Sphinx (>=1.7)", "sphinx-book-theme", "mock", "moto", "myst-parser"] -test = ["codecov", "coverage", "ipython", "ipykernel", "ipywidgets", "pytest (>=4.1)", "pytest-cov (>=2.6.1)", "check-manifest", "flake8", "mypy", "tox", "xmltodict", "pip (>=18.1)", "wheel (>=0.31.0)", "setuptools (>=38.6.0)", "twine (>=1.11.0)", "black"] - -[[package]] -name = "nbconvert" -version = "6.4.0" -description = "Converting Jupyter Notebooks" -category = "main" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -bleach = "*" -defusedxml = "*" -entrypoints = ">=0.2.2" -jinja2 = ">=2.4" -jupyter-core = "*" -jupyterlab-pygments = "*" -mistune = ">=0.8.1,<2" -nbclient = ">=0.5.0,<0.6.0" -nbformat = ">=4.4" -pandocfilters = ">=1.4.1" -pygments = ">=2.4.1" -testpath = "*" -traitlets = ">=5.0" - -[package.extras] -all = ["pytest", "pytest-cov", "pytest-dependency", "ipykernel", "ipywidgets (>=7)", "pyppeteer (==0.2.6)", "tornado (>=4.0)", "sphinx (>=1.5.1)", "sphinx-rtd-theme", "nbsphinx (>=0.2.12)", "ipython"] -docs = ["sphinx (>=1.5.1)", "sphinx-rtd-theme", "nbsphinx (>=0.2.12)", "ipython"] -serve = ["tornado (>=4.0)"] -test = ["pytest", "pytest-cov", "pytest-dependency", "ipykernel", "ipywidgets (>=7)", "pyppeteer (==0.2.6)"] -webpdf = ["pyppeteer (==0.2.6)"] - -[[package]] -name = "nbformat" -version = "5.1.3" -description = "The Jupyter Notebook format" -category = "main" -optional = false -python-versions = ">=3.5" - -[package.dependencies] -ipython-genutils = "*" -jsonschema = ">=2.4,<2.5.0 || >2.5.0" -jupyter-core = "*" -traitlets = ">=4.1" - -[package.extras] -fast = ["fastjsonschema"] -test = ["check-manifest", "fastjsonschema", "testpath", "pytest", "pytest-cov"] - -[[package]] -name = "nest-asyncio" -version = "1.5.4" -description = "Patch asyncio to allow nested event loops" -category = "main" -optional = false -python-versions = ">=3.5" - -[[package]] -name = "networkx" -version = "2.6.3" -description = "Python package for creating and manipulating graphs and networks" -category = "main" -optional = false -python-versions = ">=3.7" - -[package.extras] -default = ["numpy (>=1.19)", "scipy (>=1.5,!=1.6.1)", "matplotlib (>=3.3)", "pandas (>=1.1)"] -developer = ["black (==21.5b1)", "pre-commit (>=2.12)"] -doc = ["sphinx (>=4.0,<5.0)", "pydata-sphinx-theme (>=0.6,<1.0)", "sphinx-gallery (>=0.9,<1.0)", "numpydoc (>=1.1)", "pillow (>=8.2)", "nb2plots (>=0.6)", "texext (>=0.6.6)"] -extra = ["lxml (>=4.5)", "pygraphviz (>=1.7)", "pydot (>=1.4.1)"] -test = ["pytest (>=6.2)", "pytest-cov (>=2.12)", "codecov (>=2.1)"] - -[[package]] -name = "notebook" -version = "6.4.7" -description = "A web-based notebook environment for interactive computing" -category = "main" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -argon2-cffi = "*" -ipykernel = "*" -ipython-genutils = "*" -jinja2 = "*" -jupyter-client = ">=5.3.4" -jupyter-core = ">=4.6.1" -nbconvert = "*" -nbformat = "*" -nest-asyncio = ">=1.5" -prometheus-client = "*" -pyzmq = ">=17" -Send2Trash = ">=1.8.0" -terminado = ">=0.8.3" -tornado = ">=6.1" -traitlets = ">=4.2.1" - -[package.extras] -docs = ["sphinx", "nbsphinx", "sphinxcontrib-github-alt", "sphinx-rtd-theme", "myst-parser"] -json-logging = ["json-logging"] -test = ["pytest", "coverage", "requests", "nbval", "selenium", "pytest-cov", "requests-unixsocket"] - -[[package]] -name = "numpy" -version = "1.22.0" -description = "NumPy is the fundamental package for array computing with Python." -category = "main" -optional = false -python-versions = ">=3.8" - -[[package]] -name = "packaging" -version = "21.3" -description = "Core utilities for Python packages" -category = "main" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" - -[[package]] -name = "pandas" -version = "1.3.5" -description = "Powerful data structures for data analysis, time series, and statistics" -category = "main" -optional = false -python-versions = ">=3.7.1" - -[package.dependencies] -numpy = [ - {version = ">=1.17.3", markers = "platform_machine != \"aarch64\" and platform_machine != \"arm64\" and python_version < \"3.10\""}, - {version = ">=1.19.2", markers = "platform_machine == \"aarch64\" and python_version < \"3.10\""}, - {version = ">=1.20.0", markers = "platform_machine == \"arm64\" and python_version < \"3.10\""}, - {version = ">=1.21.0", markers = "python_version >= \"3.10\""}, -] -python-dateutil = ">=2.7.3" -pytz = ">=2017.3" - -[package.extras] -test = ["hypothesis (>=3.58)", "pytest (>=6.0)", "pytest-xdist"] - -[[package]] -name = "pandocfilters" -version = "1.5.0" -description = "Utilities for writing pandoc filters in python" -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" - -[[package]] -name = "parso" -version = "0.8.3" -description = "A Python Parser" -category = "main" -optional = false -python-versions = ">=3.6" - -[package.extras] -qa = ["flake8 (==3.8.3)", "mypy (==0.782)"] -testing = ["docopt", "pytest (<6.0.0)"] - -[[package]] -name = "pathspec" -version = "0.9.0" -description = "Utility library for gitignore style pattern matching of file paths." -category = "main" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" - -[[package]] -name = "pexpect" -version = "4.8.0" -description = "Pexpect allows easy control of interactive console applications." -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -ptyprocess = ">=0.5" - -[[package]] -name = "pickleshare" -version = "0.7.5" -description = "Tiny 'shelve'-like database with concurrency support" -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "pillow" -version = "9.0.0" -description = "Python Imaging Library (Fork)" -category = "main" -optional = false -python-versions = ">=3.7" - -[[package]] -name = "pinject" -version = "0.14.1" -description = "A pythonic dependency injection library" -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -decorator = ">=4.3.0" -six = ">=1.7.3" - -[[package]] -name = "pprintpp" -version = "0.4.0" -description = "A drop-in replacement for pprint that's actually pretty" -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "prometheus-client" -version = "0.12.0" -description = "Python client for the Prometheus monitoring system." -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" - -[package.extras] -twisted = ["twisted"] - -[[package]] -name = "prompt-toolkit" -version = "3.0.24" -description = "Library for building powerful interactive command lines in Python" -category = "main" -optional = false -python-versions = ">=3.6.2" - -[package.dependencies] -wcwidth = "*" - -[[package]] -name = "ptyprocess" -version = "0.7.0" -description = "Run a subprocess in a pseudo terminal" -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "pure-eval" -version = "0.2.1" -description = "Safely evaluate AST nodes without side effects" -category = "main" -optional = false -python-versions = "*" - -[package.extras] -tests = ["pytest"] - -[[package]] -name = "py" -version = "1.11.0" -description = "library with cross-python path, ini-parsing, io, code, log facilities" -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" - -[[package]] -name = "pycparser" -version = "2.21" -description = "C parser in Python" -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" - -[[package]] -name = "pygments" -version = "2.11.2" -description = "Pygments is a syntax highlighting package written in Python." -category = "main" -optional = false -python-versions = ">=3.5" - -[[package]] -name = "pyparsing" -version = "3.0.6" -description = "Python parsing module" -category = "main" -optional = false -python-versions = ">=3.6" - -[package.extras] -diagrams = ["jinja2", "railroad-diagrams"] - -[[package]] -name = "pyrsistent" -version = "0.18.0" -description = "Persistent/Functional/Immutable data structures" -category = "main" -optional = false -python-versions = ">=3.6" - -[[package]] -name = "python-dateutil" -version = "2.8.2" -description = "Extensions to the standard Python datetime module" -category = "main" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" - -[package.dependencies] -six = ">=1.5" - -[[package]] -name = "pytz" -version = "2021.3" -description = "World timezone definitions, modern and historical" -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "pyvis" -version = "0.1.9" -description = "A Python network visualization library" -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -ipython = ">=5.3.0" -jinja2 = ">=2.9.6" -jsonpickle = ">=1.4.1" -networkx = ">=1.11" - -[[package]] -name = "pywin32" -version = "303" -description = "Python for Window Extensions" -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "pywinpty" -version = "1.1.6" -description = "Pseudo terminal support for Windows from Python." -category = "main" -optional = false -python-versions = ">=3.6" - -[[package]] -name = "pyyaml" -version = "6.0" -description = "YAML parser and emitter for Python" -category = "main" -optional = false -python-versions = ">=3.6" - -[[package]] -name = "pyzmq" -version = "22.3.0" -description = "Python bindings for 0MQ" -category = "main" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -cffi = {version = "*", markers = "implementation_name == \"pypy\""} -py = {version = "*", markers = "implementation_name == \"pypy\""} - -[[package]] -name = "regex" -version = "2021.11.10" -description = "Alternative regular expression module, to replace re." -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "retry" -version = "0.9.2" -description = "Easy to use retry decorator." -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -decorator = ">=3.4.2" -py = ">=1.4.26,<2.0.0" - -[[package]] -name = "send2trash" -version = "1.8.0" -description = "Send file to trash natively under Mac OS X, Windows and Linux." -category = "main" -optional = false -python-versions = "*" - -[package.extras] -nativelib = ["pyobjc-framework-cocoa", "pywin32"] -objc = ["pyobjc-framework-cocoa"] -win32 = ["pywin32"] - -[[package]] -name = "setuptools-scm" -version = "6.3.2" -description = "the blessed package to manage your versions by scm tags" -category = "main" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -packaging = ">=20.0" -tomli = ">=1.0.0" - -[package.extras] -toml = ["setuptools (>=42)", "tomli (>=1.0.0)"] - -[[package]] -name = "six" -version = "1.16.0" -description = "Python 2 and 3 compatibility utilities" -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" - -[[package]] -name = "stack-data" -version = "0.1.3" -description = "Extract data from python stack frames and tracebacks for informative displays" -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -asttokens = "*" -executing = "*" -pure-eval = "*" - -[package.extras] -tests = ["pytest", "typeguard", "pygments", "littleutils"] - -[[package]] -name = "tabulate" -version = "0.8.9" -description = "Pretty-print tabular data" -category = "main" -optional = false -python-versions = "*" - -[package.extras] -widechars = ["wcwidth"] - -[[package]] -name = "tblib" -version = "1.7.0" -description = "Traceback serialization library." -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" - -[[package]] -name = "terminado" -version = "0.12.1" -description = "Tornado websocket backend for the Xterm.js Javascript terminal emulator library." -category = "main" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -ptyprocess = {version = "*", markers = "os_name != \"nt\""} -pywinpty = {version = ">=1.1.0", markers = "os_name == \"nt\""} -tornado = ">=4" - -[package.extras] -test = ["pytest"] - -[[package]] -name = "testpath" -version = "0.5.0" -description = "Test utilities for code working with files and commands" -category = "main" -optional = false -python-versions = ">= 3.5" - -[package.extras] -test = ["pytest", "pathlib2"] - -[[package]] -name = "toml" -version = "0.10.2" -description = "Python Library for Tom's Obvious, Minimal Language" -category = "main" -optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" - -[[package]] -name = "tomli" -version = "2.0.0" -description = "A lil' TOML parser" -category = "main" -optional = false -python-versions = ">=3.7" - -[[package]] -name = "toolz" -version = "0.11.2" -description = "List processing tools and functional utilities" -category = "main" -optional = false -python-versions = ">=3.5" - -[[package]] -name = "tornado" -version = "6.1" -description = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed." -category = "main" -optional = false -python-versions = ">= 3.5" - -[[package]] -name = "tqdm" -version = "4.62.3" -description = "Fast, Extensible Progress Meter" -category = "main" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} - -[package.extras] -dev = ["py-make (>=0.1.0)", "twine", "wheel"] -notebook = ["ipywidgets (>=6)"] -telegram = ["requests"] - -[[package]] -name = "traitlets" -version = "5.1.1" -description = "Traitlets Python configuration system" -category = "main" -optional = false -python-versions = ">=3.7" - -[package.extras] -test = ["pytest"] - -[[package]] -name = "traittypes" -version = "0.2.1" -description = "Scipy trait types" -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -traitlets = ">=4.2.2" - -[package.extras] -test = ["numpy", "pandas", "xarray", "pytest"] - -[[package]] -name = "wcwidth" -version = "0.2.5" -description = "Measures the displayed width of unicode strings in a terminal" -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "webencodings" -version = "0.5.1" -description = "Character encoding aliases for legacy web content" -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "widgetsnbextension" -version = "3.5.2" -description = "IPython HTML widgets for Jupyter" -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -notebook = ">=4.4.1" - -[[package]] -name = "win32-setctime" -version = "1.0.4" -description = "A small Python utility to set file creation time on Windows" -category = "main" -optional = false -python-versions = ">=3.5" - -[package.extras] -dev = ["pytest (>=4.6.2)", "black (>=19.3b0)"] - -[[package]] -name = "zipp" -version = "3.7.0" -description = "Backport of pathlib-compatible object wrapper for zip files" -category = "main" -optional = false -python-versions = ">=3.7" - -[package.extras] -docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] -testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"] - -[extras] -torch = [] - -[metadata] -lock-version = "1.1" -python-versions = "^3.8" -content-hash = "f22d4d81f63829db7c2aa8f5a96b08e4c73a0e54bd7cb1e0f73eb468d67a35f3" - -[metadata.files] -appdirs = [ - {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, - {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, -] -appnope = [ - {file = "appnope-0.1.2-py2.py3-none-any.whl", hash = "sha256:93aa393e9d6c54c5cd570ccadd8edad61ea0c4b9ea7a01409020c9aa019eb442"}, - {file = "appnope-0.1.2.tar.gz", hash = "sha256:dd83cd4b5b460958838f6eb3000c660b1f9caf2a5b1de4264e941512f603258a"}, -] -argon2-cffi = [ - {file = "argon2-cffi-21.3.0.tar.gz", hash = "sha256:d384164d944190a7dd7ef22c6aa3ff197da12962bd04b17f64d4e93d934dba5b"}, - {file = "argon2_cffi-21.3.0-py3-none-any.whl", hash = "sha256:8c976986f2c5c0e5000919e6de187906cfd81fb1c72bf9d88c01177e77da7f80"}, -] -argon2-cffi-bindings = [ - {file = "argon2-cffi-bindings-21.2.0.tar.gz", hash = "sha256:bb89ceffa6c791807d1305ceb77dbfacc5aa499891d2c55661c6459651fc39e3"}, - {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:ccb949252cb2ab3a08c02024acb77cfb179492d5701c7cbdbfd776124d4d2367"}, - {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9524464572e12979364b7d600abf96181d3541da11e23ddf565a32e70bd4dc0d"}, - {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b746dba803a79238e925d9046a63aa26bf86ab2a2fe74ce6b009a1c3f5c8f2ae"}, - {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:58ed19212051f49a523abb1dbe954337dc82d947fb6e5a0da60f7c8471a8476c"}, - {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:bd46088725ef7f58b5a1ef7ca06647ebaf0eb4baff7d1d0d177c6cc8744abd86"}, - {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_i686.whl", hash = "sha256:8cd69c07dd875537a824deec19f978e0f2078fdda07fd5c42ac29668dda5f40f"}, - {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:f1152ac548bd5b8bcecfb0b0371f082037e47128653df2e8ba6e914d384f3c3e"}, - {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-win32.whl", hash = "sha256:603ca0aba86b1349b147cab91ae970c63118a0f30444d4bc80355937c950c082"}, - {file = "argon2_cffi_bindings-21.2.0-cp36-abi3-win_amd64.whl", hash = "sha256:b2ef1c30440dbbcba7a5dc3e319408b59676e2e039e2ae11a8775ecf482b192f"}, - {file = "argon2_cffi_bindings-21.2.0-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:e415e3f62c8d124ee16018e491a009937f8cf7ebf5eb430ffc5de21b900dad93"}, - {file = "argon2_cffi_bindings-21.2.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:3e385d1c39c520c08b53d63300c3ecc28622f076f4c2b0e6d7e796e9f6502194"}, - {file = "argon2_cffi_bindings-21.2.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2c3e3cc67fdb7d82c4718f19b4e7a87123caf8a93fde7e23cf66ac0337d3cb3f"}, - {file = "argon2_cffi_bindings-21.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6a22ad9800121b71099d0fb0a65323810a15f2e292f2ba450810a7316e128ee5"}, - {file = "argon2_cffi_bindings-21.2.0-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f9f8b450ed0547e3d473fdc8612083fd08dd2120d6ac8f73828df9b7d45bb351"}, - {file = "argon2_cffi_bindings-21.2.0-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:93f9bf70084f97245ba10ee36575f0c3f1e7d7724d67d8e5b08e61787c320ed7"}, - {file = "argon2_cffi_bindings-21.2.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:3b9ef65804859d335dc6b31582cad2c5166f0c3e7975f324d9ffaa34ee7e6583"}, - {file = "argon2_cffi_bindings-21.2.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d4966ef5848d820776f5f562a7d45fdd70c2f330c961d0d745b784034bd9f48d"}, - {file = "argon2_cffi_bindings-21.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:20ef543a89dee4db46a1a6e206cd015360e5a75822f76df533845c3cbaf72670"}, - {file = "argon2_cffi_bindings-21.2.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ed2937d286e2ad0cc79a7087d3c272832865f779430e0cc2b4f3718d3159b0cb"}, - {file = "argon2_cffi_bindings-21.2.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:5e00316dabdaea0b2dd82d141cc66889ced0cdcbfa599e8b471cf22c620c329a"}, -] -asttokens = [ - {file = "asttokens-2.0.5-py2.py3-none-any.whl", hash = "sha256:0844691e88552595a6f4a4281a9f7f79b8dd45ca4ccea82e5e05b4bbdb76705c"}, - {file = "asttokens-2.0.5.tar.gz", hash = "sha256:9a54c114f02c7a9480d56550932546a3f1fe71d8a02f1bc7ccd0ee3ee35cf4d5"}, -] -attrs = [ - {file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"}, - {file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"}, -] -backcall = [ - {file = "backcall-0.2.0-py2.py3-none-any.whl", hash = "sha256:fbbce6a29f263178a1f7915c1940bde0ec2b2a967566fe1c65c1dfb7422bd255"}, - {file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"}, -] -black = [ - {file = "black-21.6b0-py3-none-any.whl", hash = "sha256:dfb8c5a069012b2ab1e972e7b908f5fb42b6bbabcba0a788b86dc05067c7d9c7"}, - {file = "black-21.6b0.tar.gz", hash = "sha256:dc132348a88d103016726fe360cb9ede02cecf99b76e3660ce6c596be132ce04"}, -] -bleach = [ - {file = "bleach-4.1.0-py2.py3-none-any.whl", hash = "sha256:4d2651ab93271d1129ac9cbc679f524565cc8a1b791909c4a51eac4446a15994"}, - {file = "bleach-4.1.0.tar.gz", hash = "sha256:0900d8b37eba61a802ee40ac0061f8c2b5dee29c1927dd1d233e075ebf5a71da"}, -] -bqplot = [ - {file = "bqplot-0.12.32-py2.py3-none-any.whl", hash = "sha256:815289a0136615bd0fbe05b851471622c27b4e56bda96e0db947c9a5827b8501"}, - {file = "bqplot-0.12.32.tar.gz", hash = "sha256:6fbfb93955ac15f87b6fa37368b04fd00da1f2d43843d8d9bc3d59116c6f5f00"}, -] -cffi = [ - {file = "cffi-1.15.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:c2502a1a03b6312837279c8c1bd3ebedf6c12c4228ddbad40912d671ccc8a962"}, - {file = "cffi-1.15.0-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:23cfe892bd5dd8941608f93348c0737e369e51c100d03718f108bf1add7bd6d0"}, - {file = "cffi-1.15.0-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:41d45de54cd277a7878919867c0f08b0cf817605e4eb94093e7516505d3c8d14"}, - {file = "cffi-1.15.0-cp27-cp27m-win32.whl", hash = "sha256:4a306fa632e8f0928956a41fa8e1d6243c71e7eb59ffbd165fc0b41e316b2474"}, - {file = "cffi-1.15.0-cp27-cp27m-win_amd64.whl", hash = "sha256:e7022a66d9b55e93e1a845d8c9eba2a1bebd4966cd8bfc25d9cd07d515b33fa6"}, - {file = "cffi-1.15.0-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:14cd121ea63ecdae71efa69c15c5543a4b5fbcd0bbe2aad864baca0063cecf27"}, - {file = "cffi-1.15.0-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:d4d692a89c5cf08a8557fdeb329b82e7bf609aadfaed6c0d79f5a449a3c7c023"}, - {file = "cffi-1.15.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0104fb5ae2391d46a4cb082abdd5c69ea4eab79d8d44eaaf79f1b1fd806ee4c2"}, - {file = "cffi-1.15.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:91ec59c33514b7c7559a6acda53bbfe1b283949c34fe7440bcf917f96ac0723e"}, - {file = "cffi-1.15.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:f5c7150ad32ba43a07c4479f40241756145a1f03b43480e058cfd862bf5041c7"}, - {file = "cffi-1.15.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:00c878c90cb53ccfaae6b8bc18ad05d2036553e6d9d1d9dbcf323bbe83854ca3"}, - {file = "cffi-1.15.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:abb9a20a72ac4e0fdb50dae135ba5e77880518e742077ced47eb1499e29a443c"}, - {file = "cffi-1.15.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a5263e363c27b653a90078143adb3d076c1a748ec9ecc78ea2fb916f9b861962"}, - {file = "cffi-1.15.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f54a64f8b0c8ff0b64d18aa76675262e1700f3995182267998c31ae974fbc382"}, - {file = "cffi-1.15.0-cp310-cp310-win32.whl", hash = "sha256:c21c9e3896c23007803a875460fb786118f0cdd4434359577ea25eb556e34c55"}, - {file = "cffi-1.15.0-cp310-cp310-win_amd64.whl", hash = "sha256:5e069f72d497312b24fcc02073d70cb989045d1c91cbd53979366077959933e0"}, - {file = "cffi-1.15.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:64d4ec9f448dfe041705426000cc13e34e6e5bb13736e9fd62e34a0b0c41566e"}, - {file = "cffi-1.15.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2756c88cbb94231c7a147402476be2c4df2f6078099a6f4a480d239a8817ae39"}, - {file = "cffi-1.15.0-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3b96a311ac60a3f6be21d2572e46ce67f09abcf4d09344c49274eb9e0bf345fc"}, - {file = "cffi-1.15.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:75e4024375654472cc27e91cbe9eaa08567f7fbdf822638be2814ce059f58032"}, - {file = "cffi-1.15.0-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:59888172256cac5629e60e72e86598027aca6bf01fa2465bdb676d37636573e8"}, - {file = "cffi-1.15.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:27c219baf94952ae9d50ec19651a687b826792055353d07648a5695413e0c605"}, - {file = "cffi-1.15.0-cp36-cp36m-win32.whl", hash = "sha256:4958391dbd6249d7ad855b9ca88fae690783a6be9e86df65865058ed81fc860e"}, - {file = "cffi-1.15.0-cp36-cp36m-win_amd64.whl", hash = "sha256:f6f824dc3bce0edab5f427efcfb1d63ee75b6fcb7282900ccaf925be84efb0fc"}, - {file = "cffi-1.15.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:06c48159c1abed75c2e721b1715c379fa3200c7784271b3c46df01383b593636"}, - {file = "cffi-1.15.0-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:c2051981a968d7de9dd2d7b87bcb9c939c74a34626a6e2f8181455dd49ed69e4"}, - {file = "cffi-1.15.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:fd8a250edc26254fe5b33be00402e6d287f562b6a5b2152dec302fa15bb3e997"}, - {file = "cffi-1.15.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:91d77d2a782be4274da750752bb1650a97bfd8f291022b379bb8e01c66b4e96b"}, - {file = "cffi-1.15.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:45db3a33139e9c8f7c09234b5784a5e33d31fd6907800b316decad50af323ff2"}, - {file = "cffi-1.15.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:263cc3d821c4ab2213cbe8cd8b355a7f72a8324577dc865ef98487c1aeee2bc7"}, - {file = "cffi-1.15.0-cp37-cp37m-win32.whl", hash = "sha256:17771976e82e9f94976180f76468546834d22a7cc404b17c22df2a2c81db0c66"}, - {file = "cffi-1.15.0-cp37-cp37m-win_amd64.whl", hash = "sha256:3415c89f9204ee60cd09b235810be700e993e343a408693e80ce7f6a40108029"}, - {file = "cffi-1.15.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4238e6dab5d6a8ba812de994bbb0a79bddbdf80994e4ce802b6f6f3142fcc880"}, - {file = "cffi-1.15.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0808014eb713677ec1292301ea4c81ad277b6cdf2fdd90fd540af98c0b101d20"}, - {file = "cffi-1.15.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:57e9ac9ccc3101fac9d6014fba037473e4358ef4e89f8e181f8951a2c0162024"}, - {file = "cffi-1.15.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8b6c2ea03845c9f501ed1313e78de148cd3f6cad741a75d43a29b43da27f2e1e"}, - {file = "cffi-1.15.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:10dffb601ccfb65262a27233ac273d552ddc4d8ae1bf93b21c94b8511bffe728"}, - {file = "cffi-1.15.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:786902fb9ba7433aae840e0ed609f45c7bcd4e225ebb9c753aa39725bb3e6ad6"}, - {file = "cffi-1.15.0-cp38-cp38-win32.whl", hash = "sha256:da5db4e883f1ce37f55c667e5c0de439df76ac4cb55964655906306918e7363c"}, - {file = "cffi-1.15.0-cp38-cp38-win_amd64.whl", hash = "sha256:181dee03b1170ff1969489acf1c26533710231c58f95534e3edac87fff06c443"}, - {file = "cffi-1.15.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:45e8636704eacc432a206ac7345a5d3d2c62d95a507ec70d62f23cd91770482a"}, - {file = "cffi-1.15.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:31fb708d9d7c3f49a60f04cf5b119aeefe5644daba1cd2a0fe389b674fd1de37"}, - {file = "cffi-1.15.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:6dc2737a3674b3e344847c8686cf29e500584ccad76204efea14f451d4cc669a"}, - {file = "cffi-1.15.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:74fdfdbfdc48d3f47148976f49fab3251e550a8720bebc99bf1483f5bfb5db3e"}, - {file = "cffi-1.15.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ffaa5c925128e29efbde7301d8ecaf35c8c60ffbcd6a1ffd3a552177c8e5e796"}, - {file = "cffi-1.15.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3f7d084648d77af029acb79a0ff49a0ad7e9d09057a9bf46596dac9514dc07df"}, - {file = "cffi-1.15.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ef1f279350da2c586a69d32fc8733092fd32cc8ac95139a00377841f59a3f8d8"}, - {file = "cffi-1.15.0-cp39-cp39-win32.whl", hash = "sha256:2a23af14f408d53d5e6cd4e3d9a24ff9e05906ad574822a10563efcef137979a"}, - {file = "cffi-1.15.0-cp39-cp39-win_amd64.whl", hash = "sha256:3773c4d81e6e818df2efbc7dd77325ca0dcb688116050fb2b3011218eda36139"}, - {file = "cffi-1.15.0.tar.gz", hash = "sha256:920f0d66a896c2d99f0adbb391f990a84091179542c205fa53ce5787aff87954"}, -] -click = [ - {file = "click-8.0.3-py3-none-any.whl", hash = "sha256:353f466495adaeb40b6b5f592f9f91cb22372351c84caeb068132442a4518ef3"}, - {file = "click-8.0.3.tar.gz", hash = "sha256:410e932b050f5eed773c4cda94de75971c89cdb3155a72a0831139a79e5ecb5b"}, -] -colorama = [ - {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, - {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, -] -cycler = [ - {file = "cycler-0.11.0-py3-none-any.whl", hash = "sha256:3a27e95f763a428a739d2add979fa7494c912a32c17c4c38c4d5f082cad165a3"}, - {file = "cycler-0.11.0.tar.gz", hash = "sha256:9c87405839a19696e837b3b818fed3f5f69f16f1eec1a1ad77e043dcea9c772f"}, -] -cytoolz = [ - {file = "cytoolz-0.11.2.tar.gz", hash = "sha256:ea23663153806edddce7e4153d1d407d62357c05120a4e8485bddf1bd5ab22b4"}, -] -debugpy = [ - {file = "debugpy-1.5.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:70b422c63a833630c33e3f9cdbd9b6971f8c5afd452697e464339a21bbe862ba"}, - {file = "debugpy-1.5.1-cp310-cp310-win32.whl", hash = "sha256:3a457ad9c0059a21a6c7d563c1f18e924f5cf90278c722bd50ede6f56b77c7fe"}, - {file = "debugpy-1.5.1-cp310-cp310-win_amd64.whl", hash = "sha256:5d76a4fd028d8009c3faf1185b4b78ceb2273dd2499447664b03939e0368bb90"}, - {file = "debugpy-1.5.1-cp36-cp36m-macosx_10_15_x86_64.whl", hash = "sha256:16db27b4b91991442f91d73604d32080b30de655aca9ba821b1972ea8171021b"}, - {file = "debugpy-1.5.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2b073ad5e8d8c488fbb6a116986858bab0c9c4558f28deb8832c7a5a27405bd6"}, - {file = "debugpy-1.5.1-cp36-cp36m-win32.whl", hash = "sha256:318f81f37341e4e054b4267d39896b73cddb3612ca13b39d7eea45af65165e1d"}, - {file = "debugpy-1.5.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b5b3157372e0e0a1297a8b6b5280bcf1d35a40f436c7973771c972726d1e32d5"}, - {file = "debugpy-1.5.1-cp37-cp37m-macosx_10_15_x86_64.whl", hash = "sha256:1ec3a086e14bba6c472632025b8fe5bdfbaef2afa1ebd5c6615ce6ed8d89bc67"}, - {file = "debugpy-1.5.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:26fbe53cca45a608679094791ce587b6e2798acd1d4777a8b303b07622e85182"}, - {file = "debugpy-1.5.1-cp37-cp37m-win32.whl", hash = "sha256:d876db8c312eeb02d85611e0f696abe66a2c1515e6405943609e725d5ff36f2a"}, - {file = "debugpy-1.5.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4404a62fb5332ea5c8c9132290eef50b3a0ba38cecacad5529e969a783bcbdd7"}, - {file = "debugpy-1.5.1-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:f3a3dca9104aa14fd4210edcce6d9ce2b65bd9618c0b222135a40b9d6e2a9eeb"}, - {file = "debugpy-1.5.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:b2df2c373e85871086bd55271c929670cd4e1dba63e94a08d442db830646203b"}, - {file = "debugpy-1.5.1-cp38-cp38-win32.whl", hash = "sha256:82f5f9ce93af6861a0713f804e62ab390bb12a17f113153e47fea8bbb1dfbe36"}, - {file = "debugpy-1.5.1-cp38-cp38-win_amd64.whl", hash = "sha256:17a25ce9d7714f92fc97ef00cc06269d7c2b163094990ada30156ed31d9a5030"}, - {file = "debugpy-1.5.1-cp39-cp39-macosx_10_15_x86_64.whl", hash = "sha256:01e98c594b3e66d529e40edf314f849cd1a21f7a013298df58cd8e263bf8e184"}, - {file = "debugpy-1.5.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f73988422b17f071ad3c4383551ace1ba5ed810cbab5f9c362783d22d40a08dc"}, - {file = "debugpy-1.5.1-cp39-cp39-win32.whl", hash = "sha256:23df67fc56d59e386c342428a7953c2c06cc226d8525b11319153e96afb65b0c"}, - {file = "debugpy-1.5.1-cp39-cp39-win_amd64.whl", hash = "sha256:a2aa64f6d2ca7ded8a7e8a4e7cae3bc71866b09876b7b05cecad231779cb9156"}, - {file = "debugpy-1.5.1-py2.py3-none-any.whl", hash = "sha256:194f95dd3e84568b5489aab5689a3a2c044e8fdc06f1890b8b4f70b6b89f2778"}, - {file = "debugpy-1.5.1.zip", hash = "sha256:d2b09e91fbd1efa4f4fda121d49af89501beda50c18ed7499712c71a4bf3452e"}, -] -decorator = [ - {file = "decorator-5.1.1-py3-none-any.whl", hash = "sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"}, - {file = "decorator-5.1.1.tar.gz", hash = "sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330"}, -] -defusedxml = [ - {file = "defusedxml-0.7.1-py2.py3-none-any.whl", hash = "sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61"}, - {file = "defusedxml-0.7.1.tar.gz", hash = "sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69"}, -] -dill = [ - {file = "dill-0.3.4-py2.py3-none-any.whl", hash = "sha256:7e40e4a70304fd9ceab3535d36e58791d9c4a776b38ec7f7ec9afc8d3dca4d4f"}, - {file = "dill-0.3.4.zip", hash = "sha256:9f9734205146b2b353ab3fec9af0070237b6ddae78452af83d2fca84d739e675"}, -] -easydict = [ - {file = "easydict-1.9.tar.gz", hash = "sha256:3f3f0dab07c299f0f4df032db1f388d985bb57fa4c5be30acd25c5f9a516883b"}, -] -entrypoints = [ - {file = "entrypoints-0.3-py2.py3-none-any.whl", hash = "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19"}, - {file = "entrypoints-0.3.tar.gz", hash = "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451"}, -] -executing = [ - {file = "executing-0.8.2-py2.py3-none-any.whl", hash = "sha256:32fc6077b103bd19e6494a72682d66d5763cf20a106d5aa7c5ccbea4e47b0df7"}, - {file = "executing-0.8.2.tar.gz", hash = "sha256:c23bf42e9a7b9b212f185b1b2c3c91feb895963378887bb10e64a2e612ec0023"}, -] -expression = [ - {file = "Expression-1.1.1-py3-none-any.whl", hash = "sha256:909c6f109687e00514183e2fd2483f2942acccfab7bd1ba489baed236d332580"}, - {file = "Expression-1.1.1.tar.gz", hash = "sha256:beb1befd68de2ccb7888c4944e6c3b3113cb6916caba1562dde3bb1991240018"}, -] -filelock = [ - {file = "filelock-3.4.2-py3-none-any.whl", hash = "sha256:cf0fc6a2f8d26bd900f19bf33915ca70ba4dd8c56903eeb14e1e7a2fd7590146"}, - {file = "filelock-3.4.2.tar.gz", hash = "sha256:38b4f4c989f9d06d44524df1b24bd19e167d851f19b50bf3e3559952dddc5b80"}, -] -fonttools = [ - {file = "fonttools-4.28.5-py3-none-any.whl", hash = "sha256:edf251d5d2cc0580d5f72de4621c338d8c66c5f61abb50cf486640f73c8194d5"}, - {file = "fonttools-4.28.5.zip", hash = "sha256:545c05d0f7903a863c2020e07b8f0a57517f2c40d940bded77076397872d14ca"}, -] -frozendict = [ - {file = "frozendict-2.1.3-py3-none-any.whl", hash = "sha256:cfa47860932d549947157d68f246898f60b05da392f67219a913b85d8c36b1b2"}, - {file = "frozendict-2.1.3.tar.gz", hash = "sha256:7a12336ba271066e1261a70d8ba97d5178392f3b317b31c6686e401423e70670"}, -] -h5py = [ - {file = "h5py-3.6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a5320837c60870911645e9a935099bdb2be6a786fcf0dac5c860f3b679e2de55"}, - {file = "h5py-3.6.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98646e659bf8591a2177e12a4461dced2cad72da0ba4247643fd118db88880d2"}, - {file = "h5py-3.6.0-cp310-cp310-win_amd64.whl", hash = "sha256:5996ff5adefd2d68c330a4265b6ef92e51b2fc674834a5990add5033bf109e20"}, - {file = "h5py-3.6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:c9a5529343a619fea777b7caa27d493595b28b5af8b005e8d1817559fcccf493"}, - {file = "h5py-3.6.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:e2b49c48df05e19bb20b400b7ff7dc6f1ee36b84dc717c3771c468b33697b466"}, - {file = "h5py-3.6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cd9447633b0bafaf82190d9a8d56f3cb2e8d30169483aee67d800816e028190a"}, - {file = "h5py-3.6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:1c5acc660c458421e88c4c5fe092ce15923adfac4c732af1ac4fced683a5ea97"}, - {file = "h5py-3.6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:35ab552c6f0a93365b3cb5664a5305f3920daa0a43deb5b2c547c52815ec46b9"}, - {file = "h5py-3.6.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:542781d50e1182b8fb619b1265dfe1c765e18215f818b0ab28b2983c28471325"}, - {file = "h5py-3.6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9f39242960b8d7f86f3056cc2546aa3047ff4835985f6483229af8f029e9c8db"}, - {file = "h5py-3.6.0-cp38-cp38-win_amd64.whl", hash = "sha256:8ecedf16c613973622a334701f67edcc0249469f9daa0576e994fb20ac0405db"}, - {file = "h5py-3.6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d8cacad89aa7daf3626fce106f7f2662ac35b14849df22d252d0d8fab9dc1c0b"}, - {file = "h5py-3.6.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:dbaa1ed9768bf9ff04af0919acc55746e62b28333644f0251f38768313f31745"}, - {file = "h5py-3.6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:954c5c39a09b5302f69f752c3bbf165d368a65c8d200f7d5655e0fa6368a75e6"}, - {file = "h5py-3.6.0-cp39-cp39-win_amd64.whl", hash = "sha256:9fd8a14236fdd092a20c0bdf25c3aba3777718d266fabb0fdded4fcf252d1630"}, - {file = "h5py-3.6.0.tar.gz", hash = "sha256:8752d2814a92aba4e2b2a5922d2782d0029102d99caaf3c201a566bc0b40db29"}, -] -importlib-resources = [ - {file = "importlib_resources-5.4.0-py3-none-any.whl", hash = "sha256:33a95faed5fc19b4bc16b29a6eeae248a3fe69dd55d4d229d2b480e23eeaad45"}, - {file = "importlib_resources-5.4.0.tar.gz", hash = "sha256:d756e2f85dd4de2ba89be0b21dba2a3bbec2e871a42a3a16719258a11f87506b"}, -] -ipykernel = [ - {file = "ipykernel-6.6.1-py3-none-any.whl", hash = "sha256:de99f6c1caa72578305cc96122ee3a19669e9c1958694a2b564ed1be28240ab9"}, - {file = "ipykernel-6.6.1.tar.gz", hash = "sha256:91ff0058b45660aad4a68088041059c0d378cd53fc8aff60e5abc91bcc049353"}, -] -ipython = [ - {file = "ipython-8.0.0-py3-none-any.whl", hash = "sha256:5b58cf977635abad74d76be49dbb2e97fddd825fb8503083d55496aa1160b854"}, - {file = "ipython-8.0.0.tar.gz", hash = "sha256:004a0d05aeecd32adec4841b6e2586d5ca35785b1477db4d8333a39333e0ce98"}, -] -ipython-genutils = [ - {file = "ipython_genutils-0.2.0-py2.py3-none-any.whl", hash = "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8"}, - {file = "ipython_genutils-0.2.0.tar.gz", hash = "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8"}, -] -ipywidgets = [ - {file = "ipywidgets-7.6.5-py2.py3-none-any.whl", hash = "sha256:d258f582f915c62ea91023299603be095de19afb5ee271698f88327b9fe9bf43"}, - {file = "ipywidgets-7.6.5.tar.gz", hash = "sha256:00974f7cb4d5f8d494c19810fedb9fa9b64bffd3cda7c2be23c133a1ad3c99c5"}, -] -jedi = [ - {file = "jedi-0.18.1-py2.py3-none-any.whl", hash = "sha256:637c9635fcf47945ceb91cd7f320234a7be540ded6f3e99a50cb6febdfd1ba8d"}, - {file = "jedi-0.18.1.tar.gz", hash = "sha256:74137626a64a99c8eb6ae5832d99b3bdd7d29a3850fe2aa80a4126b2a7d949ab"}, -] -jinja2 = [ - {file = "Jinja2-3.0.3-py3-none-any.whl", hash = "sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8"}, - {file = "Jinja2-3.0.3.tar.gz", hash = "sha256:611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7"}, -] -jsonpickle = [ - {file = "jsonpickle-2.0.0-py2.py3-none-any.whl", hash = "sha256:c1010994c1fbda87a48f8a56698605b598cb0fc6bb7e7927559fc1100e69aeac"}, - {file = "jsonpickle-2.0.0.tar.gz", hash = "sha256:0be49cba80ea6f87a168aa8168d717d00c6ca07ba83df3cec32d3b30bfe6fb9a"}, -] -jsonschema = [ - {file = "jsonschema-4.4.0-py3-none-any.whl", hash = "sha256:77281a1f71684953ee8b3d488371b162419767973789272434bbc3f29d9c8823"}, - {file = "jsonschema-4.4.0.tar.gz", hash = "sha256:636694eb41b3535ed608fe04129f26542b59ed99808b4f688aa32dcf55317a83"}, -] -jupyter-client = [ - {file = "jupyter_client-7.1.0-py3-none-any.whl", hash = "sha256:64d93752d8cbfba0c1030c3335c3f0d9797cd1efac012652a14aac1653db11a3"}, - {file = "jupyter_client-7.1.0.tar.gz", hash = "sha256:a5f995a73cffb314ed262713ae6dfce53c6b8216cea9f332071b8ff44a6e1654"}, -] -jupyter-core = [ - {file = "jupyter_core-4.9.1-py3-none-any.whl", hash = "sha256:1c091f3bbefd6f2a8782f2c1db662ca8478ac240e962ae2c66f0b87c818154ea"}, - {file = "jupyter_core-4.9.1.tar.gz", hash = "sha256:dce8a7499da5a53ae3afd5a9f4b02e5df1d57250cf48f3ad79da23b4778cd6fa"}, -] -jupyterlab-pygments = [ - {file = "jupyterlab_pygments-0.1.2-py2.py3-none-any.whl", hash = "sha256:abfb880fd1561987efaefcb2d2ac75145d2a5d0139b1876d5be806e32f630008"}, - {file = "jupyterlab_pygments-0.1.2.tar.gz", hash = "sha256:cfcda0873626150932f438eccf0f8bf22bfa92345b814890ab360d666b254146"}, -] -jupyterlab-widgets = [ - {file = "jupyterlab_widgets-1.0.2-py3-none-any.whl", hash = "sha256:f5d9efface8ec62941173ba1cffb2edd0ecddc801c11ae2931e30b50492eb8f7"}, - {file = "jupyterlab_widgets-1.0.2.tar.gz", hash = "sha256:7885092b2b96bf189c3a705cc3c412a4472ec5e8382d0b47219a66cccae73cfa"}, -] -kiwisolver = [ +files = [ {file = "kiwisolver-1.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:1d819553730d3c2724582124aee8a03c846ec4362ded1034c16fb3ef309264e6"}, {file = "kiwisolver-1.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:8d93a1095f83e908fc253f2fb569c2711414c0bfd451cab580466465b235b470"}, {file = "kiwisolver-1.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c4550a359c5157aaf8507e6820d98682872b9100ce7607f8aa070b4b8af6c298"}, @@ -1574,11 +826,27 @@ kiwisolver = [ {file = "kiwisolver-1.3.2-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:bcadb05c3d4794eb9eee1dddf1c24215c92fb7b55a80beae7a60530a91060560"}, {file = "kiwisolver-1.3.2.tar.gz", hash = "sha256:fc4453705b81d03568d5b808ad8f09c77c47534f6ac2e72e733f9ca4714aa75c"}, ] -lazy = [ + +[[package]] +name = "lazy" +version = "1.4" +description = "Lazy attributes for Python objects" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "lazy-1.4-py2.py3-none-any.whl", hash = "sha256:9f293fd531546f3eda039da8f919b513b94f219e562764e3ceefc26fa503bf03"}, {file = "lazy-1.4.zip", hash = "sha256:2c6d27a5ab130fb85435320651a47403adcb37ecbcc501b0c6606391f65f5b43"}, ] -lazy-object-proxy = [ + +[[package]] +name = "lazy-object-proxy" +version = "1.7.1" +description = "A fast and thorough lazy object proxy." +category = "main" +optional = false +python-versions = ">=3.6" +files = [ {file = "lazy-object-proxy-1.7.1.tar.gz", hash = "sha256:d609c75b986def706743cdebe5e47553f4a5a1da9c5ff66d76013ef396b5a8a4"}, {file = "lazy_object_proxy-1.7.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:bb8c5fd1684d60a9902c60ebe276da1f2281a318ca16c1d0a96db28f62e9166b"}, {file = "lazy_object_proxy-1.7.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a57d51ed2997e97f3b8e3500c984db50a554bb5db56c50b5dab1b41339b37e36"}, @@ -1617,22 +885,72 @@ lazy-object-proxy = [ {file = "lazy_object_proxy-1.7.1-cp39-cp39-win_amd64.whl", hash = "sha256:677ea950bef409b47e51e733283544ac3d660b709cfce7b187f5ace137960d61"}, {file = "lazy_object_proxy-1.7.1-pp37.pp38-none-any.whl", hash = "sha256:d66906d5785da8e0be7360912e99c9188b70f52c422f9fc18223347235691a84"}, ] -loguru = [ + +[[package]] +name = "loguru" +version = "0.5.3" +description = "Python logging made (stupidly) simple" +category = "main" +optional = false +python-versions = ">=3.5" +files = [ {file = "loguru-0.5.3-py3-none-any.whl", hash = "sha256:f8087ac396b5ee5f67c963b495d615ebbceac2796379599820e324419d53667c"}, {file = "loguru-0.5.3.tar.gz", hash = "sha256:b28e72ac7a98be3d28ad28570299a393dfcd32e5e3f6a353dec94675767b6319"}, ] -logzero = [ + +[package.dependencies] +colorama = {version = ">=0.3.4", markers = "sys_platform == \"win32\""} +win32-setctime = {version = ">=1.0.0", markers = "sys_platform == \"win32\""} + +[package.extras] +dev = ["Sphinx (>=2.2.1)", "black (>=19.10b0)", "codecov (>=2.0.15)", "colorama (>=0.3.4)", "flake8 (>=3.7.7)", "isort (>=5.1.1)", "pytest (>=4.6.2)", "pytest-cov (>=2.7.1)", "sphinx-autobuild (>=0.7.1)", "sphinx-rtd-theme (>=0.4.3)", "tox (>=3.9.0)", "tox-travis (>=0.12)"] + +[[package]] +name = "logzero" +version = "1.7.0" +description = "Robust and effective logging for Python 2 and 3" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "logzero-1.7.0-py2.py3-none-any.whl", hash = "sha256:23eb1f717a2736f9ab91ca0d43160fd2c996ad49ae6bad34652d47aba908769d"}, {file = "logzero-1.7.0.tar.gz", hash = "sha256:7f73ddd3ae393457236f081ffebd044a3aa2e423a47ae6ddb5179ab90d0ad082"}, ] -lru-dict = [ + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} + +[[package]] +name = "lru-dict" +version = "1.1.7" +description = "An Dict like LRU container." +category = "main" +optional = false +python-versions = "*" +files = [ {file = "lru-dict-1.1.7.tar.gz", hash = "sha256:45b81f67d75341d4433abade799a47e9c42a9e22a118531dcb5e549864032d7c"}, ] -makefun = [ + +[[package]] +name = "makefun" +version = "1.13.1" +description = "Small library to dynamically create python functions." +category = "main" +optional = false +python-versions = "*" +files = [ {file = "makefun-1.13.1-py2.py3-none-any.whl", hash = "sha256:f10ea6e570d06e84d5488dd109cc09a3127ebbdc0696ddb7bfc234263ab2ac26"}, {file = "makefun-1.13.1.tar.gz", hash = "sha256:985bb8b670ffbbb95d2a8aa996d318e6e9a3f26fc6f3ef2da93ebdf8f9c616bf"}, ] -markupsafe = [ + +[[package]] +name = "markupsafe" +version = "2.0.1" +description = "Safely add untrusted strings to HTML/XML markup." +category = "main" +optional = false +python-versions = ">=3.6" +files = [ {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53"}, {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38"}, {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad"}, @@ -1703,7 +1021,15 @@ markupsafe = [ {file = "MarkupSafe-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8"}, {file = "MarkupSafe-2.0.1.tar.gz", hash = "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a"}, ] -matplotlib = [ + +[[package]] +name = "matplotlib" +version = "3.5.1" +description = "Python plotting package" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ {file = "matplotlib-3.5.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:456cc8334f6d1124e8ff856b42d2cc1c84335375a16448189999496549f7182b"}, {file = "matplotlib-3.5.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:8a77906dc2ef9b67407cec0bdbf08e3971141e535db888974a915be5e1e3efc6"}, {file = "matplotlib-3.5.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8e70ae6475cfd0fad3816dcbf6cac536dc6f100f7474be58d59fa306e6e768a4"}, @@ -1740,43 +1066,208 @@ matplotlib = [ {file = "matplotlib-3.5.1-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:14334b9902ec776461c4b8c6516e26b450f7ebe0b3ef8703bf5cdfbbaecf774a"}, {file = "matplotlib-3.5.1.tar.gz", hash = "sha256:b2e9810e09c3a47b73ce9cab5a72243a1258f61e7900969097a817232246ce1c"}, ] -matplotlib-inline = [ + +[package.dependencies] +cycler = ">=0.10" +fonttools = ">=4.22.0" +kiwisolver = ">=1.0.1" +numpy = ">=1.17" +packaging = ">=20.0" +pillow = ">=6.2.0" +pyparsing = ">=2.2.1" +python-dateutil = ">=2.7" + +[[package]] +name = "matplotlib-inline" +version = "0.1.3" +description = "Inline Matplotlib backend for Jupyter" +category = "main" +optional = false +python-versions = ">=3.5" +files = [ {file = "matplotlib-inline-0.1.3.tar.gz", hash = "sha256:a04bfba22e0d1395479f866853ec1ee28eea1485c1d69a6faf00dc3e24ff34ee"}, {file = "matplotlib_inline-0.1.3-py3-none-any.whl", hash = "sha256:aed605ba3b72462d64d475a21a9296f400a19c4f74a31b59103d2a99ffd5aa5c"}, ] -mistune = [ + +[package.dependencies] +traitlets = "*" + +[[package]] +name = "mistune" +version = "0.8.4" +description = "The fastest markdown parser in pure Python" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "mistune-0.8.4-py2.py3-none-any.whl", hash = "sha256:88a1051873018da288eee8538d476dffe1262495144b33ecb586c4ab266bb8d4"}, {file = "mistune-0.8.4.tar.gz", hash = "sha256:59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e"}, ] -mypy-extensions = [ + +[[package]] +name = "mypy-extensions" +version = "0.4.3" +description = "Experimental type system extensions for programs checked with the mypy typechecker." +category = "main" +optional = false +python-versions = "*" +files = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] -nbclient = [ + +[[package]] +name = "nbclient" +version = "0.5.9" +description = "A client library for executing notebooks. Formerly nbconvert's ExecutePreprocessor." +category = "main" +optional = false +python-versions = ">=3.6.1" +files = [ {file = "nbclient-0.5.9-py3-none-any.whl", hash = "sha256:8a307be4129cce5f70eb83a57c3edbe45656623c31de54e38bb6fdfbadc428b3"}, {file = "nbclient-0.5.9.tar.gz", hash = "sha256:99e46ddafacd0b861293bf246fed8540a184adfa3aa7d641f89031ec070701e0"}, ] -nbconvert = [ + +[package.dependencies] +jupyter-client = ">=6.1.5" +nbformat = ">=5.0" +nest-asyncio = "*" +traitlets = ">=4.2" + +[package.extras] +dev = ["black", "check-manifest", "codecov", "coverage", "flake8", "ipykernel", "ipython", "ipywidgets", "mypy", "pip (>=18.1)", "pytest (>=4.1)", "pytest-cov (>=2.6.1)", "setuptools (>=38.6.0)", "tox", "twine (>=1.11.0)", "wheel (>=0.31.0)", "xmltodict"] +sphinx = ["Sphinx (>=1.7)", "mock", "moto", "myst-parser", "sphinx-book-theme"] +test = ["black", "check-manifest", "codecov", "coverage", "flake8", "ipykernel", "ipython", "ipywidgets", "mypy", "pip (>=18.1)", "pytest (>=4.1)", "pytest-cov (>=2.6.1)", "setuptools (>=38.6.0)", "tox", "twine (>=1.11.0)", "wheel (>=0.31.0)", "xmltodict"] + +[[package]] +name = "nbconvert" +version = "6.4.0" +description = "Converting Jupyter Notebooks" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ {file = "nbconvert-6.4.0-py3-none-any.whl", hash = "sha256:f5ec6a1fad9e3aa2bee7c6a1c4ad3e0fafaa7ff64f29ba56d9da7e1669f8521c"}, {file = "nbconvert-6.4.0.tar.gz", hash = "sha256:5412ec774c6db4fccecb8c4ba07ec5d37d6dcf5762593cb3d6ecbbeb562ebbe5"}, ] -nbformat = [ + +[package.dependencies] +bleach = "*" +defusedxml = "*" +entrypoints = ">=0.2.2" +jinja2 = ">=2.4" +jupyter-core = "*" +jupyterlab-pygments = "*" +mistune = ">=0.8.1,<2" +nbclient = ">=0.5.0,<0.6.0" +nbformat = ">=4.4" +pandocfilters = ">=1.4.1" +pygments = ">=2.4.1" +testpath = "*" +traitlets = ">=5.0" + +[package.extras] +all = ["ipykernel", "ipython", "ipywidgets (>=7)", "nbsphinx (>=0.2.12)", "pyppeteer (==0.2.6)", "pytest", "pytest-cov", "pytest-dependency", "sphinx (>=1.5.1)", "sphinx-rtd-theme", "tornado (>=4.0)"] +docs = ["ipython", "nbsphinx (>=0.2.12)", "sphinx (>=1.5.1)", "sphinx-rtd-theme"] +serve = ["tornado (>=4.0)"] +test = ["ipykernel", "ipywidgets (>=7)", "pyppeteer (==0.2.6)", "pytest", "pytest-cov", "pytest-dependency"] +webpdf = ["pyppeteer (==0.2.6)"] + +[[package]] +name = "nbformat" +version = "5.1.3" +description = "The Jupyter Notebook format" +category = "main" +optional = false +python-versions = ">=3.5" +files = [ {file = "nbformat-5.1.3-py3-none-any.whl", hash = "sha256:eb8447edd7127d043361bc17f2f5a807626bc8e878c7709a1c647abda28a9171"}, {file = "nbformat-5.1.3.tar.gz", hash = "sha256:b516788ad70771c6250977c1374fcca6edebe6126fd2adb5a69aa5c2356fd1c8"}, ] -nest-asyncio = [ + +[package.dependencies] +ipython-genutils = "*" +jsonschema = ">=2.4,<2.5.0 || >2.5.0" +jupyter-core = "*" +traitlets = ">=4.1" + +[package.extras] +fast = ["fastjsonschema"] +test = ["check-manifest", "fastjsonschema", "pytest", "pytest-cov", "testpath"] + +[[package]] +name = "nest-asyncio" +version = "1.5.4" +description = "Patch asyncio to allow nested event loops" +category = "main" +optional = false +python-versions = ">=3.5" +files = [ {file = "nest_asyncio-1.5.4-py3-none-any.whl", hash = "sha256:3fdd0d6061a2bb16f21fe8a9c6a7945be83521d81a0d15cff52e9edee50101d6"}, {file = "nest_asyncio-1.5.4.tar.gz", hash = "sha256:f969f6013a16fadb4adcf09d11a68a4f617c6049d7af7ac2c676110169a63abd"}, ] -networkx = [ + +[[package]] +name = "networkx" +version = "2.6.3" +description = "Python package for creating and manipulating graphs and networks" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ {file = "networkx-2.6.3-py3-none-any.whl", hash = "sha256:80b6b89c77d1dfb64a4c7854981b60aeea6360ac02c6d4e4913319e0a313abef"}, {file = "networkx-2.6.3.tar.gz", hash = "sha256:c0946ed31d71f1b732b5aaa6da5a0388a345019af232ce2f49c766e2d6795c51"}, ] -notebook = [ - {file = "notebook-6.4.7-py3-none-any.whl", hash = "sha256:968e9c09639fe4b9dbf4b9f028daf861b563c124d735a99d6d48c09317553f31"}, - {file = "notebook-6.4.7.tar.gz", hash = "sha256:b01da66f11a203b3839d6afa4013674bcfff41c36552f9ad0fbcb2d93c92764a"}, + +[package.extras] +default = ["matplotlib (>=3.3)", "numpy (>=1.19)", "pandas (>=1.1)", "scipy (>=1.5,!=1.6.1)"] +developer = ["black (==21.5b1)", "pre-commit (>=2.12)"] +doc = ["nb2plots (>=0.6)", "numpydoc (>=1.1)", "pillow (>=8.2)", "pydata-sphinx-theme (>=0.6,<1.0)", "sphinx (>=4.0,<5.0)", "sphinx-gallery (>=0.9,<1.0)", "texext (>=0.6.6)"] +extra = ["lxml (>=4.5)", "pydot (>=1.4.1)", "pygraphviz (>=1.7)"] +test = ["codecov (>=2.1)", "pytest (>=6.2)", "pytest-cov (>=2.12)"] + +[[package]] +name = "notebook" +version = "6.4.12" +description = "A web-based notebook environment for interactive computing" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "notebook-6.4.12-py3-none-any.whl", hash = "sha256:8c07a3bb7640e371f8a609bdbb2366a1976c6a2589da8ef917f761a61e3ad8b1"}, + {file = "notebook-6.4.12.tar.gz", hash = "sha256:6268c9ec9048cff7a45405c990c29ac9ca40b0bc3ec29263d218c5e01f2b4e86"}, ] -numpy = [ + +[package.dependencies] +argon2-cffi = "*" +ipykernel = "*" +ipython-genutils = "*" +jinja2 = "*" +jupyter-client = ">=5.3.4" +jupyter-core = ">=4.6.1" +nbconvert = ">=5" +nbformat = "*" +nest-asyncio = ">=1.5" +prometheus-client = "*" +pyzmq = ">=17" +Send2Trash = ">=1.8.0" +terminado = ">=0.8.3" +tornado = ">=6.1" +traitlets = ">=4.2.1" + +[package.extras] +docs = ["myst-parser", "nbsphinx", "sphinx", "sphinx-rtd-theme", "sphinxcontrib-github-alt"] +json-logging = ["json-logging"] +test = ["coverage", "nbval", "pytest", "pytest-cov", "requests", "requests-unixsocket", "selenium", "testpath"] + +[[package]] +name = "numpy" +version = "1.22.0" +description = "NumPy is the fundamental package for array computing with Python." +category = "main" +optional = false +python-versions = ">=3.8" +files = [ {file = "numpy-1.22.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3d22662b4b10112c545c91a0741f2436f8ca979ab3d69d03d19322aa970f9695"}, {file = "numpy-1.22.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:11a1f3816ea82eed4178102c56281782690ab5993251fdfd75039aad4d20385f"}, {file = "numpy-1.22.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5dc65644f75a4c2970f21394ad8bea1a844104f0fe01f278631be1c7eae27226"}, @@ -1800,11 +1291,65 @@ numpy = [ {file = "numpy-1.22.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bb02929b0d6bfab4c48a79bd805bd7419114606947ec8284476167415171f55b"}, {file = "numpy-1.22.0.zip", hash = "sha256:a955e4128ac36797aaffd49ab44ec74a71c11d6938df83b1285492d277db5397"}, ] -packaging = [ + +[[package]] +name = "omni-cv-rules" +version = "0.1.15" +description = "" +category = "main" +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "omni-cv-rules-0.1.15.tar.gz", hash = "sha256:b595adc94cb27d9d2af615d6de8cce092c6206531c65c4be37d09e34a76ca593"}, + {file = "omni_cv_rules-0.1.15-py3-none-any.whl", hash = "sha256:ccfd3d34eeab201eedceb899e105b85ff3bfe97f92125faf17b542fd83f0795c"}, +] + +[package.dependencies] +attrs = "*" +bqplot = "*" +frozendict = "*" +ipywidgets = "*" +numpy = "*" +pandas = "*" +Pillow = "*" +pprintpp = "*" +py-omni-converter = "*" + +[[package]] +name = "packaging" +version = "21.3" +description = "Core utilities for Python packages" +category = "main" +optional = false +python-versions = ">=3.6" +files = [ {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, ] -pandas = [ + +[package.dependencies] +pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" + +[[package]] +name = "pampy" +version = "0.3.0" +description = "The Pattern Matching for Python you always dreamed of" +category = "main" +optional = false +python-versions = ">3.6" +files = [ + {file = "pampy-0.3.0-py3-none-any.whl", hash = "sha256:304470a6562173096fc88c22dc0ab50401ca2e3875a8725ee510759ec8ba58ff"}, + {file = "pampy-0.3.0.tar.gz", hash = "sha256:82054212e4478fc22163c55321a3583eda9918aff4440eed6c197e872a2a667b"}, +] + +[[package]] +name = "pandas" +version = "1.3.5" +description = "Powerful data structures for data analysis, time series, and statistics" +category = "main" +optional = false +python-versions = ">=3.7.1" +files = [ {file = "pandas-1.3.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:62d5b5ce965bae78f12c1c0df0d387899dd4211ec0bdc52822373f13a3a022b9"}, {file = "pandas-1.3.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:adfeb11be2d54f275142c8ba9bf67acee771b7186a5745249c7d5a06c670136b"}, {file = "pandas-1.3.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:60a8c055d58873ad81cae290d974d13dd479b82cbb975c3e1fa2cf1920715296"}, @@ -1831,27 +1376,95 @@ pandas = [ {file = "pandas-1.3.5-cp39-cp39-win_amd64.whl", hash = "sha256:32e1a26d5ade11b547721a72f9bfc4bd113396947606e00d5b4a5b79b3dcb006"}, {file = "pandas-1.3.5.tar.gz", hash = "sha256:1e4285f5de1012de20ca46b188ccf33521bff61ba5c5ebd78b4fb28e5416a9f1"}, ] -pandocfilters = [ + +[package.dependencies] +numpy = [ + {version = ">=1.17.3", markers = "platform_machine != \"aarch64\" and platform_machine != \"arm64\" and python_version < \"3.10\""}, + {version = ">=1.19.2", markers = "platform_machine == \"aarch64\" and python_version < \"3.10\""}, + {version = ">=1.20.0", markers = "platform_machine == \"arm64\" and python_version < \"3.10\""}, + {version = ">=1.21.0", markers = "python_version >= \"3.10\""}, +] +python-dateutil = ">=2.7.3" +pytz = ">=2017.3" + +[package.extras] +test = ["hypothesis (>=3.58)", "pytest (>=6.0)", "pytest-xdist"] + +[[package]] +name = "pandocfilters" +version = "1.5.0" +description = "Utilities for writing pandoc filters in python" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ {file = "pandocfilters-1.5.0-py2.py3-none-any.whl", hash = "sha256:33aae3f25fd1a026079f5d27bdd52496f0e0803b3469282162bafdcbdf6ef14f"}, {file = "pandocfilters-1.5.0.tar.gz", hash = "sha256:0b679503337d233b4339a817bfc8c50064e2eff681314376a47cb582305a7a38"}, ] -parso = [ + +[[package]] +name = "parso" +version = "0.8.3" +description = "A Python Parser" +category = "main" +optional = false +python-versions = ">=3.6" +files = [ {file = "parso-0.8.3-py2.py3-none-any.whl", hash = "sha256:c001d4636cd3aecdaf33cbb40aebb59b094be2a74c556778ef5576c175e19e75"}, {file = "parso-0.8.3.tar.gz", hash = "sha256:8c07be290bb59f03588915921e29e8a50002acaf2cdc5fa0e0114f91709fafa0"}, ] -pathspec = [ + +[package.extras] +qa = ["flake8 (==3.8.3)", "mypy (==0.782)"] +testing = ["docopt", "pytest (<6.0.0)"] + +[[package]] +name = "pathspec" +version = "0.9.0" +description = "Utility library for gitignore style pattern matching of file paths." +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" +files = [ {file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"}, {file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"}, ] -pexpect = [ + +[[package]] +name = "pexpect" +version = "4.8.0" +description = "Pexpect allows easy control of interactive console applications." +category = "main" +optional = false +python-versions = "*" +files = [ {file = "pexpect-4.8.0-py2.py3-none-any.whl", hash = "sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937"}, {file = "pexpect-4.8.0.tar.gz", hash = "sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c"}, ] -pickleshare = [ + +[package.dependencies] +ptyprocess = ">=0.5" + +[[package]] +name = "pickleshare" +version = "0.7.5" +description = "Tiny 'shelve'-like database with concurrency support" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "pickleshare-0.7.5-py2.py3-none-any.whl", hash = "sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56"}, {file = "pickleshare-0.7.5.tar.gz", hash = "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca"}, ] -pillow = [ + +[[package]] +name = "pillow" +version = "9.0.0" +description = "Python Imaging Library (Fork)" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ {file = "Pillow-9.0.0-cp310-cp310-macosx_10_10_universal2.whl", hash = "sha256:113723312215b25c22df1fdf0e2da7a3b9c357a7d24a93ebbe80bfda4f37a8d4"}, {file = "Pillow-9.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:bb47a548cea95b86494a26c89d153fd31122ed65255db5dcbc421a2d28eb3379"}, {file = "Pillow-9.0.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:31b265496e603985fad54d52d11970383e317d11e18e856971bdbb86af7242a4"}, @@ -1885,47 +1498,171 @@ pillow = [ {file = "Pillow-9.0.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:95545137fc56ce8c10de646074d242001a112a92de169986abd8c88c27566a05"}, {file = "Pillow-9.0.0.tar.gz", hash = "sha256:ee6e2963e92762923956fe5d3479b1fdc3b76c83f290aad131a2f98c3df0593e"}, ] -pinject = [ + +[[package]] +name = "pinject" +version = "0.14.1" +description = "A pythonic dependency injection library" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "pinject-0.14.1-py3-none-any.whl", hash = "sha256:dfc4981a36d3f7cf2fa82bd8922f713c769004fe7af935def3e2a52147aeda66"}, {file = "pinject-0.14.1.tar.gz", hash = "sha256:0f0a0b14f9df87a85b529a21cdaf530269b1f24fb303d418583a12bb53f69382"}, ] -pprintpp = [ + +[package.dependencies] +decorator = ">=4.3.0" +six = ">=1.7.3" + +[[package]] +name = "pprintpp" +version = "0.4.0" +description = "A drop-in replacement for pprint that's actually pretty" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "pprintpp-0.4.0-py2.py3-none-any.whl", hash = "sha256:b6b4dcdd0c0c0d75e4d7b2f21a9e933e5b2ce62b26e1a54537f9651ae5a5c01d"}, {file = "pprintpp-0.4.0.tar.gz", hash = "sha256:ea826108e2c7f49dc6d66c752973c3fc9749142a798d6b254e1e301cfdbc6403"}, ] -prometheus-client = [ + +[[package]] +name = "prometheus-client" +version = "0.12.0" +description = "Python client for the Prometheus monitoring system." +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ {file = "prometheus_client-0.12.0-py2.py3-none-any.whl", hash = "sha256:317453ebabff0a1b02df7f708efbab21e3489e7072b61cb6957230dd004a0af0"}, {file = "prometheus_client-0.12.0.tar.gz", hash = "sha256:1b12ba48cee33b9b0b9de64a1047cbd3c5f2d0ab6ebcead7ddda613a750ec3c5"}, ] -prompt-toolkit = [ + +[package.extras] +twisted = ["twisted"] + +[[package]] +name = "prompt-toolkit" +version = "3.0.24" +description = "Library for building powerful interactive command lines in Python" +category = "main" +optional = false +python-versions = ">=3.6.2" +files = [ {file = "prompt_toolkit-3.0.24-py3-none-any.whl", hash = "sha256:e56f2ff799bacecd3e88165b1e2f5ebf9bcd59e80e06d395fa0cc4b8bd7bb506"}, {file = "prompt_toolkit-3.0.24.tar.gz", hash = "sha256:1bb05628c7d87b645974a1bad3f17612be0c29fa39af9f7688030163f680bad6"}, ] -ptyprocess = [ + +[package.dependencies] +wcwidth = "*" + +[[package]] +name = "ptyprocess" +version = "0.7.0" +description = "Run a subprocess in a pseudo terminal" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35"}, {file = "ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220"}, ] -pure-eval = [ + +[[package]] +name = "pure-eval" +version = "0.2.1" +description = "Safely evaluate AST nodes without side effects" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "pure_eval-0.2.1-py3-none-any.whl", hash = "sha256:94eeb505a88721bec7bb21a4ac49758b8b1a01530da1a70d4ffc1d9937689d71"}, {file = "pure_eval-0.2.1.tar.gz", hash = "sha256:0f04483b16c9429532d2c0ddc96e2b3bb6b2dc37a2bfb0e986248dbfd0b78873"}, ] -py = [ + +[package.extras] +tests = ["pytest"] + +[[package]] +name = "py" +version = "1.11.0" +description = "library with cross-python path, ini-parsing, io, code, log facilities" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] -pycparser = [ + +[[package]] +name = "py-omni-converter" +version = "0.1.24" +description = "" +category = "main" +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "py-omni-converter-0.1.24.tar.gz", hash = "sha256:4ec5c9c7ffeb70be7a5fe24f6c922853416eb16b1cbc3cf05ccb1e6979a6ee33"}, + {file = "py_omni_converter-0.1.24-py3-none-any.whl", hash = "sha256:f7ec9f96519fd053f7ee29522c99d88fe98157c5c62f99a63fdaf98ce80f3b42"}, +] + +[package.dependencies] +cytoolz = "*" +loguru = "*" +lru-dict = ">=1.0.0,<2.0.0" +pampy = "*" +tabulate = "*" +tqdm = "*" + +[[package]] +name = "pycparser" +version = "2.21" +description = "C parser in Python" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, ] -pygments = [ + +[[package]] +name = "pygments" +version = "2.11.2" +description = "Pygments is a syntax highlighting package written in Python." +category = "main" +optional = false +python-versions = ">=3.5" +files = [ {file = "Pygments-2.11.2-py3-none-any.whl", hash = "sha256:44238f1b60a76d78fc8ca0528ee429702aae011c265fe6a8dd8b63049ae41c65"}, {file = "Pygments-2.11.2.tar.gz", hash = "sha256:4e426f72023d88d03b2fa258de560726ce890ff3b630f88c21cbb8b2503b8c6a"}, ] -pyparsing = [ + +[[package]] +name = "pyparsing" +version = "3.0.6" +description = "Python parsing module" +category = "main" +optional = false +python-versions = ">=3.6" +files = [ {file = "pyparsing-3.0.6-py3-none-any.whl", hash = "sha256:04ff808a5b90911829c55c4e26f75fa5ca8a2f5f36aa3a51f68e27033341d3e4"}, {file = "pyparsing-3.0.6.tar.gz", hash = "sha256:d9bdec0013ef1eb5a84ab39a3b3868911598afa494f5faa038647101504e2b81"}, ] -pyrsistent = [ + +[package.extras] +diagrams = ["jinja2", "railroad-diagrams"] + +[[package]] +name = "pyrsistent" +version = "0.18.0" +description = "Persistent/Functional/Immutable data structures" +category = "main" +optional = false +python-versions = ">=3.6" +files = [ {file = "pyrsistent-0.18.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f4c8cabb46ff8e5d61f56a037974228e978f26bfefce4f61a4b1ac0ba7a2ab72"}, {file = "pyrsistent-0.18.0-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:da6e5e818d18459fa46fac0a4a4e543507fe1110e808101277c5a2b5bab0cd2d"}, {file = "pyrsistent-0.18.0-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:5e4395bbf841693eaebaa5bb5c8f5cdbb1d139e07c975c682ec4e4f8126e03d2"}, @@ -1948,19 +1685,60 @@ pyrsistent = [ {file = "pyrsistent-0.18.0-cp39-cp39-win_amd64.whl", hash = "sha256:404e1f1d254d314d55adb8d87f4f465c8693d6f902f67eb6ef5b4526dc58e6ea"}, {file = "pyrsistent-0.18.0.tar.gz", hash = "sha256:773c781216f8c2900b42a7b638d5b517bb134ae1acbebe4d1e8f1f41ea60eb4b"}, ] -python-dateutil = [ + +[[package]] +name = "python-dateutil" +version = "2.8.2" +description = "Extensions to the standard Python datetime module" +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +files = [ {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, ] -pytz = [ + +[package.dependencies] +six = ">=1.5" + +[[package]] +name = "pytz" +version = "2021.3" +description = "World timezone definitions, modern and historical" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "pytz-2021.3-py2.py3-none-any.whl", hash = "sha256:3672058bc3453457b622aab7a1c3bfd5ab0bdae451512f6cf25f64ed37f5b87c"}, {file = "pytz-2021.3.tar.gz", hash = "sha256:acad2d8b20a1af07d4e4c9d2e9285c5ed9104354062f275f3fcd88dcef4f1326"}, ] -pyvis = [ + +[[package]] +name = "pyvis" +version = "0.1.9" +description = "A Python network visualization library" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "pyvis-0.1.9-py3-none-any.whl", hash = "sha256:4d7cab58f120db544e668ac53194fbb3f312e5ba691d7843e2048a43981b1356"}, {file = "pyvis-0.1.9.tar.gz", hash = "sha256:f9ea603025f31f02155760be638e6c443d992050a2e6942496fbba0586170cbf"}, ] -pywin32 = [ + +[package.dependencies] +ipython = ">=5.3.0" +jinja2 = ">=2.9.6" +jsonpickle = ">=1.4.1" +networkx = ">=1.11" + +[[package]] +name = "pywin32" +version = "303" +description = "Python for Window Extensions" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "pywin32-303-cp310-cp310-win32.whl", hash = "sha256:6fed4af057039f309263fd3285d7b8042d41507343cd5fa781d98fcc5b90e8bb"}, {file = "pywin32-303-cp310-cp310-win_amd64.whl", hash = "sha256:51cb52c5ec6709f96c3f26e7795b0bf169ee0d8395b2c1d7eb2c029a5008ed51"}, {file = "pywin32-303-cp311-cp311-win32.whl", hash = "sha256:d9b5d87ca944eb3aa4cd45516203ead4b37ab06b8b777c54aedc35975dec0dee"}, @@ -1974,7 +1752,15 @@ pywin32 = [ {file = "pywin32-303-cp39-cp39-win32.whl", hash = "sha256:7d3271c98434617a11921c5ccf74615794d97b079e22ed7773790822735cc352"}, {file = "pywin32-303-cp39-cp39-win_amd64.whl", hash = "sha256:79cbb862c11b9af19bcb682891c1b91942ec2ff7de8151e2aea2e175899cda34"}, ] -pywinpty = [ + +[[package]] +name = "pywinpty" +version = "1.1.6" +description = "Pseudo terminal support for Windows from Python." +category = "main" +optional = false +python-versions = ">=3.6" +files = [ {file = "pywinpty-1.1.6-cp310-none-win_amd64.whl", hash = "sha256:5f526f21b569b5610a61e3b6126259c76da979399598e5154498582df3736ade"}, {file = "pywinpty-1.1.6-cp36-none-win_amd64.whl", hash = "sha256:7576e14f42b31fa98b62d24ded79754d2ea4625570c016b38eb347ce158a30f2"}, {file = "pywinpty-1.1.6-cp37-none-win_amd64.whl", hash = "sha256:979ffdb9bdbe23db3f46fc7285fd6dbb86b80c12325a50582b211b3894072354"}, @@ -1982,7 +1768,15 @@ pywinpty = [ {file = "pywinpty-1.1.6-cp39-none-win_amd64.whl", hash = "sha256:c703bf569a98ab7844b9daf37e88ab86f31862754ef6910a8b3824993a525c72"}, {file = "pywinpty-1.1.6.tar.gz", hash = "sha256:8808f07350c709119cc4464144d6e749637f98e15acc1e5d3c37db1953d2eebc"}, ] -pyyaml = [ + +[[package]] +name = "pyyaml" +version = "6.0" +description = "YAML parser and emitter for Python" +category = "main" +optional = false +python-versions = ">=3.6" +files = [ {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, {file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"}, {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc"}, @@ -1990,6 +1784,13 @@ pyyaml = [ {file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"}, {file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"}, {file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"}, + {file = "PyYAML-6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358"}, + {file = "PyYAML-6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1"}, + {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d"}, + {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f"}, + {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782"}, + {file = "PyYAML-6.0-cp311-cp311-win32.whl", hash = "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7"}, + {file = "PyYAML-6.0-cp311-cp311-win_amd64.whl", hash = "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf"}, {file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"}, {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"}, {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"}, @@ -2017,7 +1818,15 @@ pyyaml = [ {file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"}, {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, ] -pyzmq = [ + +[[package]] +name = "pyzmq" +version = "22.3.0" +description = "Python bindings for 0MQ" +category = "main" +optional = false +python-versions = ">=3.6" +files = [ {file = "pyzmq-22.3.0-cp310-cp310-macosx_10_15_universal2.whl", hash = "sha256:6b217b8f9dfb6628f74b94bdaf9f7408708cb02167d644edca33f38746ca12dd"}, {file = "pyzmq-22.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2841997a0d85b998cbafecb4183caf51fd19c4357075dfd33eb7efea57e4c149"}, {file = "pyzmq-22.3.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:f89468059ebc519a7acde1ee50b779019535db8dcf9b8c162ef669257fef7a93"}, @@ -2066,7 +1875,19 @@ pyzmq = [ {file = "pyzmq-22.3.0-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:d6157793719de168b199194f6b6173f0ccd3bf3499e6870fac17086072e39115"}, {file = "pyzmq-22.3.0.tar.gz", hash = "sha256:8eddc033e716f8c91c6a2112f0a8ebc5e00532b4a6ae1eb0ccc48e027f9c671c"}, ] -regex = [ + +[package.dependencies] +cffi = {version = "*", markers = "implementation_name == \"pypy\""} +py = {version = "*", markers = "implementation_name == \"pypy\""} + +[[package]] +name = "regex" +version = "2021.11.10" +description = "Alternative regular expression module, to replace re." +category = "main" +optional = false +python-versions = "*" +files = [ {file = "regex-2021.11.10-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9345b6f7ee578bad8e475129ed40123d265464c4cfead6c261fd60fc9de00bcf"}, {file = "regex-2021.11.10-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:416c5f1a188c91e3eb41e9c8787288e707f7d2ebe66e0a6563af280d9b68478f"}, {file = "regex-2021.11.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e0538c43565ee6e703d3a7c3bdfe4037a5209250e8502c98f20fea6f5fdf2965"}, @@ -2142,55 +1963,183 @@ regex = [ {file = "regex-2021.11.10-cp39-cp39-win_amd64.whl", hash = "sha256:83ee89483672b11f8952b158640d0c0ff02dc43d9cb1b70c1564b49abe92ce29"}, {file = "regex-2021.11.10.tar.gz", hash = "sha256:f341ee2df0999bfdf7a95e448075effe0db212a59387de1a70690e4acb03d4c6"}, ] -retry = [ + +[[package]] +name = "retry" +version = "0.9.2" +description = "Easy to use retry decorator." +category = "main" +optional = false +python-versions = "*" +files = [ {file = "retry-0.9.2-py2.py3-none-any.whl", hash = "sha256:ccddf89761fa2c726ab29391837d4327f819ea14d244c232a1d24c67a2f98606"}, {file = "retry-0.9.2.tar.gz", hash = "sha256:f8bfa8b99b69c4506d6f5bd3b0aabf77f98cdb17f3c9fc3f5ca820033336fba4"}, ] -send2trash = [ + +[package.dependencies] +decorator = ">=3.4.2" +py = ">=1.4.26,<2.0.0" + +[[package]] +name = "send2trash" +version = "1.8.0" +description = "Send file to trash natively under Mac OS X, Windows and Linux." +category = "main" +optional = false +python-versions = "*" +files = [ {file = "Send2Trash-1.8.0-py3-none-any.whl", hash = "sha256:f20eaadfdb517eaca5ce077640cb261c7d2698385a6a0f072a4a5447fd49fa08"}, {file = "Send2Trash-1.8.0.tar.gz", hash = "sha256:d2c24762fd3759860a0aff155e45871447ea58d2be6bdd39b5c8f966a0c99c2d"}, ] -setuptools-scm = [ - {file = "setuptools_scm-6.3.2-py3-none-any.whl", hash = "sha256:4c64444b1d49c4063ae60bfe1680f611c8b13833d556fd1d6050c0023162a119"}, - {file = "setuptools_scm-6.3.2.tar.gz", hash = "sha256:a49aa8081eeb3514eb9728fa5040f2eaa962d6c6f4ec9c32f6c1fba88f88a0f2"}, + +[package.extras] +nativelib = ["pyobjc-framework-Cocoa", "pywin32"] +objc = ["pyobjc-framework-Cocoa"] +win32 = ["pywin32"] + +[[package]] +name = "setuptools" +version = "67.8.0" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "setuptools-67.8.0-py3-none-any.whl", hash = "sha256:5df61bf30bb10c6f756eb19e7c9f3b473051f48db77fddbe06ff2ca307df9a6f"}, + {file = "setuptools-67.8.0.tar.gz", hash = "sha256:62642358adc77ffa87233bc4d2354c4b2682d214048f500964dbe760ccedf102"}, ] -six = [ + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, ] -stack-data = [ + +[[package]] +name = "stack-data" +version = "0.1.3" +description = "Extract data from python stack frames and tracebacks for informative displays" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "stack_data-0.1.3-py3-none-any.whl", hash = "sha256:e3f4e54cde03af62e9afd680b3407d38f2e4f3d0e23c3d53371c088c9bea299d"}, {file = "stack_data-0.1.3.tar.gz", hash = "sha256:5cb2aff8164a81901160078ea2f5e39de978f08c96ac69e552a5c5345f892a81"}, ] -tabulate = [ + +[package.dependencies] +asttokens = "*" +executing = "*" +pure-eval = "*" + +[package.extras] +tests = ["littleutils", "pygments", "pytest", "typeguard"] + +[[package]] +name = "tabulate" +version = "0.8.9" +description = "Pretty-print tabular data" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "tabulate-0.8.9-py3-none-any.whl", hash = "sha256:d7c013fe7abbc5e491394e10fa845f8f32fe54f8dc60c6622c6cf482d25d47e4"}, {file = "tabulate-0.8.9.tar.gz", hash = "sha256:eb1d13f25760052e8931f2ef80aaf6045a6cceb47514db8beab24cded16f13a7"}, ] -tblib = [ + +[package.extras] +widechars = ["wcwidth"] + +[[package]] +name = "tblib" +version = "1.7.0" +description = "Traceback serialization library." +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ {file = "tblib-1.7.0-py2.py3-none-any.whl", hash = "sha256:289fa7359e580950e7d9743eab36b0691f0310fce64dee7d9c31065b8f723e23"}, {file = "tblib-1.7.0.tar.gz", hash = "sha256:059bd77306ea7b419d4f76016aef6d7027cc8a0785579b5aad198803435f882c"}, ] -terminado = [ + +[[package]] +name = "terminado" +version = "0.12.1" +description = "Tornado websocket backend for the Xterm.js Javascript terminal emulator library." +category = "main" +optional = false +python-versions = ">=3.6" +files = [ {file = "terminado-0.12.1-py3-none-any.whl", hash = "sha256:09fdde344324a1c9c6e610ee4ca165c4bb7f5bbf982fceeeb38998a988ef8452"}, {file = "terminado-0.12.1.tar.gz", hash = "sha256:b20fd93cc57c1678c799799d117874367cc07a3d2d55be95205b1a88fa08393f"}, ] -testpath = [ + +[package.dependencies] +ptyprocess = {version = "*", markers = "os_name != \"nt\""} +pywinpty = {version = ">=1.1.0", markers = "os_name == \"nt\""} +tornado = ">=4" + +[package.extras] +test = ["pytest"] + +[[package]] +name = "testpath" +version = "0.5.0" +description = "Test utilities for code working with files and commands" +category = "main" +optional = false +python-versions = ">= 3.5" +files = [ {file = "testpath-0.5.0-py3-none-any.whl", hash = "sha256:8044f9a0bab6567fc644a3593164e872543bb44225b0e24846e2c89237937589"}, {file = "testpath-0.5.0.tar.gz", hash = "sha256:1acf7a0bcd3004ae8357409fc33751e16d37ccc650921da1094a86581ad1e417"}, ] -toml = [ + +[package.extras] +test = ["pathlib2", "pytest"] + +[[package]] +name = "toml" +version = "0.10.2" +description = "Python Library for Tom's Obvious, Minimal Language" +category = "main" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] -tomli = [ - {file = "tomli-2.0.0-py3-none-any.whl", hash = "sha256:b5bde28da1fed24b9bd1d4d2b8cba62300bfb4ec9a6187a957e8ddb9434c5224"}, - {file = "tomli-2.0.0.tar.gz", hash = "sha256:c292c34f58502a1eb2bbb9f5bbc9a5ebc37bee10ffb8c2d6bbdfa8eb13cc14e1"}, -] -toolz = [ + +[[package]] +name = "toolz" +version = "0.11.2" +description = "List processing tools and functional utilities" +category = "main" +optional = false +python-versions = ">=3.5" +files = [ {file = "toolz-0.11.2-py3-none-any.whl", hash = "sha256:a5700ce83414c64514d82d60bcda8aabfde092d1c1a8663f9200c07fdcc6da8f"}, {file = "toolz-0.11.2.tar.gz", hash = "sha256:6b312d5e15138552f1bda8a4e66c30e236c831b612b2bf0005f8a1df10a4bc33"}, ] -tornado = [ + +[[package]] +name = "tornado" +version = "6.1" +description = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed." +category = "main" +optional = false +python-versions = ">= 3.5" +files = [ {file = "tornado-6.1-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:d371e811d6b156d82aa5f9a4e08b58debf97c302a35714f6f45e35139c332e32"}, {file = "tornado-6.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:0d321a39c36e5f2c4ff12b4ed58d41390460f798422c4504e09eb5678e09998c"}, {file = "tornado-6.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:9de9e5188a782be6b1ce866e8a51bc76a0fbaa0e16613823fc38e4fc2556ad05"}, @@ -2233,35 +2182,134 @@ tornado = [ {file = "tornado-6.1-cp39-cp39-win_amd64.whl", hash = "sha256:548430be2740e327b3fe0201abe471f314741efcb0067ec4f2d7dcfb4825f3e4"}, {file = "tornado-6.1.tar.gz", hash = "sha256:33c6e81d7bd55b468d2e793517c909b139960b6c790a60b7991b9b6b76fb9791"}, ] -tqdm = [ + +[[package]] +name = "tqdm" +version = "4.62.3" +description = "Fast, Extensible Progress Meter" +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" +files = [ {file = "tqdm-4.62.3-py2.py3-none-any.whl", hash = "sha256:8dd278a422499cd6b727e6ae4061c40b48fce8b76d1ccbf5d34fca9b7f925b0c"}, {file = "tqdm-4.62.3.tar.gz", hash = "sha256:d359de7217506c9851b7869f3708d8ee53ed70a1b8edbba4dbcb47442592920d"}, ] -traitlets = [ + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + +[package.extras] +dev = ["py-make (>=0.1.0)", "twine", "wheel"] +notebook = ["ipywidgets (>=6)"] +telegram = ["requests"] + +[[package]] +name = "traitlets" +version = "5.1.1" +description = "Traitlets Python configuration system" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ {file = "traitlets-5.1.1-py3-none-any.whl", hash = "sha256:2d313cc50a42cd6c277e7d7dc8d4d7fedd06a2c215f78766ae7b1a66277e0033"}, {file = "traitlets-5.1.1.tar.gz", hash = "sha256:059f456c5a7c1c82b98c2e8c799f39c9b8128f6d0d46941ee118daace9eb70c7"}, ] -traittypes = [ + +[package.extras] +test = ["pytest"] + +[[package]] +name = "traittypes" +version = "0.2.1" +description = "Scipy trait types" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "traittypes-0.2.1-py2.py3-none-any.whl", hash = "sha256:1340af133810b6eee1a2eb2e988f862b0d12b6c2d16f282aaf3207b782134c2e"}, {file = "traittypes-0.2.1.tar.gz", hash = "sha256:be6fa26294733e7489822ded4ae25da5b4824a8a7a0e0c2dccfde596e3489bd6"}, ] -wcwidth = [ + +[package.dependencies] +traitlets = ">=4.2.2" + +[package.extras] +test = ["numpy", "pandas", "pytest", "xarray"] + +[[package]] +name = "wcwidth" +version = "0.2.5" +description = "Measures the displayed width of unicode strings in a terminal" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "wcwidth-0.2.5-py2.py3-none-any.whl", hash = "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784"}, {file = "wcwidth-0.2.5.tar.gz", hash = "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"}, ] -webencodings = [ + +[[package]] +name = "webencodings" +version = "0.5.1" +description = "Character encoding aliases for legacy web content" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "webencodings-0.5.1-py2.py3-none-any.whl", hash = "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78"}, {file = "webencodings-0.5.1.tar.gz", hash = "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923"}, ] -widgetsnbextension = [ + +[[package]] +name = "widgetsnbextension" +version = "3.5.2" +description = "IPython HTML widgets for Jupyter" +category = "main" +optional = false +python-versions = "*" +files = [ {file = "widgetsnbextension-3.5.2-py2.py3-none-any.whl", hash = "sha256:763a9fdc836d141fa080005a886d63f66f73d56dba1fb5961afc239c77708569"}, {file = "widgetsnbextension-3.5.2.tar.gz", hash = "sha256:e0731a60ba540cd19bbbefe771a9076dcd2dde90713a8f87f27f53f2d1db7727"}, ] -win32-setctime = [ + +[package.dependencies] +notebook = ">=4.4.1" + +[[package]] +name = "win32-setctime" +version = "1.0.4" +description = "A small Python utility to set file creation time on Windows" +category = "main" +optional = false +python-versions = ">=3.5" +files = [ {file = "win32_setctime-1.0.4-py3-none-any.whl", hash = "sha256:7964234073ad9bc7a689ef2ebe6ce931976b644fe73fd50cf7729c996b7d8385"}, {file = "win32_setctime-1.0.4.tar.gz", hash = "sha256:2b72b798fdc1d909fb3cc0d25e0be52a42f4848857e3588dd3947c6a18b42609"}, ] -zipp = [ + +[package.extras] +dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] + +[[package]] +name = "zipp" +version = "3.7.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ {file = "zipp-3.7.0-py3-none-any.whl", hash = "sha256:b47250dd24f92b7dd6a0a8fc5244da14608f3ca90a5efcd37a3b1642fac9a375"}, {file = "zipp-3.7.0.tar.gz", hash = "sha256:9f50f446828eb9d45b267433fd3e9da8d801f614129124863f9c51ebceafb87d"}, ] + +[package.extras] +docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] +testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy"] + +[extras] +torch = [] + +[metadata] +lock-version = "2.0" +python-versions = "^3.8" +content-hash = "3c683e4726d7795d6b930b2be8b1d2013fb3f33420fa6fac634696001ace254f" diff --git a/test/coconut/__init__.py b/test/coconut/__init__.py index 7147573..ee31649 100644 --- a/test/coconut/__init__.py +++ b/test/coconut/__init__.py @@ -1,12 +1,29 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +<<<<<<< HEAD +# __coconut_hash__ = 0x1781686b + +# Compiled with Coconut version 1.4.3 [Ernest Scribbler] +======= # __coconut_hash__ = 0x1492afa2 # Compiled with Coconut version 2.2.0 +>>>>>>> master # Coconut Header: ------------------------------------------------------------- from __future__ import generator_stop +<<<<<<< HEAD +import sys as _coconut_sys, os.path as _coconut_os_path +_coconut_file_path = _coconut_os_path.dirname(_coconut_os_path.abspath(__file__)) +_coconut_cached_module = _coconut_sys.modules.get("__coconut__") +if _coconut_cached_module is not None and _coconut_os_path.dirname(_coconut_cached_module.__file__) != _coconut_file_path: + del _coconut_sys.modules["__coconut__"] +_coconut_sys.path.insert(0, _coconut_file_path) +from __coconut__ import * +from __coconut__ import _coconut, _coconut_MatchError, _coconut_igetitem, _coconut_base_compose, _coconut_forward_compose, _coconut_back_compose, _coconut_forward_star_compose, _coconut_back_star_compose, _coconut_forward_dubstar_compose, _coconut_back_dubstar_compose, _coconut_pipe, _coconut_back_pipe, _coconut_star_pipe, _coconut_back_star_pipe, _coconut_dubstar_pipe, _coconut_back_dubstar_pipe, _coconut_bool_and, _coconut_bool_or, _coconut_none_coalesce, _coconut_minus, _coconut_map, _coconut_partial, _coconut_get_function_match_error, _coconut_base_pattern_func, _coconut_addpattern, _coconut_sentinel, _coconut_assert, _coconut_mark_as_match +_coconut_sys.path.pop(0) +======= import sys as _coconut_sys _coconut_header_info = ('2.2.0', '35', True, False, False) import os as _coconut_os @@ -37,5 +54,6 @@ from __coconut__ import _coconut_call_set_names, _namedtuple_of, _coconut, _coconut_super, _coconut_Expected, _coconut_MatchError, _coconut_iter_getitem, _coconut_base_compose, _coconut_forward_compose, _coconut_back_compose, _coconut_forward_star_compose, _coconut_back_star_compose, _coconut_forward_dubstar_compose, _coconut_back_dubstar_compose, _coconut_pipe, _coconut_star_pipe, _coconut_dubstar_pipe, _coconut_back_pipe, _coconut_back_star_pipe, _coconut_back_dubstar_pipe, _coconut_none_pipe, _coconut_none_star_pipe, _coconut_none_dubstar_pipe, _coconut_bool_and, _coconut_bool_or, _coconut_none_coalesce, _coconut_minus, _coconut_map, _coconut_partial, _coconut_get_function_match_error, _coconut_base_pattern_func, _coconut_addpattern, _coconut_sentinel, _coconut_assert, _coconut_raise, _coconut_mark_as_match, _coconut_reiterable, _coconut_self_match_types, _coconut_dict_merge, _coconut_exec, _coconut_comma_op, _coconut_multi_dim_arr, _coconut_mk_anon_namedtuple, _coconut_matmul, _coconut_py_str, _coconut_flatten, _coconut_multiset, _coconut_back_none_pipe, _coconut_back_none_star_pipe, _coconut_back_none_dubstar_pipe, _coconut_forward_none_compose, _coconut_back_none_compose, _coconut_forward_none_star_compose, _coconut_back_none_star_compose, _coconut_forward_none_dubstar_compose, _coconut_back_none_dubstar_compose if _coconut_pop_path: _coconut_sys.path.pop(0) +>>>>>>> master # Compiled Coconut: ----------------------------------------------------------- diff --git a/test/test_conversion.py b/test/test_conversion.py index feae2a6..259a90a 100644 --- a/test/test_conversion.py +++ b/test/test_conversion.py @@ -1,3 +1,12 @@ +<<<<<<< HEAD +from IPython import embed +from loguru import logger +def test_rgb_to_yuv(): + from data_tree import auto + from archpainter.experiments.rgba2xyz_mod.instances import torch_xyz, pix2pix_rgb_batch, TORCH_XYZ_BATCH + from archpainter.dataset.ask import ask256 + img = ask256.original_pairs[0][0] +======= import pytest from IPython import embed @@ -8,6 +17,7 @@ def test_rgb_to_yuv(archpainter=u): from archpainter.rulebook import legacy_auto as auto +>>>>>>> master import numpy as np a_data = auto("numpy,uint8,HWC,RGB,0_255")(None) logger.info(a_data) @@ -20,6 +30,17 @@ def test_rgb_to_yuv(archpainter=u): # plt.show() #auto("numpy,uint8,HWC,YCbCr,0_255")(ary).convert("numpy,uint8,CHW,YCbCr,0_255").cast("numpy,uint8,BHW,L,0_255").show() #logger.info(auto("image,RGB,RGB")(None).converter("image,YCbCr,YCbCr")) +<<<<<<< HEAD + +def test_list_vgg_prep_to_vgg_prep_batch(): + from data_tree import auto + from archpainter.dataset.ask import ask256 + img = ask256.original_pairs[0][0] + vgg_prep = auto("numpy,uint8,HWC,RGB,0_255")(img[1]).to("vgg_prep") + converted = auto("vgg_prep")(vgg_prep).convert("vgg_prep_batch").to("numpy,uint8,HWC,RGB,0_255") + # now, can we embed numbers into a state? + embed() +======= formats = [ "numpy_rgb", "numpy_rgba", @@ -79,4 +100,5 @@ def test_convert_impath_to_image(): from archpainter.rulebook import legacy_auto as auto from data_tree.coconut.omni_converter import rule_image_path_to_image logger.info(rule_image_path_to_image("image_path")) - logger.info(auto("image_path")(None).converter("image,RGB,RGB")) \ No newline at end of file + logger.info(auto("image_path")(None).converter("image,RGB,RGB")) +>>>>>>> master