Skip to content

Commit 9ad019e

Browse files
committed
Rename interval & builtIn eval imports
1 parent 6310edd commit 9ad019e

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/external.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ declare module 'interval-arithmetic-eval' {
77
export class Interval {
88
lo: number
99
hi: number
10-
10+
constructor(lo: number | Interval, hi?: number)
1111
static isEmpty(n: Interval | number): boolean
1212
static isWhole(n: Interval | number): boolean
1313
static intervalsOverlap(n: Interval, r: Interval): boolean

src/samplers/builtIn.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { linspace, sgn, infinity, clamp, space, isValidNumber } from '../utils.mjs'
2-
import { builtIn as evaluate } from './eval.mjs'
2+
import { builtIn as builtInEvaluate } from './eval.mjs'
33

44
import type { FunctionPlotDatum, FunctionPlotScale, PointFunction, VectorFunction } from '../types.js'
55
import type { SamplerParams, SamplerFn, BuiltInSamplerResult, BuiltInSamplerResultGroup } from './types.js'
@@ -27,7 +27,7 @@ function checkAsymptote(
2727
let oldY: number, oldX: number
2828
for (let i = 0; i < n; i += 1) {
2929
const x = samples[i]
30-
const y = evaluate(d, 'fn', { x })
30+
const y = builtInEvaluate(d, 'fn', { x })
3131

3232
if (oldY) {
3333
const deltaY = y - oldY
@@ -122,7 +122,7 @@ function linear(samplerParams: SamplerParams): BuiltInSamplerResult {
122122
const data: Array<[number, number]> = []
123123
for (let i = 0; i < allX.length; i += 1) {
124124
const x = allX[i]
125-
let y = evaluate(samplerParams.d, 'fn', { x })
125+
let y = builtInEvaluate(samplerParams.d, 'fn', { x })
126126
if (isValidNumber(x) && isValidNumber(y)) {
127127
y = clamp(y, yMin, yMax)
128128
data.push([x, y])
@@ -140,8 +140,8 @@ function parametric(samplerParams: SamplerParams): BuiltInSamplerResult {
140140
const samples: BuiltInSamplerResultGroup = []
141141
for (let i = 0; i < tCoords.length; i += 1) {
142142
const t = tCoords[i]
143-
const x = evaluate(samplerParams.d, 'x', { t })
144-
const y = evaluate(samplerParams.d, 'y', { t })
143+
const x = builtInEvaluate(samplerParams.d, 'x', { t })
144+
const y = builtInEvaluate(samplerParams.d, 'y', { t })
145145
samples.push([x, y])
146146
}
147147
return [samples]
@@ -155,7 +155,7 @@ function polar(samplerParams: SamplerParams): BuiltInSamplerResult {
155155
const samples: BuiltInSamplerResultGroup = []
156156
for (let i = 0; i < thetaSamples.length; i += 1) {
157157
const theta = thetaSamples[i]
158-
const r = evaluate(samplerParams.d, 'r', { theta })
158+
const r = builtInEvaluate(samplerParams.d, 'r', { theta })
159159
const x = r * Math.cos(theta)
160160
const y = r * Math.sin(theta)
161161
samples.push([x, y])

src/samplers/interval.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import intervalArithmeticEval, { Interval } from 'interval-arithmetic-eval'
22

3-
import { interval as evaluate } from './eval.mjs'
3+
import { interval as intervalEvaluate, builtIn as builtInEvaluate } from './eval.mjs'
44
import { infinity, space, interval2dTypedArray } from '../utils.mjs'
55
import globals from '../globals.mjs'
66

@@ -125,7 +125,7 @@ function interval1d({ d, xAxis, range, nSamples, xScale, yScale }: SamplerParams
125125
const samples: IntervalSamplerResultGroup = []
126126
for (let i = 0; i < xCoords.length - 1; i += 1) {
127127
const x = { lo: xCoords[i], hi: xCoords[i + 1] }
128-
const y = evaluate(d, 'fn', { x })
128+
const y = intervalEvaluate(d, 'fn', { x })
129129
if (!Interval.isEmpty(y) && !Interval.isWhole(y)) {
130130
samples.push([x, y])
131131
}
@@ -179,7 +179,7 @@ function smallRect(x: Interval, _: Interval) {
179179
}
180180

181181
function quadTree(x: Interval, y: Interval, d: FunctionPlotDatum) {
182-
const sample = evaluate(d, 'fn', { x, y })
182+
const sample = intervalEvaluate(d, 'fn', { x, y })
183183
const fulfills = Interval.zeroIn(sample)
184184
if (!fulfills) {
185185
return this

0 commit comments

Comments
 (0)