repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
coremltools | coremltools/converters/sklearn/_logistic_regression.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from collections.abc import Iterable
from ..._deps import _HAS_SKLEARN
from ...models import MLModel as... | 110 | 3,111 |
coremltools | coremltools/converters/sklearn/_imputer.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from packaging.version import Version
from coremltools import proto
from ... import SPECIFICATION_VERS... | 115 | 3,396 |
coremltools | coremltools/converters/sklearn/_standard_scaler.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools import proto
from ... import SPECIFICATION_VERSION
from ..._deps import _HAS_SKLEARN
... | 91 | 2,617 |
coremltools | coremltools/converters/sklearn/_dict_vectorizer.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools import proto
from ... import SPECIFICATION_VERSION
from ..._deps import _HAS_SKLEARN
f... | 115 | 3,572 |
coremltools | coremltools/converters/sklearn/_NuSVR.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from ..._deps import _HAS_SKLEARN
from . import _SVR as _SVR
if _HAS_SKLEARN:
from sklearn.svm impo... | 55 | 1,458 |
coremltools | coremltools/converters/sklearn/_one_hot_encoder.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools import proto
from ... import SPECIFICATION_VERSION
from ..._deps import _HAS_SKLEARN, ... | 264 | 9,864 |
coremltools | coremltools/converters/sklearn/_linear_regression.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import numpy as _np
from coremltools import proto
from ... import SPECIFICATION_VERSION
from ..._deps ... | 83 | 2,367 |
coremltools | coremltools/converters/sklearn/_SVC.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools import proto
from ... import SPECIFICATION_VERSION as _SPECIFICATION_VERSION
from ..._... | 134 | 4,012 |
coremltools | coremltools/converters/sklearn/_random_forest_classifier.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from ..._deps import _HAS_SKLEARN
from ...models import MLModel as _MLModel
from ._tree_ensemble import ... | 71 | 1,916 |
coremltools | coremltools/converters/sklearn/_LinearSVR.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from ..._deps import _HAS_SKLEARN
from ...models import MLModel as _MLModel
if _HAS_SKLEARN:
import... | 54 | 1,405 |
coremltools | coremltools/converters/sklearn/_ridge_regression.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from ..._deps import _HAS_SKLEARN
from ...models import MLModel as _MLModel
if _HAS_SKLEARN:
import... | 54 | 1,422 |
coremltools | coremltools/converters/sklearn/_gradient_boosting_classifier.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import numpy as np
from ..._deps import _HAS_SKLEARN
from ...models import MLModel as _MLModel
from ._t... | 109 | 3,521 |
coremltools | coremltools/converters/sklearn/_NuSVC.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from ..._deps import _HAS_SKLEARN
from . import _SVC as _SVC
if _HAS_SKLEARN:
from sklearn.svm impo... | 69 | 1,882 |
coremltools | coremltools/converters/sklearn/_gradient_boosting_regressor.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from packaging.version import Version
from ..._deps import _HAS_SKLEARN, _SKLEARN_VERSION
from ...model... | 75 | 2,234 |
coremltools | coremltools/converters/sklearn/_k_neighbors_classifier.py | .py | # Copyright (c) 2019, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import coremltools
from coremltools import proto
from ..._deps import _HAS_SCIPY, _HAS_SKLEARN
from ...... | 290 | 9,498 |
coremltools | coremltools/converters/sklearn/_converter.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import coremltools as ct
from coremltools import __version__ as ct_version
"""
Defines the primary func... | 162 | 5,890 |
coremltools | coremltools/converters/sklearn/_sklearn_util.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
def check_fitted(model, func):
"""Check if a model is fitted. Raise error if not.
Parameters
... | 38 | 1,032 |
coremltools | deps/pybind11/setup.py | .py | #!/usr/bin/env python3
# Setup script for PyPI; use CMakeFile.txt to build extension modules
from __future__ import annotations
import contextlib
import os
import re
import shutil
import string
import subprocess
import sys
from collections.abc import Generator
from pathlib import Path
from tempfile import TemporaryDi... | 150 | 4,882 |
coremltools | deps/pybind11/noxfile.py | .py | from __future__ import annotations
import argparse
import nox
nox.needs_version = ">=2024.3.2"
nox.options.sessions = ["lint", "tests", "tests_packaging"]
nox.options.default_venv_backend = "uv|virtualenv"
@nox.session(reuse_venv=True)
def lint(session: nox.Session) -> None:
"""
Lint the codebase (except f... | 108 | 2,897 |
coremltools | deps/pybind11/pybind11/_version.py | .py | from __future__ import annotations
def _to_int(s: str) -> int | str:
try:
return int(s)
except ValueError:
return s
__version__ = "2.13.1"
version_info = tuple(_to_int(s) for s in __version__.split("."))
| 13 | 232 |
coremltools | deps/pybind11/pybind11/__main__.py | .py | # pylint: disable=missing-function-docstring
from __future__ import annotations
import argparse
import sys
import sysconfig
from ._version import __version__
from .commands import get_cmake_dir, get_include, get_pkgconfig_dir
def print_includes() -> None:
dirs = [
sysconfig.get_path("include"),
... | 64 | 1,579 |
coremltools | deps/pybind11/pybind11/__init__.py | .py | from __future__ import annotations
import sys
if sys.version_info < (3, 7): # noqa: UP036
msg = "pybind11 does not support Python < 3.7. v2.12 was the last release supporting Python 3.6."
raise ImportError(msg)
from ._version import __version__, version_info
from .commands import get_cmake_dir, get_include... | 20 | 459 |
coremltools | deps/pybind11/pybind11/setup_helpers.py | .py | """
This module provides helpers for C++11+ projects using pybind11.
LICENSE:
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions... | 501 | 17,490 |
coremltools | deps/pybind11/pybind11/commands.py | .py | from __future__ import annotations
import os
DIR = os.path.abspath(os.path.dirname(__file__))
def get_include(user: bool = False) -> str: # noqa: ARG001
"""
Return the path to the pybind11 include directory. The historical "user"
argument is unused, and may be removed.
"""
installed_path = os.p... | 40 | 1,243 |
coremltools | deps/pybind11/tools/codespell_ignore_lines_from_errors.py | .py | """Simple script for rebuilding .codespell-ignore-lines
Usage:
cat < /dev/null > .codespell-ignore-lines
pre-commit run --all-files codespell >& /tmp/codespell_errors.txt
python3 tools/codespell_ignore_lines_from_errors.py /tmp/codespell_errors.txt > .codespell-ignore-lines
git diff to review changes, then commit, p... | 41 | 1,129 |
coremltools | deps/pybind11/tools/libsize.py | .py | from __future__ import annotations
import os
import sys
# Internal build script for generating debugging test .so size.
# Usage:
# python libsize.py file.so save.txt -- displays the size of file.so and, if save.txt exists, compares it to the
# size in it, then overwrites ... | 39 | 1,067 |
coremltools | deps/pybind11/tools/make_changelog.py | .py | #!/usr/bin/env python3
from __future__ import annotations
import re
import ghapi.all
from rich import print
from rich.syntax import Syntax
ENTRY = re.compile(
r"""
Suggested \s changelog \s entry:
.*
```rst
\s*
(.*?)
\s*
```
""",
re.DOTALL | re.VERBOSE,
)
print()
api = ghapi.al... | 93 | 2,136 |
coremltools | deps/pybind11/docs/benchmark.py | .py | from __future__ import annotations
import datetime as dt
import os
import random
nfns = 4 # Functions per class
nargs = 4 # Arguments per function
def generate_dummy_code_pybind11(nclasses=10):
decl = ""
bindings = ""
for cl in range(nclasses):
decl += f"class cl{cl:03};\n"
decl += "\n"
... | 90 | 2,889 |
coremltools | deps/pybind11/tests/test_copy_move.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import copy_move_policies as m
def test_lacking_copy_ctor():
with pytest.raises(RuntimeError) as excinfo:
m.lacking_copy_ctor.get_one()
assert "is non-copyable!" in str(excinfo.value)
def test_lacking_move_ctor():
with pytest... | 141 | 5,090 |
coremltools | deps/pybind11/tests/test_local_bindings.py | .py | from __future__ import annotations
import pytest
import env # noqa: F401
from pybind11_tests import local_bindings as m
def test_load_external():
"""Load a `py::module_local` type that's only registered in an external module"""
import pybind11_cross_module_tests as cm
assert m.load_external1(cm.Extern... | 260 | 8,090 |
coremltools | deps/pybind11/tests/test_virtual_functions.py | .py | from __future__ import annotations
import pytest
import env # noqa: F401
m = pytest.importorskip("pybind11_tests.virtual_functions")
from pybind11_tests import ConstructorStats # noqa: E402
def test_override(capture, msg):
class ExtendedExampleVirt(m.ExampleVirt):
def __init__(self, state):
... | 461 | 12,949 |
coremltools | deps/pybind11/tests/test_pickling.py | .py | from __future__ import annotations
import pickle
import re
import pytest
import env
from pybind11_tests import pickling as m
def test_pickle_simple_callable():
assert m.simple_callable() == 20220426
if env.PYPY:
serialized = pickle.dumps(m.simple_callable)
deserialized = pickle.loads(serial... | 96 | 2,756 |
coremltools | deps/pybind11/tests/test_exceptions.py | .py | from __future__ import annotations
import sys
import pytest
import env
import pybind11_cross_module_tests as cm
import pybind11_tests
from pybind11_tests import exceptions as m
def test_std_exception(msg):
with pytest.raises(RuntimeError) as excinfo:
m.throw_std_exception()
assert msg(excinfo.value... | 435 | 14,573 |
coremltools | deps/pybind11/tests/test_eigen_tensor.py | .py | from __future__ import annotations
import sys
import pytest
np = pytest.importorskip("numpy")
eigen_tensor = pytest.importorskip("pybind11_tests.eigen_tensor")
submodules = [eigen_tensor.c_style, eigen_tensor.f_style]
try:
import eigen_tensor_avoid_stl_array as avoid
submodules += [avoid.c_style, avoid.f_st... | 291 | 9,450 |
coremltools | deps/pybind11/tests/test_iostream.py | .py | from __future__ import annotations
from contextlib import redirect_stderr, redirect_stdout
from io import StringIO
from pybind11_tests import iostream as m
def test_captured(capsys):
msg = "I've been redirected to Python, I hope!"
m.captured_output(msg)
stdout, stderr = capsys.readouterr()
assert st... | 294 | 7,180 |
coremltools | deps/pybind11/tests/test_numpy_dtypes.py | .py | from __future__ import annotations
import re
import pytest
import env # noqa: F401
from pybind11_tests import PYBIND11_NUMPY_1_ONLY
from pybind11_tests import numpy_dtypes as m
np = pytest.importorskip("numpy")
@pytest.fixture(scope="module")
def simple_dtype():
ld = np.dtype("longdouble")
return np.dtyp... | 449 | 14,655 |
coremltools | deps/pybind11/tests/test_modules.py | .py | from __future__ import annotations
import builtins
import pytest
import env
from pybind11_tests import ConstructorStats
from pybind11_tests import modules as m
from pybind11_tests.modules import subsubmodule as ms
def test_nested_modules():
import pybind11_tests
assert pybind11_tests.__name__ == "pybind11... | 119 | 3,999 |
coremltools | deps/pybind11/tests/test_buffers.py | .py | from __future__ import annotations
import ctypes
import io
import struct
import pytest
import env
from pybind11_tests import ConstructorStats
from pybind11_tests import buffers as m
np = pytest.importorskip("numpy")
if m.long_double_and_double_have_same_size:
# Determined by the compiler used to build the pybi... | 231 | 7,160 |
coremltools | deps/pybind11/tests/test_custom_type_setup.py | .py | from __future__ import annotations
import gc
import weakref
import pytest
import env # noqa: F401
from pybind11_tests import custom_type_setup as m
@pytest.fixture()
def gc_tester():
"""Tests that an object is garbage collected.
Assumes that any unreferenced objects are fully collected after calling
... | 51 | 1,127 |
coremltools | deps/pybind11/tests/test_vector_unique_ptr_member.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import vector_unique_ptr_member as m
@pytest.mark.parametrize("num_elems", range(3))
def test_create(num_elems):
vo = m.VectorOwner.Create(num_elems)
assert vo.data_size() == num_elems
def test_cast():
vo = m.VectorOwner.Create(0)
... | 17 | 365 |
coremltools | deps/pybind11/tests/test_methods_and_attributes.py | .py | from __future__ import annotations
import sys
import pytest
import env # noqa: F401
from pybind11_tests import ConstructorStats
from pybind11_tests import methods_and_attributes as m
NO_GETTER_MSG = (
"unreadable attribute" if sys.version_info < (3, 11) else "object has no getter"
)
NO_SETTER_MSG = (
"can'... | 540 | 18,462 |
coremltools | deps/pybind11/tests/test_factory_constructors.py | .py | from __future__ import annotations
import re
import pytest
from pybind11_tests import ConstructorStats
from pybind11_tests import factory_constructors as m
from pybind11_tests.factory_constructors import tag
def test_init_factory_basic():
"""Tests py::init_factory() wrapper around various ways of returning the... | 519 | 16,527 |
coremltools | deps/pybind11/tests/test_class.py | .py | from __future__ import annotations
from unittest import mock
import pytest
import env
from pybind11_tests import PYBIND11_REFCNT_IMMORTAL, ConstructorStats, UserType
from pybind11_tests import class_ as m
def test_obj_class_name():
expected_name = "UserType" if env.PYPY else "pybind11_tests.UserType"
asser... | 504 | 15,331 |
coremltools | deps/pybind11/tests/test_enum.py | .py | # ruff: noqa: SIM201 SIM300 SIM202
from __future__ import annotations
import pytest
from pybind11_tests import enums as m
def test_unscoped_enum():
assert str(m.UnscopedEnum.EOne) == "UnscopedEnum.EOne"
assert str(m.UnscopedEnum.ETwo) == "UnscopedEnum.ETwo"
assert str(m.EOne) == "UnscopedEnum.EOne"
... | 271 | 9,104 |
coremltools | deps/pybind11/tests/test_multiple_inheritance.py | .py | from __future__ import annotations
import pytest
import env # noqa: F401
from pybind11_tests import ConstructorStats
from pybind11_tests import multiple_inheritance as m
def test_multiple_inheritance_cpp():
mt = m.MIType(3, 4)
assert mt.foo() == 3
assert mt.bar() == 4
@pytest.mark.xfail("env.PYPY")
... | 496 | 11,910 |
coremltools | deps/pybind11/tests/test_python_multiple_inheritance.py | .py | # Adapted from:
# https://github.com/google/clif/blob/5718e4d0807fd3b6a8187dde140069120b81ecef/clif/testing/python/python_multiple_inheritance_test.py
from __future__ import annotations
from pybind11_tests import python_multiple_inheritance as m
class PC(m.CppBase):
pass
class PPCC(PC, m.CppDrvd):
pass
d... | 37 | 894 |
coremltools | deps/pybind11/tests/test_stl.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import ConstructorStats, UserType
from pybind11_tests import stl as m
def test_vector(doc):
"""std::vector <-> list"""
lst = m.cast_vector()
assert lst == [1]
lst.append(2)
assert m.load_vector(lst)
assert m.load_vector(tup... | 384 | 12,343 |
coremltools | deps/pybind11/tests/test_call_policies.py | .py | from __future__ import annotations
import pytest
import env # noqa: F401
from pybind11_tests import ConstructorStats
from pybind11_tests import call_policies as m
@pytest.mark.xfail("env.PYPY", reason="sometimes comes out 1 off on PyPy", strict=False)
def test_keep_alive_argument(capture):
n_inst = Constructor... | 250 | 6,585 |
coremltools | deps/pybind11/tests/test_operator_overloading.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import ConstructorStats
from pybind11_tests import operators as m
def test_operator_overloading():
v1 = m.Vector2(1, 2)
v2 = m.Vector(3, -1)
v3 = m.Vector2(1, 2) # Same value as v1, but different instance.
assert v1 is not v3
... | 154 | 4,368 |
coremltools | deps/pybind11/tests/test_unnamed_namespace_b.py | .py | from __future__ import annotations
from pybind11_tests import unnamed_namespace_b as m
def test_have_attr_any_struct():
assert hasattr(m, "unnamed_namespace_b_any_struct")
| 8 | 179 |
coremltools | deps/pybind11/tests/test_kwargs_and_defaults.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import kwargs_and_defaults as m
def test_function_signatures(doc):
assert doc(m.kw_func0) == "kw_func0(arg0: int, arg1: int) -> str"
assert doc(m.kw_func1) == "kw_func1(x: int, y: int) -> str"
assert doc(m.kw_func2) == "kw_func2(x: int... | 429 | 14,911 |
coremltools | deps/pybind11/tests/test_numpy_array.py | .py | from __future__ import annotations
import pytest
import env # noqa: F401
from pybind11_tests import numpy_array as m
np = pytest.importorskip("numpy")
def test_dtypes():
# See issue #1328.
# - Platform-dependent sizes.
for size_check in m.get_platform_dtype_size_checks():
print(size_check)
... | 673 | 22,915 |
coremltools | deps/pybind11/tests/test_opaque_types.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import ConstructorStats, UserType
from pybind11_tests import opaque_types as m
def test_string_list():
lst = m.StringList()
lst.push_back("Element 1")
lst.push_back("Element 2")
assert m.print_opaque_list(lst) == "Opaque list: [Ele... | 61 | 1,883 |
coremltools | deps/pybind11/tests/test_eigen_matrix.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import ConstructorStats
np = pytest.importorskip("numpy")
m = pytest.importorskip("pybind11_tests.eigen_matrix")
ref = np.array(
[
[0.0, 3, 0, 0, 0, 11],
[22, 0, 0, 0, 17, 11],
[7, 5, 0, 1, 0, 11],
[0, 0, 0, 0,... | 817 | 29,211 |
coremltools | deps/pybind11/tests/test_async.py | .py | from __future__ import annotations
import pytest
asyncio = pytest.importorskip("asyncio")
m = pytest.importorskip("pybind11_tests.async_module")
@pytest.fixture()
def event_loop():
loop = asyncio.new_event_loop()
yield loop
loop.close()
async def get_await_result(x):
return await x
def test_awai... | 27 | 572 |
coremltools | deps/pybind11/tests/test_chrono.py | .py | from __future__ import annotations
import datetime
import pytest
import env # noqa: F401
from pybind11_tests import chrono as m
def test_chrono_system_clock():
# Get the time from both c++ and datetime
date0 = datetime.datetime.today()
date1 = m.test_chrono1()
date2 = datetime.datetime.today()
... | 208 | 5,727 |
coremltools | deps/pybind11/tests/test_eval.py | .py | from __future__ import annotations
import os
import pytest
import env # noqa: F401
from pybind11_tests import eval_ as m
def test_evals(capture):
with capture:
assert m.test_eval_statements()
assert capture == "Hello World!"
assert m.test_eval()
assert m.test_eval_single_statement()
... | 53 | 1,179 |
coremltools | deps/pybind11/tests/test_const_name.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import const_name as m
@pytest.mark.parametrize("func", [m.const_name_tests, m.underscore_tests])
@pytest.mark.parametrize(
("selector", "expected"),
enumerate(
(
"",
"A",
"Bd",
"Cef"... | 32 | 629 |
coremltools | deps/pybind11/tests/test_eval_call.py | .py | # This file is called from 'test_eval.py'
from __future__ import annotations
if "call_test2" in locals():
call_test2(y) # noqa: F821 undefined name
| 6 | 154 |
coremltools | deps/pybind11/tests/test_tagbased_polymorphic.py | .py | from __future__ import annotations
from pybind11_tests import tagbased_polymorphic as m
def test_downcast():
zoo = m.create_zoo()
assert [type(animal) for animal in zoo] == [
m.Labrador,
m.Dog,
m.Chihuahua,
m.Cat,
m.Panther,
]
assert [animal.name for animal in ... | 31 | 777 |
coremltools | deps/pybind11/tests/test_union.py | .py | from __future__ import annotations
from pybind11_tests import union_ as m
def test_union():
instance = m.TestUnion()
instance.as_uint = 10
assert instance.as_int == 10
| 11 | 184 |
coremltools | deps/pybind11/tests/test_pytypes.py | .py | from __future__ import annotations
import contextlib
import sys
import types
import pytest
import env
from pybind11_tests import detailed_error_messages_enabled
from pybind11_tests import pytypes as m
def test_obj_class_name():
assert m.obj_class_name(None) == "NoneType"
assert m.obj_class_name(list) == "l... | 1,051 | 27,883 |
coremltools | deps/pybind11/tests/test_type_caster_pyobject_ptr.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import type_caster_pyobject_ptr as m
# For use as a temporary user-defined object, to maximize sensitivity of the tests below.
class ValueHolder:
def __init__(self, value):
self.value = value
def test_cast_from_pyobject_ptr():
as... | 123 | 3,866 |
coremltools | deps/pybind11/tests/test_gil_scoped.py | .py | from __future__ import annotations
import multiprocessing
import sys
import threading
import time
import pytest
import env
from pybind11_tests import gil_scoped as m
class ExtendedVirtClass(m.VirtClass):
def virtual_func(self):
pass
def pure_virtual_func(self):
pass
def test_callback_py_... | 245 | 8,543 |
coremltools | deps/pybind11/tests/test_docstring_options.py | .py | from __future__ import annotations
from pybind11_tests import docstring_options as m
def test_docstring_options():
# options.disable_function_signatures()
assert not m.test_function1.__doc__
assert m.test_function2.__doc__ == "A custom docstring"
# docstring specified on just the first overload def... | 67 | 2,459 |
coremltools | deps/pybind11/tests/test_callbacks.py | .py | from __future__ import annotations
import time
from threading import Thread
import pytest
import env # noqa: F401
from pybind11_tests import callbacks as m
from pybind11_tests import detailed_error_messages_enabled
def test_callbacks():
from functools import partial
def func1():
return "func1"
... | 228 | 6,991 |
coremltools | deps/pybind11/tests/test_unnamed_namespace_a.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import unnamed_namespace_a as m
from pybind11_tests import unnamed_namespace_b as mb
XFAIL_CONDITION = (
"(m.PYBIND11_INTERNALS_VERSION <= 4 and (m.defined___clang__ or not m.defined___GLIBCXX__))"
" or "
"(m.PYBIND11_INTERNALS_VERSION ... | 37 | 1,177 |
coremltools | deps/pybind11/tests/test_stl_binders.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import stl_binders as m
def test_vector_int():
v_int = m.VectorInt([0, 0])
assert len(v_int) == 2
assert bool(v_int) is True
# test construction from a generator
v_int1 = m.VectorInt(x for x in range(5))
assert v_int1 == m... | 396 | 11,079 |
coremltools | deps/pybind11/tests/test_sequences_and_iterators.py | .py | from __future__ import annotations
import pytest
from pytest import approx # noqa: PT013
from pybind11_tests import ConstructorStats
from pybind11_tests import sequences_and_iterators as m
def test_slice_constructors():
assert m.make_forward_slice_size_t() == slice(0, -1, 1)
assert m.make_reversed_slice_ob... | 268 | 8,695 |
coremltools | deps/pybind11/tests/env.py | .py | from __future__ import annotations
import platform
import sys
import sysconfig
import pytest
LINUX = sys.platform.startswith("linux")
MACOS = sys.platform.startswith("darwin")
WIN = sys.platform.startswith("win32") or sys.platform.startswith("cygwin")
CPYTHON = platform.python_implementation() == "CPython"
PYPY = p... | 32 | 1,047 |
coremltools | deps/pybind11/tests/test_thread.py | .py | from __future__ import annotations
import threading
from pybind11_tests import thread as m
class Thread(threading.Thread):
def __init__(self, fn):
super().__init__()
self.fn = fn
self.e = None
def run(self):
try:
for i in range(10):
self.fn(i, i)
... | 45 | 862 |
coremltools | deps/pybind11/tests/test_smart_ptr.py | .py | from __future__ import annotations
import pytest
m = pytest.importorskip("pybind11_tests.smart_ptr")
from pybind11_tests import ConstructorStats # noqa: E402
def test_smart_ptr(capture):
# Object1
for i, o in enumerate(
[m.make_object_1(), m.make_object_2(), m.MyObject1(3)], start=1
):
... | 318 | 9,566 |
coremltools | deps/pybind11/tests/test_numpy_vectorize.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import numpy_vectorize as m
np = pytest.importorskip("numpy")
def test_vectorize(capture):
assert np.isclose(m.vectorized_func3(np.array(3 + 7j)), [6 + 14j])
for f in [m.vectorized_func, m.vectorized_func2]:
with capture:
... | 269 | 9,694 |
coremltools | deps/pybind11/tests/test_custom_type_casters.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import custom_type_casters as m
def test_noconvert_args(msg):
a = m.ArgInspector()
assert (
msg(a.f("hi"))
== """
loading ArgInspector1 argument WITH conversion allowed. Argument value = hi
"""
)
assert... | 125 | 4,028 |
coremltools | deps/pybind11/tests/test_constants_and_functions.py | .py | from __future__ import annotations
import pytest
m = pytest.importorskip("pybind11_tests.constants_and_functions")
def test_constants():
assert m.some_constant == 14
def test_function_overloading():
assert m.test_function() == "test_function()"
assert m.test_function(7) == "test_function(7)"
asser... | 59 | 1,587 |
coremltools | deps/pybind11/tests/test_builtin_casters.py | .py | from __future__ import annotations
import sys
import pytest
import env
from pybind11_tests import IncType, UserType
from pybind11_tests import builtin_casters as m
def test_simple_string():
assert m.string_roundtrip("const char *") == "const char *"
def test_unicode_conversion():
"""Tests unicode convers... | 531 | 17,279 |
coremltools | deps/pybind11/tests/conftest.py | .py | """pytest configuration
Extends output capture as needed by pybind11: ignore constructors, optional unordered lines.
Adds docstring and exceptions message sanitizers.
"""
from __future__ import annotations
import contextlib
import difflib
import gc
import multiprocessing
import re
import sys
import textwrap
import t... | 225 | 5,728 |
coremltools | deps/pybind11/tests/test_cmake_build/test.py | .py | from __future__ import annotations
import sys
import test_cmake_build
assert isinstance(__file__, str) # Test this is properly set
assert test_cmake_build.add(1, 2) == 3
print(f"{sys.argv[1]} imports, runs, and adds: 1 + 2 = 3")
| 11 | 234 |
coremltools | deps/pybind11/tests/test_embed/test_interpreter.py | .py | from __future__ import annotations
import sys
from widget_module import Widget
class DerivedWidget(Widget):
def __init__(self, message):
super().__init__(message)
def the_answer(self):
return 42
def argv0(self):
return sys.argv[0]
| 17 | 273 |
coremltools | deps/pybind11/tests/test_embed/test_trampoline.py | .py | from __future__ import annotations
import trampoline_module
def func():
class Test(trampoline_module.test_override_cache_helper):
def func(self):
return 42
return Test()
def func2():
class Test(trampoline_module.test_override_cache_helper):
pass
return Test()
| 19 | 311 |
coremltools | deps/pybind11/tests/extra_python_package/test_files.py | .py | from __future__ import annotations
import contextlib
import os
import string
import subprocess
import sys
import tarfile
import zipfile
# These tests must be run explicitly
# They require CMake 3.15+ (--install)
DIR = os.path.abspath(os.path.dirname(__file__))
MAIN_DIR = os.path.dirname(os.path.dirname(DIR))
PKGCON... | 297 | 8,580 |
coremltools | deps/pybind11/tests/extra_setuptools/test_setuphelper.py | .py | from __future__ import annotations
import os
import subprocess
import sys
from textwrap import dedent
import pytest
DIR = os.path.abspath(os.path.dirname(__file__))
MAIN_DIR = os.path.dirname(os.path.dirname(DIR))
WIN = sys.platform.startswith("win32") or sys.platform.startswith("cygwin")
@pytest.mark.parametrize(... | 154 | 4,189 |
coremltools | deps/protobuf/update_version.py | .py | #!/usr/bin/env python
# Usage: ./update_version.py <MAJOR>.<MINOR>.<MICRO> [<RC version>]
#
# Example:
# ./update_version.py 3.7.1 2
# => Version will become 3.7.1-rc-2 (beta)
# ./update_version.py 3.7.1
# => Version will become 3.7.1 (stable)
import datetime
import re
import sys
from xml.dom import minidom
if le... | 411 | 13,451 |
coremltools | deps/protobuf/update_compatibility_version.py | .py | #!/usr/bin/env python
"""Compatibility tests between last released and the current version.
Usage: ./update_compatibility_version.py <MAJOR>.<MINOR>.<MICRO> [<RC version>]
Example: ./update_compatibility_version.py 3.7.1
"""
from __future__ import print_function
import re
import sys
if len(sys.argv) < 2 or len(sys.a... | 57 | 1,405 |
coremltools | deps/protobuf/generate_changelog.py | .py | #!/usr/bin/env python
"""Generates a friendly list of changes per language since the last release."""
import sys
import os
class Language(object):
def __init__(self, name, pathspec):
self.name = name
self.pathspec = pathspec
languages = [
Language("C++", [
"':(glob)src/google/protobuf/*'",
"... | 66 | 1,549 |
coremltools | deps/protobuf/kokoro/linux/make_test_output.py | .py | """Gathers output from test runs and create an XML file in JUnit format.
The output files from the individual tests have been written in a directory
structure like:
$DIR/joblog (output from "parallel --joblog joblog")
$DIR/logs/1/cpp/stdout
$DIR/logs/1/cpp/stderr
$DIR/logs/1/csharp/stdout
$DIR/logs/1/cshar... | 95 | 2,620 |
coremltools | deps/protobuf/python/stubout.py | .py | #!/usr/bin/python2.4
#
# Copyright 2008 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 144 | 4,957 |
coremltools | deps/protobuf/python/setup.py | .py | #! /usr/bin/env python
#
# See README for usage instructions.
from distutils import util
import fnmatch
import glob
import os
import pkg_resources
import re
import subprocess
import sys
import sysconfig
import platform
# We must use setuptools, not distutils, because we need to use the
# namespace_packages option for ... | 314 | 12,982 |
coremltools | deps/protobuf/python/mox.py | .py | #!/usr/bin/python2.4
#
# Copyright 2008 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 1,402 | 38,238 |
coremltools | deps/protobuf/python/protobuf_distutils/setup.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 76 | 3,337 |
coremltools | deps/protobuf/python/protobuf_distutils/protobuf_distutils/generate_py_protobufs.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 148 | 6,466 |
coremltools | deps/protobuf/python/docs/generate_docs.py | .py | #!/usr/bin/env python
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are... | 193 | 5,938 |
coremltools | deps/protobuf/python/docs/conf.py | .py | # -*- coding: utf-8 -*-
# Protocol Buffers - Google's data interchange format
# Copyright 2019 Google LLC. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions a... | 255 | 8,260 |
coremltools | deps/protobuf/python/google/__init__.py | .py | try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
| 5 | 150 |
coremltools | deps/protobuf/python/google/protobuf/descriptor_database.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 178 | 6,819 |
coremltools | deps/protobuf/python/google/protobuf/message_factory.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 186 | 7,482 |
coremltools | deps/protobuf/python/google/protobuf/service_reflection.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 288 | 11,072 |
coremltools | deps/protobuf/python/google/protobuf/descriptor.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 1,183 | 45,140 |
coremltools | deps/protobuf/python/google/protobuf/symbol_database.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 195 | 6,944 |
coremltools | deps/protobuf/python/google/protobuf/json_format.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 857 | 32,690 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.