Skip to content

Commit

Permalink
Address pylint issues (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
camposandro authored May 14, 2024
1 parent 5ded7d1 commit 006a60c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 30 deletions.
13 changes: 7 additions & 6 deletions src/lsdb/loaders/hipscat/abstract_catalog_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,18 @@ def _load_df_from_paths(
dask_meta_schema = self._load_metadata_schema(catalog)
if self.config.columns:
dask_meta_schema = dask_meta_schema[self.config.columns]
ddf = dd.io.from_map(
kwargs = self.config.get_kwargs_dict()
if self.config.dtype_backend is not None:
kwargs["dtype_backend"] = self.config.dtype_backend
return dd.io.from_map(
file_io.read_parquet_file_to_pandas,
paths,
columns=self.config.columns,
divisions=divisions,
storage_options=self.storage_options,
meta=dask_meta_schema,
columns=self.config.columns,
dtype_backend=self.config.get_dtype_backend(),
**self.config.get_kwargs_dict(),
storage_options=self.storage_options,
**kwargs,
)
return ddf

def _load_metadata_schema(self, catalog: HCHealpixDataset) -> pd.DataFrame:
metadata_pointer = hc.io.paths.get_common_metadata_pointer(catalog.catalog_base_dir)
Expand Down
11 changes: 7 additions & 4 deletions src/lsdb/loaders/hipscat/hipscat_loader_factory.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from typing import Any, Dict, Type, Union
from __future__ import annotations

from typing import Dict, Type

from lsdb.catalog.association_catalog import AssociationCatalog
from lsdb.catalog.catalog import Catalog
from lsdb.catalog.dataset.dataset import Dataset
from lsdb.catalog.margin_catalog import MarginCatalog
from lsdb.loaders.hipscat.abstract_catalog_loader import AbstractCatalogLoader
from lsdb.loaders.hipscat.abstract_catalog_loader import AbstractCatalogLoader, CatalogTypeVar
from lsdb.loaders.hipscat.association_catalog_loader import AssociationCatalogLoader
from lsdb.loaders.hipscat.hipscat_catalog_loader import HipscatCatalogLoader
from lsdb.loaders.hipscat.hipscat_loading_config import HipscatLoadingConfig
Expand All @@ -18,10 +20,10 @@


def get_loader_for_type(
catalog_type_to_use: Type[Dataset],
catalog_type_to_use: Type[CatalogTypeVar],
path: str,
config: HipscatLoadingConfig,
storage_options: Union[Dict[Any, Any], None] = None,
storage_options: dict | None = None,
) -> AbstractCatalogLoader:
"""Constructs a CatalogLoader that loads a Dataset of the specified type
Expand All @@ -30,6 +32,7 @@ def get_loader_for_type(
as the input, not a string or enum value
path (str): the path to load the catalog from
config (HipscatLoadingConfig): Additional configuration for loading the catalog
storage_options (dict): Dictionary that contains abstract filesystem credentials
Returns:
An initialized CatalogLoader object with the path and config specified
Expand Down
12 changes: 0 additions & 12 deletions src/lsdb/loaders/hipscat/hipscat_loader_factory.pyi

This file was deleted.

6 changes: 0 additions & 6 deletions src/lsdb/loaders/hipscat/hipscat_loading_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import Callable, List

import pandas as pd
from pandas._libs import lib
from pandas.io._util import _arrow_dtype_mapping

from lsdb.catalog.margin_catalog import MarginCatalog
Expand Down Expand Up @@ -42,11 +41,6 @@ def get_kwargs_dict(self) -> dict:
"""Returns a dictionary with the extra kwargs"""
return self.kwargs if self.kwargs is not None else {}

def get_dtype_backend(self) -> str:
"""Returns the data type backend. It is either "pyarrow", "numpy_nullable",
or "<no_default>", which allows us to keep the original data types."""
return lib.no_default if self.dtype_backend is None else self.dtype_backend

def get_dtype_mapper(self) -> Callable | None:
"""Returns a mapper for pyarrow or numpy types, mirroring Pandas behaviour."""
mapper = None
Expand Down
4 changes: 2 additions & 2 deletions src/lsdb/loaders/hipscat/read_hipscat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ For more information on stub files, view here: https://mypy.readthedocs.io/en/st
"""

from typing import List, Type, overload
from __future__ import annotations

from hipscat.pixel_math import HealpixPixel
from typing import List, Type, overload

from lsdb.catalog.dataset.dataset import Dataset
from lsdb.catalog.margin_catalog import MarginCatalog
Expand Down

0 comments on commit 006a60c

Please sign in to comment.