Repository: PMEAL/OpenPNM
Pull request #2106 (2021-10-25 15:26:02)

Delete unused functions from misc
For issue #2034. See first if deleting these functions broke anything. 


Patch:
diff --git a/openpnm/algorithms/__init__.py b/openpnm/algorithms/__init__.py
index cc7bf0c77..fb18a06ac 100644
--- a/openpnm/algorithms/__init__.py
+++ b/openpnm/algorithms/__init__.py
@@ -37,12 +37,10 @@ from .Porosimetry import Porosimetry
 from .IonicConduction import IonicConduction
 from .TransientIonicConduction import TransientIonicConduction
 
-from .NernstPlanck import NernstPlanck
-from .TransientNernstPlanck import TransientNernstPlanck
+# from .NernstPlanck import *
+# from .TransientNernstPlanck import *
 
-from .NernstPlanckMultiphysicsSolver import NernstPlanckMultiphysicsSolver
-from .TransientNernstPlanckMultiphysicsSolver import (
-    TransientNernstPlanckMultiphysicsSolver
-)
+# from .NernstPlanckMultiphysicsSolver import *
+# from .TransientNernstPlanckMultiphysicsSolver *
 
 from . import metrics
diff --git a/openpnm/physics/__init__.py b/openpnm/physics/__init__.py
index 0658c432b..a9ef4193d 100644
--- a/openpnm/physics/__init__.py
+++ b/openpnm/physics/__init__.py
@@ -25,5 +25,4 @@ classes that include common pore-scale physical models
 
 from .GenericPhysics import GenericPhysics
 from .Standard import Standard
-from .Standard2D import Standard2D
 from .Basic import Basic
diff --git a/openpnm/utils/misc.py b/openpnm/utils/misc.py
index 5903757da..722eec450 100644
--- a/openpnm/utils/misc.py
+++ b/openpnm/utils/misc.py
@@ -26,11 +26,8 @@ __all__ = [
     "tic", "toc",
     "is_symmetric",
     "is_valid_propname",
-    "nbr_to_str",
-    "conduit_dict_to_array",
-    "conduit_array_to_dict",
     "prettify_logger_message",
-    "remove_prop_deep"
+    "remove_prop_deep",
 ]
 
 
@@ -553,92 +550,6 @@ def is_valid_propname(propname):
     return True
 
 
