1616from collections .abc import Iterable
1717
1818# from spatialmath.base import symbolic as sym # HACK
19- from spatialmath .base .symbolic import issymbol , symtype
19+ from spatialmath .base .symbolic import issymbol
2020
2121# valid scalar types
22- _scalartypes = (int , np .integer , float , np .floating ) + symtype
22+ _scalartypes = (int , np .integer , float , np .floating )
2323
2424# from typing import Union, List, Tuple, Any, Optional, Type, Callable
2525# from numpy.typing import DTypeLike
@@ -47,7 +47,9 @@ def isscalar(x: Any) -> bool:
4747 >>> isscalar([1])
4848
4949 """
50- return isinstance (x , _scalartypes )
50+ return isinstance (x , _scalartypes ) or (
51+ not isinstance (x , (list , tuple )) and issymbol (x )
52+ )
5153
5254
5355def isinteger (x : Any ) -> bool :
@@ -386,7 +388,7 @@ def getvector(
386388 """
387389 dt = dtype
388390
389- if isinstance ( v , _scalartypes ): # handle scalar case
391+ if isscalar ( v ): # handle scalar case
390392 v = [v ] # type: ignore
391393 if isinstance (v , (list , tuple )):
392394 # list or tuple was passed in
@@ -501,7 +503,7 @@ def isvector(v: Any, dim: Optional[int] = None) -> bool:
501503 if (
502504 isinstance (v , (list , tuple ))
503505 and (dim is None or len (v ) == dim )
504- and all (map (lambda x : isinstance ( x , _scalartypes ) , v ))
506+ and all (map (isscalar , v ))
505507 ):
506508 return True # list or tuple
507509
@@ -516,7 +518,7 @@ def isvector(v: Any, dim: Optional[int] = None) -> bool:
516518 else :
517519 return s == (dim ,) or s == (1 , dim ) or s == (dim , 1 )
518520
519- if (dim is None or dim == 1 ) and isinstance ( v , _scalartypes ):
521+ if (dim is None or dim == 1 ) and isscalar ( v ):
520522 return True
521523
522524 return False
@@ -620,11 +622,7 @@ def isnumberlist(x: Any) -> bool:
620622 >>> isnumberlist(np.r_[1,2])
621623 """
622624
623- return (
624- isinstance (x , (list , tuple ))
625- and len (x ) > 0
626- and all (map (lambda x : isinstance (x , _scalartypes ), x ))
627- )
625+ return isinstance (x , (list , tuple )) and len (x ) > 0 and all (map (isscalar , x ))
628626
629627
630628def isvectorlist (x : Any , n : int ) -> bool :
0 commit comments