python类set_printoptions()的实例源码

invResults.py 文件源码 项目:BISIP 作者: clberube 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def print_resul(sol):
#==============================================================================
    # Impression des résultats
    pm, model, filename = sol.pm, sol.model, sol.filename
    print('\n\nInversion success!')
    print('Name of file:', filename)
    print('Model used:', model)
    try:
        pm.pop("cond_std")
        pm.pop("tau_i_std")
        pm.pop("m_i_std")
    except:
        pass
    e_keys = sorted([s for s in list(pm.keys()) if "_std" in s])

    v_keys = [e.replace("_std", "") for e in e_keys]
    labels = ["{:<8}".format(x+":") for x in v_keys]
    np.set_printoptions(formatter={'float': lambda x: format(x, '6.3E')})
    for l, v, e in zip(labels, v_keys, e_keys):
        if "noise" not in l:
            print(l, np.atleast_1d(pm[v]), '+/-', np.atleast_1d(pm[e]), np.char.mod('(%.2f%%)',abs(100*pm[e]/pm[v])))
        else:
            print(l, np.atleast_1d(pm[v]), '+/-', np.atleast_1d(pm[e]))
invResults.py 文件源码 项目:BISIP 作者: clberube 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def print_resul(sol):
#==============================================================================
    # Impression des résultats
    pm, model, filename = sol.pm, sol.model, sol.filename
    print('\n\nInversion success!')
    print('Name of file:', filename)
    print('Model used:', model)
    try:
        pm.pop("cond_std")
        pm.pop("tau_i_std")
        pm.pop("m_i_std")
    except:
        pass
    e_keys = sorted([s for s in list(pm.keys()) if "_std" in s])

    v_keys = [e.replace("_std", "") for e in e_keys]
    labels = ["{:<8}".format(x+":") for x in v_keys]
    np.set_printoptions(formatter={'float': lambda x: format(x, '6.3E')})
    for l, v, e in zip(labels, v_keys, e_keys):
        if "noise" not in l:
            print(l, np.atleast_1d(pm[v]), '+/-', np.atleast_1d(pm[e]), np.char.mod('(%.2f%%)',abs(100*pm[e]/pm[v])))
        else:
            print(l, np.atleast_1d(pm[v]), '+/-', np.atleast_1d(pm[e]))
test_basc.py 文件源码 项目:PyBASC 作者: AkiNikolaidis 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_timeseries_bootstrap():
    """
    Tests the timeseries_bootstrap method of BASC workflow
    """
    np.random.seed(27)
    #np.set_printoptions(threshold=np.nan)

    # Create a 10x5 matrix which counts up by column-wise
    x = np.arange(50).reshape((5,10)).T
    actual= timeseries_bootstrap(x,3)
    desired = np.array([[ 4, 14, 24, 34, 44],
                       [ 5, 15, 25, 35, 45],
                       [ 6, 16, 26, 36, 46],
                       [ 8, 18, 28, 38, 48],
                       [ 9, 19, 29, 39, 49],
                       [ 0, 10, 20, 30, 40],
                       [ 7, 17, 27, 37, 47],
                       [ 8, 18, 28, 38, 48],
                       [ 9, 19, 29, 39, 49],
                       [ 8, 18, 28, 38, 48]])
    np.testing.assert_equal(actual, desired)
DataLoader.py 文件源码 项目:ISLES2017 作者: MiguelMonteiro 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def to_tfrecord(data, file_dir):
    for key, values in data.iteritems():
        writer = tf.python_io.TFRecordWriter(os.path.join(file_dir, key + '.tfrecord'))
        image = values['image']
        ground_truth = values['ground_truth']

        shape = np.array(image.shape).astype(np.int32)

        # set precision of string printing to be float32
        np.set_printoptions(precision=32)

        example = tf.train.Example(features=tf.train.Features(feature={
            'example_name': _bytes_feature(key),
            'shape': _bytes_feature(shape.tostring()),
            'img_raw': _bytes_feature(image.tostring()),
            'gt_raw': _bytes_feature(ground_truth.tostring())}))

        writer.write(example.SerializeToString())
        writer.close()
