Skip to content

Commit 3499a15

Browse files
committed
adapt to latest changes in Cuis
1 parent 56ce9d3 commit 3499a15

File tree

2 files changed

+118
-118
lines changed

2 files changed

+118
-118
lines changed

LinearAlgebra.pck.st

+48-48
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
'From Cuis 6.0 [latest update: #5202] on 26 May 2022 at 12:46:22 pm'!
1+
'From Cuis 6.0 [latest update: #5791] on 7 May 2023 at 6:18:48 pm'!
22
'Description '!
3-
!provides: 'LinearAlgebra' 1 59!
3+
!provides: 'LinearAlgebra' 1 60!
44
SystemOrganization addCategory: 'LinearAlgebra'!
55

66

@@ -2149,15 +2149,15 @@ rowsCloserToZero: count
21492149
asSortedCollection: [ :a :b | a y < b y ])
21502150
copyFrom: 1 to: count) collect: [ :each | each x ] ) asSortedCollection! !
21512151

2152-
!FloatMatrix methodsFor: 'files' stamp: 'jmv 12/4/2017 14:59:32'!
2152+
!FloatMatrix methodsFor: 'files' stamp: 'jmv 5/7/2023 11:00:59'!
21532153
readFromNpyStream: byteStream bigEndian: isByteStreamBigEndian
21542154
| bytesPerElement rowBytes |
2155-
bytesPerElement _ 4.
2156-
rowBytes _ ByteArray new: width*bytesPerElement.
2155+
bytesPerElement := 4.
2156+
rowBytes := ByteArray new: width*bytesPerElement.
21572157
1 to: height do: [ :i |
21582158
byteStream nextInto: rowBytes.
21592159
1 to: width do: [ :j |
2160-
self i: i j: j put: (rowBytes floatAt: j-1*bytesPerElement+1 bigEndian: isByteStreamBigEndian) ]].! !
2160+
self i: i j: j put: (rowBytes float32At: j-1*bytesPerElement+1 bigEndian: isByteStreamBigEndian) ]].! !
21612161

21622162
!FloatMatrix methodsFor: 'operations' stamp: 'jmv 9/2/2014 11:28'!
21632163
round
@@ -2219,7 +2219,7 @@ fromNpyFile: aFileEntry
22192219
stream binary.
22202220
self fromNpyStream: stream ]! !
22212221

