stringcalc 0.1.0.dev13__py3-none-any.whl → 0.1.0.dev15__py3-none-any.whl
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.
- stringcalc/__init__.py +1 -1
- stringcalc/cli.py +79 -8
- stringcalc/data/ghs.csv +22 -22
- stringcalc/frets.py +4 -3
- stringcalc/tension.py +112 -39
- {stringcalc-0.1.0.dev13.dist-info → stringcalc-0.1.0.dev15.dist-info}/METADATA +3 -3
- stringcalc-0.1.0.dev15.dist-info/RECORD +16 -0
- {stringcalc-0.1.0.dev13.dist-info → stringcalc-0.1.0.dev15.dist-info}/WHEEL +1 -1
- stringcalc-0.1.0.dev13.dist-info/RECORD +0 -16
- {stringcalc-0.1.0.dev13.dist-info → stringcalc-0.1.0.dev15.dist-info}/LICENSE +0 -0
- {stringcalc-0.1.0.dev13.dist-info → stringcalc-0.1.0.dev15.dist-info}/entry_points.txt +0 -0
stringcalc/__init__.py
CHANGED
stringcalc/cli.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
2
|
CLI
|
|
3
3
|
"""
|
|
4
|
+
|
|
4
5
|
from __future__ import annotations
|
|
5
6
|
|
|
6
7
|
import functools
|
|
@@ -85,7 +86,7 @@ def _version_callback(show: bool):
|
|
|
85
86
|
|
|
86
87
|
|
|
87
88
|
@app.callback()
|
|
88
|
-
def main(
|
|
89
|
+
def main( # noqa: E704
|
|
89
90
|
version: bool = typer.Option(
|
|
90
91
|
False,
|
|
91
92
|
"--version/",
|
|
@@ -93,8 +94,7 @@ def main(
|
|
|
93
94
|
callback=_version_callback,
|
|
94
95
|
is_eager=True,
|
|
95
96
|
)
|
|
96
|
-
):
|
|
97
|
-
...
|
|
97
|
+
): ...
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
def _with_float_nonext_dtypes(df):
|
|
@@ -287,11 +287,45 @@ def gauge_(
|
|
|
287
287
|
help=("If true, suggest D'Addario gauges. If false, compute exact gauge."),
|
|
288
288
|
),
|
|
289
289
|
types: list[str] = typer.Option(
|
|
290
|
-
None,
|
|
290
|
+
None,
|
|
291
|
+
"--type",
|
|
292
|
+
help=(
|
|
293
|
+
"String type. Can specify multiple times if using --suggest. "
|
|
294
|
+
"For --suggest, defaults to D'Addario phosphor bronze and plain steel ('DA:PB', 'DA:PL'). "
|
|
295
|
+
"If not using --suggest, must specify exactly one type (no default). "
|
|
296
|
+
),
|
|
291
297
|
),
|
|
292
298
|
nsuggest: int = typer.Option(
|
|
293
299
|
3, "-N", "--nsuggest", help="Number of suggestions. Only relevant if using --suggest."
|
|
294
300
|
),
|
|
301
|
+
is_fan: bool = typer.Option(
|
|
302
|
+
None,
|
|
303
|
+
"--fanned",
|
|
304
|
+
help=(
|
|
305
|
+
"Fanned calculations. Must provide two scale lengths. "
|
|
306
|
+
"Assumed if two scale lengths are provided."
|
|
307
|
+
),
|
|
308
|
+
),
|
|
309
|
+
nut_width: float = typer.Option(
|
|
310
|
+
None,
|
|
311
|
+
"-w",
|
|
312
|
+
"--nut-width",
|
|
313
|
+
help=(
|
|
314
|
+
"Neck width at (center of?) nut (for fanned calculations). "
|
|
315
|
+
"Required if using --fanned."
|
|
316
|
+
),
|
|
317
|
+
),
|
|
318
|
+
edge_space: list[float] = typer.Option(
|
|
319
|
+
None,
|
|
320
|
+
"-e",
|
|
321
|
+
"--edge-space",
|
|
322
|
+
help=(
|
|
323
|
+
"Edge space, between the edge of the neck and the center of the first string. "
|
|
324
|
+
"You can specify one (used for both left and right) or two (left, right). "
|
|
325
|
+
'The default is 5/32" on the left and 1/8" on the right. '
|
|
326
|
+
"Only used for fanned calculations."
|
|
327
|
+
),
|
|
328
|
+
),
|
|
295
329
|
float_format: str = typer.Option(
|
|
296
330
|
r"%.3f", help="Format for float-to-string conversion. Only relevant if using --suggest."
|
|
297
331
|
),
|
|
@@ -316,11 +350,45 @@ def gauge_(
|
|
|
316
350
|
types_set: set[str]
|
|
317
351
|
if not types:
|
|
318
352
|
if verbose:
|
|
319
|
-
info("No string types specified, defaulting to PB + PL.")
|
|
320
|
-
types_set = {"PB", "PL"}
|
|
353
|
+
info("No string types specified, defaulting to D'Addario PB + PL.")
|
|
354
|
+
types_set = {"DA:PB", "DA:PL"}
|
|
321
355
|
else:
|
|
322
356
|
types_set = set(types)
|
|
323
357
|
|
|
358
|
+
if is_fan is None:
|
|
359
|
+
is_fan = len(L) == 2
|
|
360
|
+
if is_fan:
|
|
361
|
+
if len(L) != 2:
|
|
362
|
+
error(
|
|
363
|
+
"Must supply two scale lengths (bass and treble sides) for fanned calculation. "
|
|
364
|
+
f"Got {len(L)}.",
|
|
365
|
+
rc=2,
|
|
366
|
+
)
|
|
367
|
+
n_str = max(len(T), len(P))
|
|
368
|
+
if n_str < 2:
|
|
369
|
+
error("Need at least two strings for fanned calculation.", rc=2)
|
|
370
|
+
if not nut_width:
|
|
371
|
+
error("Must supply nut width for fanned calculation.", rc=2)
|
|
372
|
+
if edge_space is None:
|
|
373
|
+
edge_space = [5 / 32, 1 / 8]
|
|
374
|
+
else:
|
|
375
|
+
if len(edge_space) == 1:
|
|
376
|
+
edge_space *= 2
|
|
377
|
+
elif len(edge_space) > 2:
|
|
378
|
+
error(f"Specify one or two edge space values. Got {len(edge_space)}.", rc=2)
|
|
379
|
+
e_b, e_t = edge_space
|
|
380
|
+
L_b, L_t = L
|
|
381
|
+
dLdx = (L_t - L_b) / nut_width
|
|
382
|
+
d = (nut_width - e_b - e_t) / (n_str - 1) # string spacing
|
|
383
|
+
xs = [e_b + i * d for i in range(n_str)]
|
|
384
|
+
L = [round(L_b + dLdx * x, 4) for x in xs]
|
|
385
|
+
if verbose:
|
|
386
|
+
info(f"Nut width: {nut_width}")
|
|
387
|
+
info(f"Left/bass edge space: {e_b}")
|
|
388
|
+
info(f"Right/treble edge space: {e_t}")
|
|
389
|
+
info(f"Computed string spacing: {round(d, 4)}")
|
|
390
|
+
info(f"Computed string nut positions: {[round(x, 4) for x in xs]}")
|
|
391
|
+
|
|
324
392
|
if verbose:
|
|
325
393
|
info(f"Searching string types: {types_set}")
|
|
326
394
|
|
|
@@ -345,7 +413,7 @@ def gauge_(
|
|
|
345
413
|
g_df.attrs["col_desc"]["dT"] += f" ({T_} lbf)"
|
|
346
414
|
table = _rich_table(
|
|
347
415
|
g_df,
|
|
348
|
-
title=f
|
|
416
|
+
title=f'Closest gauges\nfor {L_}" @ {P_}',
|
|
349
417
|
float_format=float_format,
|
|
350
418
|
panel=n_cases > 1,
|
|
351
419
|
column_info=column_info,
|
|
@@ -357,7 +425,10 @@ def gauge_(
|
|
|
357
425
|
|
|
358
426
|
else:
|
|
359
427
|
if not types:
|
|
360
|
-
error(
|
|
428
|
+
error(
|
|
429
|
+
"Must supply type to use exact gauge calculation, e.g. 'plain nylon', 'plain steel'.",
|
|
430
|
+
rc=2,
|
|
431
|
+
)
|
|
361
432
|
|
|
362
433
|
if len(types) > 1:
|
|
363
434
|
error(f"Only specify one type for exact gauge calculation. Got {types}.", rc=2)
|
stringcalc/data/ghs.csv
CHANGED
|
@@ -178,28 +178,28 @@ DY58,0.0006736,0.058,Electric - Boomers,DY
|
|
|
178
178
|
DY60,0.0008791,0.06,Electric - Boomers,DY
|
|
179
179
|
DY70,0.0008867,0.07,Electric - Boomers,DY
|
|
180
180
|
DY80,0.001211,0.08,Electric - Boomers,DY
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
181
|
+
N18,7.424e-05,0.018,Electric - Nickel Rockers,N
|
|
182
|
+
N20,9.326e-05,0.02,Electric - Nickel Rockers,N
|
|
183
|
+
N22,0.0001024,0.022,Electric - Nickel Rockers,N
|
|
184
|
+
N24,0.0001202,0.024,Electric - Nickel Rockers,N
|
|
185
|
+
N26,0.0001528,0.026,Electric - Nickel Rockers,N
|
|
186
|
+
N28,0.0001695,0.028,Electric - Nickel Rockers,N
|
|
187
|
+
N30,0.0001829,0.03,Electric - Nickel Rockers,N
|
|
188
|
+
N32,0.0002186,0.032,Electric - Nickel Rockers,N
|
|
189
|
+
N34,0.0002485,0.034,Electric - Nickel Rockers,N
|
|
190
|
+
N36,0.0002786,0.036,Electric - Nickel Rockers,N
|
|
191
|
+
N38,0.0003128,0.038,Electric - Nickel Rockers,N
|
|
192
|
+
N40,0.0003234,0.04,Electric - Nickel Rockers,N
|
|
193
|
+
N42,0.0003701,0.042,Electric - Nickel Rockers,N
|
|
194
|
+
N44,0.0004174,0.044,Electric - Nickel Rockers,N
|
|
195
|
+
N46,0.0004404,0.046,Electric - Nickel Rockers,N
|
|
196
|
+
N48,0.0004999,0.048,Electric - Nickel Rockers,N
|
|
197
|
+
N50,0.0005332,0.05,Electric - Nickel Rockers,N
|
|
198
|
+
N52,0.000564,0.052,Electric - Nickel Rockers,N
|
|
199
|
+
N54,0.0006025,0.054,Electric - Nickel Rockers,N
|
|
200
|
+
N56,0.0006762,0.056,Electric - Nickel Rockers,N
|
|
201
|
+
N58,0.000759,0.058,Electric - Nickel Rockers,N
|
|
202
|
+
N60,0.0007527,0.06,Electric - Nickel Rockers,N
|
|
203
203
|
ST18,0.0001028,0.018,Electric - Super Steels,ST
|
|
204
204
|
ST20,0.0001081,0.02,Electric - Super Steels,ST
|
|
205
205
|
ST22,0.0001018,0.022,Electric - Super Steels,ST
|
stringcalc/frets.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Fret distances
|
|
3
3
|
"""
|
|
4
|
+
|
|
4
5
|
from __future__ import annotations
|
|
5
6
|
|
|
6
7
|
from typing import Union
|
|
@@ -18,7 +19,7 @@ QLike = Union[Quantity, str]
|
|
|
18
19
|
# Note also `pint._typing.UnitLike`
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
def distance_et(n: int | npt.ArrayLike, *, L: float) -> np.
|
|
22
|
+
def distance_et(n: int | npt.ArrayLike, *, L: float) -> np.float64 | npt.NDArray[np.float64]:
|
|
22
23
|
"""Exact equal-temperament distance from nut for fret(s) `n` for scale length `L`.
|
|
23
24
|
|
|
24
25
|
Using the 12th-root-of-2 method.
|
|
@@ -33,12 +34,12 @@ def distance_et(n: int | npt.ArrayLike, *, L: float) -> np.float_ | npt.NDArray[
|
|
|
33
34
|
s
|
|
34
35
|
Scale length.
|
|
35
36
|
"""
|
|
36
|
-
n = np.floor(n, dtype=
|
|
37
|
+
n = np.floor(n, dtype=np.float64)
|
|
37
38
|
|
|
38
39
|
if not np.all(n > 0):
|
|
39
40
|
raise ValueError("input fret numbers should be positive")
|
|
40
41
|
|
|
41
|
-
return L * (1 - 1 / (2 ** (n / 12)))
|
|
42
|
+
return (L * (1 - 1 / (2 ** (n / 12)))).astype(np.float64)
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
def distances(N: int, *, L: float, method: str = "et") -> pd.DataFrame:
|
stringcalc/tension.py
CHANGED
|
@@ -5,13 +5,14 @@ e.g.
|
|
|
5
5
|
- For specified strings, calculate tensions
|
|
6
6
|
- For specified total or per-string tension, suggest strings
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
from __future__ import annotations
|
|
9
10
|
|
|
10
11
|
import math
|
|
11
12
|
import re
|
|
12
13
|
import warnings
|
|
13
14
|
from functools import lru_cache
|
|
14
|
-
from typing import
|
|
15
|
+
from typing import NamedTuple, Protocol
|
|
15
16
|
|
|
16
17
|
import pandas as pd
|
|
17
18
|
|
|
@@ -31,10 +32,10 @@ DATA = _get_data()
|
|
|
31
32
|
def load_data() -> pd.DataFrame:
|
|
32
33
|
"""Load all string data.
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
Combines results from the individual ``load_*_data`` functions with ``for_combined=True``.
|
|
35
36
|
"""
|
|
36
37
|
df = pd.concat(
|
|
37
|
-
[fn() for fn in _DATA_LOADERS],
|
|
38
|
+
[fn(for_combined=True) for fn in _DATA_LOADERS],
|
|
38
39
|
ignore_index=True,
|
|
39
40
|
)
|
|
40
41
|
|
|
@@ -45,23 +46,42 @@ def load_data() -> pd.DataFrame:
|
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
@lru_cache(2)
|
|
48
|
-
def load_daddario_data(*,
|
|
49
|
-
"""Load the data (currently only D'Addario) needed for the calculations.
|
|
49
|
+
def load_daddario_data(*, for_combined: bool = False) -> pd.DataFrame:
|
|
50
|
+
"""Load the data (currently only D'Addario) needed for the calculations.
|
|
51
|
+
|
|
52
|
+
Parameters
|
|
53
|
+
----------
|
|
54
|
+
for_combined
|
|
55
|
+
Return the frame intended for use in the combined dataset (:func:`load_data`),
|
|
56
|
+
adding appropriate prefixes and dropping extraneous columns.
|
|
57
|
+
"""
|
|
50
58
|
|
|
51
59
|
df = pd.read_csv(DATA.joinpath("daddario-tension.csv"), header=0).convert_dtypes()
|
|
52
60
|
|
|
53
|
-
if
|
|
61
|
+
if for_combined:
|
|
54
62
|
df = df.drop(columns=["notes", "tens"])
|
|
55
63
|
|
|
64
|
+
df["group"] = "D'Addario - " + df["category"] + " - " + df["group"]
|
|
65
|
+
df["group_id"] = "DA:" + df["group_id"]
|
|
66
|
+
df["id"] = "DA:" + df["id"]
|
|
67
|
+
|
|
68
|
+
df = df.drop(columns=["category", "id_pref", "id_suff"])
|
|
69
|
+
|
|
56
70
|
# Set categorical columns
|
|
57
71
|
for name in ["category", "group", "id_pref", "id_suff", "group_id"]:
|
|
58
|
-
|
|
72
|
+
if name in df.columns:
|
|
73
|
+
df[name] = df[name].astype("category")
|
|
59
74
|
|
|
60
75
|
return df
|
|
61
76
|
|
|
62
77
|
|
|
78
|
+
@lru_cache(1)
|
|
79
|
+
def _get_daddario_group_ids() -> set[str]:
|
|
80
|
+
return set(load_daddario_data(for_combined=False).group_id.cat.categories)
|
|
81
|
+
|
|
82
|
+
|
|
63
83
|
@lru_cache
|
|
64
|
-
def load_aquila_data(*, nng_density: float = 1300,
|
|
84
|
+
def load_aquila_data(*, nng_density: float = 1300, for_combined: bool = False) -> pd.DataFrame:
|
|
65
85
|
"""Load Aquila NNG (New Nylgut) data.
|
|
66
86
|
|
|
67
87
|
Parameters
|
|
@@ -71,6 +91,9 @@ def load_aquila_data(*, nng_density: float = 1300, drop_gauge_eqvs: bool = True)
|
|
|
71
91
|
They are supposed to be the same density as gut.
|
|
72
92
|
https://www.cs.helsinki.fi/u/wikla/mus/Calcs/wwwscalc.html says gut is 1276 kg/m3;
|
|
73
93
|
I have seen 1300 elsewhere.
|
|
94
|
+
for_combined
|
|
95
|
+
Return the frame intended for use in the combined dataset (:func:`load_data`),
|
|
96
|
+
adding appropriate prefixes and dropping extraneous columns.
|
|
74
97
|
"""
|
|
75
98
|
import numpy as np
|
|
76
99
|
|
|
@@ -81,84 +104,121 @@ def load_aquila_data(*, nng_density: float = 1300, drop_gauge_eqvs: bool = True)
|
|
|
81
104
|
df["uw"] = nng_density * 2.205 / 1e6 * (2.54**3) * (np.pi * df.gauge**2 / 4)
|
|
82
105
|
|
|
83
106
|
# Set group ID (used to select string type)
|
|
84
|
-
df["group"] = "
|
|
107
|
+
df["group"] = "New Nylgut"
|
|
85
108
|
df["group_id"] = "NNG"
|
|
86
|
-
for name in ["group", "group_id"]:
|
|
87
|
-
df[name] = df[name].astype("category")
|
|
88
109
|
|
|
89
|
-
# Include gauge equivalents?
|
|
90
110
|
gauge_eqv_cols = [col for col in df.columns if col.startswith("gauge_")]
|
|
91
|
-
if
|
|
111
|
+
if for_combined:
|
|
112
|
+
df["group"] = "Aquila " + df["group"]
|
|
113
|
+
df["group_id"] = "A:" + df["group_id"]
|
|
114
|
+
df["id"] = "A:" + df["id"]
|
|
115
|
+
|
|
92
116
|
df = df.drop(columns=gauge_eqv_cols)
|
|
93
117
|
else:
|
|
94
118
|
df = df.rename(columns={col: col.replace("gauge_", "gauge_eqv_") for col in gauge_eqv_cols})
|
|
95
119
|
|
|
120
|
+
for name in ["group", "group_id"]:
|
|
121
|
+
df[name] = df[name].astype("category")
|
|
122
|
+
|
|
96
123
|
return df
|
|
97
124
|
|
|
98
125
|
|
|
99
|
-
@lru_cache(
|
|
100
|
-
def load_worth_data() -> pd.DataFrame:
|
|
101
|
-
"""Load Worth fluorocarbon data.
|
|
126
|
+
@lru_cache(2)
|
|
127
|
+
def load_worth_data(*, for_combined: bool = False) -> pd.DataFrame:
|
|
128
|
+
"""Load Worth fluorocarbon data.
|
|
129
|
+
|
|
130
|
+
Parameters
|
|
131
|
+
----------
|
|
132
|
+
for_combined
|
|
133
|
+
Return the frame intended for use in the combined dataset (:func:`load_data`),
|
|
134
|
+
adding appropriate prefixes and dropping extraneous columns.
|
|
135
|
+
"""
|
|
102
136
|
|
|
103
137
|
df = pd.read_csv(DATA.joinpath("worth.csv"), header=0).convert_dtypes()
|
|
104
138
|
|
|
105
139
|
# Set group ID (used to select string type)
|
|
106
|
-
df["group"] = "
|
|
107
|
-
df["group_id"] = "
|
|
140
|
+
df["group"] = "Fluorocarbon"
|
|
141
|
+
df["group_id"] = "FC"
|
|
142
|
+
|
|
143
|
+
if for_combined:
|
|
144
|
+
df["group"] = "Worth " + df["group"]
|
|
145
|
+
df["group_id"] = "W" + df["group_id"]
|
|
146
|
+
df["id"] = "WFC:" + df["id"]
|
|
147
|
+
|
|
148
|
+
df = df.drop(columns="rho")
|
|
149
|
+
|
|
108
150
|
for name in ["group", "group_id"]:
|
|
109
151
|
df[name] = df[name].astype("category")
|
|
110
152
|
|
|
111
153
|
return df
|
|
112
154
|
|
|
113
155
|
|
|
114
|
-
@lru_cache(
|
|
115
|
-
def load_stringjoy_data() -> pd.DataFrame:
|
|
156
|
+
@lru_cache(2)
|
|
157
|
+
def load_stringjoy_data(*, for_combined: bool = False) -> pd.DataFrame:
|
|
116
158
|
"""Load Stringjoy data.
|
|
117
159
|
|
|
118
160
|
https://tension.stringjoy.com/
|
|
161
|
+
|
|
162
|
+
Parameters
|
|
163
|
+
----------
|
|
164
|
+
for_combined
|
|
165
|
+
Return the frame intended for use in the combined dataset (:func:`load_data`),
|
|
166
|
+
adding appropriate prefixes and dropping extraneous columns.
|
|
119
167
|
"""
|
|
120
168
|
|
|
121
169
|
df = pd.read_csv(DATA.joinpath("stringjoy.csv"), header=0).convert_dtypes()
|
|
122
170
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
171
|
+
if for_combined:
|
|
172
|
+
df["id"] = "SJ:" + df["id"]
|
|
173
|
+
df["group"] = "Stringjoy " + df["group"]
|
|
174
|
+
df["group_id"] = "SJ:" + df["group_id"]
|
|
175
|
+
|
|
127
176
|
for name in ["group", "group_id"]:
|
|
128
177
|
df[name] = df[name].astype("category")
|
|
129
178
|
|
|
130
179
|
return df
|
|
131
180
|
|
|
132
181
|
|
|
133
|
-
@lru_cache(
|
|
134
|
-
def load_ghs_data() -> pd.DataFrame:
|
|
182
|
+
@lru_cache(2)
|
|
183
|
+
def load_ghs_data(*, for_combined: bool = False) -> pd.DataFrame:
|
|
135
184
|
"""Load GHS data.
|
|
136
185
|
|
|
137
186
|
https://www.ghsstrings.com/pages/tension-calc
|
|
187
|
+
|
|
188
|
+
Parameters
|
|
189
|
+
----------
|
|
190
|
+
for_combined
|
|
191
|
+
Return the frame intended for use in the combined dataset (:func:`load_data`),
|
|
192
|
+
adding appropriate prefixes and dropping extraneous columns.
|
|
138
193
|
"""
|
|
139
194
|
|
|
140
195
|
df = pd.read_csv(DATA.joinpath("ghs.csv"), header=0).convert_dtypes()
|
|
141
196
|
|
|
142
197
|
# Drop ID dupes (e.g. PL which is included for both acoustic and electric)
|
|
143
|
-
df = df.drop_duplicates(subset=["id"])
|
|
198
|
+
df = df.drop_duplicates(subset=["id"], keep="first")
|
|
144
199
|
|
|
145
200
|
# Drop where we don't have gauge (bass strings for different scale lengths)
|
|
146
201
|
df = df.dropna(subset=["gauge"])
|
|
147
202
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
203
|
+
if for_combined:
|
|
204
|
+
df["id"] = "GHS:" + df["id"]
|
|
205
|
+
df["group"] = "GHS - " + df["group"]
|
|
206
|
+
df["group_id"] = "GHS:" + df["group_id"]
|
|
207
|
+
|
|
152
208
|
for name in ["group", "group_id"]:
|
|
153
209
|
df[name] = df[name].astype("category")
|
|
154
210
|
|
|
155
211
|
return df.reset_index(drop=True)
|
|
156
212
|
|
|
157
213
|
|
|
158
|
-
|
|
214
|
+
class _DataLoader(Protocol):
|
|
215
|
+
def __call__(self, *, for_combined: bool = False) -> pd.DataFrame: ... # noqa: E704
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
_DATA_LOADERS: list[_DataLoader] = [
|
|
159
219
|
load_daddario_data,
|
|
160
220
|
load_aquila_data,
|
|
161
|
-
|
|
221
|
+
load_worth_data,
|
|
162
222
|
load_stringjoy_data,
|
|
163
223
|
load_ghs_data,
|
|
164
224
|
]
|
|
@@ -258,13 +318,13 @@ def tension(s: String, pitch: str = "A4") -> float:
|
|
|
258
318
|
L = s.L
|
|
259
319
|
|
|
260
320
|
if t in {"PL", "S", "PS"}: # plain steel
|
|
261
|
-
tda = "PL"
|
|
321
|
+
tda = "DA:PL"
|
|
262
322
|
elif t in {"PB"}: # phosphor bronze
|
|
263
|
-
tda = "PB"
|
|
323
|
+
tda = "DA:PB"
|
|
264
324
|
elif t in {"NYL", "N"}: # plain "rectified" nylon
|
|
265
|
-
tda = "NYL"
|
|
325
|
+
tda = "DA:NYL"
|
|
266
326
|
elif t in {"NYLW", "NW"}: # standard silver-wrapped nylon
|
|
267
|
-
tda = "NYLW"
|
|
327
|
+
tda = "DA:NYLW"
|
|
268
328
|
else:
|
|
269
329
|
raise ValueError(f"string type {t!r} invalid or not supported")
|
|
270
330
|
|
|
@@ -362,7 +422,19 @@ def suggest_gauge(
|
|
|
362
422
|
from pyabc2 import Pitch
|
|
363
423
|
|
|
364
424
|
if types is None:
|
|
365
|
-
types = {"PB", "PL"}
|
|
425
|
+
types = {"DA:PB", "DA:PL"}
|
|
426
|
+
|
|
427
|
+
# Assume D'Addario if match to an original D'Addario group ID (with no `DA:` prefix)
|
|
428
|
+
daddario_group_ids = _get_daddario_group_ids()
|
|
429
|
+
types_in = types
|
|
430
|
+
types = {t if t not in daddario_group_ids else f"DA:{t}" for t in types}
|
|
431
|
+
types_changed = types_in - types
|
|
432
|
+
if types_changed:
|
|
433
|
+
warnings.warn(
|
|
434
|
+
f"string type groups {sorted(types_changed)} assumed to be D'Addario. "
|
|
435
|
+
f"Use group ID prefix 'DA:' to be explicit and avoid this warning.",
|
|
436
|
+
stacklevel=2,
|
|
437
|
+
)
|
|
366
438
|
|
|
367
439
|
data_all = load_data()
|
|
368
440
|
data = data_all.query("group_id in @types")
|
|
@@ -388,7 +460,8 @@ def suggest_gauge(
|
|
|
388
460
|
b = 1.7 # TODO: allow to set this?
|
|
389
461
|
if (data_sort["dT"] > b).all() or (data_sort["dT"] < -b).all():
|
|
390
462
|
warnings.warn(
|
|
391
|
-
f"
|
|
463
|
+
f"(T={T}, L={L}, P={pitch}) "
|
|
464
|
+
f"is outside the range of what string type group(s) {types} can provide. "
|
|
392
465
|
"Maybe a different string type can give the tension/pitch/length you desire.",
|
|
393
466
|
stacklevel=2,
|
|
394
467
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: stringcalc
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev15
|
|
4
4
|
Summary: Calculations for instrument strings
|
|
5
5
|
Author-email: zmoon <zmoon92@gmail.com>
|
|
6
6
|
Requires-Python: ~=3.9
|
|
@@ -26,7 +26,7 @@ Provides-Extra: test
|
|
|
26
26
|
|
|
27
27
|
# stringcalc
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
_Calculations for [string instrument](https://en.wikipedia.org/wiki/String_instrument)s' strings_
|
|
30
30
|
|
|
31
31
|
[](https://github.com/zmoon/stringcalc/actions/workflows/ci.yml)
|
|
32
32
|
[](https://pypi.org/project/stringcalc/)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
stringcalc/__init__.py,sha256=gTPuQjuhWOIGeb2ILIx_Lb_cXAR6YOZt5zq8eAk5zi0,73
|
|
2
|
+
stringcalc/cli.py,sha256=Cc-1UuA-bG4LJzpeZG30Njee5eafdRLLlmqCC7XCHws,14483
|
|
3
|
+
stringcalc/frets.py,sha256=p9o7yrp9adCqzVyEp8AzxMecu5XwGM98UOM21yCYyYk,3476
|
|
4
|
+
stringcalc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
stringcalc/tension.py,sha256=3e8oZDJuyJYR-g-bjgTC049d1mE7HBrRgux9yx58nWs,14210
|
|
6
|
+
stringcalc/data/__init__.py,sha256=K9uwWfdSMDlhF15qV84g1ZGpG0784rOsUFuSN_rc4EQ,27
|
|
7
|
+
stringcalc/data/aquila-nng.csv,sha256=nV-kXoRPEXr59NvzMyYob5dg5E3yEw3SW7x1obBeK80,1762
|
|
8
|
+
stringcalc/data/daddario-tension.csv,sha256=gX2waKA9Vt9Bg-jkIC62fugTAZ38EHTegOEhi5fFcsk,124808
|
|
9
|
+
stringcalc/data/ghs.csv,sha256=RQiBahLEkrozCjru1K6T2UKu60LUgJQt3PWKwps4BwA,26173
|
|
10
|
+
stringcalc/data/stringjoy.csv,sha256=qGKvHcLKMpGMo8tN10qkyocbp8OT0WtzTqQNge_RFqU,5004
|
|
11
|
+
stringcalc/data/worth.csv,sha256=S0HVB7sww4gTR4DunkHcqR1YHgVHG8b_u_63B6vkE7s,288
|
|
12
|
+
stringcalc-0.1.0.dev15.dist-info/entry_points.txt,sha256=0DV5ry2A4YzcRzPmWKPXWSFG_dd2rE1Q17UORWHN9vI,49
|
|
13
|
+
stringcalc-0.1.0.dev15.dist-info/LICENSE,sha256=QJZDkt5nq7Pto8WzgmPHKnpeTyEyyqscYUFlKoyXgZg,1090
|
|
14
|
+
stringcalc-0.1.0.dev15.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
|
|
15
|
+
stringcalc-0.1.0.dev15.dist-info/METADATA,sha256=vB6hjihaJuUvGoPelpp9HhPUvIL-i0RFYwKIppIY-BY,1436
|
|
16
|
+
stringcalc-0.1.0.dev15.dist-info/RECORD,,
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
stringcalc/__init__.py,sha256=UaABEKfBcGeEnyIW7BtRozTTeHax24wap89PgiMkspo,73
|
|
2
|
-
stringcalc/cli.py,sha256=TQRTeysBvYJ05okMZKL095xl3XIayvV3Cj6mtD5BB_k,11756
|
|
3
|
-
stringcalc/frets.py,sha256=9cYKDhAVk6Zzf4f1rHCZHkh-CFBph-83gdDy1d8ztXU,3447
|
|
4
|
-
stringcalc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
stringcalc/tension.py,sha256=6fQIrM9N0xJovi1DTu94zpBFzq9_59k1UrMJ76otrwI,11757
|
|
6
|
-
stringcalc/data/__init__.py,sha256=K9uwWfdSMDlhF15qV84g1ZGpG0784rOsUFuSN_rc4EQ,27
|
|
7
|
-
stringcalc/data/aquila-nng.csv,sha256=nV-kXoRPEXr59NvzMyYob5dg5E3yEw3SW7x1obBeK80,1762
|
|
8
|
-
stringcalc/data/daddario-tension.csv,sha256=gX2waKA9Vt9Bg-jkIC62fugTAZ38EHTegOEhi5fFcsk,124808
|
|
9
|
-
stringcalc/data/ghs.csv,sha256=JDS0PmNck01b561tiEqwHS9nMF8-zOXMzAYor5BBu-w,26217
|
|
10
|
-
stringcalc/data/stringjoy.csv,sha256=qGKvHcLKMpGMo8tN10qkyocbp8OT0WtzTqQNge_RFqU,5004
|
|
11
|
-
stringcalc/data/worth.csv,sha256=S0HVB7sww4gTR4DunkHcqR1YHgVHG8b_u_63B6vkE7s,288
|
|
12
|
-
stringcalc-0.1.0.dev13.dist-info/entry_points.txt,sha256=0DV5ry2A4YzcRzPmWKPXWSFG_dd2rE1Q17UORWHN9vI,49
|
|
13
|
-
stringcalc-0.1.0.dev13.dist-info/LICENSE,sha256=QJZDkt5nq7Pto8WzgmPHKnpeTyEyyqscYUFlKoyXgZg,1090
|
|
14
|
-
stringcalc-0.1.0.dev13.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
15
|
-
stringcalc-0.1.0.dev13.dist-info/METADATA,sha256=LMbLPku_xdHbBuTVNHBBaM4ZsTBnE0ytYQMKPkpjjs8,1436
|
|
16
|
-
stringcalc-0.1.0.dev13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|