syncoder 0.0.6a0__tar.gz → 0.0.6a1__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,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: syncoder
3
- Version: 0.0.6a0
3
+ Version: 0.0.6a1
4
4
  Summary: A codec for DNA data storage
5
5
  Project-URL: Homepage, https://example.com/TBD
6
6
  Project-URL: Issues, https://example.com/TBD/issues
@@ -3,4 +3,4 @@ from .codec import _default_b32_alphabet, _default_b32_alphabet_alt
3
3
  default_b32_alphabet = _default_b32_alphabet
4
4
  default_b32_alphabet_alt = _default_b32_alphabet_alt
5
5
 
6
- __version__ = "0.0.6a0"
6
+ __version__ = "0.0.6a1"
@@ -115,7 +115,8 @@ class BaseNBlockCodec:
115
115
  n_strands:int=100,
116
116
  max_strand_index:Optional[int]=None,
117
117
  index_type:Literal["binary", "inner symbol", "inner"]="binary",
118
- index_location:Literal["middle", "beginning", "end"]="middle"):
118
+ index_location:Literal["middle", "beginning", "end"]="middle",
119
+ lazy_outer:bool = False):
119
120
  """
120
121
  Initialize the Codec object.
121
122
 
@@ -135,6 +136,7 @@ class BaseNBlockCodec:
135
136
  index_location "middle" (default) places the index after the data symbols but before the redundancy symbols.
136
137
  index_location "beginning" places the index before the data symbols.
137
138
  index_location "end" places the index after the redundancy symbols. (not implemented)
139
+ lazy_outer (bool): If True, the outer code will be initialized lazily. Default: False.
138
140
  """
139
141
  if n_strands<=255:
140
142
  self.outer_alphabet_size_bytes = 1
@@ -216,10 +218,16 @@ class BaseNBlockCodec:
216
218
  raise ValueError("data_chunk_size must be even for 16 bit outer code.")
217
219
  #c=0 to match reedsolo library's default for code compatibility with prior versions of this codec.
218
220
  # This may be changed in a future major version.
219
- self.outer_coder_fast = galois.ReedSolomon(n=2**(self.outer_alphabet_size_bytes*8)-1,
220
- d=n_redundant_strands+1,
221
- c=0,
222
- field=galois.GF(2**(self.outer_alphabet_size_bytes*8)))
221
+
222
+ self.outer_d = n_redundant_strands+1
223
+ self.outer_field = galois.GF(2**(self.outer_alphabet_size_bytes*8))
224
+ if lazy_outer:
225
+ self.outer_coder_fast = None
226
+ else:
227
+ self.outer_coder_fast = galois.ReedSolomon(n=2**(self.outer_alphabet_size_bytes*8)-1,
228
+ d=self.outer_d,
229
+ c=0,
230
+ field=self.outer_field)
223
231
 
224
232
  def __compute_waste(self):
225
233
  k = self.inner_k
@@ -261,7 +269,7 @@ class BaseNBlockCodec:
261
269
  files_nstrands = 0
262
270
  if file_meta_data is not None:
263
271
  for block_name, block_meta in file_meta_data.items():
264
- strand_count_code_block = block_meta["blen"]//self.data_chunk_size+self.outer_coder_fast.d-1
272
+ strand_count_code_block = block_meta["blen"]//self.data_chunk_size+self.outer_d-1
265
273
  strand_count = strand_count_code_block*len(block_meta["istart"])
266
274
  files_nstrands+=strand_count
267
275
 
@@ -282,7 +290,7 @@ class BaseNBlockCodec:
282
290
  codec_params["innerd"] = self.inner_coder.d
283
291
  codec_params["innern"] = self.inner_n
284
292
  codec_params["nstrands"] = self.n_strands
285
- codec_params["neccstrand"] = self.outer_coder_fast.d-1
293
+ codec_params["neccstrand"] = self.outer_d-1
286
294
  codec_params["imax"] = self.max_strand_index
287
295
  codec_params["itype"] = self.index_type
288
296
  codec_params["ilocation"] = self.index_location
@@ -358,6 +366,13 @@ class BaseNBlockCodec:
358
366
  # ...
359
367
  # |<rrrrrrrrrrrrrrrrr self.data_chunk_size rrrrrrrrrrrrraaaRRRRRRRR>|
360
368
 
369
+ #lazy init outer code
370
+ if self.outer_coder_fast is None:
371
+ self.outer_coder_fast = galois.ReedSolomon(n=2**(self.outer_alphabet_size_bytes*8)-1,
372
+ d=self.outer_d,
373
+ c=0,
374
+ field=self.outer_field)
375
+
361
376
  #1. Reshape data
362
377
  logging.debug("applying outer code to {} bytes".format(len(data)))
363
378
  # reshape data so columns can be coded independently.
@@ -434,6 +449,14 @@ class BaseNBlockCodec:
434
449
  Raises:
435
450
  None
436
451
  """
452
+
453
+ #lazy init outer code
454
+ if self.outer_coder_fast is None:
455
+ self.outer_coder_fast = galois.ReedSolomon(n=2**(self.outer_alphabet_size_bytes*8)-1,
456
+ d=self.outer_d,
457
+ c=0,
458
+ field=self.outer_field)
459
+
437
460
  if n_strands is None:
438
461
  n_strands = self.n_strands
439
462
 
File without changes
File without changes
File without changes
File without changes