@@ -83,7 +83,7 @@ def create(shape, chunks, dtype=None, compression='default',
83
83
84
84
def empty (shape , chunks , dtype = None , compression = 'default' ,
85
85
compression_opts = None , order = 'C' , store = None , synchronizer = None ,
86
- path = None ):
86
+ path = None , overwrite = False ):
87
87
"""Create an empty array.
88
88
89
89
For parameter definitions see :func:`zarr.creation.create`.
@@ -98,12 +98,12 @@ def empty(shape, chunks, dtype=None, compression='default',
98
98
return create (shape = shape , chunks = chunks , dtype = dtype ,
99
99
compression = compression , compression_opts = compression_opts ,
100
100
fill_value = None , order = order , store = store ,
101
- synchronizer = synchronizer , path = path )
101
+ synchronizer = synchronizer , path = path , overwrite = overwrite )
102
102
103
103
104
104
def zeros (shape , chunks , dtype = None , compression = 'default' ,
105
105
compression_opts = None , order = 'C' , store = None , synchronizer = None ,
106
- path = None ):
106
+ path = None , overwrite = False ):
107
107
"""Create an array, with zero being used as the default value for
108
108
uninitialised portions of the array.
109
109
@@ -127,12 +127,13 @@ def zeros(shape, chunks, dtype=None, compression='default',
127
127
return create (shape = shape , chunks = chunks , dtype = dtype ,
128
128
compression = compression ,
129
129
compression_opts = compression_opts , fill_value = 0 , order = order ,
130
- store = store , synchronizer = synchronizer , path = path )
130
+ store = store , synchronizer = synchronizer , path = path ,
131
+ overwrite = overwrite )
131
132
132
133
133
134
def ones (shape , chunks , dtype = None , compression = 'default' ,
134
135
compression_opts = None , order = 'C' , store = None , synchronizer = None ,
135
- path = None ):
136
+ path = None , overwrite = False ):
136
137
"""Create an array, with one being used as the default value for
137
138
uninitialised portions of the array.
138
139
@@ -156,12 +157,12 @@ def ones(shape, chunks, dtype=None, compression='default',
156
157
return create (shape = shape , chunks = chunks , dtype = dtype ,
157
158
compression = compression , compression_opts = compression_opts ,
158
159
fill_value = 1 , order = order , store = store ,
159
- synchronizer = synchronizer , path = path )
160
+ synchronizer = synchronizer , path = path , overwrite = overwrite )
160
161
161
162
162
163
def full (shape , chunks , fill_value , dtype = None , compression = 'default' ,
163
164
compression_opts = None , order = 'C' , store = None , synchronizer = None ,
164
- path = None ):
165
+ path = None , overwrite = False ):
165
166
"""Create an array, with `fill_value` being used as the default value for
166
167
uninitialised portions of the array.
167
168
@@ -185,12 +186,12 @@ def full(shape, chunks, fill_value, dtype=None, compression='default',
185
186
return create (shape = shape , chunks = chunks , dtype = dtype ,
186
187
compression = compression , compression_opts = compression_opts ,
187
188
fill_value = fill_value , order = order , store = store ,
188
- synchronizer = synchronizer , path = path )
189
+ synchronizer = synchronizer , path = path , overwrite = overwrite )
189
190
190
191
191
192
def array (data , chunks = None , dtype = None , compression = 'default' ,
192
193
compression_opts = None , fill_value = None , order = 'C' , store = None ,
193
- synchronizer = None , path = None ):
194
+ synchronizer = None , path = None , overwrite = False ):
194
195
"""Create an array filled with `data`.
195
196
196
197
The `data` argument should be a NumPy array or array-like object. For
@@ -237,7 +238,7 @@ def array(data, chunks=None, dtype=None, compression='default',
237
238
z = create (shape = shape , chunks = chunks , dtype = dtype ,
238
239
compression = compression , compression_opts = compression_opts ,
239
240
fill_value = fill_value , order = order , store = store ,
240
- synchronizer = synchronizer , path = path )
241
+ synchronizer = synchronizer , path = path , overwrite = overwrite )
241
242
242
243
# fill with data
243
244
z [:] = data
@@ -246,9 +247,9 @@ def array(data, chunks=None, dtype=None, compression='default',
246
247
247
248
248
249
# noinspection PyShadowingBuiltins
249
- def open (path , mode = 'a' , shape = None , chunks = None , dtype = None ,
250
- compression = 'default' , compression_opts = None , fill_value = 0 , order = 'C' ,
251
- synchronizer = None ):
250
+ def open_array (path , mode = 'a' , shape = None , chunks = None , dtype = None ,
251
+ compression = 'default' , compression_opts = None , fill_value = 0 ,
252
+ order = 'C' , synchronizer = None ):
252
253
"""Open an array stored in a directory on the file system.
253
254
254
255
Parameters
@@ -357,6 +358,10 @@ def open(path, mode='a', shape=None, chunks=None, dtype=None,
357
358
return z
358
359
359
360
361
+ # backwards compatibility
362
+ open = open_array
363
+
364
+
360
365
def _like_args (a , shape , chunks , dtype , compression , compression_opts , order ):
361
366
if shape is None :
362
367
shape = a .shape
@@ -387,43 +392,46 @@ def _like_args(a, shape, chunks, dtype, compression, compression_opts, order):
387
392
388
393
def empty_like (a , shape = None , chunks = None , dtype = None , compression = None ,
389
394
compression_opts = None , order = None , store = None ,
390
- synchronizer = None , path = None ):
395
+ synchronizer = None , path = None , overwrite = False ):
391
396
"""Create an empty array like `a`."""
392
397
shape , chunks , dtype , compression , compression_opts , order = \
393
398
_like_args (a , shape , chunks , dtype , compression , compression_opts ,
394
399
order )
395
400
return empty (shape , chunks , dtype = dtype , compression = compression ,
396
401
compression_opts = compression_opts , order = order ,
397
- store = store , synchronizer = synchronizer , path = path )
402
+ store = store , synchronizer = synchronizer , path = path ,
403
+ overwrite = overwrite )
398
404
399
405
400
406
def zeros_like (a , shape = None , chunks = None , dtype = None , compression = None ,
401
407
compression_opts = None , order = None , store = None ,
402
- synchronizer = None , path = None ):
408
+ synchronizer = None , path = None , overwrite = False ):
403
409
"""Create an array of zeros like `a`."""
404
410
shape , chunks , dtype , compression , compression_opts , order = \
405
411
_like_args (a , shape , chunks , dtype , compression , compression_opts ,
406
412
order )
407
413
return zeros (shape , chunks , dtype = dtype , compression = compression ,
408
414
compression_opts = compression_opts , order = order ,
409
- store = store , synchronizer = synchronizer , path = path )
415
+ store = store , synchronizer = synchronizer , path = path ,
416
+ overwrite = overwrite )
410
417
411
418
412
419
def ones_like (a , shape = None , chunks = None , dtype = None , compression = None ,
413
420
compression_opts = None , order = None , store = None ,
414
- synchronizer = None , path = None ):
421
+ synchronizer = None , path = None , overwrite = False ):
415
422
"""Create an array of ones like `a`."""
416
423
shape , chunks , dtype , compression , compression_opts , order = \
417
424
_like_args (a , shape , chunks , dtype , compression , compression_opts ,
418
425
order )
419
426
return ones (shape , chunks , dtype = dtype , compression = compression ,
420
427
compression_opts = compression_opts , order = order ,
421
- store = store , synchronizer = synchronizer , path = path )
428
+ store = store , synchronizer = synchronizer , path = path ,
429
+ overwrite = overwrite )
422
430
423
431
424
432
def full_like (a , shape = None , chunks = None , fill_value = None , dtype = None ,
425
433
compression = None , compression_opts = None , order = None ,
426
- store = None , synchronizer = None , path = None ):
434
+ store = None , synchronizer = None , path = None , overwrite = False ):
427
435
"""Create a filled array like `a`."""
428
436
shape , chunks , dtype , compression , compression_opts , order = \
429
437
_like_args (a , shape , chunks , dtype , compression , compression_opts ,
@@ -435,7 +443,8 @@ def full_like(a, shape=None, chunks=None, fill_value=None, dtype=None,
435
443
raise ValueError ('fill_value must be specified' )
436
444
return full (shape , chunks , fill_value , dtype = dtype ,
437
445
compression = compression , compression_opts = compression_opts ,
438
- order = order , store = store , synchronizer = synchronizer , path = path )
446
+ order = order , store = store , synchronizer = synchronizer ,
447
+ path = path , overwrite = overwrite )
439
448
440
449
441
450
def open_like (a , path , mode = 'a' , shape = None , chunks = None , dtype = None ,
@@ -451,7 +460,8 @@ def open_like(a, path, mode='a', shape=None, chunks=None, dtype=None,
451
460
except AttributeError :
452
461
# leave empty
453
462
pass
454
- return open (path , mode = mode , shape = shape , chunks = chunks , dtype = dtype ,
455
- compression = compression , compression_opts = compression_opts ,
456
- fill_value = fill_value , order = order ,
457
- synchronizer = synchronizer )
463
+ return open_array (path , mode = mode , shape = shape , chunks = chunks , dtype = dtype ,
464
+ compression = compression ,
465
+ compression_opts = compression_opts ,
466
+ fill_value = fill_value , order = order ,
467
+ synchronizer = synchronizer )
0 commit comments