Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More test coverage #437

Merged
merged 11 commits into from
Feb 25, 2025
6 changes: 1 addition & 5 deletions supriya/contexts/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Callable,
Dict,
List,
Literal,
Optional,
Sequence,
SupportsFloat,
Expand All @@ -26,11 +27,6 @@
cast,
)

try:
from typing import Literal
except ImportError:
from typing_extensions import Literal # type: ignore

from uqbar.objects import new

from ..enums import AddAction, BootStatus, CalculationRate, ParameterRate
Expand Down
6 changes: 1 addition & 5 deletions supriya/contexts/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Container,
Dict,
List,
Literal,
Optional,
Sequence,
SupportsFloat,
Expand All @@ -17,11 +18,6 @@
cast,
)

try:
from typing import Literal
except ImportError:
from typing_extensions import Literal # type: ignore

from ..assets.synthdefs.default import default
from ..enums import AddAction, CalculationRate
from ..io import PlayMemo
Expand Down
6 changes: 1 addition & 5 deletions supriya/contexts/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@
TYPE_CHECKING,
Dict,
List,
Literal,
Optional,
Sequence,
SupportsInt,
Tuple,
Union,
)

try:
from typing import Literal
except ImportError:
from typing_extensions import Literal # type: ignore

from uqbar.objects import new

from ..enums import AddAction, HeaderFormat, RequestName, SampleFormat
Expand Down
10 changes: 5 additions & 5 deletions supriya/contexts/shm.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 5 additions & 12 deletions supriya/scsynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ class Options:
protocol: str = "udp"
random_number_generator_count: int = 64
realtime: bool = True
remote_control_volume: bool = False
restricted_path: Optional[str] = None
safety_clip: Optional[Union[int, Literal["inf"]]] = None
sample_rate: Optional[int] = None
threads: Optional[int] = None
threads: int = 6
ugen_plugins_path: Optional[str] = None
verbosity: int = 0
wire_buffer_count: int = 64
Expand All @@ -85,14 +84,6 @@ class Options:
### INITIALIZER ###

def __post_init__(self):
if self.input_bus_channel_count is None:
object.__setattr__(self, "input_bus_channel_count", 8)
if self.output_bus_channel_count is None:
object.__setattr__(self, "output_bus_channel_count", 8)
if self.input_bus_channel_count < 0:
raise ValueError(self.input_bus_channel_count)
if self.output_bus_channel_count < 0:
raise ValueError(self.output_bus_channel_count)
if self.audio_bus_channel_count < (
self.input_bus_channel_count + self.output_bus_channel_count
):
Expand Down Expand Up @@ -135,6 +126,8 @@ def serialize(self) -> List[str]:
result = [str(find(self.executable))]
pairs: Dict[str, Optional[Union[List[str], str]]] = {}
if self.realtime:
if self.ip_address != DEFAULT_IP_ADDRESS:
pairs["-B"] = self.ip_address
if self.protocol == "tcp":
pairs["-t"] = str(self.port)
else:
Expand Down Expand Up @@ -189,8 +182,8 @@ def serialize(self) -> List[str]:
pairs["-P"] = str(self.restricted_path)
if self.safety_clip is not None:
pairs["-s"] = str(self.safety_clip)
if self.threads and find(self.executable).stem == "supernova":
pairs["-t"] = str(self.threads)
if self.threads != 6 and find(self.executable).stem == "supernova":
pairs["-T"] = str(self.threads)
if self.ugen_plugins_path:
pairs["-U"] = str(self.ugen_plugins_path)
if 0 < self.verbosity:
Expand Down
6 changes: 1 addition & 5 deletions supriya/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@
SupportsFloat,
SupportsInt,
Tuple,
TypeAlias,
TypeVar,
Union,
runtime_checkable,
)

try:
from typing import TypeAlias
except ImportError:
from typing_extensions import TypeAlias # noqa

