From 88cbbe60097f653ee39e7d527fbb25300da00138 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Mon, 26 Mar 2018 18:05:52 -0300 Subject: [PATCH 01/20] Updated .travis.yml --- .travis.yml | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 832bba8..cd2c997 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,16 +11,29 @@ php: - nightly cache: - apt: true - ccache: true + directories: + - $HOME/.composer/cache + +matrix: + fast_finish: true + + include: + - os: linux + php: '7.2' + env: PHPUNIT_FLAGS="--coverage-clover build/logs/clover.xml" + + - os: osx + osx_image: xcode7.3 + language: generic + env: + - _OSX=10.11 + - _PHP: php71 install: - curl -s http://getcomposer.org/installer | php - php composer.phar install --no-interaction --ignore-platform-reqs before_script: - - ccache --version - - ccache --zero-stats - export USE_CCACHE=1 - git clone https://github.com/phpsci/phpsci-ext.git - cd phpsci-ext @@ -32,5 +45,10 @@ script: - cd $TRAVIS_BUILD_DIR - vendor/bin/phpunit $PHPUNIT_FLAGS + after_success: - - ccache --show-stats \ No newline at end of file + - | + if [[ $PHPUNIT_FLAGS != "" ]]; then + wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.0.0/php-coveralls.phar + php php-coveralls.phar --verbose; + fi From dfac4cc37c6e90bb4c9879cbf9a66a3010b25e9d Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Mon, 26 Mar 2018 18:08:30 -0300 Subject: [PATCH 02/20] Updated .travis.yml with new OS configuration --- .travis.yml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd2c997..b9e7cc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,20 +14,6 @@ cache: directories: - $HOME/.composer/cache -matrix: - fast_finish: true - - include: - - os: linux - php: '7.2' - env: PHPUNIT_FLAGS="--coverage-clover build/logs/clover.xml" - - - os: osx - osx_image: xcode7.3 - language: generic - env: - - _OSX=10.11 - - _PHP: php71 install: - curl -s http://getcomposer.org/installer | php @@ -43,7 +29,7 @@ before_script: script: - cd $TRAVIS_BUILD_DIR - - vendor/bin/phpunit $PHPUNIT_FLAGS + - vendor/bin/phpunit --coverage-clover build/logs/clover.xml after_success: From 77588ea8390b8d75543ada3b96ec26203b26501d Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Mon, 26 Mar 2018 18:41:36 -0300 Subject: [PATCH 03/20] Reduced test sizes for travis memory limits. --- .travis.yml | 1 + tests/LinearAlgebra/MatmulTest.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b9e7cc4..e26bcf6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ addons: - libopenblas-base dist: trusty php: + - 7.1 - 7.2 - nightly diff --git a/tests/LinearAlgebra/MatmulTest.php b/tests/LinearAlgebra/MatmulTest.php index ec2e732..2a3a491 100644 --- a/tests/LinearAlgebra/MatmulTest.php +++ b/tests/LinearAlgebra/MatmulTest.php @@ -50,7 +50,7 @@ public function testMatmulSmallIdentity() { * @author Henrique Borba */ public function testMatmulBigIdentity() { - $a = ps::identity(1000); + $a = ps::identity(100); $expected = $a->toArray(); $result = ps::matmul($a, $a)->toArray(); $this->assertEquals($expected, $result); From b623a98516bd59b5bc5964649122fdf06b3bd060 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Mon, 26 Mar 2018 18:43:50 -0300 Subject: [PATCH 04/20] Removed clover coverage from testing. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e26bcf6..dba4041 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ before_script: script: - cd $TRAVIS_BUILD_DIR - - vendor/bin/phpunit --coverage-clover build/logs/clover.xml + - vendor/bin/phpunit after_success: From 6e4e8b8ca90ba9d609a992873e9f9d75dbab193b Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Mon, 26 Mar 2018 18:47:01 -0300 Subject: [PATCH 05/20] Removed coveralls. Removed PHP 7.1 support after too many zend_heap problems. --- .coveralls.yml | 1 - .travis.yml | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) delete mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 4ead616..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1 +0,0 @@ -repo_token: Ik9zvyyMlcEvYEIHY2fVgu6vf7wCRbock \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index dba4041..2587e34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,15 @@ addons: - libopenblas-base dist: trusty php: - - 7.1 - 7.2 - nightly +matrix: + fast_finish: true + allow_failures: + - php: nightly + + cache: directories: - $HOME/.composer/cache From 1d5e403a2e4776848c9d365487e53c3b3ea1d1f6 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Mon, 26 Mar 2018 18:49:36 -0300 Subject: [PATCH 06/20] Allow failures for PHP 7.0 and PHP 7.1 for future investigation. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2587e34..bcf7918 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ addons: - libopenblas-base dist: trusty php: + - 7.0 + - 7.1 - 7.2 - nightly @@ -14,6 +16,8 @@ matrix: fast_finish: true allow_failures: - php: nightly + - php: 7.1 + - php: 7.0 cache: From 165a122417afa4f7db72d7af7c5484ba480e4060 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Mon, 26 Mar 2018 18:56:25 -0300 Subject: [PATCH 07/20] Testing new travis.yml build --- .travis.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index bcf7918..31f30c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,8 @@ addons: dist: trusty php: - 7.0 - - 7.1 - - 7.2 + - 7.1.9 + - 7.2.4 - nightly matrix: @@ -40,11 +40,3 @@ before_script: script: - cd $TRAVIS_BUILD_DIR - vendor/bin/phpunit - - -after_success: - - | - if [[ $PHPUNIT_FLAGS != "" ]]; then - wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.0.0/php-coveralls.phar - php php-coveralls.phar --verbose; - fi From d3993e92705ac2a48014758d979d31dca8fc87ef Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Mon, 26 Mar 2018 18:57:47 -0300 Subject: [PATCH 08/20] Testing old configuration with .travis --- .travis.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 31f30c6..f148548 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,8 @@ addons: dist: trusty php: - 7.0 - - 7.1.9 - - 7.2.4 + - 7.1 + - 7.2 - nightly matrix: @@ -21,15 +21,16 @@ matrix: cache: - directories: - - $HOME/.composer/cache - + apt: true + ccache: true install: - curl -s http://getcomposer.org/installer | php - php composer.phar install --no-interaction --ignore-platform-reqs before_script: + - ccache --version + - ccache --zero-stats - export USE_CCACHE=1 - git clone https://github.com/phpsci/phpsci-ext.git - cd phpsci-ext @@ -39,4 +40,7 @@ before_script: script: - cd $TRAVIS_BUILD_DIR - - vendor/bin/phpunit + - vendor/bin/phpunit $PHPUNIT_FLAGS + +after_success: + - ccache --show-stats \ No newline at end of file From 912de43b98e5fda9db6baacc377d654541696338 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Mon, 26 Mar 2018 19:01:07 -0300 Subject: [PATCH 09/20] Updated Transformable operations and CArray to new C implementation. --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f148548..7a9067f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,17 +7,14 @@ addons: - libopenblas-base dist: trusty php: - - 7.0 - 7.1 - 7.2 - - nightly matrix: fast_finish: true allow_failures: - - php: nightly - php: 7.1 - - php: 7.0 + - php: 7.2 cache: From 6adf37b57b015c9f63f28e199a4a98293f525110 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Mon, 26 Mar 2018 19:01:55 -0300 Subject: [PATCH 10/20] Updated travis-ci --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7a9067f..fa15aec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,6 @@ matrix: fast_finish: true allow_failures: - php: 7.1 - - php: 7.2 cache: From f3125dda15988ea107224f4b31b019ee9aaa71d0 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Mon, 26 Mar 2018 19:04:53 -0300 Subject: [PATCH 11/20] Test Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fa15aec..5d65be0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ before_script: script: - cd $TRAVIS_BUILD_DIR - - vendor/bin/phpunit $PHPUNIT_FLAGS + - vendor/bin/phpunit after_success: - ccache --show-stats \ No newline at end of file From 5bd107fcb5fdcc3363cfb0a251e088e06b937ab4 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Tue, 27 Mar 2018 00:17:22 -0300 Subject: [PATCH 12/20] Added logo to README.MD --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 5c296e1..e4153bd 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/phpsci/phpsci/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/phpsci/phpsci/?branch=master) [![Coverage Status](https://coveralls.io/repos/github/phpsci/phpsci/badge.svg?branch=master)](https://coveralls.io/github/phpsci/phpsci?branch=master) +

