PMEAL / OpenPNM

A Python package for performing pore network modeling of porous media
http://openpnm.org
MIT License
442 stars 175 forks source link

Fix deprecation warnings #1602

Closed ma-sadeghi closed 4 years ago

ma-sadeghi commented 4 years ago

After merging @Ni2M's PR, most of the deprecation warnings are now fixed. There are a few left though that need to be addressed. Here is a summary of outstanding warnings:

=============================================================== warnings summary ===============================================================
openpnm/materials/VoronoiFibers.py::openpnm.materials.VoronoiFibers.VoronoiFibers
tests/unit/materials/VoronoiFibersTest.py::VoronoiTest::test_props_all
tests/unit/materials/VoronoiFibersTest.py::VoronoiTest::test_vertex_dimension
tests/unit/materials/VoronoiFibersTest.py::VoronoiTest::test_linear_scale
tests/unit/materials/VoronoiFibersTest.py::VoronoiTest::test_linear_scale_wrong_shape
tests/unit/models/physics/CapillaryPressureTest.py::CapillaryPressureTest::test_ransohoff_snapoff_verts
  C:\Users\Amin\Code\OpenPNM\openpnm\materials\VoronoiFibers.py:595: DeprecationWarning: `itemfreq` is deprecated!
  `itemfreq` is deprecated and will be removed in a future version. Use instead `np.unique(..., return_counts=True)`
    freq_pore_vox = itemfreq(pore_space)

openpnm/materials/VoronoiFibers.py::openpnm.materials.VoronoiFibers.VoronoiFibers
tests/unit/materials/VoronoiFibersTest.py::VoronoiTest::test_props_all
tests/unit/materials/VoronoiFibersTest.py::VoronoiTest::test_vertex_dimension
tests/unit/materials/VoronoiFibersTest.py::VoronoiTest::test_linear_scale
tests/unit/materials/VoronoiFibersTest.py::VoronoiTest::test_linear_scale_wrong_shape
tests/unit/models/physics/CapillaryPressureTest.py::CapillaryPressureTest::test_ransohoff_snapoff_verts
  C:\Users\Amin\Code\OpenPNM\openpnm\materials\VoronoiFibers.py:597: DeprecationWarning: `itemfreq` is deprecated!
  `itemfreq` is deprecated and will be removed in a future version. Use instead `np.unique(..., return_counts=True)`
    freq_fiber_vox = itemfreq(fiber_space)

openpnm/topotools/topotools.py::openpnm.topotools.topotools.find_clusters
  <doctest openpnm.topotools.topotools.find_clusters[3]>:1: DeprecationWarning: scipy.rand is deprecated and will be removed in SciPy 2.0.0, use numpy.random.rand instead

openpnm/topotools/topotools.py::openpnm.topotools.topotools.find_clusters
  <doctest openpnm.topotools.topotools.find_clusters[4]>:1: DeprecationWarning: scipy.rand is deprecated and will be removed in SciPy 2.0.0, use numpy.random.rand instead

tests/unit/core/BaseTest.py::BaseTest::test_setitem_replace_all
  C:\Users\Amin\Code\OpenPNM\openpnm\core\Base.py:232: UserWarning: pore.all is already defined.
    warnings.warn(key+' is already defined.')

tests/unit/core/SubdomainTest.py::SubdomainTest::test_interleave_data_object
  C:\Users\Amin\Code\OpenPNM\openpnm\core\Base.py:218: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
    value = np.array(value, ndmin=1)  # Convert value to an ndarray

tests/unit/geometry/BoundaryTest.py::BoundaryTest::test_plot_histogram
tests/unit/geometry/GenericGeometryTest.py::GenericGeometryTest::test_plot_histogram
  C:\Users\Amin\Code\OpenPNM\openpnm\core\Base.py:1633: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
    plt.subplot(r, c, i+1)

tests/unit/io/VTKTest.py: 46 warnings
  C:\Users\Amin\Code\OpenPNM\openpnm\io\VTK.py:233: DeprecationWarning: Numeric-style type codes are deprecated and will result in an error in the future.
    array = array.astype(dtype)

tests/unit/utils/ProjectTest.py::ProjectTest::test_dump_and_fetch_data
  C:\Users\Amin\Code\OpenPNM\openpnm\utils\Project.py:645: H5pyDeprecationWarning: The default file mode will change to 'r' (read-only) in h5py 3.0. To suppress this warning, pass the mode you need to h5py.File(), or set the global default h5.get_config().default_file_mode, or set the environment variable H5PY_DEFAULT_READONLY=1. Available modes are: 'r', 'r+', 'w', 'w-'/'x', 'a'. See the docs for details.
    with h5py.File(self.name + '.hdf5') as f:

tests/unit/utils/ProjectTest.py::ProjectTest::test_dump_and_fetch_data
  C:\Users\Amin\Code\OpenPNM\openpnm\utils\Project.py:678: H5pyDeprecationWarning: The default file mode will change to 'r' (read-only) in h5py 3.0. To suppress this warning, pass the mode you need to h5py.File(), or set the global default h5.get_config().default_file_mode, or set the environment variable H5PY_DEFAULT_READONLY=1. Available modes are: 'r', 'r+', 'w', 'w-'/'x', 'a'. See the docs for details.
    with h5py.File(self.name + '.hdf5') as f:

-- Docs: https://docs.pytest.org/en/stable/warnings.html
====================================================== 937 passed, 66 warnings in 53.56s =======================================================

@Ni2M Could you please address these outstanding warnings? Thank you.

Ni2M commented 4 years ago

Thank you @ma-sadeghi for following up. I will check these warnings and fix them in a PR.