-
Notifications
You must be signed in to change notification settings - Fork 154
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
Add dwave.samplers and dwave.composite namespace #21
Open
arcondello
wants to merge
2
commits into
dwavesystems:master
Choose a base branch
from
arcondello:feature/dwave-samplers-namespace
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2018 D-Wave Systems 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. | ||
# | ||
# ================================================================================================ | ||
import pkgutil | ||
__path__ = pkgutil.extend_path(__path__, __name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2018 D-Wave Systems 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. | ||
# | ||
# ================================================================================================ | ||
""" | ||
A unified namespace for :class:`dimod.Composite`s. | ||
|
||
This namespace is populated by entry points. To contribute a composite, you | ||
must identify it in your setup.py file like so. | ||
|
||
.. code-block:: python | ||
|
||
entry_points = {'dwave.composites': ['YourComposite = import.path.to.composite:YourComposite']} | ||
|
||
setup( | ||
entry_points=entry_points, | ||
... | ||
) | ||
|
||
""" | ||
from pkg_resources import iter_entry_points | ||
|
||
# add the composites to the module from entrypoints, name conflicts override | ||
globals().update((ep.name, ep.load()) for ep in iter_entry_points('dwave.composites')) | ||
del iter_entry_points # remove from namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2018 D-Wave Systems 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. | ||
# | ||
# ================================================================================================ | ||
""" | ||
A unified namespace for :class:`dimod.Sampler`s. | ||
|
||
This namespace is populated by entry points. To contribute a sampler, you | ||
must identify it in your setup.py file like so. | ||
|
||
.. code-block:: python | ||
|
||
entry_points = {'dwave.samplers': ['YourSampler = import.path.to.sampler:YourSampler']} | ||
|
||
setup( | ||
entry_points=entry_points, | ||
... | ||
) | ||
|
||
""" | ||
from pkg_resources import iter_entry_points | ||
|
||
# add the samplers to the module from entrypoints, name conflicts override | ||
globals().update((ep.name, ep.load()) for ep in iter_entry_points('dwave.samplers')) | ||
del iter_entry_points # remove from namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ | |
# ================================================================================================ | ||
from __future__ import absolute_import | ||
|
||
import os | ||
import sys | ||
|
||
from setuptools import setup | ||
|
||
_PY2 = sys.version_info.major == 2 | ||
|
@@ -27,6 +29,8 @@ | |
else: | ||
exec(open("./dwaveoceansdk/package_info.py").read()) | ||
|
||
os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why do you need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea, probably don't |
||
|
||
install_requires = [ | ||
'dwave-networkx>=0.6.1,<0.7.0', | ||
'dwave-system>=0.5.0,<0.6.0', | ||
|
@@ -43,7 +47,11 @@ | |
] | ||
} | ||
|
||
packages = ['dwaveoceansdk'] | ||
packages = ['dwaveoceansdk', | ||
'dwave', | ||
'dwave.samplers', | ||
'dwave.composites', | ||
] | ||
|
||
classifiers = [ | ||
'License :: OSI Approved :: Apache Software License', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import unittest | ||
|
||
|
||
class Test_dwave_samplers(unittest.TestCase): | ||
pass | ||
|
||
|
||
class Test_dwave_composites(unittest.TestCase): | ||
pass |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, since now we have samplers in Hybrid as well, maybe we want to differentiate those from dimod samplers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like:
Or think of a way to reconciliate the two. Same goes for
dwave.composites
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love it, but it could work.
On a somewhat related note, I'm getting fond of
from dwave import dimod, hybrid
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you proposing making dimod and hybrid into namespace packages? That would be easy to do, but at some point it would make sense to just make them all into a monolith package.
Or do you mean like the above where just the samplers/composites are present? I think it would be extremely confusing for
from dwave import hybrid, dimod
to contain different contents/structure thanimport hybrid, dimod
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The former. I'm toying with the idea.