Skip to content

Conversation

@translunar
Copy link
Contributor

Fixes #33 and adds a convenience function, SymEngine::symbols which allows us to create multiple symbols simultaneously.


context 'with a splatted argument' do
it 'returns an Enumerable of Symbol objects' do
@test_symbols_method.call(2, 'x', 'y')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you test the following:

    #    x, y = SymEngine.symbols(%i{x y})
    #    x, y = SymEngine.symbols(%w{x y})
    #    x, y = SymEngine.symbols('x', 'y')
    #    x, y = SymEngine.symbols('x y')

Based on your comment above, should we also test these:

    #    x, y = SymEngine.symbols([:x, :y])
    #    x, y = SymEngine.symbols(['x', 'y'])

I can see that you test SymEngine::Symbol.new('x') and SymEngine::Symbol.new(:x) below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%i{x y} is the same as [:x, :y], and %w{x y} is the same as ['x', 'y'].

I suppose we could also be exhaustive and test SymEngine.symbols(:x, :y), but it follows the same execution path as SymEngine.symbols('x', 'y'), so I think it's redundant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. Then all is good.

@certik
Copy link
Contributor

certik commented Apr 7, 2016

@MohawkJohn thanks for the PR! I left a minor comment. Otherwise it looks good.

@certik
Copy link
Contributor

certik commented Apr 7, 2016

There is an error in Ruby 1.9.3 (https://travis-ci.org/symengine/symengine.rb/jobs/121473492):

/home/travis/.rvm/gems/ruby-1.9.3-p551/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in `load': /home/travis/gems/symengine-0.1.0/spec/symbol_spec.rb:33: unknown type of %string (SyntaxError)

        @test_symbols_method.call(2, %i{x y})

                                        ^

/home/travis/gems/symengine-0.1.0/spec/symbol_spec.rb:33: syntax error, unexpected $end, expecting ')'

        @test_symbols_method.call(2, %i{x y})

Is this syntax not supported in Ruby 1.9.3?

@abinashmeher999
Copy link
Contributor

Thanks a lot @MohawkJohn! This makes the interface better.

@certik
Copy link
Contributor

certik commented Apr 7, 2016

I checked that the first release of Ruby 1.9.3 was at the end of 2011. For example, the first release of Python 2.6 was in 2008, but we are dropping it in SymPy this year. Python 2.7 was first released in 2010, and we definitely still support it --- but Python 2.7 is special in that it is the last version of Python 2.x, so it will be around for a long, long time. @MohawkJohn, what is the situation in Ruby --- what is the earliest version that we should support?

…ultiple symbols simultaneously. Allows Symbol.new to take a Ruby symbol or a string.
@translunar
Copy link
Contributor Author

Oh, bleh. I didn't realize %i was introduced in Ruby 2.0.

http://stackoverflow.com/questions/17355177/what-is-the-origin-of-i-notation

It's probably reasonable to support 1.9.3. We should definitely cut off before 1.9.1. I'd say just require 1.9.3 or higher for now.

I've fixed the commit and tested it with 1.9.3-p551 now.

@certik
Copy link
Contributor

certik commented Apr 7, 2016

Thanks, that sounds reasonable. Let's support 1.9.3 and up. All tests pass, so I am merging this.

@certik certik merged commit 704ed9f into symengine:master Apr 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants