Skip to content

Commit

Permalink
All tests pass!
Browse files Browse the repository at this point in the history
All unit tests pass since I made some fixes to how I handle generators.  rpn also no longer hits oeis.org when running the test suite.

This is a 9.0 beta candidate, but I still want to get the Windows exe build sorted out.
  • Loading branch information
ConceptJunkie committed Oct 21, 2024
1 parent c414b9e commit 6e1d681
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
20 changes: 16 additions & 4 deletions rpn/makeHelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ def makeCommandExample( command, indent=0, slow=False ):
-o, --octal
octal mode: equivalent to \'-r8 -w9 -g3 -z\'

-O, --ignore_oeis-cache
ignore cached results from OEIS, accesses the website and updates the cache

-pn, --precision n
precision, i.e., number of significant digits to use

Expand Down Expand Up @@ -2150,9 +2153,9 @@ def makeCommandExample( command, indent=0, slow=False ):
''',
'''
''' + makeCommandExample( '[ 1 2 ] geometric_mean' ) + '''
''' + makeCommandExample( '[ 1 10 range ] geometric_mean' ) + '''
''' + makeCommandExample( '1 10 range geometric_mean' ) + '''
Calculate the geometric mean of the first n numbers from 1 to 5:
''' + makeCommandExample( '[ 1 1 5 range range ] geometric_mean' ),
''' + makeCommandExample( '1 1 5 range range lambda x geometric_mean for_each_list' ),
[ 'mean', 'agm', 'harmonic_mean', 'root_mean_square' ] ],

'harmonic_mean' : [
Expand Down Expand Up @@ -7085,14 +7088,23 @@ def makeCommandExample( command, indent=0, slow=False ):
''' + makeCommandExample( '[ [ 1 2 ] [ 3 4 ] [ 5 6 ] [ 7 8 ] ] lambda x sum for_each_list' ),
[ 'for_each', 'sequence' ] ],

'for_each_list' : [
'for_each_list_filter' : [
'functions', 'filters based on function k on elements of list n, treating each element as a list argument',
'''
''',
'''
''' + makeCommandExample( '[ [ 2 3 ] [ 4 5 ] [ 7 7 ] [ 8 9 ] ] lambda x 0 element x 1 element is_equal for_each_list' ),
''' + makeCommandExample( '[ [ 2 3 ] [ 4 5 ] [ 7 7 ] [ 8 9 ] ] lambda x 0 element x 1 element is_equal for_each_list_filter' ),
[ 'for_each', 'sequence' ] ],

'for_each_list_unfilter' : [
'functions', 'filters based on the inverse of function k on elements of list n, treating each element as a list argument',
'''
''',
'''
''' + makeCommandExample( '[ [ 2 3 ] [ 4 5 ] [ 7 7 ] [ 8 9 ] ] lambda x 0 element x 1 element is_equal for_each_list_unfilter' ),
[ 'for_each', 'sequence' ] ],


'function': [
'functions', 'creates a user-defined function k named n',
'''
Expand Down
5 changes: 4 additions & 1 deletion rpn/rpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ def rpn( cmdArgs ):
parser.add_argument( '-m', '--maximum_fixed', type=int, default=g.defaultMaximumFixed )
parser.add_argument( '-n', '--numerals', type=str, default=g.defaultNumerals )
parser.add_argument( '-o', '--octal', action='store_true' )
parser.add_argument( '-O', '--ignore_oeis_cache', action='store_true' )
parser.add_argument( '-p', '--precision', type=int, default=g.defaultPrecision )
parser.add_argument( '-r', '--output_radix', type=str, default=g.defaultOutputRadix )
parser.add_argument( '-s', '--list_format_level', nargs='?', type=int, default=0,
Expand Down Expand Up @@ -550,7 +551,6 @@ def rpn( cmdArgs ):

# handle -I
g.ignoreCache = args.ignore_cache
g.refreshOEISCache = args.ignore_cache

if args.show_timezones:
g.showTimeZones = True
Expand All @@ -571,6 +571,9 @@ def rpn( cmdArgs ):
g.integerGrouping = 3
g.bitwiseGroupSize = 9

# handle -O
g.refreshOEISCache = args.ignore_oeis_cache

# handle -p
setPrecision( args.precision )

Expand Down
2 changes: 0 additions & 2 deletions rpn/special/rpnList.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,6 @@ def calculateGeometricMean( args ):
count = 0

for arg in args:
print( 'arg', arg, type( arg ) )

result = fmul( result, arg )
count += 1

Expand Down
6 changes: 3 additions & 3 deletions rpn/test/testRPN.py
Original file line number Diff line number Diff line change
Expand Up @@ -3173,8 +3173,8 @@ def runListOperatorTests( ):
# geometric_mean
expectEqual( '1 500 range lambda [ x sigma x euler_phi ] geometric_mean is_integer filter', '11257 oeis 500 filter_max' )
# rpn isn't smart enough to let me turn this into a lamdba I can run on a range, so let's just pick 2 particular values to try.
expectEqual( '12 lambda 1 x range powerset eval geometric_mean lambda x is_integer filter count', '326027 oeis 12 element' )
expectEqual( '14 lambda 1 x range powerset eval geometric_mean lambda x is_integer filter count', '326027 oeis 14 element' )
expectEqual( '12 lambda 1 x range powerset eval lambda x geometric_mean for_each_list lambda x is_integer filter count', '326027 oeis 12 element' )
expectEqual( '14 lambda 1 x range powerset eval lambda x geometric_mean for_each_list lambda x is_integer filter count', '326027 oeis 14 element' )

# geometric_range
expectEqual( '2 8 8 geometric_range', '0 7 range lambda 2 8 x ** * eval' )
Expand Down Expand Up @@ -4951,7 +4951,7 @@ def runPrimeNumberOperatorTests( ):

# prime_pi
testOperator( '87 prime_pi' )
expectEqual( '0 998 range lambda x x prime_pi combinations eval', '37031 oeis 999 left' )
expectEqual( '1 999 range lambda x x prime_pi combinations eval', '37031 oeis 999 left' )

# primes
testOperator( '1 5 range 5 primes' )
Expand Down

0 comments on commit 6e1d681

Please sign in to comment.