4
4
__all__ = ["setas" ]
5
5
import re
6
6
import copy
7
- from collections .abc import MutableMapping , Mapping , Iterable
7
+ from collections .abc import MutableMapping , Iterable
8
8
9
9
import numpy as np
10
10
11
- from ..compat import string_types , int_types , index_types , _pattern_type
11
+ from ..compat import string_types , index_types , _pattern_type
12
12
from ..tools import AttributeStore , isiterable , typedList , isLikeList
13
13
from .utils import decode_string
14
14
@@ -339,7 +339,8 @@ def __contains__(self, item):
339
339
def __delitem__ (self , name ):
340
340
"""Unset either by column index or column assignment.
341
341
342
- Equivalent to unsetting the same object."""
342
+ Equivalent to unsetting the same object.
343
+ """
343
344
self .unset (name )
344
345
345
346
def __eq__ (self , other ):
@@ -445,7 +446,7 @@ def __setitem__(self, name, value):
445
446
case "x" | "y" | "z" | "u" | "v" | "w" | "d" | "e" | "f" | "." | "-" :
446
447
for c in self .find_col (value , force_list = True ):
447
448
self ._setas [c ] = name
448
- case int () | str () | _pattern_type () if value in [ letter for letter in "xyzuvwdef.-" ] :
449
+ case int () | str () | _pattern_type () if value in list ( "xyzuvwdef.-" ) :
449
450
for c in self .find_col (name , force_list = True ):
450
451
self .setas [c ] = value
451
452
case _:
@@ -646,21 +647,24 @@ def get(self, key, default=None): # pylint: disable=arguments-differ
646
647
def keys (self ):
647
648
"""Access mapping keys.
648
649
649
- Mapping keys are the same as iterating over the unique headers"""
650
+ Mapping keys are the same as iterating over the unique headers
651
+ """
650
652
for c in self ._unique_headers :
651
653
yield c
652
654
653
655
def values (self ):
654
656
"""Access mapping values.
655
657
656
- Mapping values are the same as iterating over setas."""
658
+ Mapping values are the same as iterating over setas.
659
+ """
657
660
for v in self .setas :
658
661
yield v
659
662
660
663
def items (self ):
661
664
"""Access mapping items.
662
665
663
- Mapping items iterates over keys and values."""
666
+ Mapping items iterates over keys and values.
667
+ """
664
668
for k , v in zip (self ._unique_headers , self .setas ):
665
669
yield k , v
666
670
@@ -746,7 +750,8 @@ def to_dict(self):
746
750
"""Return the setas attribute as a dictionary.
747
751
748
752
If multiple columns are assigned to the same type, then the column names are
749
- returned as a list. If column headers are duplicated"""
753
+ returned as a list. If column headers are duplicated.
754
+ """
750
755
ret = dict ()
751
756
for k , ch in zip (self ._setas , self ._unique_headers ):
752
757
if k != "." :
@@ -766,7 +771,8 @@ def to_list(self):
766
771
def to_string (self , encode = False ):
767
772
"""Return the setas attribute encoded as a string.
768
773
769
- Optionally replaces runs of 3 or more identical characters with a precediung digit."""
774
+ Optionally replaces runs of 3 or more identical characters with a precediung digit.
775
+ """
770
776
expanded = "" .join (self )
771
777
if encode :
772
778
pat = re .compile (r"((.)\2{2,9})" )
0 commit comments