Skip to content

Commit

Permalink
Release PolyMath v1.0.2 (#165)
Browse files Browse the repository at this point in the history
* [skip CI]

* [skip CI]

* [skip CI] typos

* [skip CI]

* Update SMark to 1.0.3

* Update README.md

* [Issue 152] Remove Magic From 'initialize' Methods (#153)

* [issue-152] Improved code formatting.

* [issue-152] Removed some reflection magic so that the code is easier to understand.

* [issue-152] Improved code formatting.

* Cleanup to load in PharoGs (#150)

* Do not use an inst variable name as an argument

* Don't use 'p' and 'q' as method temps

They are defined as instance variables in the class. If they are not supposed to modify the instance variable, then they should have different names.

* Don't begin a block with a dot

GemStone isn't happy with empty statements.

* Cleanup of Array constructors

While legal syntax, GemStone has trouble parsing these.

* Don't use instance var name as method argument

* Add spacing to clarify when number ends

GemStone doesn't like '11do:' as a number since 'd' is a legal exponent.

* Spacing to clarify separation of statements

* Fix typo with extra space.

* [issue-154] Corrected the behaviour of findKey to return 'AllTheRest' when selector has no corresponding initialize message. (#155)

* [issue-154] Corrected the behaviour of findKey, making it more testable in the subclass to mitigate risk.

* [issue-154] Promoted the local variables in the test to state variable to remove duplication.

* [issue-154] Extracted duplicate code to a custom assertion.

* [skip CI]

* [skip CI]

* Create FUNDING.yml

* Update FUNDING.yml

* Remove curly braces, replaced with Arrays in most cases, should close #159 (#162)

* Update dependencies to load from github, should close #160 (#161)

* [Issue 154] Refactor PMAccuracy testDataTree method (#163)

* [issue-154] Moved the test method to its own test case class so that we can break up the long test method and understand the message better.

* [issue-154] Moved some test code to an intention-revealing test method & identified a possible smell.

* [issue-154] Moved a block of code to its own intention-revealing test method.

* [issue-154] Moved some test code to its own intention-revealing method.

* [issue-154] Added a smell comment to help the next developer.

* [issue-154] Added more smells to the smell comment.

* [issue-154] Moved the test code to an intention-revealing test method, extracted the expected result to a role-revealing local variable.

* [issue-154] Extracted test code to its own intention-revealing test method, with a comment identifying a coincidence between expected outcome and a default I discovered in the initialize method.

* [issue-154] Added calls to the super class methods as required.

* [issue-154] Put the call to the super class method in the right place.

* [issue-154] Improved the name of the local variable. We still don't know the role it plays in the test yet so gave it a structural name.

* [issue-154] Improved the name of a local variable.

* [issue-154] Moved the test code to its own better named test method.

* Update .travis.yml

* Update appveyor.yml

* Fix some of the red tests for Pharo 8 (#164)

* Update appveyor.yml

* Move from Pharo 7.0 to Pharo 8.0

* Update README.md

Co-authored-by: Hemal Varambhia <hemal.varambhia@simplybusiness.co.uk>
Co-authored-by: James Foster <github@jgfoster.net>
Co-authored-by: Julian Maestri <serpi90@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 25, 2020
1 parent 8bcf998 commit 95aebd1
Show file tree
Hide file tree
Showing 51 changed files with 495 additions and 510 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ os:
- osx

smalltalk:
- Pharo-6.1
- Pharo32-7.0
- Pharo64-7.0
- Pharo32-8.0
- Pharo64-8.0

matrix:
fast_finish: true
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
This file is currently not complete but will be improve step by step.

# Contributing code
Use last version of Pharo 7.0 in order to use Iceberg.
Use last version of Pharo 8.0 in order to use Iceberg.
## Fork the Pharo repository

All changes you'll do will be versionned in your own fork of the [PolyMath repository](https://github.com/PolyMathOrg/PolyMath). Then, from your fork you'll be able to issue pull requests to PolyMath, where they will be reviewed, and luckily, integrated.

Go to PolyMath github's repository and click on the fork button on the top right. Yes, this means that you'll need a github account to contribute to PolyMath, yes.

## Load last dev version of PolyMath
In a fresh Pharo 7.0 image, load last development version of Polymath :
In a fresh Pharo 8.0 image, load last development version of Polymath :

```Smalltalk
Metacello new
Expand Down
1 change: 1 addition & 0 deletions FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: SergeStinckwich
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<p align="center">
Scientific Computing with Pharo
<br>
<a href="docs/"><strong>Explore the docs »</strong></a>
<a href="https://github.com/PolyMathOrg/PolyMath/wiki"><strong>Explore the docs »</strong></a>
<br>
<br>
<a href="https://github.com/PolyMathOrg/PolyMath/issues/new?labels=Type%3A+Defect">Report a defect</a>
Expand All @@ -19,11 +19,12 @@

<img width="1675" alt="Screenshot 2019-04-24 at 11 12 57" src="https://user-images.githubusercontent.com/327334/56652094-66eb7780-6682-11e9-9753-101be18df67c.png">

You can load PolyMath 1.0 into a fresh Pharo 7.0 image with:

You can load PolyMath 1.0.1 into a fresh Pharo 7.0 image with:

```Smalltalk
Metacello new
repository: 'github://PolyMathOrg/PolyMath:v1.0/src';
repository: 'github://PolyMathOrg/PolyMath:v1.0.1/src';
baseline: 'PolyMath';
load
```
Expand All @@ -37,7 +38,8 @@ Metacello new
load
```

We have **806** green tests ! At the moment, all the development happens in the master branch (we are using trunk-based development).

We have **815** green tests ! At the moment, all the development happens in the master branch (we are using trunk-based development).

PolyMath is a Pharo project, similar to existing scientific libraries like NumPy, SciPy for Python or SciRuby for Ruby. PolyMath already provides the following basic functionalities:
- complex and quaternions extensions,
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ environment:
CYG_MIRROR: http://cygwin.mirror.constant.com
SCI_RUN: /cygdrive/c/smalltalkCI-master/run.sh
matrix:
- SMALLTALK: Pharo-7.0
- SMALLTALK: Pharo-8.0

platform:
- x86
Expand Down
14 changes: 4 additions & 10 deletions src/BaselineOfPolyMath/BaselineOfPolyMath.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,13 @@ BaselineOfPolyMath >> projectClass [
{ #category : #dependencies }
BaselineOfPolyMath >> sMark: spec [
spec
project: 'SMark'
with: [ spec
className: #ConfigurationOfSMark;
versionString: '1.0.3';
repository: 'http://smalltalkhub.com/mc/StefanMarr/SMark/main' ]
baseline: 'SMark'
with: [ spec repository: 'github://smarr/SMark:v1.0.4/repository' ]
]

{ #category : #dependencies }
BaselineOfPolyMath >> xmlWriter: spec [
spec
project: 'XMLWriter'
with: [ spec
className: #ConfigurationOfXMLWriter;
versionString: '2.3.10';
repository: 'http://smalltalkhub.com/mc/PharoExtras/XMLWriter/main' ]
baseline: 'XMLWriter'
with: [ spec repository: 'github://pharo-contributions/XML-XMLWriter:2.9.0/src' ]
]
2 changes: 1 addition & 1 deletion src/ExtendedNumberParser/ExtendedNumberParser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ ExtendedNumberParser >> readNumberWithFractionPartNumberOfTrailingZeroInIntegerP
fractionPart := 0.
numberOfNonZeroFractionDigits := 0.
numberOfTrailingZeroInFractionPart := 0]
ifNotNil: [.
ifNotNil: [
numberOfNonZeroFractionDigits := lastNonZero.
numberOfTrailingZeroInFractionPart := nDigits - lastNonZero].
self readExponent
Expand Down
8 changes: 4 additions & 4 deletions src/Math-Accuracy-Core/PMAccuracy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Class {
#classVars : [
'DecimalPlaces'
],
#category : 'Math-Accuracy-Core'
#category : #'Math-Accuracy-Core'
}

{ #category : #accessing }
Expand Down Expand Up @@ -134,7 +134,7 @@ PMAccuracy >> argumentAt: aName [
PMAccuracy >> asArray: aCol [
^(aCol isCollection and: [ aCol isSequenceable and: [aCol isString not] ])
ifTrue: [ aCol asArray ]
ifFalse: [ {aCol} ]
ifFalse: [ Array with: aCol ]
]

{ #category : #private }
Expand Down Expand Up @@ -302,7 +302,7 @@ no isCollection ifFalse: [^1].
PMAccuracy >> numberOfDifferentResultsAt: aname [
|no|
no := self resultsAt: aname.
no isCollection ifFalse:[no:={no}].
no isCollection ifFalse:[no:= Array with: no].
^ no first isCollection ifTrue: [ no size ] ifFalse: [ 1 ]
]

Expand Down Expand Up @@ -426,7 +426,7 @@ PMAccuracy >> run: anArrayOfNames [
<< 'Report for: ';
<< self class name;
cr.
self ifSeveralterations: [ aStream << 'iterations: ' << iterations; cr ].
self ifSeveralterations: [ aStream << 'iterations: ' << iterations asString; cr ].
(self tree: dataTree removeAll type: self class name data: 'names')
at: 'iterations' put: iterations;
at: 'names' put: (self tree: KeyedTree new type: 'names' data: a).
Expand Down
2 changes: 1 addition & 1 deletion src/Math-Benchmarks-ODE/PMODEBenchmark.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PMODEBenchmark class >> runAllToXML: numOfIterations [
xml.
writer tag: 'smark' with: [
(self runAll: numOfIterations) do: [ :runner |
writer tag: 'suite' attributes: { #name -> runner suite class name asString } asDictionary with: [
writer tag: 'suite' attributes: (Dictionary with: #name -> runner suite class name asString) with: [
runner results keysAndValuesDo: [ :key :value |
writer tag: key with: ((value inject: 0 into: [ :subTotal :result |
subTotal + result total ]) / value size) asFloat asString] ] ] ].
Expand Down
6 changes: 3 additions & 3 deletions src/Math-Core-Process/PMFixpoint.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ verbose ifFalse: [ ^self ].
GrowlMorph
openWithLabel: 'Info'
contents: ('{1} iterations used.
warning: {2}-cycle detected' format: {iterations. cycleLength})
warning: {2}-cycle detected' format: (Array with: iterations with: cycleLength))
color: Color gray muchDarker
]

Expand Down Expand Up @@ -151,7 +151,7 @@ PMFixpoint >> simpleInfo [
verbose ifFalse: [ ^self ].
GrowlMorph
openWithLabel: 'Info'
contents: ('{1} iterations needed.' format: {iterations})
contents: ('{1} iterations needed.' format: (Array with: iterations))
color: Color green muchDarker
]

Expand All @@ -161,7 +161,7 @@ verbose ifFalse: [ ^self ].
GrowlMorph
openWithLabel: 'Warning'
contents: ('maximumIterations ({1}) reached.
you can run evaluate a second time' format: {maximumIterations})
you can run evaluate a second time' format: (Array with: maximumIterations))
color: Color orange darker
]

Expand Down
2 changes: 1 addition & 1 deletion src/Math-Core/PMVector.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ PMVector >> householder [
put: ((x <=0) ifTrue: [x -u] ifFalse: [0 - s / (x + u)]).
b :=(v at: 1) squared * 2 / (s + (v at: 1) squared).
v := v / (v at: 1) ].
^{b. v}
^Array with: b with: v
]

{ #category : #operation }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ PMFastFourierTransform >> initPermTable [
r := (i - 1 bitReverse: nu) + 1.
r > i
ifTrue: [ permTable
add:
{i.
r} ] ]
add: (Array with: i with: r) ] ]
]

{ #category : #initializing }
Expand Down
10 changes: 5 additions & 5 deletions src/Math-FunctionFit/PMAnotherGeneticOptimizer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ PMAnotherGeneticOptimizer >> printOn: aStream [
{ #category : #operation }
PMAnotherGeneticOptimizer >> processRandomParents: aNumberArray [
"puts the better chromosome at the first place (is eg necessary for lineCrossOver:and:)"
|pos1 pos2 c|
pos1:=self randomIndex: aNumberArray.
pos2:=self randomIndex: aNumberArray.
pos1>pos2 ifTrue:[c:=pos1.pos1:=pos2. pos2:=c].
| pos1 pos2 c |
pos1 := self randomIndex: aNumberArray.
pos2 := self randomIndex: aNumberArray.
pos1 > pos2 ifTrue: [c := pos1. pos1 := pos2. pos2 := c].
chromosomeManager process: ( bestPoints at: pos1) position
and: ( bestPoints at: pos2) position.
]
Expand All @@ -219,7 +219,7 @@ PMAnotherGeneticOptimizer >> rangeScale [
| size best|
size:=bestPoints size -1.
best := 0.0 .
^(size to:1 by:( -1))collect: [:i|best:=2*i/(size*(size+1))+best].
^(size to: 1 by: (-1)) collect: [:i | best := 2 * i / (size * (size + 1)) + best].

]

Expand Down
8 changes: 5 additions & 3 deletions src/Math-FunctionFit/PMGeneralFunctionFit.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ n:=0.
[ self quartile: max.
self evaluate.
errorCol:= self errorCollection sort.
d2:=(errorFunction parameterSize to: (errorCol size -4) ) collect: [:i| {i+2.
(2*(errorCol at: i)) - (errorCol at: i+1) - (2*(errorCol at: i+2))- (errorCol at: i+3)+(2*(errorCol at: i+4))} ].
d2:=(errorFunction parameterSize to: (errorCol size -4) ) collect: [:i|
Array
with: (i+2)
with: ((2*(errorCol at: i)) - (errorCol at: i+1) - (2*(errorCol at: i+2))- (errorCol at: i+3)+(2*(errorCol at: i+4))) ].
[max :=#(5 0).
d2 do: [:d|((d at: 2) >= (max at:2)) ifTrue: [max :=d]].
(max first = (d2 last first))ifTrue: [
Expand Down Expand Up @@ -296,7 +298,7 @@ PMGeneralFunctionFit >> truncateData [
|ec ei |
dataTruncated ifTrue: [^Error signal:'data is already truncated'].
ec:=self errorCollection .
ei:=(ec withIndexCollect: [:e :i|{e.i}]).
ei:=(ec withIndexCollect: [:e :i| Array with: e with: i]).
ei:=(ei sort:[:a :b|a first<b first]) collect: [:e|e second ].
ei :=ei copyFrom: 1 to: (self quartile * ec size) truncated.
self resetResult.
Expand Down
8 changes: 3 additions & 5 deletions src/Math-KDTree/PMIndexedKDTree.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ Class {
{ #category : #'instance creation' }
PMIndexedKDTree class >> withAll: aCollectionOfCollections [
"make a KDTree from a SequenceableCollection of SequenceableCollections ,which is an ordered Collection of points in a n-dimensional space. the nearest neighbour search then returns the indices of the neighbours"
|c|
c :=aCollectionOfCollections withIndexCollect: [:v :i| {i.v.}] .
^super withAll: c.
^super withAll: (aCollectionOfCollections withIndexCollect: [:v :i| Array with: i with: v ]).
]

{ #category : #private }
PMIndexedKDTree >> add: aDistance to: aNNStore [
aNNStore add: {aDistance . {index . value}} .
aNNStore add: (Array with: aDistance with: (Array with: index with: value)) .
]

{ #category : #private }
Expand All @@ -36,7 +34,7 @@ PMIndexedKDTree >> nnSearch: aSequenceableCollection i: anInt [
|n|
n :=PMNNStore new: anInt .
self nnSearch: aSequenceableCollection asFloatArray near: n .
^anInt =1 ifTrue: [n data first first ] ifFalse: [n completeData collect: [:i | {(i at:2)first . i first}] ]
^anInt =1 ifTrue: [n data first first ] ifFalse: [n completeData collect: [:i | Array with: (i at:2) first with: i first] ]
]

{ #category : #private }
Expand Down
2 changes: 1 addition & 1 deletion src/Math-KDTree/PMKDTree.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ aCollectionOfCollections first ifEmpty: [self error: 'KDTree withAll: error' ].

{ #category : #private }
PMKDTree >> add: aDistance to: aNNStore [
aNNStore add: {aDistance . value} .
aNNStore add: (Array with: aDistance with: value) .
]

{ #category : #initialize }
Expand Down
4 changes: 2 additions & 2 deletions src/Math-KDTree/PMNNStore.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Class {

{ #category : #'instance creation' }
PMNNStore class >> new: anInt [
^((super new: anInt) atAllPut: {Float infinity. nil} )initialize
^((super new: anInt) atAllPut: (Array with: Float infinity with: nil))initialize
]

{ #category : #'instance creation' }
Expand All @@ -30,7 +30,7 @@ PMNNStore class >> newFrom: aCollectionWithSortingIndex [
PMNNStore class >> withAll: aCollection [
"this is the peferable form of instance creation for subclasses since freeIndex is correctly initialized this way. then 'sortFor:' must be overwritten and called at least once (!); an example is StupidNN. the other possibility is to use 'new:' and to fill NNStore subclass with 'add:' . the advantage is, that NNStore has not to be filled completely this way and the sorting logic can be applied outside of the subclass without sortFor: (see also comment on add:).
you cant enter the sorting index with the method withAll: . if you want to do that, use 'newFrom:' instead"
^(super withAll: (aCollection collect: [:coll| {nil. coll}]))lastUsedIndex: aCollection size
^(super withAll: (aCollection collect: [:coll| Array with: nil with: coll]))lastUsedIndex: aCollection size
]

{ #category : #comparing }
Expand Down
29 changes: 9 additions & 20 deletions src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov2Sample.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,11 @@ PMKolmogorovSmirnov2Sample >> initCachedUCalculation [
cij := self cFrom: i and: j.
i * j = 0
ifTrue: [ cij ]
ifFalse: [ cij
*
((uCalcBlock
value:
{i.
(j - 1)})
+
(uCalcBlock
value:
{(i - 1).
j})) ] ] memoized
ifFalse: [ cij * (
(uCalcBlock value: (Array with: i with: j - 1))
+
(uCalcBlock value: (Array with: i - 1 with: j))
) ] ] memoized
]

{ #category : #initialization }
Expand Down Expand Up @@ -123,18 +117,15 @@ PMKolmogorovSmirnov2Sample >> ksStatistic [
{ #category : #private }
PMKolmogorovSmirnov2Sample >> makeCDFOf: aCollection intoFirst: aBoolean [
"if aCollection consists of numbers,
it returns a sorted array of (number->{cdf.aBoolean})"
it returns a sorted array of (number-> (Array with: cdf with: aBoolean))"

| cd s result |
cd := 0.
s := aCollection size.
result := aCollection asBag sortedElements
do: [ :a |
cd := a value / s + cd.
a
value:
{cd.
aBoolean} ].
a value: (Array with: cd with: aBoolean) ].
^ aBoolean
ifTrue: [ data := result ]
ifFalse: [ compareWith := result ]
Expand All @@ -154,10 +145,8 @@ Kim, P. J. & Jennrich, R. I.
in 'Selected Tables in Mathematical Statistics Volume I' (1973)."

ksStatistic ifNil: [ self ksStatistic ].
^ (uCalcBlock
value:
{smallSize.
bigSize}) / (smallSize + bigSize take: smallSize)
^ (uCalcBlock value: (Array with: smallSize with: bigSize))
/ (smallSize + bigSize take: smallSize)
]

{ #category : #printing }
Expand Down
6 changes: 2 additions & 4 deletions src/Math-Matrix/PMMatrix.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ PMMatrix >> qrFactorization [
i>0 ifTrue: [ r :=PMMatrix rows: (r rows copyFrom: 1 to: colSize).
i := q numberOfColumns - i.
q := PMMatrix rows: ( q rows collect: [:row| row copyFrom: 1 to: i]) ].
^{q. r}
^Array with: q with: r
]

{ #category : #'as yet unclassified' }
Expand Down Expand Up @@ -729,9 +729,7 @@ PMMatrix >> qrFactorizationWithPivoting [
i := q numberOfColumns - i.
pivot := pivot copyFrom: 1 to: i.
q := PMMatrix rows: (q rows collect: [ :row | row copyFrom: 1 to: i ]) ].
^ {q.
r.
pivot}
^ Array with: q with: r with: pivot
]

{ #category : #'as yet unclassified' }
Expand Down
2 changes: 1 addition & 1 deletion src/Math-ODE/PMAB2Solver.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ PMAB2Solver >> mainStepsPrevState: prevState startTime: initialTime endTime: end
self announceState: state time: time + self dt.
lastTime := time + self dt].

^ {previousState . state}
^ Array with: previousState with: state
]

{ #category : #'as yet unclassified' }
Expand Down
2 changes: 1 addition & 1 deletion src/Math-ODE/PMAB3Solver.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ PMAB3Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState startT
self announceState: state time: time + self dt.
lastTime := time + (3*self dt)].

^ { previousPrevState. previousState}
^ Array with: previousPrevState with: previousState

]

Expand Down
Loading

0 comments on commit 95aebd1

Please sign in to comment.