Repository: ramonhagenaars/nptyping

Issue:
BUG: cannot validate 0d arrays
0d arrays crash basic validation
```python
import numpy as np
from nptyping import NDArray

isinstance(np.array(1), NDArray)
```

<details>
<summary>Traceback</summary>

```
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/robcleme/.pyenv/versions/3.9.6/envs/unyt-dev/lib/python3.9/site-packages/typish/classes/_ │
│ cls_function.py:68 in __call__                                                                   │
│                                                                                                  │
│   65 │   │   │   │   │   │   │   'positional argument.')                                         │
│   66 │   │   callable_ = self.body[args[0]]                                                      │
│   67 │   │   try:                                                                                │
│ ❱ 68 │   │   │   return callable_(*args, **kwargs)                                               │
│   69 │   │   except TypeError as err:                                                            │
│   70 │   │   │   raise TypeError('Unable to call function for \'{}\': {}'                        │
│   71 │   │   │   │   │   │   │   .format(args[0], err.args[0]))                                  │
│                                                                                                  │
│ /Users/robcleme/.pyenv/versions/3.9.6/envs/unyt-dev/lib/python3.9/site-packages/nptyping/functio │
│ ns/_get_type.py:74 in _get_type_arrary                                                           │
│                                                                                                  │
│    71 def _get_type_arrary(arr: numpy.ndarray) -> Type['NPType']:                                │
│    72 │   # Return the nptyping type of a numpy array.                                           │
│    73 │   type_ = get_type(arr.dtype)                                                            │
│ ❱  74 │   return NDArray[arr.shape, type_]                                                       │
│    75                                                                                            │
│    76                                                                                            │
│    77 def _get_type_of_number(                                                                   │
│                                                                                                  │
│ /Users/robcleme/.pyenv/versions/3.9.6/envs/unyt-dev/lib/python3.9/site-packages/nptyping/types/_ │
│ ndarray_meta.py:113 in __getitem__                                                               │
│                                                                                                  │
│   110 │   │   ]))                                                                                │
│   111 │   │                                                                                      │
│   112 │   │   if not method.understands(item):                                                   │
│ ❱ 113 │   │   │   raise TypeError('Invalid parameter for NDArray: "{}"'.format(item))            │
│   114 │   │   shape, type_ = method(item)                                                        │
│   115 │   │   return HashedSubscriptableType.__getitem__(cls, (shape, type_))                    │
│   116                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: Invalid parameter for NDArray: "((), Int[64])"

During handling of the above exception, another exception occurred:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ <ipython-input-2-6a26cbf626dd>:4 in <module>                                                     │
│                                                                                                  │
│ /Users/robcleme/.pyenv/versions/3.9.6/envs/unyt-dev/lib/python3.9/site-packages/nptyping/types/_ │
│ ndarray_meta.py:74 in __instancecheck__                                                          │
│                                                                                                  │
│    71 │   │   :return: True if instance is an instance of cls.                                   │
│    72 │   │   """                                                                                │
│    73 │   │   from nptyping.functions._get_type import get_type                                  │
│ ❱  74 │   │   np_type = get_type(instance)                                                       │
│    75 │   │   return (np_type.__name__ == cls.__name__                                           │
│    76 │   │   │   │   and _NDArrayMeta.__subclasscheck__(                                        │
│    77 │   │   │   │   │   cls, _NDArray[instance.shape, instance.dtype]))                        │
│                                                                                                  │
│ /Users/robcleme/.pyenv/versions/3.9.6/envs/unyt-dev/lib/python3.9/site-packages/nptyping/functio │
│ ns/_get_type.py:40 in get_type                                                                   │
│                                                                                                  │
│    37 │   :param obj: the object for which an nptyping type is to be returned.                   │
│    38 │   :return: a subclass of NPType.                                                         │
│    39 │   """                                                                                    │
│ ❱  40 │   return ClsFunction(_delegates)(obj)                                                    │
│    41                                                                                            │
│    42                                                                                            │
│    43 def _get_type_type(type_: type) -> Type['NPType']:                                         │
│                                                                                                  │
│ /Users/robcleme/.pyenv/versions/3.9.6/envs/unyt-dev/lib/python3.9/site-packages/typish/classes/_ │
│ cls_function.py:70 in __call__                                                                   │
│                                                                                                  │
│   67 │   │   try:                                                                                │
│   68 │   │   │   return callable_(*args, **kwargs)                                               │
│   69 │   │   except TypeError as err:                                                            │
│ ❱ 70 │   │   │   raise TypeError('Unable to call function for \'{}\': {}'                        │
│   71 │   │   │   │   │   │   │   .format(args[0], err.args[0]))                                  │
│   72                                                                                             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: Unable to call function for '1': Invalid parameter for NDArray: "((), Int[64])"
```