test_arrayprint.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def test_formatter_reset(self):
        x = np.arange(3)
        np.set_printoptions(formatter={'all':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'int':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        np.set_printoptions(formatter={'all':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'all':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        np.set_printoptions(formatter={'int':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'int_kind':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        x = np.arange(3.)
        np.set_printoptions(formatter={'float':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1.0, 0.0, 1.0])")
        np.set_printoptions(formatter={'float_kind':None})
        assert_equal(repr(x), "array([ 0.,  1.,  2.])")
show.py 文件源码 项目:evolvingcopter 作者: antocuni 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def main():
    # don't use scientific notation when printing
    numpy.set_printoptions(suppress=True)

    filename = sys.argv[1]
    with open(filename) as f:
        c = pickle.load(f)
    c.reset()

    print 'Matrix'
    print c.matrix
    print
    print 'Constant'
    print c.constant

    #env = Environment(show=True, z1=5, z2=3)
    #env = Environment(show=True, z1=5, z2=8)
    env = Environment(z0=100+3, z1=100+10, total_t=4, show=True)

    fitness = env.run(c)
    print 'fitness:', fitness
model_evaluator.py 文件源码 项目:johnson-county-ddj-public 作者: dssg 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def plot_normalized_confusion_matrix_at_depth(self):
        """ Returns a normalized confusion matrix.

        :returns: normalized confusion matrix
        :rtype: matplotlib figure
        """
        cm = metrics.confusion_matrix(self.predictions['label'], self.y_pred)
        np.set_printoptions(precision = 2)
        fig = plt.figure()
        cm_normalized = cm.astype('float') / cm.sum(axis = 1)[:, np.newaxis]

        plt.imshow(cm_normalized, interpolation = 'nearest',
                   cmap = plt.cm.Blues)
        plt.title("Normalized Confusion Matrix")
        plt.colorbar()
        tick_marks = np.arange(len(self.labels))
        plt.xticks(tick_marks, self.labels, rotation = 45)
        plt.yticks(tick_marks, self.labels)
        plt.tight_layout()
        plt.ylabel('True label')
        plt.xlabel('Predicted label')
        return(fig)
flex_util.py 文件源码 项目:ngraph 作者: NervanaSystems 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def execute_calculation(operands, first_operand, const_executor):
    iterations = len(operands) != 1
    for i in operands:
        _operands, expected_result, description = unpack_list(*i)
        if description:
            print("Description: ", description)
        print("Operands: ", _operands)
        print("Expected result: ", expected_result)
        flex_result = const_executor(*_operands)
        try:
            print("flex_result: {0:.30}".format(float(flex_result)))
        except TypeError:
            # exception for arrays
            np.set_printoptions(precision=30)
            print("flex_result: {}".format(flex_result))
        print("difference: ", flex_result - expected_result)
        if iterations:
            assert_allclose(flex_result, expected_result)
        elif not isinstance(first_operand, np.ndarray):
            assert flex_result == expected_result
        else:
            assert np.array_equal(flex_result, expected_result)
min_max_norm.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list):

        logger = logging.getLogger("acoustic_norm")

        mean_vector = numpy.zeros((1, self.feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features = io_funcs.load_binary_file(file_name, self.feature_dimension)
            current_frame_number = features.size // self.feature_dimension
            mean_vector += numpy.reshape(numpy.sum(features, axis=0), (1, self.feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
feature_normalisation_base.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list, start_index, end_index):

        local_feature_dimension = end_index - start_index

        mean_vector = numpy.zeros((1, local_feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features, current_frame_number = io_funcs.load_binary_file_frame(file_name, self.feature_dimension)

            mean_vector += numpy.reshape(numpy.sum(features[:, start_index:end_index], axis=0), (1, local_feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        self.logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        self.logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
test_kf.py 文件源码 项目:KaFKA 作者: jgomezdans 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_propagate_information_filter():
    np.set_printoptions(precision=2, linewidth=132)

    M_matrix = np.eye(7)
    sigma = np.array([0.12, 0.7, 0.0959, 0.15, 1.5, 0.2, 0.5])
    x_analysis = np.array([0.17, 1.0, 0.1, 0.7, 2.0, 0.18, np.exp(-0.5*1.5)])
    Pd = np.diag(sigma**2).astype(np.float32)
    Pd[5, 2] = 0.8862*0.0959*0.2
    Pd[2, 5] = 0.8862*0.0959*0.2
    Pi = np.linalg.inv(Pd)
    Q_matrix = np.eye(7)*0.1

    x_forecast, P_forecast, P_forecast_inverse = propagate_information_filter(
        x_analysis, None, Pi, M_matrix, Q_matrix)
    assert np.allclose(
        np.array(P_forecast_inverse.todense()).squeeze().diagonal(),
        np.array([8.74, 1.69, 9.81, 8.16, 0.43, 9.21, 2.86]), atol=0.01)
    # In reality, the matrix ought to be
    # [[ 8.74  0.    0.    0.    0.    0.    0.  ]
    # [ 0.    1.69  0.    0.    0.    0.    0.  ]
    # [ 0.    0.    9.33  0.    0.   -1.13  0.  ]
    # [ 0.    0.    0.    8.16  0.    0.    0.  ]
    # [ 0.    0.    0.    0.    0.43  0.    0.  ]
    # [ 0.    0.   -1.13  0.    0.    7.28  0.  ]
    # [ 0.    0.    0.    0.    0.    0.    2.86]]
visualize_space.py 文件源码 项目:Msc_Multi_label_ZeroShot 作者: thomasSve 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def main():

    args = parse_args()

    print('Called with args:')
    print(args)
    lang_db = get_language_model(args.lang_name)
    imdb = get_imdb(args.imdb_name)

    # Get words in space
    vocabulary = imdb.get_labels(args.space)

    # Get features for words
    wv = [lang_db.word_vector(w) for w in vocabulary]
    from sklearn.metrics.pairwise import cosine_similarity
    from scipy import spatial
    #spatial.distance.cosine(dataSetI, dataSetII)
    tsne = TSNE(n_components=2, random_state=0)
    np.set_printoptions(suppress=True)
    Y = tsne.fit_transform(wv)

    plt.scatter(Y[:, 0], Y[:, 1])
    for label, x, y in zip(vocabulary, Y[:, 0], Y[:, 1]):
        plt.annotate(label, xy=(x, y), xytext=(0, 0), textcoords='offset points')
    plt.show()
test_arrayprint.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_formatter_reset(self):
        x = np.arange(3)
        np.set_printoptions(formatter={'all':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'int':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        np.set_printoptions(formatter={'all':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'all':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        np.set_printoptions(formatter={'int':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'int_kind':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        x = np.arange(3.)
        np.set_printoptions(formatter={'float':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1.0, 0.0, 1.0])")
        np.set_printoptions(formatter={'float_kind':None})
        assert_equal(repr(x), "array([ 0.,  1.,  2.])")
theano_helpers.py 文件源码 项目:NADE 作者: MarcCote 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def detect_nan(i, node, fn):
    '''
    x = theano.tensor.dscalar('x')
    f = theano.function([x], [theano.tensor.log(x) * x],
                        mode=theano.compile.MonitorMode(post_func=detect_nan))
    '''
    nan_detected = False
    for output in fn.outputs:
        if np.isnan(output[0]).any():
            nan_detected = True
            np.set_printoptions(threshold=np.nan)  # Print the whole arrays
            print '*** NaN detected ***'
            print '--------------------------NODE DESCRIPTION:'
            theano.printing.debugprint(node)
            print '--------------------------Variables:'
            print 'Inputs : %s' % [input[0] for input in fn.inputs]
            print 'Outputs: %s' % [output[0] for output in fn.outputs]
            break
    if nan_detected:
        exit()
driver.py 文件源码 项目:mgail 作者: itaicaspi 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__(self, environment):

        self.env = environment
        self.algorithm = MGAIL(environment=self.env)
        self.init_graph = tf.global_variables_initializer()
        self.saver = tf.train.Saver()
        self.sess = tf.Session()
        if self.env.trained_model:
            self.saver.restore(self.sess, self.env.trained_model)
        else:
            self.sess.run(self.init_graph)
        self.run_dir = self.env.run_dir
        self.loss = 999. * np.ones(3)
        self.reward_mean = 0
        self.reward_std = 0
        self.run_avg = 0.001
        self.discriminator_policy_switch = 0
        self.policy_loop_time = 0
        self.disc_acc = 0
        self.er_count = 0
        self.itr = 0
        self.best_reward = 0
        self.mode = 'Prep'
        np.set_printoptions(precision=2)
        np.set_printoptions(linewidth=220)
target_setup_gui.py 文件源码 项目:gps 作者: cbfinn 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def update_target_text(self):
        np.set_printoptions(precision=3, suppress=True)
        text = (
            'target number = %s\n' % str(self._target_number) +
            'actuator name = %s\n' % str(self._actuator_name) +
            '\ninitial position\n%s' % self.position_to_str(self._initial_position) +
            '\ntarget position\n%s' % self.position_to_str(self._target_position) +
            '\ninitial image (left) =\n%s\n' % str(self._initial_image) +
            '\ntarget image (right) =\n%s\n' % str(self._target_image)
        )
        self._target_output.set_text(text)

        if config['image_on']:
            self._initial_image_visualizer.update(self._initial_image)
            self._target_image_visualizer.update(self._target_image)
            self._image_visualizer.set_initial_image(self._initial_image, alpha=0.3)
            self._image_visualizer.set_target_image(self._target_image, alpha=0.3)
main.py 文件源码 项目:SynThai 作者: KenjiroAI 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def encode(content, word_delimiter="|", tag_delimiter="/", num_step=60):
    # Create corpus instance
    corpus = Corpus(word_delimiter=word_delimiter, tag_delimiter=tag_delimiter)

    # Add text to corpus
    corpus.add_text(content)

    # Create index for character and tag
    char_index = index_builder(constant.CHARACTER_LIST,
                               constant.CHAR_START_INDEX)
    tag_index = index_builder(constant.TAG_LIST, constant.TAG_START_INDEX)

    # Generate input
    inb = InputBuilder(corpus, char_index, tag_index, num_step, y_one_hot=False)

    # Display encoded content
    np.set_printoptions(threshold=np.inf)
    print("[Input]")
    print(inb.x)
    print("[Label]")
    print(inb.y)
solveCrossTime.py 文件源码 项目:TICC 作者: davidhallac 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def PrintSolution(self, Filename=None):
        numpy.set_printoptions(linewidth=numpy.inf)
        out = sys.stdout if (Filename == None) else open(Filename, 'w+')

        out.write('Status: %s\n' % self.status)
        out.write('Total Objective: %f\n' % self.value)
        for ni in self.Nodes():
            nid = ni.GetId()
            s = 'Node %d:\n' % nid
            out.write(s)
            for (varID, varName, var, offset) in self.node_variables[nid]:
                val = numpy.transpose(self.GetNodeValue(nid, varName))
                s = '  %s %s\n' % (varName, str(val))
                out.write(s)

    # Helper method to verify existence of an NId.
min_max_norm.py 文件源码 项目:world_merlin 作者: pbaljeka 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list):

        logger = logging.getLogger("acoustic_norm")

        mean_vector = numpy.zeros((1, self.feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features = io_funcs.load_binary_file(file_name, self.feature_dimension)
            current_frame_number = features.size / self.feature_dimension
            mean_vector += numpy.reshape(numpy.sum(features, axis=0), (1, self.feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
feature_normalisation_base.py 文件源码 项目:world_merlin 作者: pbaljeka 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list, start_index, end_index):

        local_feature_dimension = end_index - start_index

        mean_vector = numpy.zeros((1, local_feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features, current_frame_number = io_funcs.load_binary_file_frame(file_name, self.feature_dimension)

            mean_vector += numpy.reshape(numpy.sum(features[:, start_index:end_index], axis=0), (1, local_feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        self.logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        self.logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
test_arrayprint.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def test_formatter_reset(self):
        x = np.arange(3)
        np.set_printoptions(formatter={'all':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'int':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        np.set_printoptions(formatter={'all':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'all':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        np.set_printoptions(formatter={'int':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'int_kind':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        x = np.arange(3.)
        np.set_printoptions(formatter={'float':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1.0, 0.0, 1.0])")
        np.set_printoptions(formatter={'float_kind':None})
        assert_equal(repr(x), "array([ 0.,  1.,  2.])")
logger.py 文件源码 项目:mlens 作者: flennerhag 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def pformat(obj, indent=0, depth=3):
    if 'numpy' in sys.modules:
        import numpy as np
        print_options = np.get_printoptions()
        np.set_printoptions(precision=6, threshold=64, edgeitems=1)
    else:
        print_options = None
    out = pprint.pformat(obj, depth=depth, indent=indent)
    if print_options:
        np.set_printoptions(**print_options)
    return out


###############################################################################
# class `Logger`
###############################################################################
min_max_norm.py 文件源码 项目:mimicry.ai 作者: fizerkhan 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list):

        logger = logging.getLogger("acoustic_norm")

        mean_vector = numpy.zeros((1, self.feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features = io_funcs.load_binary_file(file_name, self.feature_dimension)
            current_frame_number = features.size / self.feature_dimension
            mean_vector += numpy.reshape(numpy.sum(features, axis=0), (1, self.feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
feature_normalisation_base.py 文件源码 项目:mimicry.ai 作者: fizerkhan 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list, start_index, end_index):

        local_feature_dimension = end_index - start_index

        mean_vector = numpy.zeros((1, local_feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features, current_frame_number = io_funcs.load_binary_file_frame(file_name, self.feature_dimension)

            mean_vector += numpy.reshape(numpy.sum(features[:, start_index:end_index], axis=0), (1, local_feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        self.logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        self.logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
test_irreps.py 文件源码 项目:upho 作者: yuzie007 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_fcc_conv(self):
        # np.set_printoptions(threshold=2304, linewidth=145)  # 48 * 48
        filename = "../poscars/POSCAR_fcc"

        atoms = read_vasp(filename)
        symmetry = UnfolderSymmetry(atoms)

        rotations = symmetry.get_pointgroup_operations()
        check_irreps(rotations)

        rotations = symmetry.get_group_of_wave_vector([0.00, 0.25, 0.25])[0]
        check_irreps(rotations)

        rotations = symmetry.get_group_of_wave_vector([0.25, 0.00, 0.25])[0]
        check_irreps(rotations)

        rotations = symmetry.get_group_of_wave_vector([0.25, 0.25, 0.00])[0]
        check_irreps(rotations)
test_arrayprint.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_formatter_reset(self):
        x = np.arange(3)
        np.set_printoptions(formatter={'all':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'int':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        np.set_printoptions(formatter={'all':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'all':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        np.set_printoptions(formatter={'int':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1, 0, 1])")
        np.set_printoptions(formatter={'int_kind':None})
        assert_equal(repr(x), "array([0, 1, 2])")

        x = np.arange(3.)
        np.set_printoptions(formatter={'float':lambda x: str(x-1)})
        assert_equal(repr(x), "array([-1.0, 0.0, 1.0])")
        np.set_printoptions(formatter={'float_kind':None})
        assert_equal(repr(x), "array([ 0.,  1.,  2.])")
target_setup_gui.py 文件源码 项目:gps_superball_public 作者: young-geng 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def update_target_text(self):
        np.set_printoptions(precision=3, suppress=True)
        text = (
            'target number = %s\n' % str(self._target_number) +
            'actuator name = %s\n' % str(self._actuator_name) +
            '\ninitial position\n%s' % self.position_to_str(self._initial_position) +
            '\ntarget position\n%s' % self.position_to_str(self._target_position) +
            '\ninitial image (left) =\n%s\n' % str(self._initial_image) +
            '\ntarget image (right) =\n%s\n' % str(self._target_image)
        )
        self._target_output.set_text(text)

        if config['image_on']:
            self._initial_image_visualizer.update(self._initial_image)
            self._target_image_visualizer.update(self._target_image)
            self._image_visualizer.set_initial_image(self._initial_image, alpha=0.3)
            self._image_visualizer.set_target_image(self._target_image, alpha=0.3)
im_pipeline.py 文件源码 项目:anirban-imitation 作者: Santara 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def main():
    np.set_printoptions(suppress=True, precision=5, linewidth=1000)

    phases = {
        '0_sampletrajs': phase0_sampletrajs,
        '1_train': phase1_train,
        '2_eval': phase2_eval,
    }

    parser = argparse.ArgumentParser()
    parser.add_argument('spec', type=str)
    parser.add_argument('phase', choices=sorted(phases.keys()))
    args = parser.parse_args()

    with open(args.spec, 'r') as f:
        spec = yaml.load(f)

    phases[args.phase](spec, args.spec)
export.py 文件源码 项目:pyhiro 作者: wanweiwei07 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def export_collada(mesh):
    '''
    Export a mesh as a COLLADA file.
    '''
    from ..templates import get_template
    from string import Template

    template_string = get_template('collada.dae.template')
    template = Template(template_string)

    # we bother setting this because np.array2string uses these printoptions 
    np.set_printoptions(threshold=np.inf, precision=5, linewidth=np.inf)
    replacement = dict()
    replacement['VERTEX']   = np.array2string(mesh.vertices.reshape(-1))[1:-1]
    replacement['FACES']    = np.array2string(mesh.faces.reshape(-1))[1:-1]
    replacement['NORMALS']  = np.array2string(mesh.vertex_normals.reshape(-1))[1:-1]
    replacement['VCOUNT']   = str(len(mesh.vertices))
    replacement['VCOUNTX3'] = str(len(mesh.vertices) * 3)
    replacement['FCOUNT']   = str(len(mesh.faces))

    export = template.substitute(replacement)
    return export
ACOscillator.py 文件源码 项目:AutoTrading 作者: curme 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def ACO(self, df):
        """
        Helper indicator
        :param df:
        :return:
        """
        df_mid_points = (df['High'] + df['Low']) / 2
        mid_points = Data.toFloatArray(df_mid_points)
        longav = tl.SMA(np.array(mid_points), timeperiod=40)
        shortav = tl.SMA(np.array(mid_points), timeperiod=15)
        A0 = longav - shortav
        Mavg = tl.SMA(A0, timeperiod=15)
        AcResult = tl.SMA(Mavg - A0, timeperiod=15)
        signals = np.diff(AcResult)
        return signals

        # if __name__ == "__main__":
        #     np.set_printoptions(threshold=np.nan)
        #     pd.set_option("display.max_rows", 280)
        #     dt = Data()
        #     df = dt.getCSVData()
        #     #ACOscillator(df)
        #     ACOscillator(df)


问题


面经


文章

微信
公众号

扫码关注公众号