Skip to content

Commit

Permalink
Qualify stdlib imports with std/ meta-package.
Browse files Browse the repository at this point in the history
  • Loading branch information
c-blake committed Sep 23, 2024
1 parent a7663a9 commit 806e21f
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion adix/bist.nim
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ proc quantile*[T](t: Bist[T], q: float): float {.inline.} =
fL * iL.float + (1 - fL) * iH.float

when isMainModule:
import cligen, strutils
import cligen, std/strutils
when not declared(addFloat): import std/formatfloat
type ct = uint16
proc tbist(verb=false, parzen=false, thresh=0.03, num=16, args: seq[int]):int=
Expand Down
2 changes: 1 addition & 1 deletion adix/cpuCT.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## lets us probe a build-time system for all pre-defined C preprocessor macros
## in one execution. We then postprocess these into a set of flags for Nim
## compile-time `when` checks to make "fall back" easy/natural.
from strutils import contains
from std/strutils import contains

const ccDumpMacro {.used.} = " -dM -E -x c - </dev/null"
const ccPreDefs* =
Expand Down
2 changes: 1 addition & 1 deletion adix/cumsum.nim
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ proc cumsum*[T](c: ptr T, n: uint) {.inline.} =
cumsum(cast[ptr UncheckedArray[T]](c), n)

when isMainModule:
import random, times, stats, cligen
import std/[random, times, stats], cligen
when not declared(stderr): import std/[syncio, formatfloat]

proc gen[T](x: var openArray[T]; low, range: int) =
Expand Down
4 changes: 2 additions & 2 deletions adix/lghisto.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
## decaying memory are not possible since FP arithmetic kind of breaks BISTs.

when not declared(addFloat): import std/formatfloat
import adix/bist, math
import adix/bist, std/math
type
LgHisto*[C] = object ## Log-spaced histogram with `Bist[C]` backing
n: int # number of bins
Expand Down Expand Up @@ -152,7 +152,7 @@ when isMainModule:
for q in qs: echo "q",q,": ",lh.quantile(q)
import cligen; dispatch lghist
else:
import random, times; randomize()
import std/[random, times]; randomize()
var data: seq[float32]
var res = newSeqOfCap[float32](9)
const N = 750_000
Expand Down
6 changes: 3 additions & 3 deletions adix/metab.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## This module provides an easy way to do compile-time switched impl swaps for
## various table/set reprs with various compile-time switched defaults. You
## should really just learn how to use `LPTabz[..]` directly, though.
import macros, strformat
import core/macros, std/strformat

when defined(axRehash):
let rDefault = true
Expand Down Expand Up @@ -46,8 +46,8 @@ proc toSet*[K](keys: openArray[K], dups=false): Set[K] =
else:
for k in keys: result.incl k""")

when defined(axStdlib): #NOTE: stdlib version cannot ctrl, e.g. `initialSize`
import tables, sets # when client just declares `var x: Tab`.
when defined(axStdlib): #NOTE: stdlib version cannot ctrl, eg. `initialSize`
import std/[tables, sets] # when client just declares `var x: Tab`.
export tables, sets
type Tab*[K,V] = Table[K,V]
type Set*[K] = HashSet[K]
Expand Down
4 changes: 2 additions & 2 deletions adix/mvstat.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
## I.e., it can perfectly "forget" a large spike when it leaves a window.

when not declared(addFloat): import std/objectdollar
from math import sqrt, sum, `^`
from strutils import formatFloat, ffDefault
from std/math import sqrt, sum, `^`
from std/strutils import formatFloat, ffDefault
when defined(useCligen): from cligen/strUt import fmtUncertainMerged
else:
when not declared(addFloat): import std/formatfloat
Expand Down
2 changes: 1 addition & 1 deletion adix/nsort.nim
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ template nsortBy*(x, field: untyped, b0=0): untyped =
nsortByTag(x, field, b0)

when isMainModule:
import random, times, stats, strutils, cligen
import std/[random, times, stats, strutils], cligen

template timeIt(dtMin, norm: float; body: untyped) =
let t0 = epochTime()
Expand Down
6 changes: 3 additions & 3 deletions adix/tdigest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
## just *intuit* histo(ln(x)), but that is a more subjective critique. }

when not declared(addFloat): import std/formatfloat
import math, algorithm
import std/[math, algorithm]
type
Scale* = enum scLog ## Other scales possible, but unimpl here

Expand Down Expand Up @@ -238,13 +238,13 @@ func cdf*(s: var DigesT, x: float): float =

when isMainModule:
when defined(test):
import os, strutils # Helpful to run against: -12 -8 -4 -1 0 1 4 8 12
import std/[os, strutils] # Helpful to run against: -12 -8 -4 -1 0 1 4 8 12
var s = initDigesT(a=0.125, b=10.0, n=8)
for i in 1 .. paramCount(): s.add parseFloat(paramStr(i))
for q in [0.01, 0.05, 0.25, 0.50, 0.75, 0.95, 0.99]: echo s.quantile(q)
echo "s: ", s
else:
import random, times; randomize()
import std/[random, times]; randomize()
var data: seq[float]
var res = newSeqOfCap[float](9)
const N = 750_000
Expand Down

0 comments on commit 806e21f

Please sign in to comment.