datafarming 3.0.0 → 3.0.1
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.
- checksums.yaml +4 -4
- data/exe/generate_design.rb +75 -62
- data/lib/datafarming/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1198f984e4e5f16e5a22b81f3a06fe658d42a55bc1de044154495e4f1d11fda8
|
|
4
|
+
data.tar.gz: 7f0916adce51ba90967f2726778ce4ec8a351eb3fe015cc6342fb4da635eed76
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 806aa73f56a21a08b7b84aeb5104613e748909fffec898ddff9f5e20b2fd5cc7eade1a21d03e35e03b1993f929ec47bec993e496cfff46593ce15fc13729b50a
|
|
7
|
+
data.tar.gz: 378d4a1f0024b9c7550ae70a249f2db6314f3d09d7b05e145b40432f965d704ab889d701d8a8bf6b9432849885f775863f5e1af69a4edba2f6f3914285f5f7a5
|
data/exe/generate_design.rb
CHANGED
|
@@ -20,6 +20,7 @@ DEFAULT_OPTIONS = {
|
|
|
20
20
|
levels: nil,
|
|
21
21
|
headers: true,
|
|
22
22
|
replicate: 1,
|
|
23
|
+
output_design: nil,
|
|
23
24
|
stack: 1,
|
|
24
25
|
centerdup: false,
|
|
25
26
|
specs: []
|
|
@@ -175,7 +176,7 @@ class Array
|
|
|
175
176
|
elsif spec[:cat].is_a? Array
|
|
176
177
|
spec[:cat]
|
|
177
178
|
else
|
|
178
|
-
|
|
179
|
+
fatal_err "Invalid category specification: #{spec[:cat]}"
|
|
179
180
|
end
|
|
180
181
|
# t = thresholds(categories.size)
|
|
181
182
|
if FREQ_DESIGNS.include? spec[:design]
|
|
@@ -297,12 +298,8 @@ def parse_specs(options, remainder)
|
|
|
297
298
|
end
|
|
298
299
|
|
|
299
300
|
def parse_args
|
|
300
|
-
yaml_input = false
|
|
301
|
-
if ARGV.size > 2 && ARGV.any? { |elt| elt.eql?("-i") || elt.eql?("--input_yaml") }
|
|
302
|
-
STDERR.puts 'NOTE: All other arguments ignored when using YAML input'
|
|
303
|
-
end
|
|
304
|
-
|
|
305
301
|
options = DEFAULT_OPTIONS
|
|
302
|
+
output_arg = false
|
|
306
303
|
|
|
307
304
|
begin
|
|
308
305
|
remainder = OptionParser.new do |opts|
|
|
@@ -332,48 +329,49 @@ def parse_args
|
|
|
332
329
|
Integer, 'NOTE: Applies only to NOLH designs',
|
|
333
330
|
'Number of levels in the base NOLH:',
|
|
334
331
|
" #{NOLH_LEVELS.join ' '}")
|
|
335
|
-
opts.on('-o', '--
|
|
332
|
+
opts.on('-o', '--output_design FILENAME',
|
|
333
|
+
'Write design to FILENAME (or STDOUT).',
|
|
334
|
+
"Use '-o -' to force STDOUT."
|
|
335
|
+
) do |fname|
|
|
336
|
+
fatal_err "Option '--output_design' missing required arg" if fname[0] == '-' && fname.size > 1
|
|
337
|
+
output_arg = true
|
|
338
|
+
fname == '-' ? nil : fname
|
|
339
|
+
end
|
|
340
|
+
opts.on('-y', '--yaml_output [FILENAME]',
|
|
336
341
|
'Write design YAML to FILENAME (or STDOUT)'
|
|
337
342
|
) do |fname|
|
|
338
343
|
if fname.nil? || '-' == fname
|
|
339
344
|
STDOUT
|
|
340
345
|
else
|
|
341
|
-
fname
|
|
346
|
+
File.open(fname, "w")
|
|
342
347
|
end
|
|
343
348
|
end
|
|
344
349
|
opts.on(
|
|
345
|
-
"-i", "--input_yaml
|
|
350
|
+
"-i", "--input_yaml FILENAME",
|
|
346
351
|
'Read design YAML from FILENAME (or STDIN)',
|
|
347
|
-
'(Mutually exclusive with all other options
|
|
348
|
-
|
|
349
|
-
'are passed)'
|
|
352
|
+
'(Mutually exclusive with all other options',
|
|
353
|
+
"except '-o')"
|
|
350
354
|
) do |fname|
|
|
351
|
-
|
|
352
|
-
# options = {specs: []}
|
|
353
|
-
options = DEFAULT_OPTIONS
|
|
354
|
-
yaml_input = true
|
|
355
|
+
o_dest = options[:output_design] if output_arg
|
|
355
356
|
if fname.nil? || '-' == fname
|
|
356
|
-
YAML::
|
|
357
|
-
|
|
358
|
-
).each do |k, v|
|
|
359
|
-
options[k.to_sym] = v
|
|
360
|
-
end
|
|
357
|
+
YAML::load(STDIN.read, symbolize_names: true)
|
|
358
|
+
.each { |k, v| options[k.to_sym] = v }
|
|
361
359
|
else
|
|
362
|
-
YAML::
|
|
363
|
-
|
|
364
|
-
).each do |k, v|
|
|
365
|
-
options[k.to_sym] = v
|
|
366
|
-
end
|
|
360
|
+
YAML::load_file(fname, symbolize_names: true)
|
|
361
|
+
.each { |k, v| options[k.to_sym] = v }
|
|
367
362
|
end
|
|
363
|
+
options[:output_design] = o_dest if output_arg
|
|
364
|
+
true
|
|
368
365
|
end
|
|
369
|
-
|
|
366
|
+
end.parse!(into: options)
|
|
370
367
|
rescue OptionParser::ParseError => error
|
|
371
368
|
fatal_err("#{error}\n(-h or --help will show valid options)")
|
|
372
369
|
end
|
|
373
370
|
|
|
374
371
|
fatal_err("Levels option only valid for NOLH designs") if options[:levels] && options[:design] != :nolh
|
|
375
372
|
|
|
376
|
-
|
|
373
|
+
options.delete(:input_yaml)
|
|
374
|
+
|
|
377
375
|
if remainder.size.positive? && options[:specs].size.positive?
|
|
378
376
|
STDERR.puts 'NOTE: Num_factors ignored when using optional factor specs'
|
|
379
377
|
options[:specs] = []
|
|
@@ -406,49 +404,64 @@ end
|
|
|
406
404
|
|
|
407
405
|
ARGV << '--help' if ARGV.empty?
|
|
408
406
|
|
|
407
|
+
if (i_loc = ARGV.find_index('-i'))
|
|
408
|
+
fatal_err("Cannot use --input_yaml and --yaml_out together") if ARGV.find_index('-y')
|
|
409
|
+
o_loc = ARGV.find_index('-y')
|
|
410
|
+
ARGV.replace(ARGV[i_loc, 2] + ARGV[o_loc, 2]) if o_loc
|
|
411
|
+
end
|
|
412
|
+
|
|
409
413
|
options = parse_args
|
|
410
414
|
|
|
411
|
-
if options[:
|
|
412
|
-
|
|
413
|
-
options.delete(:
|
|
415
|
+
if options[:yaml_output]
|
|
416
|
+
y_file = options[:yaml_output]
|
|
417
|
+
options.delete(:yaml_output)
|
|
414
418
|
begin
|
|
415
|
-
|
|
419
|
+
y_file.puts options.to_yaml
|
|
416
420
|
ensure
|
|
417
|
-
|
|
421
|
+
y_file.close unless STDIN == y_file
|
|
418
422
|
end
|
|
419
423
|
else
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
424
|
+
begin
|
|
425
|
+
o_file = options[:output_design] ? File.open(options[:output_design], "w") : STDOUT
|
|
426
|
+
base_design = method(options[:design])
|
|
427
|
+
.call(options)
|
|
428
|
+
.transpose
|
|
429
|
+
.first(options[:specs].size)
|
|
430
|
+
separator = ','
|
|
431
|
+
if options[:headers]
|
|
432
|
+
o_file.puts Array.new(options[:specs].size) { |i| options[:specs][i][:id] }.join(separator)
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
# stack
|
|
436
|
+
design = stack(base_design, options[:stack], options[:centerdup])
|
|
437
|
+
|
|
438
|
+
# scale
|
|
439
|
+
scale_factor = design.map &:max
|
|
440
|
+
d_type = options[:design]
|
|
441
|
+
design.map!.with_index do |v, i|
|
|
442
|
+
break if i >= options[:specs].size
|
|
443
|
+
spec = options[:specs][i]
|
|
444
|
+
if spec[:cat]
|
|
445
|
+
spec[:design] = d_type
|
|
446
|
+
v.categorize(spec)
|
|
447
|
+
elsif spec[:disc]
|
|
448
|
+
spec[:design] = d_type
|
|
449
|
+
v.discretize(spec)
|
|
450
|
+
else
|
|
451
|
+
scaler = Scaler.new(spec)
|
|
452
|
+
v.map do |x|
|
|
453
|
+
scaler.scale((x / scale_factor[i]).round(15))
|
|
454
|
+
end
|
|
443
455
|
end
|
|
444
456
|
end
|
|
445
|
-
end
|
|
446
457
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
puts line.join(separator)
|
|
458
|
+
# replicate
|
|
459
|
+
result = design.transpose
|
|
460
|
+
# o_file = options[:output_design]
|
|
461
|
+
options[:replicate].times do
|
|
462
|
+
result.each { |line| o_file.puts line.join(separator) }
|
|
452
463
|
end
|
|
464
|
+
ensure
|
|
465
|
+
o_file.close unless STDIN == o_file
|
|
453
466
|
end
|
|
454
467
|
end
|
data/lib/datafarming/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: datafarming
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Paul J Sanchez
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-11-
|
|
10
|
+
date: 2026-11-27 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: fwt
|
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
160
160
|
- !ruby/object:Gem::Version
|
|
161
161
|
version: "0"
|
|
162
162
|
requirements: []
|
|
163
|
-
rubygems_version: 4.1.
|
|
163
|
+
rubygems_version: 4.1.1
|
|
164
164
|
specification_version: 4
|
|
165
165
|
summary: Useful tools for data farming.
|
|
166
166
|
test_files: []
|