Skip to content

Commit

Permalink
Reformatted via black
Browse files Browse the repository at this point in the history
  • Loading branch information
wenneman committed Oct 4, 2023
1 parent 28dae5d commit 0e8d0c8
Showing 1 changed file with 29 additions and 40 deletions.
69 changes: 29 additions & 40 deletions src/tape/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,8 @@ def sf2(self, sf_method="basic", argument_container=None, use_map=True):
The following package-level methods can be used to create a new Ensemble object
by reading in the given data source.
"""


def read_pandas_dataframe(
source_frame,
object_frame=None,
Expand Down Expand Up @@ -1680,7 +1682,7 @@ def read_dask_dataframe(
dask_client: `dask.distributed.client`, optional
Accepts an existing `dask.distributed.Client`, or creates one if
`create_client=True`, passing any additional kwargs to a
dask.distributed.Client constructor call.
dask.distributed.Client constructor call.
If 'dask_client=None' and `create_client=False`,
the Ensemble is created without a distributed client.
column_mapper: 'ColumnMapper' object
Expand All @@ -1703,10 +1705,10 @@ def read_dask_dataframe(
ensemble: `tape.ensemble.Ensemble`
The ensemble object with the Dask dataframe data loaded.
"""
if (dask_client is None):
if dask_client is None:
dask_client = create_client
new_ens = Ensemble(dask_client, **kwargs)

new_ens = Ensemble(dask_client, **kwargs)
new_ens._load_column_mapper(column_mapper, **kwargs)

# Set the index of the source frame and save the resulting table
Expand Down Expand Up @@ -1779,7 +1781,7 @@ def read_parquet(
dask_client: `dask.distributed.client`, optional
Accepts an existing `dask.distributed.Client`, or creates one if
`create_client=True`, passing any additional kwargs to a
dask.distributed.Client constructor call.
dask.distributed.Client constructor call.
If 'dask_client=None' and `create_client=False`,
the Ensemble is created without a distributed client.
provenance_label: 'str', optional
Expand All @@ -1806,9 +1808,9 @@ def read_parquet(
The ensemble object with parquet data loaded
"""

if (dask_client is None):
if dask_client is None:
dask_client = create_client

new_ens = Ensemble(dask_client, **kwargs)

new_ens.from_parquet(
Expand All @@ -1827,13 +1829,13 @@ def read_parquet(


def read_hipscat(
dir,
source_subdir="source",
object_subdir="object",
column_mapper=None,
dir,
source_subdir="source",
object_subdir="object",
column_mapper=None,
create_client=True,
dask_client=None,
**kwargs
**kwargs,
):
"""Read in parquet files from a hipscat-formatted directory structure
Parameters
Expand All @@ -1855,7 +1857,7 @@ def read_hipscat(
dask_client: `dask.distributed.client`, optional
Accepts an existing `dask.distributed.Client`, or creates one if
`create_client=True`, passing any additional kwargs to a
dask.distributed.Client constructor call.
dask.distributed.Client constructor call.
If 'dask_client=None' and `create_client=False`,
the Ensemble is created without a distributed client.
**kwargs:
Expand All @@ -1868,29 +1870,24 @@ def read_hipscat(
The ensemble object with parquet data loaded
"""

if (dask_client is None):
if dask_client is None:
dask_client = create_client

Check warning on line 1874 in src/tape/ensemble.py

View check run for this annotation

Codecov / codecov/patch

src/tape/ensemble.py#L1874

Added line #L1874 was not covered by tests

new_ens = Ensemble(dask_client, **kwargs)

new_ens.from_hipscat(
dir=dir,
source_subdir=source_subdir,
object_subdir=object_subdir,
column_mapper=column_mapper,
**kwargs
dir=dir,
source_subdir=source_subdir,
object_subdir=object_subdir,
column_mapper=column_mapper,
**kwargs,
)

return new_ens


def read_source_dict(
source_dict,
column_mapper=None,
npartitions=1,
create_client=True,
dask_client=None,
**kwargs
source_dict, column_mapper=None, npartitions=1, create_client=True, dask_client=None, **kwargs
):
"""Load the sources into an ensemble from a dictionary.
Expand All @@ -1911,7 +1908,7 @@ def read_source_dict(
dask_client: `dask.distributed.client`, optional
Accepts an existing `dask.distributed.Client`, or creates one if
`create_client=True`, passing any additional kwargs to a
dask.distributed.Client constructor call.
dask.distributed.Client constructor call.
If 'dask_client=None' and `create_client=False`,
the Ensemble is created without a distributed client.
Expand All @@ -1921,27 +1918,19 @@ def read_source_dict(
The ensemble object with dictionary data loaded
"""

if (dask_client is None):
if dask_client is None:
dask_client = create_client

Check warning on line 1922 in src/tape/ensemble.py

View check run for this annotation

Codecov / codecov/patch

src/tape/ensemble.py#L1921-L1922

Added lines #L1921 - L1922 were not covered by tests

new_ens = Ensemble(dask_client, **kwargs)

Check warning on line 1924 in src/tape/ensemble.py

View check run for this annotation

Codecov / codecov/patch

src/tape/ensemble.py#L1924

Added line #L1924 was not covered by tests

new_ens.from_source_dict(

Check warning on line 1926 in src/tape/ensemble.py

View check run for this annotation

Codecov / codecov/patch

src/tape/ensemble.py#L1926

Added line #L1926 was not covered by tests
source_dict=source_dict,
column_mapper=column_mapper,
npartitions=npartitions,
**kwargs
source_dict=source_dict, column_mapper=column_mapper, npartitions=npartitions, **kwargs
)

return new_ens

Check warning on line 1930 in src/tape/ensemble.py

View check run for this annotation

Codecov / codecov/patch

src/tape/ensemble.py#L1930

Added line #L1930 was not covered by tests


def read_dataset(
dataset,
create_client=True,
dask_client=None,
**kwargs
):
def read_dataset(dataset, create_client=True, dask_client=None, **kwargs):
"""Load the ensemble from a TAPE dataset.
Parameters
Expand All @@ -1955,7 +1944,7 @@ def read_dataset(
dask_client: `dask.distributed.client`, optional
Accepts an existing `dask.distributed.Client`, or creates one if
`create_client=True`, passing any additional kwargs to a
dask.distributed.Client constructor call.
dask.distributed.Client constructor call.
If 'dask_client=None' and `create_client=False`,
the Ensemble is created without a distributed client.
Expand Down

0 comments on commit 0e8d0c8

Please sign in to comment.