Skip to content

make varn APIs separated from var APIs #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ be found at the beginning of each file.

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

* [transpose.py](./transpose.py)
+ This example shows how to use `Variable` method `put_var()` to write six 3D
Expand Down
4 changes: 2 additions & 2 deletions examples/get_vara.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def pnetcdf_io(filename, file_format):
if rank == 0 and verbose:
print("variable attribute \"str_att_name\" of type text =", str_att)

# Get the length of the variable's attribute named "float_att_name"
float_att = v.get_att("float_att_name")
# Get the variable's attribute named "float_att_name"
float_att = v.get_att("float_att_name")

# set access pattern for reading subarray
local_ny = global_ny
Expand Down
8 changes: 4 additions & 4 deletions examples/put_varn_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#

"""
This example shows how to use a single call of `Variable` method `put_var()` to
to write a sequence of requests with arbitrary array indices and lengths.
This example shows how to use a single call of `Variable` method `put_varn()`
to to write a sequence of requests with arbitrary array indices and lengths.

To run:
% mpiexec -n num_process python3 put_varn_int.py [test_file_name]
Expand Down Expand Up @@ -153,7 +153,7 @@ def pnetcdf_io(file_name, file_format):
w_buf = np.full(w_len, rank, dtype=np.int32)

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

# close the file
f.close()
Expand Down Expand Up @@ -187,7 +187,7 @@ def pnetcdf_io(file_name, file_format):
filename = args.dir

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

try:
pnetcdf_io(filename, file_format)
Expand Down
11 changes: 5 additions & 6 deletions src/pnetcdf/_File.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,11 @@ cdef class File:

Operational mode: This method must be called while the file is in define mode.
"""


cdef nc_type xtype
xtype=-99
_set_att(self, NC_GLOBAL, name, value, xtype=xtype)


def get_att(self,name,encoding='utf-8'):
"""
get_att(self,name,encoding='utf-8')
Expand All @@ -519,14 +518,14 @@ cdef class File:
:param name: Name of the attribute.
:type name: str

:rtype: str
:rtype: str or numpy.ndarray

Operational mode: This method must be called while the file is in define mode.
Operational mode: This method can be called while the file is in either
define or data mode (collective or independent).
"""


return _get_att(self, NC_GLOBAL, name, encoding=encoding)


def __delattr__(self,name):
# if it's a netCDF attribute, remove it
if name not in _private_atts:
Expand Down
Loading
Loading