python类floor_divide()的实例源码

lab2npy.py 文件源码 项目:evaluation_tools 作者: JSALT-Rosetta 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def lab2npy(input_path, out, frame_rate= 0.01):
   """
   frame_rate : sampling rate, typically 10 ms (or 0.01s)

   """

   name=os.path.basename(input_path)
   df=pd.read_table(input_path, sep=" ", header=None)
   df.columns=["onset", "offset", "phone", "score"]

   #onset and offset are in 100* nanosecond. Need to be put in second

   df["onset"]=df["onset"]*10**(-7)
   df["offset"]=df["offset"]*10**(-7)   
   phones=['a{}'.format(i) for i in range(1, 49)]   
   list_feats=[]
   R=np.empty(1)
   R[0]=frame_rate
   for i in range(len(df)): 
       on=df["onset"].iloc[i]
       off=df["offset"].iloc[i]
       nb_frame=int(np.floor_divide((off-on),R[0]))
       for ff in range(nb_frame): 
           one_hot=np.empty(len(phones))
           for j in range(len(phones)):
               if df["phone"][i]==phones[j]:
                   one_hot[j]=1
               else: 
                   one_hot[j]=0
           list_feats.append(one_hot)
   arr_feats = np.array(list_feats)

   directory=out + "/npy/"
   try:
       os.stat(directory)
   except:
       os.mkdir(directory)

   np.save(directory + "/"+ name.split(".")[0], arr=arr_feats,  allow_pickle=False)
test_umath.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_floor_division_complex(self):
        # check that implementation is correct
        msg = "Complex floor division implementation check"
        x = np.array([.9 + 1j, -.1 + 1j, .9 + .5*1j, .9 + 2.*1j], dtype=np.complex128)
        y = np.array([0., -1., 0., 0.], dtype=np.complex128)
        assert_equal(np.floor_divide(x**2, x), y, err_msg=msg)
        # check overflow, underflow
        msg = "Complex floor division overflow/underflow check"
        x = np.array([1.e+110, 1.e-110], dtype=np.complex128)
        y = np.floor_divide(x**2, x)
        assert_equal(y, [1.e+110, 0], err_msg=msg)
core.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __floordiv__(self, other):
        """
        Divide other into self, and return a new masked array.

        """
        if self._delegate_binop(other):
            return NotImplemented
        return floor_divide(self, other)
core.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __rfloordiv__(self, other):
        """
        Divide self into other, and return a new masked array.

        """
        return floor_divide(other, self)
math.py 文件源码 项目:Sverchok 作者: Sverchok 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def int_div(x1: Number = 1.0, x2: Number = 2.0) -> Int:
    return np.floor_divide(x1, x2)
fusion.py 文件源码 项目:cupy 作者: cupy 项目源码 文件源码 阅读 43 收藏 0 点赞 0 评论 0
def __floordiv__(self, other):
        return floor_divide(self, other)
fusion.py 文件源码 项目:cupy 作者: cupy 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __ifloordiv__(self, other):
        return floor_divide(self, other, self)
fusion.py 文件源码 项目:cupy 作者: cupy 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __rfloordiv__(self, other):
        return floor_divide(other, self)
cputransform.py 文件源码 项目:ngraph 作者: NervanaSystems 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def generate_op(self, op, out, x, y):
        self.append("np.floor_divide({}, {}, out={})", x, y, out)
regions.py 文件源码 项目:diluvian 作者: aschampion 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def vox_to_pos(self, vox):
        return np.floor_divide(vox - self.MOVE_GRID_OFFSET, self.MOVE_DELTA).astype(np.int64)
training.py 文件源码 项目:diluvian 作者: aschampion 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_output_margin(model_config):
    return np.floor_divide(model_config.input_fov_shape - model_config.output_fov_shape, 2)