-def nbr_to_str(nbr, t_precision):
-    r"""
-    Converts a scalar into a string in scientific (exponential) notation
-    without the decimal point.
-
-    Parameters
-    ----------
-    nbr : scalar
-        The number to be converted into a scalar.
-
-    t_precision : integer
-        The time precision (number of decimal places). Default value is 12.
-
-    """
-    from decimal import Decimal as dc
-    n = int(-dc(str(round(nbr, t_precision))).as_tuple().exponent
-            * (round(nbr, t_precision) != int(nbr)))
-    nbr_str = (str(int(round(nbr, t_precision) * 10**n)) + (f'e-{n}') * (n != 0))
-    return nbr_str
-
-
-def conduit_dict_to_array(d):
-    r"""
-    Converts a conduit dict to a 3-column wide ndarray.
-
-    A conduit dict contains 3 arrays pertaining to pore1, throat, and
-    pore2. These arrays can be accessed via keys: 'pore1', 'throat',
-    and 'pore2'.
-
-    Parameters
-    ----------
-    d : dict
-        Conduit dictionary with keys 'pore1', 'throat', and 'pore2'.
-
-    Returns
-    -------
-    ndarray
-        Conduit array, i.e. 3-column wide, with columns pertaining to
-        pore1, throat, and pore2, respectively.
-
-    """
-    _validate_conduit_dict(d)
-    return _np.vstack((d["pore1"], d["throat"], d["pore2"])).T
-
-
-def conduit_array_to_dict(arr):
-    r"""
-    Converts a conduit array to a conduit dict.
-
-    A conduit array is 3 columns wide, each pertaining to a conduit
-    property for pore1, throat, and pore2, respectively.
-
-    Parameters
-    ----------
-    arr : ndarray
-        Conduit array.
-
-    Returns
-    -------
-    dict
-        Conduit dictionary with keys 'pore1', 'throat', and 'pore2'.
-
-    """
-    _validate_conduit_array(arr)
-    return {"pore1": arr[:, 0], "throat": arr[:, 1], "pore2": arr[:, 2]}
-
-
-def _validate_conduit_dict(d):
-    r"""Validates whether the given dictionary is a proper conduit dict."""
-    if not isinstance(d, dict):
-        raise Exception("Conduit dictionary must be of type dict.")
-    allowed_keys = set(["pore1", "throat", "pore2"])
-    if allowed_keys != set(d.keys()):
-        raise Exception("Conduit dictionary keys must be 'pore1', 'throat', and 'pore2'")
-    elem_lengths = [len(x) for x in d.values()]
-    if len(_np.unique(elem_lengths)) != 1:
-        raise Exception("Conduit dictionary must have arrays of the same length.")
-
-
-def _validate_conduit_array(arr):
-    r"""Validates whether the given array is a proper conduit array."""
-    arr = _np.array(arr)
-    if arr.shape[1] != 3:
-        raise Exception("Conduit array must be exactly 3 columns wide.")
-
-
 def prettify_logger_message(msg):
     r"""
     Prettifies logger messages by breaking them up into multi lines


Test patch:
diff --git a/pytest.ini b/pytest.ini
index 4bfbd0e1a..1f6dcd411 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -17,6 +17,10 @@ addopts =
     --ignore="examples/tutorials/intro_to_openpnm_advanced.ipynb"
     --ignore="examples/paper_recreations/Tranter et al. (2017)/Tranter et al. (2017) - Part B.ipynb"
     --ignore="examples/paper_recreations/Gostick et al. (2007)/Gostick et al. (2007).ipynb"
+    --ignore="openpnm/algorithms/NernstPlanckMultiphysicsSolver.py"
+    --ignore="openpnm/algorithms/NernstPlanck.py"
+    --ignore="openpnm/algorithms/TransientNernstPlanckMultiphysicsSolver.py"
+    --ignore="openpnm/algorithms/TransientNernstPlanck.py"
     --ignore="scripts/"
     -p no:warnings
 norecursedirs =
diff --git a/tests/unit/algorithms/NernstPlanckTest.py b/tests/unit/algorithms/NernstPlanckTest.py
index d73a3eccd..936b10643 100644
--- a/tests/unit/algorithms/NernstPlanckTest.py
+++ b/tests/unit/algorithms/NernstPlanckTest.py
@@ -4,6 +4,7 @@ import openpnm as op
 from numpy.testing import assert_allclose
 
 
+@pytest.mark.skip(reason="Needs to be refactored using Integrators")
 class NernstPlanckTest:
 
     def setup_class(self):
diff --git a/tests/unit/core/ExtrasTest.py b/tests/unit/core/ExtrasTest.py
index 997f56fb8..48438847a 100644
--- a/tests/unit/core/ExtrasTest.py
+++ b/tests/unit/core/ExtrasTest.py
@@ -116,10 +116,6 @@ class ExtrasTest:
         ws.settings['loglevel'] = 50
         classes = [c for c in dir(op.algorithms) if not c.startswith('__')]
         mod = importlib.import_module('openpnm.algorithms')
-        # The following 3 should be fixed to accept no phase arguments
-        classes.pop(classes.index('NernstPlanck'))
-        classes.pop(classes.index('NernstPlanckMultiphysicsSolver'))
-        classes.pop(classes.index('TransientNernstPlanckMultiphysicsSolver'))
         # metrics should be ignored
         classes.pop(classes.index('metrics'))
         for c in classes:
@@ -135,7 +131,6 @@ if __name__ == '__main__':
 
     t = ExtrasTest()
     self = t
-    t.setup_class()
     for item in t.__dir__():
         if item.startswith('test'):
             print('running test: '+item)