当前位置: 首页>>代码示例>>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;未经允许,请勿转载。