volumes.py 文件源码 项目:diluvian 作者: aschampion 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, volume, shape, label_margin=None):
            self.volume = volume
            self.shape = shape
            self.margin = np.floor_divide(self.shape, 2).astype(np.int64)
            if label_margin is None:
                label_margin = np.zeros(3, dtype=np.int64)
            self.label_margin = label_margin
            self.skip_blank_sections = True
            self.ctr_min = self.margin
            self.ctr_max = (np.array(self.volume.shape) - self.margin - 1).astype(np.int64)
            self.random = np.random.RandomState(CONFIG.random_seed)

            # If the volume has a mask channel, further limit ctr_min and
            # ctr_max to lie inside a margin in the AABB of the mask.
            if self.volume.mask_data is not None:
                mask_min, mask_max = self.volume.mask_bounds

                mask_min = self.volume.local_coord_to_world(mask_min)
                mask_max = self.volume.local_coord_to_world(mask_max)

                self.ctr_min = np.maximum(self.ctr_min, mask_min + self.label_margin)
                self.ctr_max = np.minimum(self.ctr_max, mask_max - self.label_margin - 1)

            if np.any(self.ctr_min >= self.ctr_max):
                raise ValueError('Cannot generate subvolume bounds: bounds ({}, {}) too small for shape ({})'.format(
                                 np.array_str(self.ctr_min), np.array_str(self.ctr_max), np.array_str(self.shape)))
volumes.py 文件源码 项目:diluvian 作者: aschampion 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, parent, partitioning, partition_index):
        super(PartitionedVolume, self).__init__(
                parent,
                parent.resolution,
                image_data=parent.image_data,
                label_data=parent.label_data,
                mask_data=parent.mask_data)
        self.partitioning = np.asarray(partitioning)
        self.partition_index = np.asarray(partition_index)
        partition_shape = np.floor_divide(np.array(self.parent.shape), self.partitioning)
        self.bounds = ((np.multiply(partition_shape, self.partition_index)).astype(np.int64),
                       (np.multiply(partition_shape, self.partition_index + 1)).astype(np.int64))
volumes.py 文件源码 项目:diluvian 作者: aschampion 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def shape(self):
        return tuple(np.floor_divide(np.array(self.parent.shape), self.scale))
test_umath.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def test_floor_division_complex(self):
        # check that implementation is correct
        msg = "Complex floor division implementation check"
        x = np.array([.9 + 1j, -.1 + 1j, .9 + .5*1j, .9 + 2.*1j], dtype=np.complex128)
        y = np.array([0., -1., 0., 0.], dtype=np.complex128)
        assert_equal(np.floor_divide(x**2, x), y, err_msg=msg)
        # check overflow, underflow
        msg = "Complex floor division overflow/underflow check"
        x = np.array([1.e+110, 1.e-110], dtype=np.complex128)
        y = np.floor_divide(x**2, x)
        assert_equal(y, [1.e+110, 0], err_msg=msg)
core.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def __floordiv__(self, other):
        """
        Divide other into self, and return a new masked array.

        """
        if self._delegate_binop(other):
            return NotImplemented
        return floor_divide(self, other)
core.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def __rfloordiv__(self, other):
        """
        Divide self into other, and return a new masked array.

        """
        return floor_divide(other, self)
yt_array.py 文件源码 项目:yt 作者: yt-project 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def __ifloordiv__(self, other):
            """ See __div__. """
            oth = sanitize_units_mul(self, other)
            np.floor_divide(self, oth, out=self)
            return self
toads_analysis.py 文件源码 项目:Thrifty 作者: swkrueger 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def plot_minute_histogram(splits):
    def plot(ax, detections):
        bins = np.floor_divide(detections['timestamp'], 60).astype('int64')
        counts = np.bincount(bins)
        ax.plot(counts)
        ax.set_xlabel('Minute')
        ax.set_ylabel('Count')
    fig = plt.figure()
    plot_rxtx_matrix(fig, splits, plot)
    fig.suptitle('Histogram of number of detections per minute')
test_umath.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def test_floor_division_complex(self):
        # check that implementation is correct
        msg = "Complex floor division implementation check"
        x = np.array([.9 + 1j, -.1 + 1j, .9 + .5*1j, .9 + 2.*1j], dtype=np.complex128)
        y = np.array([0., -1., 0., 0.], dtype=np.complex128)
        assert_equal(np.floor_divide(x**2, x), y, err_msg=msg)
        # check overflow, underflow
        msg = "Complex floor division overflow/underflow check"
        x = np.array([1.e+110, 1.e-110], dtype=np.complex128)
        y = np.floor_divide(x**2, x)
        assert_equal(y, [1.e+110, 0], err_msg=msg)


问题


面经


文章

微信
公众号

扫码关注公众号