當前位置: 首頁>>代碼示例>>Python>>正文


Python tables.NaturalNameWarning方法代碼示例

本文整理匯總了Python中tables.NaturalNameWarning方法的典型用法代碼示例。如果您正苦於以下問題:Python tables.NaturalNameWarning方法的具體用法?Python tables.NaturalNameWarning怎麽用?Python tables.NaturalNameWarning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tables的用法示例。


在下文中一共展示了tables.NaturalNameWarning方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_contains

# 需要導入模塊: import tables [as 別名]
# 或者: from tables import NaturalNameWarning [as 別名]
def test_contains(self):

        with ensure_clean_store(self.path) as store:
            store['a'] = tm.makeTimeSeries()
            store['b'] = tm.makeDataFrame()
            store['foo/bar'] = tm.makeDataFrame()
            self.assert_('a' in store)
            self.assert_('b' in store)
            self.assert_('c' not in store)
            self.assert_('foo/bar' in store)
            self.assert_('/foo/bar' in store)
            self.assert_('/foo/b' not in store)
            self.assert_('bar' not in store)

            # GH 2694
            warnings.filterwarnings('ignore', category=tables.NaturalNameWarning)
            store['node())'] = tm.makeDataFrame()
            self.assert_('node())' in store) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:20,代碼來源:test_pytables.py

示例2: write_to_hdf5

# 需要導入模塊: import tables [as 別名]
# 或者: from tables import NaturalNameWarning [as 別名]
def write_to_hdf5(metadata, h5file):
    """
    Write metadata fields to a PyTables HDF5 file handle.

    Parameters
    ----------
    metadata: dict
        flat dict as generated by `Reference.to_dict()`
    h5file: tables.file.File
        pytables filehandle
    """
    from tables import NaturalNameWarning

    with warnings.catch_warnings():
        warnings.simplefilter("ignore", NaturalNameWarning)
        for key, value in metadata.items():
            h5file.root._v_attrs[key] = value  # pylint: disable=protected-access 
開發者ID:cta-observatory,項目名稱:ctapipe,代碼行數:19,代碼來源:metadata.py

示例3: save

# 需要導入模塊: import tables [as 別名]
# 或者: from tables import NaturalNameWarning [as 別名]
def save(prob, filename):
    """Save urbs model input and result cache to a HDF5 store file.

    Args:
        - prob: a urbs model instance containing a solution
        - filename: HDF5 store file to be written

    Returns:
        Nothing
    """
    import warnings
    import tables
    warnings.filterwarnings('ignore',
                            category=pd.io.pytables.PerformanceWarning)
    warnings.filterwarnings('ignore',
                            category=tables.NaturalNameWarning)

    if not hasattr(prob, '_result'):
        prob._result = create_result_cache(prob)

    with pd.HDFStore(filename, mode='w') as store:
        for name in prob._data.keys():
            store['data/'+name] = prob._data[name]
        for name in prob._result.keys():
            store['result/'+name] = prob._result[name] 
開發者ID:tum-ens,項目名稱:urbs,代碼行數:27,代碼來源:saveload.py

示例4: test_parameters

# 需要導入模塊: import tables [as 別名]
# 或者: from tables import NaturalNameWarning [as 別名]
def test_parameters(self, simple_linear_model, tmpdir):
        """
        Test the TablesRecorder

        """
        from pywr.parameters import ConstantParameter

        model = simple_linear_model
        otpt = model.nodes['Output']
        inpt = model.nodes['Input']

        p = ConstantParameter(model, 10.0, name='max_flow')
        inpt.max_flow = p

        # ensure TablesRecorder can handle parameters with a / in the name
        p_slash = ConstantParameter(model, 0.0, name='name with a / in it')
        inpt.min_flow = p_slash

        agg_node = AggregatedNode(model, 'Sum', [otpt, inpt])

        inpt.max_flow = 10.0
        otpt.cost = -2.0

        h5file = tmpdir.join('output.h5')
        import tables
        with tables.open_file(str(h5file), 'w') as h5f:
            with pytest.warns(ParameterNameWarning):
                rec = TablesRecorder(model, h5f, parameters=[p, p_slash])

            # check parameters have been added to the component tree
            # this is particularly important for parameters which update their
            # values in `after`, e.g. DeficitParameter (see #465)
            assert(not model.find_orphaned_parameters())
            assert(p in rec.children)
            assert(p_slash in rec.children)

            with pytest.warns(tables.NaturalNameWarning):
                model.run()

            for node_name in model.nodes.keys():
                ca = h5f.get_node('/', node_name)
                assert ca.shape == (365, 1)
                if node_name == 'Sum':
                    np.testing.assert_allclose(ca, 20.0)
                elif "name with a" in node_name:
                    assert(node_name == "name with a _ in it")
                    np.testing.assert_allclose(ca, 0.0)
                else:
                    np.testing.assert_allclose(ca, 10.0) 
開發者ID:pywr,項目名稱:pywr,代碼行數:51,代碼來源:test_recorders.py


注:本文中的tables.NaturalNameWarning方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。