<commit_before>#!/usr/bin/env julia

import Distributions: var, DiscreteUniform
import JSON

"""
	gen( a, b, name )

Generate fixture data and write to file.

# Arguments

* `x`: input value
* `a`: minimum support
* `b`: maximum support
* `name::AbstractString`: output filename

# Examples

``` julia
julia> a = round( Int64, rand( 1000 ) * 10.0 );
julia> b = round( Int64, ( rand( 1000 ) * 10.0 ) + a );
julia> gen( a, b, \"data.json\" );
```
"""
function gen( a, b, name )
	z = Array( Float64, length(a) );
	for i in eachindex(a)
		z[ i ] = sqrt( var( DiscreteUniform( a[i], b[i] ) ) );
	end

	# Store data to be written to file as a collection:
	data = Dict([
		("a", a),
		("b", b),
		("expected", z)
	]);

	# Based on the script directory, create an output filepath:
	filepath = joinpath( dir, name );

	# Write the data to the output filepath as JSON:
	outfile = open( filepath, "w" );
	write( outfile, JSON.json(data) );
	close( outfile );
end

# Get the filename:
file = @__FILE__;

# Extract the directory in which this file resides:
dir = dirname( file );

# Generate fixtures:
a = round( Int64, rand( 1000 ) * 10.0 );
b = round( Int64, rand( 1000 ) * 10.0 + a );
gen( a, b, "data.json" );
<commit_msg>Add missing parentheses<commit_after>#!/usr/bin/env julia

import Distributions: var, DiscreteUniform
import JSON

"""
	gen( a, b, name )

Generate fixture data and write to file.

# Arguments

* `x`: input value
* `a`: minimum support
* `b`: maximum support
* `name::AbstractString`: output filename

# Examples

``` julia
julia> a = round( Int64, rand( 1000 ) * 10.0 );
julia> b = round( Int64, ( rand( 1000 ) * 10.0 ) + a );
julia> gen( a, b, \"data.json\" );
```
"""
function gen( a, b, name )
	z = Array( Float64, length(a) );
	for i in eachindex(a)
		z[ i ] = sqrt( var( DiscreteUniform( a[i], b[i] ) ) );
	end

	# Store data to be written to file as a collection:
	data = Dict([
		("a", a),
		("b", b),
		("expected", z)
	]);

	# Based on the script directory, create an output filepath:
	filepath = joinpath( dir, name );

	# Write the data to the output filepath as JSON:
	outfile = open( filepath, "w" );
	write( outfile, JSON.json(data) );
	close( outfile );
end

# Get the filename:
file = @__FILE__;

# Extract the directory in which this file resides:
dir = dirname( file );

# Generate fixtures:
a = round( Int64, rand( 1000 ) * 10.0 );
b = round( Int64, ( rand( 1000 ) * 10.0 ) + a );
gen( a, b, "data.json" );

{'fraction_non_alphanumeric': 0.16557377049180327, 'fraction_numerical': 0.03114754098360656, 'mean_word_length': 3.5626168224299066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3145874', 'n_tokens_mistral': 989, 'n_tokens_neox': 892, 'n_words': 322}