Skip to content

Commit

Permalink
signature from_csv
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalIversen committed Dec 2, 2024
1 parent 1f798a8 commit 3a9ad4f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drevalpy/datasets/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,23 @@ class Dataset(ABC):

@classmethod
@abstractmethod
def from_csv(cls: type["Dataset"], input_file: str | Path, dataset_name: str = "unknown") -> "Dataset":
def from_csv(cls: type["Dataset"], input_file: str | Path, **kwargs) -> "Dataset":
"""
Loads the dataset from data.
:param input_file: Path to the csv file containing the data to be loaded
:param dataset_name: Optional name to associate the dataset with, default = "unknown"
:param kwargs: additional keyword arguments
:returns: Dataset object containing data from provided csv file.
"""

@abstractmethod
def to_csv(self, path: str):
def to_csv(self, path: str, **kwargs) -> None:
"""
Saves the dataset to data.
:param path: path to the dataset
:param kwargs: additional keyword arguments
"""


Expand Down Expand Up @@ -761,14 +763,13 @@ def from_csv(

return cls(features=features)

def to_csv(self, path: str | Path, id_column: str, view_name: str, **kwargs):
def to_csv(self, path: str | Path, id_column: str, view_name: str):
"""
Save the feature dataset to a CSV file.
:param path: Path to the CSV file.
:param id_column: Name of the column containing the identifiers.
:param view_name: Name of the view (e.g., gene_expression).
:param kwargs: Additional arguments for pandas to_csv function.
:raises ValueError: If the view is not found for an identifier.
"""
Expand All @@ -784,7 +785,7 @@ def to_csv(self, path: str | Path, id_column: str, view_name: str, **kwargs):

# Convert to DataFrame and save to CSV
df = pd.DataFrame(data)
df.to_csv(path, index=False, **kwargs)
df.to_csv(path, index=False)

@property
def meta_info(self) -> dict[str, Any]:
Expand Down

0 comments on commit 3a9ad4f

Please sign in to comment.