From b94afcc9178e294f6ae2d6df8ccb1fae89f24022 Mon Sep 17 00:00:00 2001 From: NickEdwards7502 Date: Thu, 19 Sep 2024 14:19:47 +1000 Subject: [PATCH] STYLE: Format with black (#237) --- python/varspark/featuresource.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/python/varspark/featuresource.py b/python/varspark/featuresource.py index 668e63d5..ef2042e6 100644 --- a/python/varspark/featuresource.py +++ b/python/varspark/featuresource.py @@ -2,6 +2,7 @@ import pandas as pd from typedecorator import params, Nullable + class FeatureSource(object): def __init__(self, _jvm, _vs_api, _jsql, sql, _jfs): self._jfs = _jfs @@ -12,7 +13,7 @@ def __init__(self, _jvm, _vs_api, _jsql, sql, _jfs): @params(sample_list_str=str) def extract_samples(sample_list_str): - """ Convert the sample list string to a list of sample names. + """Convert the sample list string to a list of sample names. :param (str) sample_list_str: The string representation of the sample list. @@ -23,29 +24,32 @@ def extract_samples(sample_list_str): @params(feature=object) def unpack_feature_data(feature): - """ Unpack feature data from byte array into a tuple of integers. + """Unpack feature data from byte array into a tuple of integers. :param feature: The feature object containing the data. return tuple: A tuple containing unpacked integers. """ byte_string = feature.data().valueAsByteArray() - format_string = f'{len(byte_string)}B' + format_string = f"{len(byte_string)}B" return struct.unpack(format_string, byte_string) @params(features_ref=object) def collect_feature_data(features_ref): - """ Collect and organize feature data into a dictionary. + """Collect and organize feature data into a dictionary. :param features_ref: The list of feature objects. :return dict: A dictionary with feature labels as keys and unpacked data as values. """ - return {feature.label(): FeatureSource.unpack_feature_data(feature) for feature in features_ref} + return { + feature.label(): FeatureSource.unpack_feature_data(feature) + for feature in features_ref + } @params(self=object, scala=Nullable(bool)) def to_df(self, scala=False): - """ Converts a Feature Source RDD to a pandas dataframe. + """Converts a Feature Source RDD to a pandas dataframe. :param (bool) scala: Indicates whether to use the scala version of DataFrame conversion @@ -56,7 +60,7 @@ def to_df(self, scala=False): jdf.count() jdf.createOrReplaceTempView("df") features = self.sql.table("df").toPandas() - features.set_index('variant_id', inplace=True) + features.set_index("variant_id", inplace=True) return features else: features_ref = self._jfs.features().collect()