@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
59 lines (58 loc) • 4 kB
TypeScript
import { type LintingResult, LintingResultCertainty, LintingRuleCertainty } from '../linter-format';
import type { MergeableRecord } from '../../util/objects';
import type { BrandedIdentifier } from '../../dataflow/environments/identifier';
import { LintingRuleTag } from '../linter-tags';
export interface SeededRandomnessResult extends LintingResult {
function: string;
}
export interface SeededRandomnessConfig extends MergeableRecord {
/**
* A set of functions and variables whose invocation or assignment causes a random seeded to be set.
* Each entry has a `type`, which is either `function` or `assignment`, and a `name`, which is the name of the function or variable.
* The default value for this is the function `set.seed` and the variable `.Random.seed`.
*/
randomnessProducers: {
type: 'function' | 'assignment';
name: string;
}[];
/**
* A set of randomness consumer function names that require a seed to be set prior to invocation.
*/
randomnessConsumers: string[];
}
export interface SeededRandomnessMeta extends MergeableRecord {
consumerCalls: number;
callsWithFunctionProducers: number;
callsWithAssignmentProducers: number;
callsWithNonConstantProducers: number;
callsWithOtherBranchProducers: number;
}
export declare const SEEDED_RANDOMNESS: {
readonly createSearch: (config: SeededRandomnessConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter", "with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: SeededRandomnessConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
results: {
involvedId: import("../../r-bridge/lang-4.x/ast/model/processing/node-id").NodeId;
certainty: LintingResultCertainty;
function: BrandedIdentifier;
loc: [startLine: number, startColumn: number, endLine: number, endColumn: number, f?: string | undefined];
}[];
'.meta': SeededRandomnessMeta;
}>;
readonly info: {
readonly defaultConfig: {
readonly randomnessProducers: {
type: "function" | "assignment";
name: string;
}[];
readonly randomnessConsumers: readonly [...BrandedIdentifier[], "princomp", "pointLabel", "some", "rbernoulli", "rdunif", "generateSeedVectors", "rvonmises", "rxor", "rmvnorm", "randomForest", "permuted", "permute", "shuffle", "shuffleSet", "data_shuffle", "sample_frac", "sample_n"];
};
readonly tags: readonly [LintingRuleTag.Robustness, LintingRuleTag.Reproducibility];
readonly certainty: LintingRuleCertainty.BestEffort;
readonly name: "Seeded Randomness";
readonly description: "Checks whether randomness-based function calls are preceded by a random seed generation function. For consistent reproducibility, functions that use randomness should only be called after a constant random seed is set using a function like `set.seed`.";
};
readonly prettyPrint: {
readonly query: (result: SeededRandomnessResult, _meta: SeededRandomnessMeta) => string;
readonly full: (result: SeededRandomnessResult, _meta: SeededRandomnessMeta) => string;
};
};