Skip to content
/ snp Public

Utility for saving inputs/outputs of Python functions for refactoring

Notifications You must be signed in to change notification settings

frnsys/snp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

snp

Utility for saving inputs and outputs of Python functions for refactoring.

Usage

import snp

# Save the inputs and outputs of this function
# to the `/tmp` directory
@snp.snap('/tmp')
def original(a, b, c):
    return a + b * c

# Test a modified function by specifying
# the save directory and the module path
# for the original function
@snp.test('/tmp', '__main__.original')
def modified(a, b, c):
    d = b * c
    return a + d

# Call the original function to
# save inputs and outputs
original(2,5,8)

# Now when you call the modified function,
# it will load the original arguments
# and check that the output matches
modified()

# If we defined a function that was incorrect:
@snp.test('/tmp', '__main__.original')
def modified_broken(a, b, c):
    d = b * c + 2
    return a + d

# This will raise an assertion error
modified_broken()

About

Utility for saving inputs/outputs of Python functions for refactoring

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages