Download src/yeorinx3/native.py from PureOne/YEORIN-X-v4-Research: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/datasets/PureOne/YEORIN-X-v4-Research/resolve/main/src/yeorinx3/native.py
- Command line
-
hf download hf://datasets/PureOne/YEORIN-X-v4-Research/src/yeorinx3/native.py
-
curl -L -o native.py https://huggingface.co/datasets/PureOne/YEORIN-X-v4-Research/resolve/main/src/yeorinx3/native.py
1.38 kB
| """Optional compiled selector. Missing library is explicit; no silent claims.""" | |
| import ctypes as c | |
| from pathlib import Path | |
| import numpy as np | |
| class NativeSelector: | |
| def __init__(self,path): | |
| self.path=str(Path(path).resolve());self.lib=c.CDLL(self.path) | |
| self.fn=self.lib.yr3_select | |
| p=np.ctypeslib.ndpointer(dtype=np.float64,ndim=1,flags='C_CONTIGUOUS') | |
| self.fn.argtypes=[c.c_int,c.c_int,p,p,p,p,p]+[c.c_double]*7+[c.c_int,p] | |
| self.fn.restype=c.c_int | |
| def select(self,moments,energy,maximum,centers,radii,slack,width,height,fov,pitch_cap,pixel_cap,path_cost=0.,strict=False): | |
| m=np.ascontiguousarray(moments,dtype=np.float64);e=np.ascontiguousarray(energy,dtype=np.float64);mx=np.ascontiguousarray(maximum,dtype=np.float64) | |
| ct=np.ascontiguousarray(centers,dtype=np.float64);rd=np.ascontiguousarray(radii,dtype=np.float64) | |
| if m.ndim!=3 or m.shape[1:]!=(2,15) or e.shape!=(len(m),) or mx.shape!=e.shape or ct.ndim!=2 or ct.shape[1]!=2 or rd.shape!=ct.shape: | |
| raise ValueError('invalid native selector shapes') | |
| out=np.zeros(4) | |
| index=self.fn(len(m),len(ct),m.ravel(),e.ravel(),mx.ravel(),ct.ravel(),rd.ravel(),slack,width,height,fov,pitch_cap,pixel_cap,path_cost,int(strict),out) | |
| if index==-3:raise ValueError('native validation rejected arguments') | |
| return int(index),out | |