Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit ec3bffc

Browse files
Implement asarray for NumPy compatibilities. (#18)
* Updated .travis.yml * Updated .travis.yml with new OS configuration * Reduced test sizes for travis memory limits. * Removed clover coverage from testing. * Removed coveralls. Removed PHP 7.1 support after too many zend_heap problems. * Allow failures for PHP 7.0 and PHP 7.1 for future investigation. * Testing new travis.yml build * Testing old configuration with .travis * Updated Transformable operations and CArray to new C implementation. * Updated travis-ci * Test Travis * Added logo to README.MD * High quality README.MD logo * Logo image reduction on README.MD * 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. * Implemented recently logspace CArray initializer. * Don't use ZEND_ALLOCATION during travis build for test purposes. * Removed CCACHE from travis file. * Added PHP 7.2.3 to travis file. * Implemented `asarray` for NumPy compatibilities (alias of toArray). Added asarray test to ArrayConvertTest. MemoryPointer input stdClass to CArray.
1 parent de46d58 commit ec3bffc

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

.travis.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ dist: trusty
99
php:
1010
- 7.1
1111
- 7.2
12+
- 7.2.3
1213

1314
matrix:
1415
fast_finish: true
1516
allow_failures:
1617
- php: 7.1
18+
- php: 7.2.3
1719

1820

1921
cache:
2022
apt: true
21-
ccache: true
2223

2324
install:
2425
- curl -s http://getcomposer.org/installer | php
@@ -27,7 +28,6 @@ install:
2728
before_script:
2829
- ccache --version
2930
- ccache --zero-stats
30-
- export USE_CCACHE=1
3131
- git clone https://github.com/phpsci/phpsci-ext.git
3232
- cd phpsci-ext
3333
- ./travis/compile.sh
@@ -36,7 +36,5 @@ before_script:
3636

3737
script:
3838
- cd $TRAVIS_BUILD_DIR
39+
- export USE_ZEND_ALLOC=0
3940
- vendor/bin/phpunit
40-
41-
after_success:
42-
- ccache --show-stats

src/PHPSci/Kernel/Orchestrator/MemoryPointer.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ class MemoryPointer
2323
* MemoryPointer constructor.
2424
*
2525
* @author Henrique Borba <[email protected]>
26-
* @param \stdClass $ptr
26+
* @param \CArray $ptr
27+
* @param int $rows
28+
* @param int $cols
2729
*/
28-
public function __construct(\stdClass $ptr, int $rows, int $cols)
30+
public function __construct(\CArray $ptr, int $rows, int $cols)
2931
{
3032
$this->uuid = $ptr->uuid;
3133
$this->rows = $rows;

src/PHPSci/Kernel/Transform/Transformable.php

+12
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,16 @@ public function toDouble() {
4040
return \CArray::toDouble($this->ptr()->getPointer());
4141
}
4242

43+
/**
44+
* Convert the input CArray to an array.
45+
*
46+
* Created for NumPy compatibility.
47+
*
48+
* @author Henrique Borba <[email protected]>
49+
* @param PHPSci $obj
50+
* @return array
51+
*/
52+
public static function asarray(PHPSci $obj) : array {
53+
return $obj->toArray();
54+
}
4355
}

tests/Initializers/ArrayConvertTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testFromArray1D() {
4747
public function testToArray1D() {
4848
$parr = [1,0,1,0,0,1,0,1];
4949
$a = ps::fromArray($parr);
50-
$b = $a->toArray();
50+
$b = ps::asarray($a);
5151
$this->assertObjectNotHasAttribute('uuid', $a);
5252
$this->assertEquals($parr, $b);
5353
}

0 commit comments

Comments
 (0)