2222-
!FloatMatrix class methodsFor: 'files' stamp: 'jmv 5/26/2022 12:18:26'!
2222+
!FloatMatrix class methodsFor: 'files' stamp: 'jmv 5/7/2023 11:07:25'!
22232223
fromNpyStream: byteStream
22242224
"
22252225
FloatMatrix fromNpyFile: 'vigneteo' asDirectoryEntry // 'vign_x.npy'
@@ -2228,15 +2228,15 @@ self asForm writeJPEGfileNamed: 'tt.jpg'.
22282228
(self asFormMin: 0.0 max: 1.0) writeJPEGfileNamed: 'ttt.jpg'.
22292229
"
22302230
| magic hLength versionMajor versionMinor headerData i1 i2 key descrString fortranOrderString columnsString rowsString answer height instanceClass isBigEndian width bytesPerElement |
2231-
magic _ byteStream next: 6.
2231+
magic := byteStream next: 6.
22322232
self assert: magic = (#[16r93], 'NUMPY' asByteArray).
2233-
versionMajor _ byteStream next.
2234-
versionMinor _ byteStream next.
2233+
versionMajor := byteStream next.
2234+
versionMinor := byteStream next.
22352235
versionMajor caseOf: {
2236-
[1] -> [hLength _ (byteStream next: 2) unsignedShortAt: 1 bigEndian: false].
2237-
[2] -> [hLength _ (byteStream next: 4) unsignedShortAt: 1 bigEndian: false].
2236+
[1] -> [hLength := (byteStream next: 2) uint16At: 1 bigEndian: false].
2237+
[2] -> [hLength := (byteStream next: 4) uint16At: 1 bigEndian: false].
22382238
} otherwise: [ self error: 'Unsupported format' ].
2239-
headerData _ String fromUtf8Bytes: (byteStream next: hLength). "It is ASCII. utf-8 will do."
2239+
headerData := String fromUtf8Bytes: (byteStream next: hLength). "It is ASCII. utf-8 will do."
22402240

22412241
" Read 'an ASCII string which contains a Python literal expression of a dictionary'
22422242
https://docs.scipy.org/doc/numpy-dev/neps/npy-format.html
@@ -2247,41 +2247,41 @@ self asForm writeJPEGfileNamed: 'tt.jpg'.
22472247
'no fortran order, i.e. row-major, i.e. row after row'
22482248
'major size (i.e. rows)= 5120. minor size (i.e. columns) = 5120
22492249
"
2250-
i1 _ 1.
2251-
key _ '''descr'''.
2252-
i1 _ (headerData findString: key startingAt: i1) + key size.
2253-
i1 _ headerData findString: $' asString startingAt: i1.
2254-
i1 _ i1 + 1.
2255-
i2 _ headerData findString: $' asString startingAt: i1.
2256-
descrString _ headerData copyFrom: i1 to: i2-1.
2257-
2258-
key _ '''fortran_order'''.
2259-
i1 _ (headerData findString: key startingAt: i1) + key size.
2260-
i1 _ headerData findString: $: asString startingAt: i1.
2261-
i1 _ i1 + 1.
2262-
i2 _ headerData findString: $, asString startingAt: i1.
2263-
fortranOrderString _ (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2264-
2265-
key _ '''shape'''.
2266-
i1 _ (headerData findString: key startingAt: i1) + key size.
2267-
i1 _ headerData findString: $( asString startingAt: i1.
2268-
i1 _ i1 + 1.
2269-
i2 _ headerData findString: $, asString startingAt: i1.
2270-
rowsString _ (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2271-
i1 _ i2 + 1.
2272-
i2 _ headerData findString: $) asString startingAt: i1.
2273-
columnsString _ (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2274-
2275-
isBigEndian _ descrString first = $>.
2250+
i1 := 1.
2251+
key := '''descr'''.
2252+
i1 := (headerData findString: key startingAt: i1) + key size.
2253+
i1 := headerData findString: $' asString startingAt: i1.
2254+
i1 := i1 + 1.
2255+
i2 := headerData findString: $' asString startingAt: i1.
2256+
descrString := headerData copyFrom: i1 to: i2-1.
2257+
2258+
key := '''fortran_order'''.
2259+
i1 := (headerData findString: key startingAt: i1) + key size.
2260+
i1 := headerData findString: $: asString startingAt: i1.
2261+
i1 := i1 + 1.
2262+
i2 := headerData findString: $, asString startingAt: i1.
2263+
fortranOrderString := (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2264+
2265+
key := '''shape'''.
2266+
i1 := (headerData findString: key startingAt: i1) + key size.
2267+
i1 := headerData findString: $( asString startingAt: i1.
2268+
i1 := i1 + 1.
2269+
i2 := headerData findString: $, asString startingAt: i1.
2270+
rowsString := (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2271+
i1 := i2 + 1.
2272+
i2 := headerData findString: $) asString startingAt: i1.
2273+
columnsString := (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2274+
2275+
isBigEndian := descrString first = $>.
22762276
self assert: descrString second = $f.
2277-
bytesPerElement _ descrString third digitValue.
2278-
instanceClass _ bytesPerElement caseOf: { [4] -> [FloatMatrix]. [8] -> [Float64Matrix]} otherwise: [self assert: false ].
2277+
bytesPerElement := descrString third digitValue.
2278+
instanceClass := bytesPerElement caseOf: { [4] -> [FloatMatrix]. [8] -> [Float64Matrix]} otherwise: [self assert: false ].
22792279

22802280
self assert: fortranOrderString = 'False'.
2281-
height _ rowsString asInteger.
2282-
width _ columnsString asInteger.
2281+
height := rowsString asInteger.
2282+
width := columnsString asInteger.
22832283

2284-
answer _ instanceClass height: height width: width.
2284+
answer := instanceClass height: height width: width.
22852285
answer readFromNpyStream: byteStream bigEndian: isBigEndian.
22862286

22872287
^ answer! !
@@ -2354,7 +2354,7 @@ true ifTrue: [ ^ super j: j put: column ].
23542354
1 to: height do: [ :i |
23552355
self i: i j: j put: (column at: i) ]! !
23562356

2357-
!Float64Matrix methodsFor: 'files' stamp: 'jmv 12/4/2017 15:09:52'!
2357+
!Float64Matrix methodsFor: 'files' stamp: 'jmv 5/7/2023 10:54:09'!
23582358
readFromNpyStream: byteStream bigEndian: isByteStreamBigEndian
23592359
"
23602360
FloatMatrix fromNpyFile: 'vigneteo' asDirectoryEntry // 'vign_x.npy'
@@ -2366,12 +2366,12 @@ readFromNpyStream: byteStream bigEndian: isByteStreamBigEndian
23662366
isByteStreamBigEndian | Smalltalk isBigEndian ifFalse: [
23672367
^ self readFromNpyStreamFastHack: byteStream ].
23682368

2369-
bytesPerElement _ 8.
2370-
rowBytes _ ByteArray new: width*bytesPerElement.
2369+
bytesPerElement := 8.
2370+
rowBytes := ByteArray new: width*bytesPerElement.
23712371
1 to: height do: [ :i |
23722372
byteStream nextInto: rowBytes.
23732373
1 to: width do: [ :j |
2374-
self i: i j: j put: (rowBytes doubleAt: j-1*bytesPerElement+1 bigEndian: isByteStreamBigEndian) ]]! !
2374+
self i: i j: j put: (rowBytes float64At: j-1*bytesPerElement+1 bigEndian: isByteStreamBigEndian) ]]! !
23752375

23762376
!Float64Matrix methodsFor: 'files' stamp: 'jmv 12/4/2017 15:07:09'!
23772377
readFromNpyStreamFastHack: byteStream

0 commit comments

Comments
 (0)