@@ -2222,26 +2222,12 @@ class DataCol(IndexCol):
2222
2222
_info_fields = ["tz" , "ordered" ]
2223
2223
2224
2224
@classmethod
2225
- def create_for_block (
2226
- cls , i : int , name = None , version = None , pos : Optional [int ] = None
2227
- ):
2225
+ def create_for_block (cls , name : str , version , pos : int ):
2228
2226
""" return a new datacol with the block i """
2227
+ assert isinstance (name , str )
2229
2228
2230
- cname = name or f"values_block_{ i } "
2231
- if name is None :
2232
- name = cname
2233
-
2234
- # prior to 0.10.1, we named values blocks like: values_block_0 an the
2235
- # name values_0
2236
- try :
2237
- if version [0 ] == 0 and version [1 ] <= 10 and version [2 ] == 0 :
2238
- m = re .search (r"values_block_(\d+)" , name )
2239
- if m :
2240
- grp = m .groups ()[0 ]
2241
- name = f"values_{ grp } "
2242
- except IndexError :
2243
- pass
2244
-
2229
+ cname = name
2230
+ name = _maybe_adjust_name (name , version )
2245
2231
return cls (name = name , cname = cname , pos = pos )
2246
2232
2247
2233
def __init__ (
@@ -3535,7 +3521,7 @@ def f(i, c):
3535
3521
if c in dc :
3536
3522
klass = DataIndexableCol
3537
3523
return klass .create_for_block (
3538
- i = i , name = c , pos = base_pos + i , version = self .version
3524
+ name = c , pos = base_pos + i , version = self .version
3539
3525
)
3540
3526
3541
3527
# Note: the definition of `values_cols` ensures that each
@@ -3914,16 +3900,16 @@ def get_blk_items(mgr, blocks):
3914
3900
encoding = self .encoding ,
3915
3901
errors = self .errors ,
3916
3902
)
3903
+ adj_name = _maybe_adjust_name (new_name , self .version )
3917
3904
3918
3905
typ = klass ._get_atom (data_converted )
3919
3906
3920
- col = klass . create_for_block ( i = i , name = new_name , version = self . version )
3921
- col . values = list (b_items )
3922
- col . typ = typ
3907
+ col = klass (
3908
+ name = adj_name , cname = new_name , values = list (b_items ), typ = typ , pos = j
3909
+ )
3923
3910
col .set_atom (block = b )
3924
3911
col .set_data (data_converted )
3925
3912
col .update_info (self .info )
3926
- col .set_pos (j )
3927
3913
3928
3914
vaxes .append (col )
3929
3915
@@ -4948,6 +4934,31 @@ def _need_convert(kind) -> bool:
4948
4934
return False
4949
4935
4950
4936
4937
+ def _maybe_adjust_name (name : str , version ) -> str :
4938
+ """
4939
+ Prior to 0.10.1, we named values blocks like: values_block_0 an the
4940
+ name values_0, adjust the given name if necessary.
4941
+
4942
+ Parameters
4943
+ ----------
4944
+ name : str
4945
+ version : Tuple[int, int, int]
4946
+
4947
+ Returns
4948
+ -------
4949
+ str
4950
+ """
4951
+ try :
4952
+ if version [0 ] == 0 and version [1 ] <= 10 and version [2 ] == 0 :
4953
+ m = re .search (r"values_block_(\d+)" , name )
4954
+ if m :
4955
+ grp = m .groups ()[0 ]
4956
+ name = f"values_{ grp } "
4957
+ except IndexError :
4958
+ pass
4959
+ return name
4960
+
4961
+
4951
4962
class Selection :
4952
4963
"""
4953
4964
Carries out a selection operation on a tables.Table object.
0 commit comments