+ +

PHPSci is a PHP Library for scientific computing powered by C. You **must** compile and install From a933749fe9ce850875c0375db9a129cb3d92d16d Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Tue, 27 Mar 2018 00:21:24 -0300 Subject: [PATCH 13/20] High quality README.MD logo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e4153bd..11d054c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![Coverage Status](https://coveralls.io/repos/github/phpsci/phpsci/badge.svg?branch=master)](https://coveralls.io/github/phpsci/phpsci?branch=master)

- +

From e94256ee075ff24ec00ffad4a752c2037215c815 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Tue, 27 Mar 2018 00:23:42 -0300 Subject: [PATCH 14/20] Logo image reduction on README.MD --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 11d054c..34ad015 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![Coverage Status](https://coveralls.io/repos/github/phpsci/phpsci/badge.svg?branch=master)](https://coveralls.io/github/phpsci/phpsci?branch=master)

- +

From c368ba660c3df849adbee1ba2d81ff16235b7570 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Tue, 27 Mar 2018 03:01:54 -0300 Subject: [PATCH 15/20] Implemented __toString for handle CArray print_r static method. Implemented Inflatable trait to handle dynamic properties. Fixed compatibility of rows and cols dynamic properties of CArrayWrapper object. --- src/PHPSci/Kernel/CArray/CArrayWrapper.php | 12 +++------ src/PHPSci/Kernel/CArray/Printable.php | 23 ++++++++++++++++ .../Kernel/Orchestrator/MemoryPointer.php | 4 +-- .../Kernel/PropertiesProcessor/Inflatable.php | 27 +++++++++++++++++++ .../PropertiesProcessor.php | 2 +- .../PropertiesProcessor/Property.php | 2 +- .../{ => Kernel}/PropertiesProcessor/cols.php | 5 ++-- .../{ => Kernel}/PropertiesProcessor/rows.php | 4 +-- .../PropertiesProcessor/sizeOf.php | 5 ++-- .../Kernel/PropertiesProcessor/took.php | 24 +++++++++++++++++ src/PHPSci/PropertiesProcessor/took.php | 14 ---------- 11 files changed, 88 insertions(+), 34 deletions(-) create mode 100644 src/PHPSci/Kernel/CArray/Printable.php create mode 100644 src/PHPSci/Kernel/PropertiesProcessor/Inflatable.php rename src/PHPSci/{ => Kernel}/PropertiesProcessor/PropertiesProcessor.php (76%) rename src/PHPSci/{ => Kernel}/PropertiesProcessor/Property.php (79%) rename src/PHPSci/{ => Kernel}/PropertiesProcessor/cols.php (68%) rename src/PHPSci/{ => Kernel}/PropertiesProcessor/rows.php (80%) rename src/PHPSci/{ => Kernel}/PropertiesProcessor/sizeOf.php (64%) create mode 100644 src/PHPSci/Kernel/PropertiesProcessor/took.php delete mode 100644 src/PHPSci/PropertiesProcessor/took.php diff --git a/src/PHPSci/Kernel/CArray/CArrayWrapper.php b/src/PHPSci/Kernel/CArray/CArrayWrapper.php index 86c1447..934c792 100644 --- a/src/PHPSci/Kernel/CArray/CArrayWrapper.php +++ b/src/PHPSci/Kernel/CArray/CArrayWrapper.php @@ -4,6 +4,7 @@ use PHPSci\Kernel\Initializers\Creatable; use PHPSci\Kernel\LinearAlgebra\Operatable; use PHPSci\Kernel\Orchestrator\MemoryPointer; +use PHPSci\Kernel\PropertiesProcessor\Inflatable; use PHPSci\Kernel\Ranges\Rangeable; use PHPSci\Kernel\Transform\Transformable; use PHPSci\PHPSci; @@ -16,8 +17,7 @@ */ abstract class CArrayWrapper implements Stackable, \ArrayAccess, \Countable { - - use Transformable, Creatable, Operatable, Rangeable; + use Transformable, Creatable, Operatable, Rangeable, Printable, Inflatable; /** * @var @@ -126,13 +126,7 @@ public function __invoke() // TODO: Implement __invoke() method. } - /** - * - */ - public function __toString() - { - // TODO: Implement __toString() method. - } + /** * Get current Pointer Object diff --git a/src/PHPSci/Kernel/CArray/Printable.php b/src/PHPSci/Kernel/CArray/Printable.php new file mode 100644 index 0000000..6a0fbce --- /dev/null +++ b/src/PHPSci/Kernel/CArray/Printable.php @@ -0,0 +1,23 @@ + + * @package PHPSci\Kernel\CArray + */ +trait Printable +{ + /** + * Print current CArray + * + * @author Henrique Borba + */ + public function __toString() + { + echo \CArray::print_r($this->ptr()->getPointer(), $this->rows, $this->cols); + return ''; + } +} \ No newline at end of file diff --git a/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php b/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php index ddd6f8d..7b8da17 100644 --- a/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php +++ b/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php @@ -42,12 +42,12 @@ public function getPointer() { } /** - * Get current UUID + * Get current UUID (alias of getPointer) * * @author Henrique Borba */ public function getUUID() { - return $this->uuid; + return $this->getPointer(); } /** diff --git a/src/PHPSci/Kernel/PropertiesProcessor/Inflatable.php b/src/PHPSci/Kernel/PropertiesProcessor/Inflatable.php new file mode 100644 index 0000000..e275a2f --- /dev/null +++ b/src/PHPSci/Kernel/PropertiesProcessor/Inflatable.php @@ -0,0 +1,27 @@ + + * @package PHPSci\Kernel\PropertiesProcessor + */ +trait Inflatable +{ + + /** + * Emulates properties based on available classes. + * + * @author Henrique Borba + * @param $name + * @return + */ + public function __get($name) + { + return call_user_func('PHPSci\\Kernel\\PropertiesProcessor\\'.$name.'::run', $this); + } + +} \ No newline at end of file diff --git a/src/PHPSci/PropertiesProcessor/PropertiesProcessor.php b/src/PHPSci/Kernel/PropertiesProcessor/PropertiesProcessor.php similarity index 76% rename from src/PHPSci/PropertiesProcessor/PropertiesProcessor.php rename to src/PHPSci/Kernel/PropertiesProcessor/PropertiesProcessor.php index 801d4fa..216c553 100644 --- a/src/PHPSci/PropertiesProcessor/PropertiesProcessor.php +++ b/src/PHPSci/Kernel/PropertiesProcessor/PropertiesProcessor.php @@ -1,5 +1,5 @@ * @param PHPSci $obj * @return int */ public static function run(PHPSci $obj) { - return $obj->getCols(); + return $obj->ptr()->getCols(); } } \ No newline at end of file diff --git a/src/PHPSci/PropertiesProcessor/rows.php b/src/PHPSci/Kernel/PropertiesProcessor/rows.php similarity index 80% rename from src/PHPSci/PropertiesProcessor/rows.php rename to src/PHPSci/Kernel/PropertiesProcessor/rows.php index 6eceaaa..705b784 100644 --- a/src/PHPSci/PropertiesProcessor/rows.php +++ b/src/PHPSci/Kernel/PropertiesProcessor/rows.php @@ -1,5 +1,5 @@ getRows(); + return $obj->ptr()->getRows(); } } \ No newline at end of file diff --git a/src/PHPSci/PropertiesProcessor/sizeOf.php b/src/PHPSci/Kernel/PropertiesProcessor/sizeOf.php similarity index 64% rename from src/PHPSci/PropertiesProcessor/sizeOf.php rename to src/PHPSci/Kernel/PropertiesProcessor/sizeOf.php index c9398f9..4e78ac1 100644 --- a/src/PHPSci/PropertiesProcessor/sizeOf.php +++ b/src/PHPSci/Kernel/PropertiesProcessor/sizeOf.php @@ -1,5 +1,5 @@ sizeOf(); + return $obj->ptr()->sizeOf(); } } \ No newline at end of file diff --git a/src/PHPSci/Kernel/PropertiesProcessor/took.php b/src/PHPSci/Kernel/PropertiesProcessor/took.php new file mode 100644 index 0000000..1102779 --- /dev/null +++ b/src/PHPSci/Kernel/PropertiesProcessor/took.php @@ -0,0 +1,24 @@ +getTook(); + } +} \ No newline at end of file diff --git a/src/PHPSci/PropertiesProcessor/took.php b/src/PHPSci/PropertiesProcessor/took.php deleted file mode 100644 index daf3368..0000000 --- a/src/PHPSci/PropertiesProcessor/took.php +++ /dev/null @@ -1,14 +0,0 @@ -getTook(); - } -} \ No newline at end of file From 0c7cb36c84915f1ebef4e303379010955f1442fa Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Tue, 27 Mar 2018 03:34:04 -0300 Subject: [PATCH 16/20] Implemented recently logspace CArray initializer. --- src/PHPSci/Kernel/CArray/CArrayWrapper.php | 1 - src/PHPSci/Kernel/Ranges/Rangeable.php | 21 +++++++++++++++ tests/Ranges/LogspaceTest.php | 31 ++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/Ranges/LogspaceTest.php diff --git a/src/PHPSci/Kernel/CArray/CArrayWrapper.php b/src/PHPSci/Kernel/CArray/CArrayWrapper.php index 934c792..e7517aa 100644 --- a/src/PHPSci/Kernel/CArray/CArrayWrapper.php +++ b/src/PHPSci/Kernel/CArray/CArrayWrapper.php @@ -26,7 +26,6 @@ abstract class CArrayWrapper implements Stackable, \ArrayAccess, \Countable /** - * * @return int|void */ public function count() diff --git a/src/PHPSci/Kernel/Ranges/Rangeable.php b/src/PHPSci/Kernel/Ranges/Rangeable.php index 51a69cd..e4f72f0 100644 --- a/src/PHPSci/Kernel/Ranges/Rangeable.php +++ b/src/PHPSci/Kernel/Ranges/Rangeable.php @@ -60,4 +60,25 @@ public static function linspace(float $stop, float $start = 0., float $num = 50) ); } + /** + * Return numbers spaced evenly on a log scale. + * + * @author Henrique Borba + * @param float $start base ** start is the starting value of the sequence. + * @param float $stop base ** stop is the final value of the sequence + * @param int $num Number of samples to generate. Default is 50. + * @param float $base The base of the log space. + * @return CArrayWrapper + */ + public static function logspace(float $start, float $stop, int $num = 50, float $base = 10) : CArrayWrapper { + $new_ptr = \CArray::logspace($start, $stop, $num, $base); + return new PHPSci( + new MemoryPointer( + $new_ptr, + $new_ptr->x, + $new_ptr->y + ) + ); + } + } \ No newline at end of file diff --git a/tests/Ranges/LogspaceTest.php b/tests/Ranges/LogspaceTest.php new file mode 100644 index 0000000..69b2b8f --- /dev/null +++ b/tests/Ranges/LogspaceTest.php @@ -0,0 +1,31 @@ + + * @package PHPSci\Tests\Ranges + */ +class LogspaceTest extends TestCase +{ + + /** + * Test logspace static range initializer + * + * @author Henrique Borba + */ + public function testLogspaceRangeInitializer() { + $expected = [100, 215.4434356689453, 464.1589660644531, 1000]; + $returned = PHPSci::logspace(2,3, 4)->toArray(); + $this->assertEquals($expected, $returned); + + $expected = [4, 5.039683818817139, 6.349604606628418, 8]; + $returned = PHPSci::logspace(2,3, 4, 2)->toArray(); + $this->assertEquals($expected, $returned); + } + +} \ No newline at end of file From 1cf3cce1fbc809dd3bad9c407f27077e2fdfc3f1 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Tue, 27 Mar 2018 04:29:55 -0300 Subject: [PATCH 17/20] Don't use ZEND_ALLOCATION during travis build for test purposes. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5d65be0..2aa63e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,7 @@ before_script: script: - cd $TRAVIS_BUILD_DIR + - export USE_ZEND_ALLOC=0 - vendor/bin/phpunit after_success: From 6b7749ecdd3e4ddf6ae95a5d8b24df80a0224908 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Tue, 27 Mar 2018 04:32:13 -0300 Subject: [PATCH 18/20] Removed CCACHE from travis file. --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2aa63e1..d4f4634 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ matrix: cache: apt: true - ccache: true install: - curl -s http://getcomposer.org/installer | php @@ -27,7 +26,6 @@ install: before_script: - ccache --version - ccache --zero-stats - - export USE_CCACHE=1 - git clone https://github.com/phpsci/phpsci-ext.git - cd phpsci-ext - ./travis/compile.sh @@ -38,6 +36,3 @@ script: - cd $TRAVIS_BUILD_DIR - export USE_ZEND_ALLOC=0 - vendor/bin/phpunit - -after_success: - - ccache --show-stats \ No newline at end of file From 88c844164ca07b4b66083bab65a4c012d7bed0a0 Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Tue, 27 Mar 2018 04:33:16 -0300 Subject: [PATCH 19/20] Added PHP 7.2.3 to travis file. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index d4f4634..c2cbacf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,11 +9,13 @@ dist: trusty php: - 7.1 - 7.2 + - 7.2.3 matrix: fast_finish: true allow_failures: - php: 7.1 + - php: 7.2.3 cache: From ad3b481830a8a6d03ebda7cfc59fa5f7928fa86a Mon Sep 17 00:00:00 2001 From: Henrique Borba Date: Tue, 27 Mar 2018 05:32:19 -0300 Subject: [PATCH 20/20] Implemented `asarray` for NumPy compatibilities (alias of toArray). Added asarray test to ArrayConvertTest. MemoryPointer input stdClass to CArray. --- src/PHPSci/Kernel/Orchestrator/MemoryPointer.php | 6 ++++-- src/PHPSci/Kernel/Transform/Transformable.php | 12 ++++++++++++ tests/Initializers/ArrayConvertTest.php | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php b/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php index 7b8da17..82cad0b 100644 --- a/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php +++ b/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php @@ -23,9 +23,11 @@ class MemoryPointer * MemoryPointer constructor. * * @author Henrique Borba - * @param \stdClass $ptr + * @param \CArray $ptr + * @param int $rows + * @param int $cols */ - public function __construct(\stdClass $ptr, int $rows, int $cols) + public function __construct(\CArray $ptr, int $rows, int $cols) { $this->uuid = $ptr->uuid; $this->rows = $rows; diff --git a/src/PHPSci/Kernel/Transform/Transformable.php b/src/PHPSci/Kernel/Transform/Transformable.php index cee0284..6fe2a27 100644 --- a/src/PHPSci/Kernel/Transform/Transformable.php +++ b/src/PHPSci/Kernel/Transform/Transformable.php @@ -40,4 +40,16 @@ public function toDouble() { return \CArray::toDouble($this->ptr()->getPointer()); } + /** + * Convert the input CArray to an array. + * + * Created for NumPy compatibility. + * + * @author Henrique Borba + * @param PHPSci $obj + * @return array + */ + public static function asarray(PHPSci $obj) : array { + return $obj->toArray(); + } } \ No newline at end of file diff --git a/tests/Initializers/ArrayConvertTest.php b/tests/Initializers/ArrayConvertTest.php index c60189d..13eca18 100644 --- a/tests/Initializers/ArrayConvertTest.php +++ b/tests/Initializers/ArrayConvertTest.php @@ -47,7 +47,7 @@ public function testFromArray1D() { public function testToArray1D() { $parr = [1,0,1,0,0,1,0,1]; $a = ps::fromArray($parr); - $b = $a->toArray(); + $b = ps::asarray($a); $this->assertObjectNotHasAttribute('uuid', $a); $this->assertEquals($parr, $b); }