Python tables.NaturalNameWarning() Examples
The following are 4
code examples of tables.NaturalNameWarning().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tables
, or try the search function
.
Example #1
Source File: test_pytables.py From Computable with MIT License | 6 votes |
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)
Example #2
Source File: metadata.py From ctapipe with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #3
Source File: saveload.py From urbs with GNU General Public License v3.0 | 6 votes |
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]
Example #4
Source File: test_recorders.py From pywr with GNU General Public License v3.0 | 4 votes |
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)