Skip to content

Commit

Permalink
Make precommit quasi happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed Apr 9, 2024
1 parent 96fcb07 commit 5cc5e68
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 22 deletions.
5 changes: 1 addition & 4 deletions tstore/archive/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ def get_partitions(base_dir, ts_variable):

metadata = read_tstore_metadata(base_dir=base_dir)
partitioning = metadata["partitioning"][ts_variable]
if partitioning is not None:
partitions = partitioning.split("/")
else:
partitions = []
partitions = partitioning.split("/") if partitioning is not None else []
return partitions

Check warning on line 82 in tstore/archive/io.py

View check run for this annotation

Codecov / codecov/patch

tstore/archive/io.py#L79-L82

Added lines #L79 - L82 were not covered by tests


Expand Down
2 changes: 1 addition & 1 deletion tstore/archive/metadata/writers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Created on Mon Apr 8 17:24:09 2024
Created on Mon Apr 8 17:24:09 2024.
@author: ghiggi
"""
Expand Down
7 changes: 6 additions & 1 deletion tstore/archive/partitions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Created on Mon Apr 8 17:05:26 2024
Created on Mon Apr 8 17:05:26 2024.
@author: ghiggi
"""
Expand Down Expand Up @@ -44,10 +44,15 @@ def get_partitioning_mapping_dict(time_var, backend="pandas"):


def get_valid_partitions():
"""Get valid partitioning components."""
return list(get_partitioning_mapping_dict(time_var="dummy"))

Check warning on line 48 in tstore/archive/partitions.py

View check run for this annotation

Codecov / codecov/patch

tstore/archive/partitions.py#L48

Added line #L48 was not covered by tests


def check_partitions(partitioning_str):
"""Check partitioning components of partitinoning string.
Return the partitioning components.
"""
if partitioning_str is None:
return None

Check warning on line 57 in tstore/archive/partitions.py

View check run for this annotation

Codecov / codecov/patch

tstore/archive/partitions.py#L56-L57

Added lines #L56 - L57 were not covered by tests

Expand Down
2 changes: 1 addition & 1 deletion tstore/archive/ts/utility.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Created on Mon Apr 8 16:31:23 2024
Created on Mon Apr 8 16:31:23 2024.
@author: ghiggi
"""
Expand Down
2 changes: 1 addition & 1 deletion tstore/archive/ts/writers/pyarrow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Created on Mon Apr 8 17:26:02 2024
Created on Mon Apr 8 17:26:02 2024.
@author: ghiggi
"""
Expand Down
2 changes: 1 addition & 1 deletion tstore/tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Created on Sun Apr 7 11:04:41 2024
Created on Sun Apr 7 11:04:41 2024.
@author: ghiggi
"""
Expand Down
10 changes: 4 additions & 6 deletions tstore/tslong/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ def to_tstore(
tstore_structure="id-var",
overwrite=True,
):
"""
TSLONG.to_tstore()
"""
"""TSLONG.to_tstore()."""
# If index time, remove
df = df.reset_index(names=time_var)

Check warning on line 71 in tstore/tslong/pandas.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/pandas.py#L71

Added line #L71 was not covered by tests

Expand Down Expand Up @@ -97,7 +95,7 @@ def to_tstore(
# - TODO: add flag to check if are actual duplicates !
df_attrs = df[[id_var, *static_variables]]
df_attrs = df_attrs.drop_duplicates(subset=id_var)
df_attrs.reset_index(drop=True, inplace=True)
df_attrs = df_attrs.reset_index(drop=True)

Check warning on line 98 in tstore/tslong/pandas.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/pandas.py#L96-L98

Added lines #L96 - L98 were not covered by tests

# Write static attributes
# --> Need to test that save id_var as large_string !
Expand Down Expand Up @@ -128,8 +126,8 @@ def to_tstore(
columns = [ts_variable]

Check warning on line 126 in tstore/tslong/pandas.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/pandas.py#L125-L126

Added lines #L125 - L126 were not covered by tests

# Retrieve TS object
df_ts = df_group[columns + [time_var]].copy()
df_ts.reset_index(drop=True, inplace=True)
df_ts = df_group[[*columns, time_var]].copy()
df_ts = df_ts.reset_index(drop=True)

Check warning on line 130 in tstore/tslong/pandas.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/pandas.py#L129-L130

Added lines #L129 - L130 were not covered by tests

# Check time is sorted ?
# TODO
Expand Down
13 changes: 7 additions & 6 deletions tstore/tslong/polars.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""TSLONG Polars implementation."""

import pandas as pd
import polars as pl

Check warning on line 4 in tstore/tslong/polars.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/polars.py#L3-L4

Added lines #L3 - L4 were not covered by tests

Expand Down Expand Up @@ -60,9 +62,7 @@ def to_tstore(
tstore_structure="id-var",
overwrite=True,
):
"""
TSLONG.to_tstore()
"""
"""TSLONG.to_tstore()."""
# Check inputs
tstore_structure = check_tstore_structure(tstore_structure)
base_dir = check_tstore_directory(base_dir, overwrite=overwrite)

Check warning on line 68 in tstore/tslong/polars.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/polars.py#L67-L68

Added lines #L67 - L68 were not covered by tests
Expand All @@ -77,7 +77,7 @@ def to_tstore(
# Check which columns remains (not specified at class init)
# TODO

# Checck partitioning
# Check partitioning
partitioning = check_partitioning(partitioning, ts_variables=list(ts_variables))

Check warning on line 81 in tstore/tslong/polars.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/polars.py#L81

Added line #L81 was not covered by tests

# Identify static dataframe (attributes)
Expand Down Expand Up @@ -120,12 +120,12 @@ def to_tstore(
columns = [ts_variable]

Check warning on line 120 in tstore/tslong/polars.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/polars.py#L119-L120

Added lines #L119 - L120 were not covered by tests

# Retrieve TS object
df_ts = df_group[columns + [time_var]]
df_ts = df_group[[*columns, time_var]]

Check warning on line 123 in tstore/tslong/polars.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/polars.py#L123

Added line #L123 was not covered by tests

# Check time is sorted ?
# TODO

# Add partioning columns
# Add partitioning columns
partitioning_str = partitioning[ts_variable]
df_ts, partitions = add_partitioning_columns(

Check warning on line 130 in tstore/tslong/polars.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/polars.py#L129-L130

Added lines #L129 - L130 were not covered by tests
df_ts,
Expand All @@ -142,6 +142,7 @@ def to_tstore(
tstore_structure=tstore_structure,
)

# TODO; Maybe create TS object and use TS.to_parquet() once implemented
# Retrieve pyarrow Table
table = df_ts.to_arrow()

Check warning on line 147 in tstore/tslong/polars.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/polars.py#L147

Added line #L147 was not covered by tests

Expand Down
2 changes: 1 addition & 1 deletion tutorials/00_example_pandas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Created on Sun Apr 7 21:10:05 2024
Created on Sun Apr 7 21:10:05 2024.
@author: ghiggi
"""
Expand Down

0 comments on commit 5cc5e68

Please sign in to comment.