</details>

I don't suppose this is expected ?

Discussion:

Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index 9eca594..1d55a6e 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,6 +3,11 @@
 History
 -------
 
+1.4.4 (2021-09-10)
+++++++++++++++++++
+
+- Fixed instance checks with 0d arrays.
+
 1.4.3 (2021-08-05)
 ++++++++++++++++++
 
diff --git a/README.md b/README.md
index 6509bac..dc96991 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 [![codecov](https://codecov.io/gh/ramonhagenaars/nptyping/branch/master/graph/badge.svg)](https://codecov.io/gh/ramonhagenaars/nptyping)
 [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ramonhagenaars/nptyping/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ramonhagenaars/nptyping/?branch=master)
 
-Type hints for `Numpy`!
+Type hints with dynamic checks for `Numpy`!
 
 <p align='center'>
   <a href='https://https://pypi.org/project/nptyping/'>
diff --git a/nptyping/_meta.py b/nptyping/_meta.py
index 7c979d8..fe13501 100644
--- a/nptyping/_meta.py
+++ b/nptyping/_meta.py
@@ -1,5 +1,5 @@
 __title__ = 'nptyping'
-__version__ = '1.4.3'
+__version__ = '1.4.4'
 __author__ = 'Ramon Hagenaars'
 __author_email__ = 'ramon.hagenaars@gmail.com'
 __description__ = 'Type hints for Numpy.'
diff --git a/nptyping/functions/_get_type.py b/nptyping/functions/_get_type.py
index 7370b42..0478f6d 100644
--- a/nptyping/functions/_get_type.py
+++ b/nptyping/functions/_get_type.py
@@ -71,7 +71,8 @@ def _get_type_dtype(dtype: numpy.dtype) -> Type['NPType']:
 def _get_type_arrary(arr: numpy.ndarray) -> Type['NPType']:
     # Return the nptyping type of a numpy array.
     type_ = get_type(arr.dtype)
-    return NDArray[arr.shape, type_]
+    shape = arr.shape or (Any, ...)
+    return NDArray[shape, type_]
 
 
 def _get_type_of_number(
diff --git a/nptyping/types/_ndarray_meta.py b/nptyping/types/_ndarray_meta.py
index 6e0bb4d..b1c9e40 100644
--- a/nptyping/types/_ndarray_meta.py
+++ b/nptyping/types/_ndarray_meta.py
@@ -72,9 +72,13 @@ class _NDArrayMeta(HashedSubscriptableType):
         """
         from nptyping.functions._get_type import get_type
         np_type = get_type(instance)
-        return (np_type.__name__ == cls.__name__
-                and _NDArrayMeta.__subclasscheck__(
-                    cls, _NDArray[instance.shape, instance.dtype]))
+        return (
+                np_type.__name__ == cls.__name__ and
+                _NDArrayMeta.__subclasscheck__(
+                    cls,
+                    _NDArray[instance.shape or (Any, ...), instance.dtype]
+                )
+        )
 
     def __subclasscheck__(cls, subclass: type) -> bool:
         """
@@ -171,7 +175,8 @@ class _NDArrayMeta(HashedSubscriptableType):
 
 
 class _NDArray(NPType, metaclass=_NDArrayMeta):
-    _shape = (Any, ...)  # type: Union[Tuple[int, ...], Tuple[Any, EllipsisType]]  # noqa # pylint: disable=line-too-long
+    _shape = (
+    Any, ...)  # type: Union[Tuple[int, ...], Tuple[Any, EllipsisType]]  # noqa # pylint: disable=line-too-long
     _type = Any
     _special = True  # Added to be able to compile types with sphinx.
 


Test patch:
diff --git a/tests/test_types/test_ndarray.py b/tests/test_types/test_ndarray.py
index 9bc987e..b95e5e5 100644
--- a/tests/test_types/test_ndarray.py
+++ b/tests/test_types/test_ndarray.py
@@ -235,3 +235,8 @@ class TestNDArray(TestCase):
         obj_arr = NDArray[(Any,), object]
         ones = np.ones(shape=(5,))
         self.assertIsInstance(ones, obj_arr)
+
+    def test_validate_0DArray(self):
+        self.assertIsInstance(np.array(1), NDArray)
+        self.assertIsInstance(np.array(1), NDArray[int])
+        self.assertNotIsInstance(np.array(1), NDArray[str])