coordax 0.2.3__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {coordax-0.2.3 → coordax-0.2.4}/PKG-INFO +1 -1
  2. {coordax-0.2.3 → coordax-0.2.4}/coordax/__init__.py +1 -1
  3. {coordax-0.2.3 → coordax-0.2.4}/coordax/coordinate_systems.py +13 -7
  4. {coordax-0.2.3 → coordax-0.2.4}/coordax/fields.py +1 -1
  5. {coordax-0.2.3 → coordax-0.2.4}/coordax.egg-info/PKG-INFO +1 -1
  6. {coordax-0.2.3 → coordax-0.2.4}/pyproject.toml +1 -1
  7. {coordax-0.2.3 → coordax-0.2.4}/LICENSE +0 -0
  8. {coordax-0.2.3 → coordax-0.2.4}/README.md +0 -0
  9. {coordax-0.2.3 → coordax-0.2.4}/coordax/coordinate_systems_test.py +0 -0
  10. {coordax-0.2.3 → coordax-0.2.4}/coordax/coords.py +0 -0
  11. {coordax-0.2.3 → coordax-0.2.4}/coordax/doctest_test.py +0 -0
  12. {coordax-0.2.3 → coordax-0.2.4}/coordax/experimental.py +0 -0
  13. {coordax-0.2.3 → coordax-0.2.4}/coordax/fields_test.py +0 -0
  14. {coordax-0.2.3 → coordax-0.2.4}/coordax/jax_datetime_integration_test.py +0 -0
  15. {coordax-0.2.3 → coordax-0.2.4}/coordax/named_axes.py +0 -0
  16. {coordax-0.2.3 → coordax-0.2.4}/coordax/named_axes_test.py +0 -0
  17. {coordax-0.2.3 → coordax-0.2.4}/coordax/ndarrays.py +0 -0
  18. {coordax-0.2.3 → coordax-0.2.4}/coordax/testing.py +0 -0
  19. {coordax-0.2.3 → coordax-0.2.4}/coordax/utils.py +0 -0
  20. {coordax-0.2.3 → coordax-0.2.4}/coordax/xarray_test.py +0 -0
  21. {coordax-0.2.3 → coordax-0.2.4}/coordax.egg-info/SOURCES.txt +0 -0
  22. {coordax-0.2.3 → coordax-0.2.4}/coordax.egg-info/dependency_links.txt +0 -0
  23. {coordax-0.2.3 → coordax-0.2.4}/coordax.egg-info/requires.txt +0 -0
  24. {coordax-0.2.3 → coordax-0.2.4}/coordax.egg-info/top_level.txt +0 -0
  25. {coordax-0.2.3 → coordax-0.2.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: coordax
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Coordinate axes for scientific computing in JAX
5
5
  Author-email: Google LLC <noreply@google.com>
6
6
  License-Expression: Apache-2.0
@@ -53,4 +53,4 @@ from coordax.ndarrays import (
53
53
  )
54
54
  import coordax.testing # pylint: disable=unused-import
55
55
 
56
- __version__ = '0.2.3' # keep sync with pyproject.toml
56
+ __version__ = '0.2.4' # keep sync with pyproject.toml
@@ -25,7 +25,7 @@ import dataclasses
25
25
  import functools
26
26
  import itertools
27
27
  import typing
28
- from typing import Any, Self, TYPE_CHECKING, Type, TypeAlias, TypeVar
28
+ from typing import Any, Self, TYPE_CHECKING, Type, TypeAlias, TypeGuard, TypeVar
29
29
  import warnings
30
30
 
31
31
  from coordax import utils
@@ -35,7 +35,7 @@ import numpy as np
35
35
  if TYPE_CHECKING:
36
36
  # import only under TYPE_CHECKING to avoid circular dependency
37
37
  # pylint: disable=g-bad-import-order
38
- from coordax import fields
38
+ from coordax import fields # pylint: disable=unused-import
39
39
  import xarray
40
40
 
41
41
 
@@ -84,7 +84,7 @@ class Coordinate(abc.ABC):
84
84
  raise NotImplementedError()
85
85
 
86
86
  @property
87
- def fields(self) -> dict[str, fields.Field]:
87
+ def fields(self) -> dict[str, 'fields.Field']:
88
88
  """Optional dict that maps from field names to their values."""
89
89
  return {}
90
90
 
@@ -110,7 +110,7 @@ class Coordinate(abc.ABC):
110
110
 
111
111
  def to_xarray(self) -> dict[str, xarray.Variable]:
112
112
  """Convert this coordinate into xarray variables."""
113
- import xarray
113
+ import xarray # pylint: disable=g-import-not-at-top
114
114
 
115
115
  variables = {}
116
116
  dims_set = {dim for dim in self.dims if dim is not None}
@@ -164,6 +164,12 @@ class ArrayKey:
164
164
  return hash((self.value.shape, self.value.tobytes()))
165
165
 
166
166
 
167
+ @utils.export
168
+ def is_coord(obj: Any) -> TypeGuard[Coordinate]:
169
+ """Returns True if obj is a Coordinate."""
170
+ return isinstance(obj, Coordinate)
171
+
172
+
167
173
  @utils.export
168
174
  @jax.tree_util.register_static
169
175
  @dataclasses.dataclass(frozen=True)
@@ -211,7 +217,7 @@ class SelectedAxis(Coordinate):
211
217
  return (self.coordinate.shape[self.axis],)
212
218
 
213
219
  @property
214
- def fields(self) -> dict[str, fields.Field]:
220
+ def fields(self) -> dict[str, 'fields.Field']:
215
221
  """A maps from field names to their values."""
216
222
  return self.coordinate.fields
217
223
 
@@ -364,7 +370,7 @@ class CartesianProduct(Coordinate):
364
370
  return _concat_tuples(c.shape for c in self.coordinates)
365
371
 
366
372
  @property
367
- def fields(self) -> dict[str, fields.Field]:
373
+ def fields(self) -> dict[str, 'fields.Field']:
368
374
  """Returns a mapping from field names to their values."""
369
375
  return _merge_dicts(c.fields for c in self.coordinates)
370
376
 
@@ -479,7 +485,7 @@ class LabeledAxis(Coordinate):
479
485
  return self.ticks.shape
480
486
 
481
487
  @property
482
- def fields(self) -> dict[str, fields.Field]:
488
+ def fields(self) -> dict[str, 'fields.Field']:
483
489
  # needs local import to avoid circular dependency
484
490
  from coordax import fields # pylint: disable=g-import-not-at-top
485
491
 
@@ -538,7 +538,7 @@ class Field:
538
538
  [0., 0., 0.]], dtype=float32)
539
539
  Dimensions without coordinates: x, y
540
540
  """
541
- import xarray
541
+ import xarray # pylint: disable=g-import-not-at-top
542
542
 
543
543
  if not all(isinstance(dim, str) for dim in self.dims):
544
544
  raise ValueError(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: coordax
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Coordinate axes for scientific computing in JAX
5
5
  Author-email: Google LLC <noreply@google.com>
6
6
  License-Expression: Apache-2.0
@@ -7,7 +7,7 @@ packages = ["coordax"]
7
7
 
8
8
  [project]
9
9
  name = "coordax"
10
- version = "0.2.3" # keep sync with __init__.py
10
+ version = "0.2.4" # keep sync with __init__.py
11
11
  description = "Coordinate axes for scientific computing in JAX"
12
12
  authors = [
13
13
  {name = "Google LLC", email = "noreply@google.com"},
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes