Skip to content

Commit

Permalink
Finish naming migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ashton314 committed Oct 15, 2024
1 parent 84948ce commit 04299b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ This tool may be useful for debugging those sorts of issues.

## Usage

1. Call `using TrackedFloats`; you may want to include functions like `enable_nan_injection` or `tf_config_logger` or the like. (See below for more details.)
1. Call `using TrackedFloats`; you may want to include functions like `tf_enable_nan_injection` or `tf_config_logger` or the like. (See below for more details.)
2. Add additional customization to logging and injection.
3. Wrap as many of your inputs in `TrackedFloatN` as you can.

Expand Down Expand Up @@ -169,16 +169,16 @@ TrackedFloats can *inject* `NaN`s at random points in your program to help you f

```julia
# Inject 2 NaNs
enable_nan_injection(2)
tf_enable_nan_injection(2)

# Inject 2 NaNs, except when in the function "nope" in "way.jl"
enable_nan_injection(n_inject=2, functions=[FunctionRef("nope", "way.jl")])
tf_enable_nan_injection(n_inject=2, functions=[FunctionRef("nope", "way.jl")])

# Enable recording of injections
record_injection("tf_recording") # this is just the file basename; will have timestamp prepended
tf_record_injection("tf_recording") # this is just the file basename; will have timestamp prepended

# Enable recording playback
replay_injection("20230530T145830-tf_recording.txt")
tf_reply_injection("20230530T145830-tf_recording.txt")
```

Keyword arguments for `tf_config_injector`:
Expand Down
14 changes: 7 additions & 7 deletions src/Config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,12 @@ a keyword argument to `tf_config_logger`.
tf_exclude_stacktrace(exclusions = [:prop]) = tf_config.log.exclusions = exclusions

"""
enable_nan_injection(n_inject::Int)
tf_enable_nan_injection(n_inject::Int)
Turn on NaN injection and injection `n_inject` NaNs. Does not modify odds,
function and library lists, or recording/replay state.
enable_nan_injection(; odds::Int = 10, n_inject::Int = 1, functions::Array{FunctionRef} = [], libraries::Array{String} = [])
tf_enable_nan_injection(; odds::Int = 10, n_inject::Int = 1, functions::Array{FunctionRef} = [], libraries::Array{String} = [])
Turn on NaN injection. Optionally configure the odds for injection, as well as
the number of NaNs to inject, and the functions/libraries in which to inject
Expand Down Expand Up @@ -370,26 +370,26 @@ function enable_injection(; odds::Int = 10, n_inject::Int = 1, value::Any = NaN,
end

"""
disable_nan_injection()
tf_disable_nan_injection()
Turn off NaN injection.
If you want to re-enable NaN injection after calling `disable_nan_injection`,
consider using the one-argument form of `enable_nan_injection(n_inject::Int)`.
If you want to re-enable NaN injection after calling `tf_disable_nan_injection`,
consider using the one-argument form of `tf_enable_nan_injection(n_inject::Int)`.
"""
tf_disable_nan_injection() = tf_config.inj.active = false
tf_disable_inf_injection() = tf_config.inj.active = false
disable_injection() = tf_config.inj.active = false

"""
record_injection(recording_file::String="tf_recording")
tf_record_injection(recording_file::String="tf_recording")
Turn on recording.
"""
tf_record_injection(recording_file::String="tf_recording") = tf_config.inj.record = recording_file

"""
replay_injection(replay_file::String)
tf_reply_injection(replay_file::String)
Sets the injector to read from a replay file.
Expand Down
1 change: 0 additions & 1 deletion src/TrackedFloats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module TrackedFloats
export FtConfig, tf_init, TrackedFloat16, TrackedFloat32, TrackedFloat64, FunctionRef
export LoggerConfig, tf_config_logger, tf_exclude_stacktrace, tf_print_log, tf_flush_logs
export InjectorConfig, tf_config_injector, tf_enable_nan_injection, tf_disable_nan_injection, tf_enable_inf_injection, tf_disable_inf_injection, tf_record_injection, tf_replay_injection
# migration: start again with adding tf_ to enable_nan_injection
export SessionConfig, tf_config_session

include("SharedStructs.jl") # Structures used in multiple places throughout TrackedFloats
Expand Down

0 comments on commit 04299b9

Please sign in to comment.