• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MilesCranmer / PySR / 12100062277

30 Nov 2024 10:48PM UTC coverage: 93.389% (-0.3%) from 93.735%
12100062277

Pull #748

github

MilesCranmer
test: skip tensorboard test on windows
Pull Request #748: Update to 1.0 backend

412 of 438 new or added lines in 13 files covered. (94.06%)

1 existing line in 1 file now uncovered.

1342 of 1437 relevant lines covered (93.39%)

2.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.48
/pysr/julia_helpers.py
1
"""Functions for initializing the Julia environment and installing deps."""
2

3
from typing import Any, Callable, cast, overload
3✔
4

5
import numpy as np
3✔
6
from juliacall import convert as jl_convert  # type: ignore
3✔
7
from numpy.typing import NDArray
3✔
8

9
from .deprecated import init_julia, install
3✔
10
from .julia_import import AnyValue, jl
3✔
11

12
jl_convert = cast(Callable[[Any, Any], Any], jl_convert)
3✔
13

14
jl.seval("using Serialization: Serialization")
3✔
15
jl.seval("using PythonCall: PythonCall")
3✔
16

17
Serialization = jl.Serialization
3✔
18
PythonCall = jl.PythonCall
3✔
19

20
jl.seval("using SymbolicRegression: plus, sub, mult, div, pow")
3✔
21

22

23
def _escape_filename(filename):
3✔
24
    """Turn a path into a string with correctly escaped backslashes."""
25
    if filename is None:
3✔
NEW
26
        return None
×
27
    str_repr = str(filename)
3✔
28
    str_repr = str_repr.replace("\\", "\\\\")
3✔
29
    return str_repr
3✔
30

31

32
def _load_cluster_manager(cluster_manager: str):
3✔
33
    jl.seval(f"using ClusterManagers: addprocs_{cluster_manager}")
×
34
    return jl.seval(f"addprocs_{cluster_manager}")
×
35

36

37
def jl_array(x, dtype=None):
3✔
38
    if x is None:
3✔
39
        return None
3✔
40
    elif dtype is None:
3✔
41
        return jl_convert(jl.Array, x)
3✔
42
    else:
43
        return jl_convert(jl.Array[dtype], x)
3✔
44

45

46
def jl_dict(x):
3✔
47
    return jl_convert(jl.Dict, x)
3✔
48

49

50
def jl_is_function(f) -> bool:
3✔
51
    return cast(bool, jl.seval("op -> op isa Function")(f))
3✔
52

53

54
def jl_serialize(obj: Any) -> NDArray[np.uint8]:
3✔
55
    buf = jl.IOBuffer()
3✔
56
    Serialization.serialize(buf, obj)
3✔
57
    return np.array(jl.take_b(buf))
3✔
58

59

60
@overload
3✔
61
def jl_deserialize(s: NDArray[np.uint8]) -> AnyValue: ...
3✔
62
@overload
3✔
63
def jl_deserialize(s: None) -> None: ...
3✔
64
def jl_deserialize(s):
3✔
65
    if s is None:
3✔
66
        return s
3✔
67
    buf = jl.IOBuffer()
3✔
68
    jl.write(buf, jl_array(s))
3✔
69
    jl.seekstart(buf)
3✔
70
    return Serialization.deserialize(buf)
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc