codezonediitj / pydatastructs

A python package for data structures and algorithms
https://pydatastructs.readthedocs.io/en/stable/
Other
199 stars 269 forks source link

Fix tiny bug in misc_util.py #456

Closed youknowqyh closed 2 years ago

youknowqyh commented 2 years ago

References to other Issues or PRs or Relevant literature

Brief description of what is fixed or changed

When I run the following code, the program won't work correctly:

>>> from pydatastructs import OneDimensionalArray
>>> from pydatastructs import OneDimensionalArray as ODA
>>> ODA(int, 5, backend='Python')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yuhaoq/yuhaoq/noob/pydatastructs/pydatastructs/linear_data_structures/arrays.py", line 78, in __new__
    raise_if_backend_is_not_python(
  File "/Users/yuhaoq/yuhaoq/noob/pydatastructs/pydatastructs/utils/misc_util.py", line 33, in raise_if_backend_is_not_python
    raise ValueError("As of {} version, only {} backend is supported for {} API".format(
ValueError: As of 1.0.1-dev version, only Python backend is supported for <class 'pydatastructs.linear_data_structures.arrays.OneDimensionalArray'> API

I figured out the reason behind is that in raise_if_backend_is_not_python, the type of backend is str, but the type of Backend.Python is Backend. So in order to solve it, we should convert the type of Backend.Python to str

Other comments

czgdp1807 commented 2 years ago

This is not a bug. It is what it is.