Skip to content

Commit

Permalink
Rename _graph.pyx -> _model.pyx
Browse files Browse the repository at this point in the history
  • Loading branch information
arcondello committed Dec 5, 2024
1 parent 572e514 commit 890bc77
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 14 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion dwave/optimization/mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import functools
import typing

from dwave.optimization._graph import ArraySymbol
from dwave.optimization._model import ArraySymbol
from dwave.optimization.symbols import (
Add,
And,
Expand Down
15 changes: 15 additions & 0 deletions dwave/optimization/model.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 D-Wave 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 or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from dwave.optimization._model cimport ArraySymbol, _Graph, Symbol
2 changes: 1 addition & 1 deletion dwave/optimization/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import tempfile
import typing

from dwave.optimization._graph import ArraySymbol, _Graph, Symbol
from dwave.optimization._model import ArraySymbol, _Graph, Symbol
from dwave.optimization.states import States

if typing.TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion dwave/optimization/states.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from libcpp.vector cimport vector

from dwave.optimization.libcpp.state cimport State as cppState
from dwave.optimization._graph cimport _Graph
from dwave.optimization.model cimport _Graph


cdef class States:
Expand Down
2 changes: 1 addition & 1 deletion dwave/optimization/states.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import weakref
from libcpp.utility cimport move

from dwave.optimization.libcpp.array cimport Array as cppArray
from dwave.optimization._graph cimport ArraySymbol
from dwave.optimization.model cimport ArraySymbol, _Graph
from dwave.optimization.model import Model

__all__ = ["States"]
Expand Down
2 changes: 1 addition & 1 deletion dwave/optimization/symbols.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

from libcpp.typeinfo cimport type_info

from dwave.optimization._graph cimport _Graph
from dwave.optimization.libcpp.graph cimport Array as cppArray
from dwave.optimization.libcpp.graph cimport Node as cppNode
from dwave.optimization.model cimport _Graph

cdef void _register(object cls, const type_info& typeinfo)

Expand Down
2 changes: 1 addition & 1 deletion dwave/optimization/symbols.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ from dwave.optimization.libcpp.nodes cimport (
WhereNode as cppWhereNode,
XorNode as cppXorNode,
)
from dwave.optimization._graph cimport ArraySymbol, _Graph, Symbol
from dwave.optimization.model cimport ArraySymbol, _Graph, Symbol
from dwave.optimization.states cimport States

__all__ = [
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ else
endif

py.extension_module(
'_graph',
'dwave/optimization/_graph.pyx',
'_model',
'dwave/optimization/_model.pyx',
dependencies: libdwave_optimization,
gnu_symbol_visibility: 'default',
install: true,
Expand Down
9 changes: 4 additions & 5 deletions releasenotes/notes/_Graph-e85b234643bb01a7.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
---
features:
- |
Add a new Cython extension type, ``_Graph``, in a new ``dwave.optimization._graph``
submodule. The ``_Graph`` class is responsible for managing a C++
``dwave::optimization::Graph``.
Add a new Cython extension type, ``_Graph``. The ``_Graph`` class is
responsible for managing a C++ ``dwave::optimization::Graph``.
Also make ``Model`` a Python class that inherits from ``_Graph``, rather than
a Cython extension type.
upgrade:
- |
It is no longer possible to ``from dwave.optimization.model cimport Model``.
Instead, importers should ``from dwave.optimization._graph cimport _Graph``.
Instead, importers should ``from dwave.optimization.model cimport _Graph``.
A ``_Graph`` has most of the functionality that a ``Model`` did, although
most of the symbol construction methods have been kept on ``Model``.
most of the symbol construction methods have been kept on ``Model``.
2 changes: 1 addition & 1 deletion tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(self, array):
def __getitem__(self, index):
if not isinstance(index, tuple):
return self[(index,)]
i0, i1 = dwave.optimization._graph._split_indices(index)
i0, i1 = dwave.optimization._model._split_indices(index)
np.testing.assert_array_equal(self.array[index], self.array[i0][i1])

def test_split_indices(self):
Expand Down

0 comments on commit 890bc77

Please sign in to comment.