ncfunc 0.2.0__tar.gz → 0.2.2__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.
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ncfunc
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Add your description here
5
5
  Author: warmpool
6
6
  Author-email: warmpool <mail@mail.com>
7
7
  Requires-Dist: datenum>=0.1.0
8
- Requires-Dist: netcdf4>=1.7.3
8
+ Requires-Dist: netcdf4>=1.6
9
9
  Requires-Dist: numpy>=1.24
10
10
  Requires-Python: >=3.10
11
11
  Project-URL: Homepage, https://github.com/warmpool/py-ncfunc
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "ncfunc"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "Add your description here"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
7
7
  dependencies = [
8
8
  "datenum>=0.1.0",
9
- "netcdf4>=1.7.3",
9
+ "netcdf4>=1.6",
10
10
  "numpy>=1.24",
11
11
  ]
12
12
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ncfunc"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "Add your description here"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -9,7 +9,7 @@ authors = [
9
9
  requires-python = ">=3.10"
10
10
  dependencies = [
11
11
  "datenum>=0.1.0",
12
- "netcdf4>=1.7.3",
12
+ "netcdf4>=1.6",
13
13
  "numpy>=1.24",
14
14
  ]
15
15
 
@@ -723,11 +723,14 @@ def write_attr(path: PathLike, var_name: str, attr_name: str, value: Any) -> Non
723
723
  the file if var_name == '/'
724
724
  the variable else
725
725
 
726
- raises KeyError if the variable does not exist, FileNotFoundError if
727
- the path does not exist
726
+ only a root write creates the file when the path does not exist; a variable
727
+ write raises FileNotFoundError instead, leaving no file behind.
728
+
729
+ raises KeyError if the variable does not exist
728
730
  """
729
- # check var_name here; KeyError and FileNotFoundError surface from here
730
- _get_variable_meta(path, var_name)
731
+ if var_name != "/": # check var_name here; KeyError and FileNotFoundError surface
732
+ _get_variable_meta(path, var_name)
733
+
731
734
  with nc.Dataset(path, "a") as h_file:
732
735
  if var_name == "/":
733
736
  h_file.setncattr(attr_name, value)
@@ -963,7 +966,7 @@ def save(
963
966
  msg = f"cannot cast data of '{name}' to a numpy array"
964
967
  raise ValueError(msg) from e
965
968
 
966
- # ---- data check - is ndim(dim) == 1?
969
+ # ---- data check
967
970
  for i, (name, value) in enumerate(arrays.items()):
968
971
  if (
969
972
  (len(arrays) == 1 and i == 0) # the only entry (variable == dimension)
@@ -979,6 +982,13 @@ def save(
979
982
  f"I'm not going to help you write an empty data of shape={value.shape} to {name=}"
980
983
  )
981
984
 
985
+ if len(arrays) > 1:
986
+ shapes = tuple(v.shape for v in arrays.values())
987
+ var_shape = shapes[0]
988
+ dim_shape = tuple(s[0] for s in shapes[1:])
989
+ if var_shape != dim_shape:
990
+ raise ValueError(f"shapes differ: {var_shape=} {dim_shape=}")
991
+
982
992
  # ---- assign parameters to create and write functions
983
993
  names = tuple(data.keys())
984
994
 
File without changes
File without changes
File without changes