Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
feat: add type hint for _read_as_numpy() method
Browse files Browse the repository at this point in the history
  • Loading branch information
trgiangdo committed Oct 2, 2023
1 parent a770067 commit fb09f79
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/taipy/core/data/_abstract_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing import Dict, List, Optional, Set

import modin.pandas as modin_pd
import numpy as np
import pandas as pd
from sqlalchemy import create_engine, text

Expand Down Expand Up @@ -214,7 +215,7 @@ def _read_as(self):
query_result = connection.execute(text(self._get_read_query()))
return list(map(lambda row: custom_class(**row), query_result))

def _read_as_numpy(self):
def _read_as_numpy(self) -> np.ndarray:
return self._read_as_pandas_dataframe().to_numpy()

def _read_as_pandas_dataframe(self, columns: Optional[List[str]] = None):
Expand Down
3 changes: 2 additions & 1 deletion src/taipy/core/data/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import Any, Dict, List, Optional, Set

import modin.pandas as modin_pd
import numpy as np
import pandas as pd

from taipy.config.common.scope import Scope
Expand Down Expand Up @@ -188,7 +189,7 @@ def _read_as(self):
res.append(custom_class(*line))
return res

def _read_as_numpy(self):
def _read_as_numpy(self) -> np.ndarray:
return self._read_as_pandas_dataframe().to_numpy()

def _read_as_pandas_dataframe(
Expand Down
3 changes: 2 additions & 1 deletion src/taipy/core/data/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from typing import Any, Dict, List, Optional, Set

import modin.pandas as modin_pd
import numpy as np
import pandas as pd

from taipy.config.common.scope import Scope
Expand Down Expand Up @@ -210,7 +211,7 @@ def _read_as(self, read_kwargs: Dict):
list_of_dicts = self._read_as_pandas_dataframe(read_kwargs).to_dict(orient="records")
return [custom_class(**dct) for dct in list_of_dicts]

def _read_as_numpy(self, read_kwargs: Dict):
def _read_as_numpy(self, read_kwargs: Dict) -> np.ndarray:
return self._read_as_pandas_dataframe(read_kwargs).to_numpy()

def _read_as_pandas_dataframe(self, read_kwargs: Dict) -> pd.DataFrame:
Expand Down

0 comments on commit fb09f79

Please sign in to comment.