Skip to content

Commit b21b7d4

Browse files
authored
Merge pull request #48 from wkliao/varn
make varn APIs separated from var APIs
2 parents 880a01b + c1ad715 commit b21b7d4

File tree

11 files changed

+744
-1031
lines changed

11 files changed

+744
-1031
lines changed

examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ be found at the beginning of each file.
9393

9494
* [put_varn_int.py](./put_varn_int.py)
9595
+ This example shows how to use a single call of `Variable` method
96-
`put_var()` to to write a sequence of requests with arbitrary array indices
97-
and lengths.
96+
`put_varn()` to write a sequence of subarray requests to a variable with
97+
arbitrary array indices and lengths.
9898

9999
* [transpose.py](./transpose.py)
100100
+ This example shows how to use `Variable` method `put_var()` to write six 3D

examples/get_vara.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ def pnetcdf_io(filename, file_format):
9595
if rank == 0 and verbose:
9696
print("variable attribute \"str_att_name\" of type text =", str_att)
9797

98-
# Get the length of the variable's attribute named "float_att_name"
99-
float_att = v.get_att("float_att_name")
98+
# Get the variable's attribute named "float_att_name"
99+
float_att = v.get_att("float_att_name")
100100

101101
# set access pattern for reading subarray
102102
local_ny = global_ny

examples/put_varn_int.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#
55

66
"""
7-
This example shows how to use a single call of `Variable` method `put_var()` to
8-
to write a sequence of requests with arbitrary array indices and lengths.
7+
This example shows how to use a single call of `Variable` method `put_varn()`
8+
to to write a sequence of requests with arbitrary array indices and lengths.
99
1010
To run:
1111
% mpiexec -n num_process python3 put_varn_int.py [test_file_name]
@@ -153,7 +153,7 @@ def pnetcdf_io(file_name, file_format):
153153
w_buf = np.full(w_len, rank, dtype=np.int32)
154154

155155
# set the buffer pointers to different offsets to the I/O buffe
156-
v.put_var_all(w_buf, start = starts, count = counts, num = num_reqs)
156+
v.put_varn_all(w_buf, num = num_reqs, starts = starts, counts = counts)
157157

158158
# close the file
159159
f.close()
@@ -187,7 +187,7 @@ def pnetcdf_io(file_name, file_format):
187187
filename = args.dir
188188

189189
if verbose and rank == 0:
190-
print("{}: example of writing multiple variables in a call".format(os.path.basename(__file__)))
190+
print("{}: example of writing multiple subarrays of a variable in a call".format(os.path.basename(__file__)))
191191

192192
try:
193193
pnetcdf_io(filename, file_format)

src/pnetcdf/_File.pyx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,11 @@ cdef class File:
499499
500500
Operational mode: This method must be called while the file is in define mode.
501501
"""
502-
503-
504502
cdef nc_type xtype
505503
xtype=-99
506504
_set_att(self, NC_GLOBAL, name, value, xtype=xtype)
507505

506+
508507
def get_att(self,name,encoding='utf-8'):
509508
"""
510509
get_att(self,name,encoding='utf-8')
@@ -519,14 +518,14 @@ cdef class File:
519518
:param name: Name of the attribute.
520519
:type name: str
521520
522-
:rtype: str
521+
:rtype: str or numpy.ndarray
523522
524-
Operational mode: This method must be called while the file is in define mode.
523+
Operational mode: This method can be called while the file is in either
524+
define or data mode (collective or independent).
525525
"""
526-
527-
528526
return _get_att(self, NC_GLOBAL, name, encoding=encoding)
529527

528+
530529
def __delattr__(self,name):
531530
# if it's a netCDF attribute, remove it
532531
if name not in _private_atts:

0 commit comments

Comments
 (0)