from .enums import (
AddAction,
CalculationRate,
Expand Down
20 changes: 11 additions & 9 deletions supriya/ugens/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,19 @@ def _new_single(
def _inputs_are_valid(source, multiplier, addend):
if CalculationRate.from_expr(source) == CalculationRate.AUDIO:
return True
if CalculationRate.from_expr(source) == CalculationRate.CONTROL:
if CalculationRate.from_expr(multiplier) in (
return (
CalculationRate.from_expr(source) == CalculationRate.CONTROL
and CalculationRate.from_expr(multiplier)
in (
CalculationRate.CONTROL,
CalculationRate.SCALAR,
):
if CalculationRate.from_expr(addend) in (
CalculationRate.CONTROL,
CalculationRate.SCALAR,
):
return True
return False
)
and CalculationRate.from_expr(addend)
in (
CalculationRate.CONTROL,
CalculationRate.SCALAR,
)
)

if multiplier == 0.0:
return addend
Expand Down
8 changes: 2 additions & 6 deletions supriya/ugens/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,13 @@
SupportsInt,
Tuple,
Type,
TypeAlias,
Union,
cast,
overload,
runtime_checkable,
)

try:
from typing import TypeAlias
except ImportError:
from typing_extensions import TypeAlias # noqa

from uqbar.graphs import Edge, Graph, Node, RecordField, RecordGroup

from .. import sclang
Expand Down Expand Up @@ -1753,7 +1749,7 @@ def recurse(operable) -> None:
for ugen in ugens:
ugen._uuid = builder._uuid
builder._add_ugen(ugen)
return builder.build(optimize=False)
return builder.build(name="...", optimize=False)

def __truediv__(self, expr: "UGenRecursiveInput") -> "UGenOperable":
"""
Expand Down
6 changes: 3 additions & 3 deletions supriya/ugens/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Changed(PseudoUGen):

>>> print(changed)
synthdef:
name: 39e1f9d61589c4acaaf297cc961d65e4
name: ...
ugens:
- In.ar:
bus: 0.0
Expand Down Expand Up @@ -146,7 +146,7 @@ def ar(cls, *, source, threshold=0) -> UGenOperable:

>>> print(changed)
synthdef:
name: 39e1f9d61589c4acaaf297cc961d65e4
name: ...
ugens:
- In.ar:
bus: 0.0
Expand Down Expand Up @@ -180,7 +180,7 @@ def kr(cls, *, source, threshold=0) -> UGenOperable:

>>> print(changed)
synthdef:
name: e2436271176995c6a0a5cac6d1553f8b
name: ...
ugens:
- In.ar:
bus: 0.0
Expand Down
21 changes: 15 additions & 6 deletions tests/book/test_ext_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,27 @@ def test_sphinx_book_html(caplog, app, status, warning, rm_dirs):
expected_44100_file_names = expected_file_names + [
"audio-08abe38d842cbaa19789618fe4675f1cf64de0eb6f9ab7ebd2165c078ce31429.mp3",
"audio-08abe38d842cbaa19789618fe4675f1cf64de0eb6f9ab7ebd2165c078ce31429.wav",
"plot-397eb6446e5486ac9137cb98affdda8577148ae41ef7857807f53be0793bc74a.svg",
"plot-99e2c0700b9eab6f980db17cc773b1ecdc8cd5db7e9fed14e03622176ef7599c.svg",
]
expected_48000_file_names = expected_file_names + [
"audio-4f0fd44621b74146c936fab67a7544438ddb60abe59b506082268778ec2e285f.mp3",
"audio-4f0fd44621b74146c936fab67a7544438ddb60abe59b506082268778ec2e285f.wav",
"plot-6e8cafcdb775004ffba3051b743f9d5a539d541c6601f723ecfcc3145f0217b4.svg",
"plot-282e7e88a25aa93b5fcf85a028bbc14b2445171e3c43018124f120579a0d2afe.svg",
]
actual_file_names = sorted(path.name for path in image_path.iterdir())
print(actual_file_names)
assert all(
file_name in actual_file_names for file_name in expected_44100_file_names
) or all(file_name in actual_file_names for file_name in expected_48000_file_names)
for file_name in sorted(actual_file_names):
print(f"actual: {file_name}")
for file_name in sorted(expected_44100_file_names):
print(f"44100: {file_name}")
for file_name in sorted(expected_48000_file_names):
print(f"48000: {file_name}")
all_44100_files_exist = all(
[file_name in actual_file_names for file_name in expected_44100_file_names]
)
all_48000_files_exist = all(
[file_name in actual_file_names for file_name in expected_48000_file_names]
)
assert all_44100_files_exist or all_48000_files_exist
# audio and plot names are not stable across platforms
audio_mp3_paths = list(image_path.glob("audio-*.mp3"))
audio_wav_paths = list(image_path.glob("audio-*.wav"))
Expand Down
Loading
Loading