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

[FIX] Cleanup ConfigSpace warnings #183

Merged
merged 4 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ConfigSpace/c_util.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cimport numpy as np
# We now need to fix a datatype for our arrays. I've used the variable
# DTYPE for this, which is assigned to the usual NumPy runtime
# type info object.
DTYPE = np.float
DTYPE = float
# "ctypedef" assigns a corresponding compile-time type to DTYPE_t. For
# every type in the numpy module there's a corresponding compile-time
# type with a _t-suffix.
Expand Down
2 changes: 1 addition & 1 deletion ConfigSpace/conditions.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cimport numpy as np
# We now need to fix a datatype for our arrays. I've used the variable
# DTYPE for this, which is assigned to the usual NumPy runtime
# type info object.
DTYPE = np.float
DTYPE = float
# "ctypedef" assigns a corresponding compile-time type to DTYPE_t. For
# every type in the numpy module there's a corresponding compile-time
# type with a _t-suffix.
Expand Down
2 changes: 1 addition & 1 deletion ConfigSpace/conditions.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ from ConfigSpace.hyperparameters cimport Hyperparameter
# We now need to fix a datatype for our arrays. I've used the variable
# DTYPE for this, which is assigned to the usual NumPy runtime
# type info object.
# DTYPE = np.float
# DTYPE = float
franchuterivera marked this conversation as resolved.
Show resolved Hide resolved
# "ctypedef" assigns a corresponding compile-time type to DTYPE_t. For
# every type in the numpy module there's a corresponding compile-time
# type with a _t-suffix.
Expand Down
2 changes: 1 addition & 1 deletion ConfigSpace/configuration_space.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ class Configuration(object):

self._query_values = True
self._vector = np.ndarray((self._num_hyperparameters,),
dtype=np.float)
dtype=float)

# Populate the vector
# TODO very unintuitive calls...
Expand Down
2 changes: 1 addition & 1 deletion ConfigSpace/forbidden.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cimport numpy as np
# We now need to fix a datatype for our arrays. I've used the variable
# DTYPE for this, which is assigned to the usual NumPy runtime
# type info object.
DTYPE = np.float
DTYPE = float
# "ctypedef" assigns a corresponding compile-time type to DTYPE_t. For
# every type in the numpy module there's a corresponding compile-time
# type with a _t-suffix.
Expand Down
4 changes: 2 additions & 2 deletions ConfigSpace/forbidden.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ from ConfigSpace.forbidden cimport AbstractForbiddenComponent
# We now need to fix a datatype for our arrays. I've used the variable
# DTYPE for this, which is assigned to the usual NumPy runtime
# type info object.
# DTYPE = np.float
# DTYPE = float
franchuterivera marked this conversation as resolved.
Show resolved Hide resolved
# "ctypedef" assigns a corresponding compile-time type to DTYPE_t. For
# every type in the numpy module there's a corresponding compile-time
# type with a _t-suffix.
# ctypedef np.float_t DTYPE_t
# ctypedef float_t DTYPE_t
from libc.stdlib cimport malloc, free
cimport numpy as np

Expand Down
2 changes: 1 addition & 1 deletion ConfigSpace/hyperparameters.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cimport numpy as np
# We now need to fix a datatype for our arrays. I've used the variable
# DTYPE for this, which is assigned to the usual NumPy runtime
# type info object.
DTYPE = np.float
DTYPE = float
# "ctypedef" assigns a corresponding compile-time type to DTYPE_t. For
# every type in the numpy module there's a corresponding compile-time
# type with a _t-suffix.
Expand Down
8 changes: 4 additions & 4 deletions ConfigSpace/hyperparameters.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cimport numpy as np
# We now need to fix a datatype for our arrays. I've used the variable
# DTYPE for this, which is assigned to the usual NumPy runtime
# type info object.
# DTYPE = np.float
# DTYPE = float
franchuterivera marked this conversation as resolved.
Show resolved Hide resolved
# "ctypedef" assigns a corresponding compile-time type to DTYPE_t. For
# every type in the numpy module there's a corresponding compile-time
# type with a _t-suffix.
Expand Down Expand Up @@ -877,7 +877,7 @@ cdef class UniformIntegerHyperparameter(IntegerHyperparameter):
if self.log:
repr_str.write(", on log-scale")
if self.q is not None:
repr_str.write(", Q: %s" % repr(np.int(self.q)))
repr_str.write(", Q: %s" % repr(np.int64(self.q)))
mfeurer marked this conversation as resolved.
Show resolved Hide resolved
repr_str.seek(0)
return repr_str.getvalue()

Expand Down Expand Up @@ -913,7 +913,7 @@ cdef class UniformIntegerHyperparameter(IntegerHyperparameter):
return self.ufhp._inverse_transform(vector)

def is_legal(self, value: int) -> bool:
if not (isinstance(value, (int, np.int, np.int32, np.int64))):
if not (isinstance(value, (int, np.int32, np.int64))):
return False
elif self.upper >= value >= self.lower:
return True
Expand Down Expand Up @@ -1174,7 +1174,7 @@ cdef class NormalIntegerHyperparameter(IntegerHyperparameter):
q=self.q, log=self.log)

def is_legal(self, value: int) -> bool:
return isinstance(value, (int, np.int, np.int32, np.int64))
return isinstance(value, (int, np.int32, np.int64))

cpdef bint is_legal_vector(self, DTYPE_t value):
return isinstance(value, float) or isinstance(value, int)
Expand Down
4 changes: 3 additions & 1 deletion ConfigSpace/read_and_write/pcs_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
pp_number = pp_e_notation | pp_float | pp_int
pp_numberorname = pp_number | pp_param_name
pp_log = pyparsing.Word("log")
pp_connective = pyparsing.Word("||" + "&&")
# A word matches each character as a set. So && is processed as &
# https://pythonhosted.org/pyparsing/pyparsing.Word-class.html
pp_connective = pyparsing.Word("|" + "&")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be pyparsing.Literal then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the log above, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch of log. I have fixed that.

Leaving pp_connective = pyparsing.Word("|" + "&") as it is was intentional, as this line assumes you will be checking for & or | not &|.

I do not know much about pyparsing, but probably we can do some Combine or And to create this behaviour. In other words, if one just makes this literal this unit test fails.

Let me know how you want to proceed (that is re-writing the pyparsing statement or keeping the pyparsing.Word("|" + "&")).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Can you check whether there's a union of literals we could use here to rewrite this statement to check for either "??" or "||"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was gonna be more complicated, sorry about that. Let me know if this change is ok!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good. There's no need to keep this simple, this should be used only very rarely anyways, so it can be slow...

pp_choices = pp_param_name + pyparsing.Optional(pyparsing.OneOrMore("," + pp_param_name))
pp_sequence = pp_param_name + pyparsing.Optional(pyparsing.OneOrMore("," + pp_param_name))
pp_ord_param = pp_param_name + pp_param_type + "{" + pp_sequence + "}" + "[" + pp_param_name + "]"
Expand Down