python类rank()的实例源码

XueqiuPersistence.py 文件源码 项目:Xueqiu 作者: OliangchenO 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_cube_list(category,count,orderType):
    url=cube_list_url+"?category="+category+"&count="+count+"&market=cn&profit="+orderType
    data = request(url,cookie)
    jsonObj = json.loads(data.read())
    rank = 1
    for TopestCube in jsonObj["list"]:
        created_at = TopestCube["created_at"]
        ltime=time.localtime(created_at/1000.0) 
        created_at_str=time.strftime("%Y-%m-%d", ltime)
        TopestCube["created_at"] = created_at_str
        updated_at = TopestCube["updated_at"]
        ltime=time.localtime(updated_at/1000.0) 
        updated_at_str=time.strftime("%Y-%m-%d", ltime)
        TopestCube["updated_at"] = updated_at_str
        TopestCube["category"] = category
        TopestCube["orderType"] = orderType
        TopestCube["Rank"] = rank
        del(TopestCube["style"],TopestCube["description"],TopestCube["owner"])
        cubelist_save(TopestCube)
        rank = rank + 1
utils.py 文件源码 项目:decoding_challenge_cortana_2016_3rd 作者: kingjr 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def clean_warning_registry():
    """Safe way to reset warnings """
    warnings.resetwarnings()
    reg = "__warningregistry__"
    bad_names = ['MovedModule']  # this is in six.py, and causes bad things
    for mod in list(sys.modules.values()):
        if mod.__class__.__name__ not in bad_names and hasattr(mod, reg):
            getattr(mod, reg).clear()
    # hack to deal with old scipy/numpy in tests
    if os.getenv('TRAVIS') == 'true' and sys.version.startswith('2.6'):
        warnings.simplefilter('default')
        try:
            np.rank([])
        except Exception:
            pass
        warnings.simplefilter('always')
gaze_data.py 文件源码 项目:simulated-unsupervised-tensorflow 作者: carpedm20 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, config, rng=None):
    self.rng = np.random.RandomState(1) if rng is None else rng

    self.data_path = os.path.join(config.data_dir, 'gaze')
    self.sample_path = os.path.join(self.data_path, config.sample_dir)
    self.batch_size = config.batch_size
    self.debug = config.debug

    self.real_data, synthetic_image_path = load(config, self.data_path, self.sample_path, rng)

    self.synthetic_data_paths = np.array(glob(os.path.join(synthetic_image_path, '*_cropped.png')))
    self.synthetic_data_dims = list(imread(self.synthetic_data_paths[0]).shape) + [1]

    self.synthetic_data_paths.sort()

    if np.rank(self.real_data) == 3:
      self.real_data = np.expand_dims(self.real_data, -1)

    self.real_p = 0
test_deprecations.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test(self):
        a = np.arange(10)
        assert_warns(np.VisibleDeprecationWarning, np.rank, a)
gaussian_process.py 文件源码 项目:probabilistic_line_search 作者: ProbabilisticNumerics 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
def k(self, x, y):
    """Kernel function."""
    for arg in [x, y]:
      assert isinstance(arg, (float, np.float32, np.float64)) or \
             (isinstance(arg, np.ndarray) and np.rank(arg) == 1)
    mi = self.offset + np.minimum(x, y)
    return self.theta**2 * (mi**3/3.0 + 0.5*np.abs(x-y)*mi**2)
gaussian_process.py 文件源码 项目:probabilistic_line_search 作者: ProbabilisticNumerics 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def kd(self, x, y):
    """Derivative of kernel function, 1st derivative w.r.t. right argument."""
    for arg in [x, y]:
      assert isinstance(arg, (float, np.float32, np.float64)) or \
             (isinstance(arg, np.ndarray) and np.rank(arg) == 1)
    xx = x + self.offset
    yy = y + self.offset
    return self.theta**2 * np.where(x<y, 0.5*xx**2, xx*yy-0.5*yy**2)
gaussian_process.py 文件源码 项目:probabilistic_line_search 作者: ProbabilisticNumerics 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def dkd(self, x, y):
    """Derivative of kernel function,  1st derivative w.r.t. both arguments."""
    for arg in [x, y]:
      assert isinstance(arg, (float, np.float32, np.float64)) or \
             (isinstance(arg, np.ndarray) and np.rank(arg) == 1)
    xx = x+self.offset
    yy = y+self.offset
    return self.theta**2 * np.minimum(xx, yy)
gaussian_process.py 文件源码 项目:probabilistic_line_search 作者: ProbabilisticNumerics 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def d2k(self, x, y):
    """Derivative of kernel function,  2nd derivative w.r.t. left argument."""
    for arg in [x, y]:
      assert isinstance(arg, (float, np.float32, np.float64)) or \
             (isinstance(arg, np.ndarray) and np.rank(arg) == 1)
    return self.theta**2 * np.where(x<y, y-x, 0.)
gaussian_process.py 文件源码 项目:probabilistic_line_search 作者: ProbabilisticNumerics 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def d3k(self, x, y):
    """Derivative of kernel function,  3rd derivative w.r.t. left argument."""
    for arg in [x, y]:
      assert isinstance(arg, (float, np.float32, np.float64)) or \
             (isinstance(arg, np.ndarray) and np.rank(arg) == 1)
    return self.theta**2 * np.where(x<y, -1., 0.)
test_deprecations.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test(self):
        a = np.arange(10)
        assert_warns(np.VisibleDeprecationWarning, np.rank, a)
