Skip to content

Commit

Permalink
Merge pull request #128 from josephnowak/feature/use-pyproject
Browse files Browse the repository at this point in the history
Feature/use pyproject
  • Loading branch information
josephnowak authored Oct 16, 2024
2 parents e73cf27 + f5b8877 commit ee4c4ba
Show file tree
Hide file tree
Showing 37 changed files with 283 additions and 200 deletions.
6 changes: 3 additions & 3 deletions docs/build/html/_static/doctools.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ var Documentation = {
var src = $(this).attr('src');
var idnum = $(this).attr('id').substr(7);
$('tr.cg-' + idnum).toggle();
if (src.substr(-9) === 'minus.png')
$(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
if (substr(-9) === 'minus.png')
$(this).attr('src', substr(0, length-9) + 'plus.png');
else
$(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
$(this).attr('src', substr(0, length-8) + 'minus.png');
}).css('display', '');
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
togglers.click();
Expand Down
28 changes: 14 additions & 14 deletions docs/build/html/_static/jquery-3.5.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5708,29 +5708,29 @@ jQuery.Event = function( src, props ) {
}

// Event object
if ( src && src.type ) {
if ( src && type ) {
this.originalEvent = src;
this.type = src.type;
this.type = type;

// Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value.
this.isDefaultPrevented = src.defaultPrevented ||
src.defaultPrevented === undefined &&
this.isDefaultPrevented = defaultPrevented ||
defaultPrevented === undefined &&

// Support: Android <=2.3 only
src.returnValue === false ?
returnValue === false ?
returnTrue :
returnFalse;

// Create target properties
// Support: Safari <=6 - 7 only
// Target should not be a text node (#504, #13143)
this.target = ( src.target && src.target.nodeType === 3 ) ?
src.target.parentNode :
src.target;
this.target = ( target && target.nodeType === 3 ) ?
target.parentNode :
target;

this.currentTarget = src.currentTarget;
this.relatedTarget = src.relatedTarget;
this.currentTarget = currentTarget;
this.relatedTarget = relatedTarget;

// Event type
} else {
Expand All @@ -5743,7 +5743,7 @@ jQuery.Event = function( src, props ) {
}

// Create a timestamp if incoming event doesn't have one
this.timeStamp = src && src.timeStamp || Date.now();
this.timeStamp = src && timeStamp || Date.now();

// Mark it as fixed
this[ jQuery.expando ] = true;
Expand Down Expand Up @@ -6035,12 +6035,12 @@ function fixInput( src, dest ) {
var nodeName = dest.nodeName.toLowerCase();

// Fails to persist the checked state of a cloned checkbox or radio button.
if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
dest.checked = src.checked;
if ( nodeName === "input" && rcheckableType.test( type ) ) {
dest.checked = checked;

// Fails to return the selected option to the default selected state when cloning options
} else if ( nodeName === "input" || nodeName === "textarea" ) {
dest.defaultValue = src.defaultValue;
dest.defaultValue = defaultValue;
}
}

Expand Down
82 changes: 82 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[tool.pdm]

[project]
name = "TensorDB"
version = "0.32.0"
description = "Database based in a file system storage combined with Xarray and Zarr"
keywords = ["Database Files Xarray Handler Zarr Store Read Write Append Update Upsert Backup Delete S3"]
readme = "README.md"
authors = [
{ name = "Joseph Nowak", email = "josephgonowak97@gmail.com" },
]
classifiers = [
"Development Status :: 1 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: General",
"Intended Audience :: Science/Research",
"Natural Language :: English",
"Programming Language :: Python :: 3.9",
]
dependencies = [
"dask[complete]>=2024.0.0",
"loguru>=0.7.0",
"more-itertools>=10.0.0",
"numbagg>=0.8.0",
"numpy>=1.26.0",
"orjson>=3.0.0",
"pandas>=2.0.0",
"pydantic>=2.0.0",
"xarray[accel]>=2023.0.0",
"zarr>=2.0.0",
]
requires-python = ">=3.11"

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[project.optional-dependencies]
dev = [
"ruff",
"pytest",
"pytest-cov",
"pytest-env",
"pytest-xdist",
"sphinx",
]

[tool.ruff]

[tool.ruff.lint]
# E402: module level import not at top of file
# E501: line too long - let black worry about that
# E731: do not assign a lambda expression, use a def
extend-safe-fixes = [
"TID252", # absolute imports
]
ignore = [
"E402",
"E501",
"E731",
"UP007",
"UP038"
]
extend-select = [
"B", # flake8-bugbear
"F", # Pyflakes
"E", # Pycodestyle
"W",
"TID", # flake8-tidy-imports (absolute imports)
"I", # isort
"UP", # Pyupgrade
]

[tool.ruff.lint.per-file-ignores]
# don't enforce absolute imports

[tool.ruff.lint.isort]
known-first-party = ["tensordb"]

[tool.ruff.lint.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"
10 changes: 0 additions & 10 deletions requirements.txt

This file was deleted.

23 changes: 0 additions & 23 deletions setup.py

This file was deleted.

16 changes: 16 additions & 0 deletions src/tensordb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from tensordb import tensor_definition, utils
from tensordb.algorithms import Algorithms
from tensordb.clients import BaseTensorClient, FileCacheTensorClient, TensorClient
from tensordb.tensor_definition import TensorDefinition
from tensordb.utils.tools import extract_paths_from_formula

__all__ = (
"tensor_definition",
"utils",
"Algorithms",
"TensorClient",
"FileCacheTensorClient",
"BaseTensorClient",
"TensorDefinition",
"extract_paths_from_formula",
)
29 changes: 17 additions & 12 deletions tensordb/algorithms.py → src/tensordb/algorithms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Union, List, Dict, Literal, Any, Callable
from collections.abc import Callable
from typing import Any, Literal, Union

import bottleneck as bn
import dask
Expand Down Expand Up @@ -143,7 +144,7 @@ def map_blocks_along_axis(
dim: str,
dtype,
drop_dim: bool = False,
kwargs: Dict = None,
kwargs: dict = None,
) -> xr.DataArray:
kwargs = kwargs or {}
template = new_data.chunk({dim: -1})
Expand Down Expand Up @@ -320,7 +321,7 @@ def rolling_along_axis(
def replace(
cls,
new_data: Union[xr.DataArray, xr.Dataset],
to_replace: Dict,
to_replace: dict,
dtype: Any = None,
default_replace=None,
):
Expand Down Expand Up @@ -355,7 +356,7 @@ def replace(
def vindex(
cls,
new_data: Union[xr.DataArray, xr.Dataset],
coords: Dict,
coords: dict,
):
"""
Implementation of dask vindex using xarray
Expand Down Expand Up @@ -395,12 +396,12 @@ def vindex(
def apply_on_groups(
cls,
new_data: Union[xr.DataArray, xr.Dataset],
groups: Union[Dict, xr.DataArray],
groups: Union[dict, xr.DataArray],
dim: str,
func: Union[str, Callable],
keep_shape: bool = False,
unique_groups: np.ndarray = None,
kwargs: Dict[str, Any] = None,
kwargs: dict[str, Any] = None,
template: Union[xr.DataArray, xr.Dataset, str] = None,
):
"""
Expand Down Expand Up @@ -556,7 +557,7 @@ def merge_duplicates_coord(
new_data: Union[xr.DataArray, xr.Dataset],
dim: str,
func: str,
kwargs: Dict[str, Any] = None,
kwargs: dict[str, Any] = None,
):
"""
Group and merge duplicates coord base on a function, this can be a sum or a max. Read numpy-groupies
Expand All @@ -583,7 +584,7 @@ def merge_duplicates_coord(
def dropna(
cls,
new_data: Union[xr.DataArray, xr.Dataset],
dims: List[str],
dims: list[str],
how: Literal["all"] = "all",
client: Client = None,
):
Expand All @@ -598,7 +599,7 @@ def dropna(
def drop_unmarked(
cls,
new_data: Union[xr.DataArray, xr.Dataset],
dims: List[str],
dims: list[str],
how: Literal["all"] = "all",
client: Client = None,
):
Expand All @@ -613,7 +614,7 @@ def drop_unmarked(
valid_coords = dask.compute(*valid_coords)
else:
valid_coords = [c.result() for c in client.compute(valid_coords)]
return new_data.sel(dict(zip(dims, valid_coords)))
return new_data.sel(dict(zip(dims, valid_coords, strict=False)))

@classmethod
def append_previous(
Expand Down Expand Up @@ -824,7 +825,7 @@ def reindex_with_pad(
cls,
data: xr.DataArray | xr.Dataset,
coords,
preferred_chunks: Dict[str, int],
preferred_chunks: dict[str, int],
fill_value: Any,
apply_chunk: bool = True,
) -> xr.Dataset | xr.DataArray:
Expand Down Expand Up @@ -875,7 +876,11 @@ def reindex_with_pad(
}
# If it is not necessary to pad additional data then just use
# reindex directly
if len(pad_width) == 0 or any(len(coord) == 0 for coord in coords):
if (
len(pad_width) == 0
or any(len(coord) == 0 for coord in coords)
or any(v == 0 for v in data.sizes.values())
):
data = data.reindex(coords, fill_value=fill_value)
if apply_chunk:
data = data.chunk(preferred_chunks)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from tensordb.clients.base import BaseTensorClient
from tensordb.clients.file_cache_tensor_client import FileCacheTensorClient
from tensordb.clients.tensor_client import TensorClient

__all__ = ("BaseTensorClient", "FileCacheTensorClient", "TensorClient")
Loading

0 comments on commit ee4c4ba

Please sign in to comment.