Skip to content

Commit a5da279

Browse files
authored
DataSet patch, numpy method update (#40)
* Patch datset index misbehavior, replace deprecated numpy module * Bump version: 1.0.0-dev → 1.0.1 * Update bitset representation tests
1 parent 60a3970 commit a5da279

7 files changed

Lines changed: 34 additions & 24 deletions

File tree

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.0.0-dev
2+
current_version = 1.0.1
33
commit = True
44
tag = True
55

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,5 @@
8686

8787

8888
# rst_epilog = """
89-
# .. |version| replace:: 1.0.0
89+
# .. |version| replace:: 1.0.1
9090
# """

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "lkdata"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
description = "A friendly package for analysing TESS & Kepler time series data"
55
authors = [
66
{ name = "TESS Science Support Center", email = "tesshelp@bigbang.gsfc.nasa.gov" }]
@@ -19,7 +19,7 @@ dev = [
1919
"coverage[toml] >=7.4.0",
2020
"ipykernel >= 6.29.5",
2121
"IPython >= 8.18.1",
22-
"jupyter >= 1.0.0",
22+
"jupyter >= 1.0.1",
2323
"line-profiler >= 4.1.2",
2424
"mypy >= 1.8.0",
2525
"nbsphinx >= 0.9.3",
@@ -48,7 +48,7 @@ dev = [
4848
"coverage[toml] (>=7.10.7,<8.0.0)",
4949
"ipykernel>=6.29.5",
5050
"IPython>=8.18.1",
51-
"jupyter>=1.0.0",
51+
"jupyter>=1.0.1",
5252
"line-profiler>=4.1.2",
5353
"mypy>=1.8.0",
5454
"nbsphinx>=0.9.3",

src/lkdata/dataseries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def __init__(
6868
for level in index.levels:
6969
common = set(level).intersection(check_index)
7070
if len(common) > n_match:
71-
inds_dict = np.where(np.in1d(check_index, list(common)))
72-
inds_index = np.where(np.in1d(level, list(common)))
71+
inds_dict = np.where(np.isin(check_index, list(common)))
72+
inds_index = np.where(np.isin(level, list(common)))
7373
n_match = len(common)
7474
if n_match > 0:
7575
data = np.array([*data.values()])[inds_dict]

src/lkdata/dataset.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,9 @@ def __init__(
287287
):
288288
ntime = kwargs.pop("ntime", 0)
289289
time_indices = kwargs.pop("time_indices", None)
290-
index = IndexProcessorMixin.parse_index(index, time_indices, ntime)
291-
290+
if (index is not None) or (time_indices is not None) or (ntime != 0):
291+
index = IndexProcessorMixin.parse_index(index, time_indices, ntime)
292+
self.index = index
292293
self._data_types = dict()
293294
if input_data is not None:
294295
input_data = self._unpack_input(input_data)
@@ -446,7 +447,7 @@ def __init__(
446447
**kwargs,
447448
):
448449
self.kwargs = kwargs
449-
super().__init__(data, index)
450+
super().__init__(data, index, **kwargs)
450451

451452

452453
class BoolProducts(ProductBundle):
@@ -464,7 +465,7 @@ def __init__(
464465
**kwargs,
465466
):
466467
self.kwargs = kwargs
467-
super().__init__(bools, index)
468+
super().__init__(bools, index, **kwargs)
468469

469470

470471
class BitwiseProducts(ProductBundle):
@@ -482,7 +483,7 @@ def __init__(
482483
**kwargs,
483484
):
484485
self.kwargs = kwargs
485-
super().__init__(bitwise, index)
486+
super().__init__(bitwise, index, **kwargs)
486487

487488

488489
class AttrsHolder(dict):

src/lkdata/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.0.0"
1+
__version__ = "1.0.1"

tests/test_datacube.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -472,34 +472,38 @@ def strip(string):
472472
assert (bitcube.array == flags).all()
473473
# Default repr shows data as given
474474
bitwise_str = strip(bitcube.styler.to_string())
475+
comp = "col0123row00123145672891011312131415"
475476
assert bitwise_str == "col0123row00123145672891011312131415"
476477
# bitset repr shows codes individually, without description
477478
bitcube.values_display = "bitset"
478479
bitset_str = strip(bitcube.styler.to_string())
479-
assert bitset_str == (
480+
comp = (
480481
"col0123row0{}{1}{2}{1,2}1{4}{1,4}{2,4}{1,2,4}"
481482
"2{8}{1,8}{2,8}{1,2,8}3{4,8}{1,4,8}{2,4,8}{1,2,4,8}"
482483
)
484+
assert bitset_str == comp
483485
# Detailed repr parses and replaces codes with descriptions in given code_dict
484486
bitcube.values_display = "detailed"
485487
detailed_str = strip(bitcube.styler.to_string())
486-
assert detailed_str == (
488+
comp = (
487489
"col0123row0{}{1:'C1'}{2:'C2'}{1:'C1',2:'C2'}1{4:'C4'}{1:'C1',4:'C4'}"
488490
"{2:'C2',4:'C4'}{1:'C1',2:'C2',4:'C4'}2{8:'C8'}{1:'C1',8:'C8'}"
489491
"{2:'C2',8:'C8'}{1:'C1',2:'C2',8:'C8'}3{4:'C4',8:'C8'}"
490492
"{1:'C1',4:'C4',8:'C8'}{2:'C2',4:'C4',8:'C8'}"
491493
"{1:'C1',2:'C2',4:'C4',8:'C8'}"
492494
)
495+
assert detailed_str == comp
493496
bitcube.codes = {i: f"New{i}" for i in [1, 2, 4, 8, 16]}
494497
detailed_str = strip(bitcube.styler.to_string())
495-
assert detailed_str == (
498+
comp = (
496499
"col0123row0{}{1:'New1'}{2:'New2'}{1:'New1',2:'New2'}"
497500
"1{4:'New4'}{1:'New1',4:'New4'}{2:'New2',4:'New4'}"
498501
"{1:'New1',2:'New2',4:'New4'}2{8:'New8'}{1:'New1',8:'New8'}"
499502
"{2:'New2',8:'New8'}{1:'New1',2:'New2',8:'New8'}"
500503
"3{4:'New4',8:'New8'}{1:'New1',4:'New4',8:'New8'}{2:'New2',"
501504
"4:'New4',8:'New8'}{1:'New1',2:'New2',4:'New4',8:'New8'}"
502505
)
506+
assert detailed_str == comp
503507
# reset codes
504508
bitcube.codes = code_dict
505509

@@ -516,7 +520,7 @@ def strip(string):
516520
assert bitframe.shape == (2, 16)
517521
# Ensure codes and values_display transferred to derivative product
518522
detailed_str = strip(bitframe.styler.to_string())
519-
assert detailed_str == (
523+
comp = (
520524
"series0123456789101112131415row0000111122223333"
521525
"col0123012301230123time_index0{}{1:'C1'}{2:'C2'}{1:'C1',2:'C2'}"
522526
"{4:'C4'}{1:'C1',4:'C4'}{2:'C2',4:'C4'}{1:'C1',2:'C2',4:'C4'}{8:'C8'}"
@@ -529,18 +533,20 @@ def strip(string):
529533
"{4:'C4',8:'C8',16:'C16'}{1:'C1',4:'C4',8:'C8',16:'C16'}{2:'C2',4:'C4',"
530534
"8:'C8',16:'C16'}{1:'C1',2:'C2',4:'C4',8:'C8',16:'C16'}"
531535
)
536+
assert detailed_str == comp
532537

533538
bitframe = BitwiseSeriesCollection(np.arange(0, 32).reshape(2, 16))
534539
# New bitframe has no codes_dict, detailed display should be the same as bitset
535540
bitframe.values_display = "bitset"
536541
bitset_str = strip(bitframe.styler.to_string())
537-
assert bitset_str == (
542+
comp = (
538543
"series(0,)(1,)(2,)(3,)(4,)(5,)(6,)(7,)(8,)(9,)(10,)(11,)(12,)(13,)"
539544
"(14,)(15,)time_index0{}{1}{2}{1,2}{4}{1,4}{2,4}{1,2,4}{8}"
540545
"{1,8}{2,8}{1,2,8}{4,8}{1,4,8}{2,4,8}{1,2,4,8}1{16}{1,16}{2,16}"
541546
"{1,2,16}{4,16}{1,4,16}{2,4,16}{1,2,4,16}{8,16}{1,8,16}{2,8,16}"
542547
"{1,2,8,16}{4,8,16}{1,4,8,16}{2,4,8,16}{1,2,4,8,16}"
543548
)
549+
assert bitset_str == comp
544550
bitframe.values_display = "detailed"
545551
detailed_str = strip(bitframe.styler.to_string())
546552
assert detailed_str == bitset_str
@@ -550,21 +556,24 @@ def strip(string):
550556
# Series
551557
assert isinstance(bitcube[:, 0, 0], BitwiseSeries)
552558
bitseries = BitwiseSeries(np.arange(0, 16), codes=code_dict)
553-
bitwise_str = strip(bitseries._repr_html_())[34:-17]
554-
assert bitwise_str == "00112233445566778899101011111212131314141515"
559+
bitwise_str = strip(bitseries._repr_html_())
560+
comp = "00112233445566778899101011111212131314141515"
561+
assert comp in bitwise_str
555562
bitseries.values_display = "bitset"
556-
bitset_str = strip(bitseries._repr_html_())[34:-18]
557-
assert bitset_str == (
563+
bitset_str = strip(bitseries._repr_html_())
564+
comp = (
558565
"0{}1{1}2{2}3{1,2}4{4}5{1,4}6{2,4}7{1,2,4}8{8}9{1,8}"
559566
"10{2,8}11{1,2,8}12{4,8}13{1,4,8}14{2,4,8}15{1,2,4,8}"
560567
)
568+
assert comp in bitset_str
561569
bitseries.values_display = "detailed"
562-
detailed_str = strip(bitseries._repr_html_())[34:-18]
563-
assert detailed_str == (
570+
detailed_str = strip(bitseries._repr_html_())
571+
comp = (
564572
"0{}1{1:'C1'}2{2:'C2'}3{1:'C1',2:'C2'}4{4:'C4'}"
565573
"5{1:'C1',4:'C4'}6{2:'C2',4:'C4'}7{1:'C1',2:'C2',4:'C4'}"
566574
"8{8:'C8'}9{1:'C1',8:'C8'}10{2:'C2',8:'C8'}"
567575
"11{1:'C1',2:'C2',8:'C8'}12{4:'C4',8:'C8'}"
568576
"13{1:'C1',4:'C4',8:'C8'}14{2:'C2',4:'C4',8:'C8'}"
569577
"15{1:'C1',2:'C2',4:'C4',8:'C8'}"
570578
)
579+
assert comp in detailed_str

0 commit comments

Comments
 (0)