audio.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, filename=None, scale2float=True):
        """Read a .wav file from disk"""
        assert filename is not None, "Specify a filename"
        self.filename = filename

        fs, samples = scipy.io.wavfile.read(filename)
        if np.rank(samples) == 1:
            samples = np.expand_dims(samples, axis=1)

        Audio.__init__(self, fs=fs, initialdata=samples)

        del samples # just to make sure

        if scale2float:
            self.convert_to_float(targetbits=64)
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_lin_to_db_to_lin_arrays(self):
        x = lin2db(db2lin((             1.234567,   2.345678)))
        self.assertEqual(np.rank(x), 1)
        self.assertEqual(len(x), 2)
        self.assertAlmostEqual(x[0],    1.234567,               places=6)
        self.assertAlmostEqual(x[1],                2.345678,   places=6)
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_pow_to_db_to_pow_arrays(self):
        x = pow2db(db2pow((             1.234567,   2.345678)))
        self.assertEqual(np.rank(x), 1)
        self.assertEqual(len(x), 2)
        self.assertAlmostEqual(x[0],    1.234567,               places=6)
        self.assertAlmostEqual(x[1],                2.345678,   places=6)
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_single(self):
        x = lin2db(1)
        self.assertEqual(np.rank(x), 0)
        self.assertAlmostEqual(x, 0.0, places=6)
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_tuple(self):
        x = lin2db((1, 0.1))
        self.assertEqual(np.rank(x), 1)
        self.assertAlmostEqual(x[0],   0.0, places=6)
        self.assertAlmostEqual(x[1], -20.0, places=6)
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_np_rank_1(self):
        x = lin2db(np.ones(10))
        self.assertEqual(np.rank(x), 1)
        self.assertTrue((x <  0.0001).all())
        self.assertTrue((x > -0.0001).all())
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_np_rank_2_10x4(self):
        x = lin2db(np.ones((10, 4)))
        self.assertEqual(np.rank(x), 2)
        self.assertTrue((x <  0.0001).all())
        self.assertTrue((x > -0.0001).all())
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_np_rank_2_4x10(self):
        x = lin2db(np.ones((4, 10)))
        self.assertEqual(np.rank(x), 2)
        self.assertTrue((x <  0.0001).all())
        self.assertTrue((x > -0.0001).all())
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_single(self):
        x = db2lin(0)
        self.assertEqual(np.rank(x), 0)
        self.assertAlmostEqual(x, 1.0, places=6)
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_tuple(self):
        x = db2lin((40, -40))
        self.assertEqual(np.rank(x), 1)
        self.assertAlmostEqual(x[0],  100.0,  places=6)
        self.assertAlmostEqual(x[1],    0.01, places=6)
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def test_np_rank_1(self):
        x = db2lin(np.zeros(10))
        self.assertEqual(np.rank(x), 1)
        self.assertTrue((x < 1.0001).all())
        self.assertTrue((x > 0.9999).all())
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_np_rank_2_10x4(self):
        x = db2lin(np.zeros((10, 4)))
        self.assertEqual(np.rank(x), 2)
        self.assertTrue((x < 1.0001).all())
        self.assertTrue((x > 0.9999).all())
test_db_conversions.py 文件源码 项目:zignal 作者: ronnyandersson 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_np_rank_2_4x10(self):
        x = db2lin(np.zeros((4, 10)))
        self.assertEqual(np.rank(x), 2)
        self.assertTrue((x < 1.0001).all())
        self.assertTrue((x > 0.9999).all())
test_deprecations.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test(self):
        a = np.arange(10)
        assert_warns(np.VisibleDeprecationWarning, np.rank, a)
test_deprecations.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test(self):
        a = np.arange(10)
        assert_warns(np.VisibleDeprecationWarning, np.rank, a)
test_deprecations.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test(self):
        a = np.arange(10)
        assert_warns(np.VisibleDeprecationWarning, np.rank, a)
test_deprecations.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test(self):
        a = np.arange(10)
        assert_warns(np.VisibleDeprecationWarning, np.rank, a)
output.py 文件源码 项目:sardana 作者: sardana-org 项目源码 文件源码 阅读 49 收藏 0 点赞 0 评论 0
def _addCustomData(self, value, name, **kwargs):
        '''
        The custom data will be added as an info line in the form:
        Custom data: name : value
        '''
        if numpy.rank(value) > 0:
            v = 'Array(%s)' % str(numpy.shape(value))
        else:
            v = str(value)
        self._stream._output('Custom data: %s : %s' % (name, v))
        self._stream._flushOutput()
storage.py 文件源码 项目:sardana 作者: sardana-org 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def _addCustomData(self, value, name, **kwargs):
        '''
        The custom data will be added as a comment line in the form::

        #C name : value

        ..note:: non-scalar values (or name/values containing end-of-line) will not be written
        '''
        if self.filename is None:
            self.info(
                'Custom data "%s" will not be stored in SPEC file. Reason: uninitialized file', name)
            return
        if numpy.rank(value) > 0:  # ignore non-scalars
            self.info(
                'Custom data "%s" will not be stored in SPEC file. Reason: value is non-scalar', name)
            return
        v = str(value)
        if '\n' in v or '\n' in name:  # ignore if name or the string representation of the value contains end-of-line
            self.info(
                'Custom data "%s" will not be stored in SPEC file. Reason: unsupported format', name)
            return

        fileWasClosed = self.fd is None or self.fd.closed
        if fileWasClosed:
            try:
                self.fd = open(self.filename, 'a')
            except:
                self.info(
                    'Custom data "%s" will not be stored in SPEC file. Reason: cannot open file', name)
                return
        self.fd.write('#C %s : %s\n' % (name, v))
        self.fd.flush()
        if fileWasClosed:
            self.fd.close()  # leave the file descriptor as found
test_deprecations.py 文件源码 项目:Alfred 作者: jkachhadia 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test(self):
        a = np.arange(10)
        assert_warns(np.VisibleDeprecationWarning, np.rank, a)


问题


面经


文章

微信
公众号

扫码关注公众号