edfcore 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/header/lookup.d.ts +10 -1
- package/dist/header/lookup.d.ts.map +1 -1
- package/dist/header/lookup.js +12 -2
- package/dist/header/lookup.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/header/lookup.ts +12 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@ alone does not tell you whether you were affected.
|
|
|
6
6
|
edfcore is pre-1.0. Patch releases have carried behaviour changes where the old behaviour was a
|
|
7
7
|
defect; those are called out below.
|
|
8
8
|
|
|
9
|
+
## 0.3.1
|
|
10
|
+
|
|
11
|
+
- **Fixed** `declaredDurationSeconds` returning a length up to a whole second short. It computed
|
|
12
|
+
`recordCount * recordDurationSeconds` in float64, and a record duration with no exact binary
|
|
13
|
+
representation makes that product land just under the true value: 100 records of 0.29 s is
|
|
14
|
+
exactly 29 s and multiplies out to 28.999999999999996, which floors to 28. Both inputs are exact
|
|
15
|
+
— an integer count and a tick-valued duration — so the product is now computed in ticks and
|
|
16
|
+
converted once.
|
|
17
|
+
- This is the same defect `formatHeader`'s duration line was fixed for in **0.2.67**, and it was
|
|
18
|
+
found the way this project keeps finding things: two functions disagreeing about one file. The
|
|
19
|
+
header line printed `00:00:29` while `declaredDurationSeconds` returned a number that floors to
|
|
20
|
+
28. The fix there left a comment naming `recordCount * recordDurationSeconds` as the wrong way to
|
|
21
|
+
do it, and the one function still doing it was three modules away.
|
|
22
|
+
|
|
9
23
|
## 0.3.0
|
|
10
24
|
|
|
11
25
|
**One rename. No behaviour change, anywhere.**
|
package/dist/constants.d.ts
CHANGED
|
@@ -109,5 +109,5 @@ export declare const SIGNAL_FIELD_BLOCK_OFFSETS: {
|
|
|
109
109
|
readonly reserved: 224;
|
|
110
110
|
};
|
|
111
111
|
/** Published package version. Kept in sync with package.json by a test. */
|
|
112
|
-
export declare const VERSION = "0.3.
|
|
112
|
+
export declare const VERSION = "0.3.1";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
package/dist/header/lookup.d.ts
CHANGED
|
@@ -62,7 +62,16 @@ export declare function matchSignals(header: EdfHeader, match: RegExp | ((label:
|
|
|
62
62
|
/**
|
|
63
63
|
* The recording's total declared length in seconds.
|
|
64
64
|
*
|
|
65
|
-
*
|
|
65
|
+
* The arithmetic every caller writes by hand — except that the hand-written version is
|
|
66
|
+
* `recordCount * recordDurationSeconds`, and that product is float64. A record duration with no
|
|
67
|
+
* exact binary representation lands just under the true value: 100 records of 0.29 s is exactly
|
|
68
|
+
* 29 s and multiplies out to 28.999999999999996. The count is exact and the duration is exact in
|
|
69
|
+
* ticks, so the product is computed there and converted once.
|
|
70
|
+
*
|
|
71
|
+
* That is the same defect `formatHeader`'s duration line was fixed for in 0.2.67, and until 0.3.1
|
|
72
|
+
* the two disagreed about the same file: the header line said `00:00:29` while this returned a
|
|
73
|
+
* number that floors to 28.
|
|
74
|
+
*
|
|
66
75
|
* Zero for a file whose record duration is zero — legal EDF, and the honest answer, since such a
|
|
67
76
|
* file's records do not advance in time.
|
|
68
77
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/header/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/header/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGxD;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE,CAGlF;AAMD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgCjF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAQpE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,GAC3C,SAAS,SAAS,EAAE,CAKtB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAEjE"}
|
package/dist/header/lookup.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { trimEdfField } from '../bytes/latin1.js';
|
|
14
14
|
import { BDF_ANNOTATIONS_LABEL, EDF_ANNOTATIONS_LABEL } from '../constants.js';
|
|
15
15
|
import { EdfAmbiguousChannelError, EdfChannelNotFoundError } from '../errors.js';
|
|
16
|
+
import { ticksToSeconds } from '../tal/ticks.js';
|
|
16
17
|
/**
|
|
17
18
|
* True for the two reserved annotation labels, matched on the trimmed text and case-sensitively.
|
|
18
19
|
*
|
|
@@ -107,7 +108,16 @@ export function matchSignals(header, match) {
|
|
|
107
108
|
/**
|
|
108
109
|
* The recording's total declared length in seconds.
|
|
109
110
|
*
|
|
110
|
-
*
|
|
111
|
+
* The arithmetic every caller writes by hand — except that the hand-written version is
|
|
112
|
+
* `recordCount * recordDurationSeconds`, and that product is float64. A record duration with no
|
|
113
|
+
* exact binary representation lands just under the true value: 100 records of 0.29 s is exactly
|
|
114
|
+
* 29 s and multiplies out to 28.999999999999996. The count is exact and the duration is exact in
|
|
115
|
+
* ticks, so the product is computed there and converted once.
|
|
116
|
+
*
|
|
117
|
+
* That is the same defect `formatHeader`'s duration line was fixed for in 0.2.67, and until 0.3.1
|
|
118
|
+
* the two disagreed about the same file: the header line said `00:00:29` while this returned a
|
|
119
|
+
* number that floors to 28.
|
|
120
|
+
*
|
|
111
121
|
* Zero for a file whose record duration is zero — legal EDF, and the honest answer, since such a
|
|
112
122
|
* file's records do not advance in time.
|
|
113
123
|
*
|
|
@@ -115,6 +125,6 @@ export function matchSignals(header, match) {
|
|
|
115
125
|
* gaps between records are not covered by any record; `timeline.spanSeconds` is that number.
|
|
116
126
|
*/
|
|
117
127
|
export function declaredDurationSeconds(header) {
|
|
118
|
-
return header.recordCount * header.
|
|
128
|
+
return ticksToSeconds(BigInt(header.recordCount) * header.recordDurationTicks);
|
|
119
129
|
}
|
|
120
130
|
//# sourceMappingURL=lookup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/header/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/header/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD;;;;;;G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QAClE,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAiB,EACjB,KAA4C;IAE5C,MAAM,IAAI,GAAG,KAAK,YAAY,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,OAAO,MAAM,CAAC,MAAM,CAClB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAChF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAiB;IACvD,OAAO,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACjF,CAAC"}
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/header/lookup.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { trimEdfField } from '../bytes/latin1.js';
|
|
15
15
|
import { BDF_ANNOTATIONS_LABEL, EDF_ANNOTATIONS_LABEL } from '../constants.js';
|
|
16
16
|
import { EdfAmbiguousChannelError, EdfChannelNotFoundError } from '../errors.js';
|
|
17
|
+
import { ticksToSeconds } from '../tal/ticks.js';
|
|
17
18
|
import type { EdfHeader, EdfSignal } from '../types.js';
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -130,7 +131,16 @@ export function matchSignals(
|
|
|
130
131
|
/**
|
|
131
132
|
* The recording's total declared length in seconds.
|
|
132
133
|
*
|
|
133
|
-
*
|
|
134
|
+
* The arithmetic every caller writes by hand — except that the hand-written version is
|
|
135
|
+
* `recordCount * recordDurationSeconds`, and that product is float64. A record duration with no
|
|
136
|
+
* exact binary representation lands just under the true value: 100 records of 0.29 s is exactly
|
|
137
|
+
* 29 s and multiplies out to 28.999999999999996. The count is exact and the duration is exact in
|
|
138
|
+
* ticks, so the product is computed there and converted once.
|
|
139
|
+
*
|
|
140
|
+
* That is the same defect `formatHeader`'s duration line was fixed for in 0.2.67, and until 0.3.1
|
|
141
|
+
* the two disagreed about the same file: the header line said `00:00:29` while this returned a
|
|
142
|
+
* number that floors to 28.
|
|
143
|
+
*
|
|
134
144
|
* Zero for a file whose record duration is zero — legal EDF, and the honest answer, since such a
|
|
135
145
|
* file's records do not advance in time.
|
|
136
146
|
*
|
|
@@ -138,5 +148,5 @@ export function matchSignals(
|
|
|
138
148
|
* gaps between records are not covered by any record; `timeline.spanSeconds` is that number.
|
|
139
149
|
*/
|
|
140
150
|
export function declaredDurationSeconds(header: EdfHeader): number {
|
|
141
|
-
return header.recordCount * header.
|
|
151
|
+
return ticksToSeconds(BigInt(header.recordCount) * header.recordDurationTicks);
|
|
142
152
|
}
|