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

triplet_formats.py example does not work #65

Closed
sherbold opened this issue Jan 8, 2024 · 2 comments
Closed

triplet_formats.py example does not work #65

sherbold opened this issue Jan 8, 2024 · 2 comments

Comments

@sherbold
Copy link

sherbold commented Jan 8, 2024

I failed to run the triplet_format example. Here is the stacktrace:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 62
     58 data = [triplets_ordered, (triplets_boolean, answers_boolean),
     59         (triplets_numeric, answers_numeric), triplet_spmatrix]
     60 formats = ["list-order", "list-boolean", "list-count", "tensor-count"]
---> 62 timings = [
     63     (time_convert_triplet(triplets, to_format),
     64      f"{from_format}->{to_format}")
     65     for from_format, triplets in zip(formats, data)
     66     for to_format in formats
     67 ]
     69 for seconds, desc in sorted(timings):
     70     print(f"{seconds * 1000:.2f}ms {desc}")

Cell In[1], line 63, in <listcomp>(.0)
     58 data = [triplets_ordered, (triplets_boolean, answers_boolean),
     59         (triplets_numeric, answers_numeric), triplet_spmatrix]
     60 formats = ["list-order", "list-boolean", "list-count", "tensor-count"]
     62 timings = [
---> 63     (time_convert_triplet(triplets, to_format),
     64      f"{from_format}->{to_format}")
     65     for from_format, triplets in zip(formats, data)
     66     for to_format in formats
     67 ]
     69 for seconds, desc in sorted(timings):
     70     print(f"{seconds * 1000:.2f}ms {desc}")

Cell In[1], line 54, in time_convert_triplet(triplets, to_format)
     52 def time_convert_triplet(triplets, to_format):
     53     time_start = time.process_time()
---> 54     check_query_response(triplets, result_format=to_format)
     55     return (time.process_time() - time_start)

File ~/test/cblearn/cblearn/utils/_validate_data.py:292, in check_query_response(query, response, result_format, standard)
    290     query = check_tensor_query_response(query, (QueryFormat.TENSOR, input_response_format), standard=False)
    291     query, response = query.coords.T, query.data
--> 292 return check_list_query_response(query, response, (output_query_format, output_response_format),
    293                                  standard=standard)

File ~/test/cblearn/cblearn/utils/_validate_data.py:135, in check_list_query_response(query, response, result_format, standard)
    132     raise ValueError(f"Expects result_format list-..., got {result_format}.")
    134 if response_format is ResponseFormat.ORDER:
--> 135     return check_order_list_query_response(query, response)
    136 elif response_format is ResponseFormat.BOOLEAN:
    137     return check_bool_list_query_response(query, response, standard=standard)

File ~/test/cblearn/cblearn/utils/_validate_data.py:96, in check_order_list_query_response(query, response)
     95 def check_order_list_query_response(query, response):
---> 96     query, response = _check_list_query_response(query, response)
     97     __, input_response_format = data_format(query, response)
     99     if input_response_format is ResponseFormat.COUNT:

File ~/test/cblearn/cblearn/utils/_validate_data.py:15, in _check_list_query_response(query, response)
     13 def _check_list_query_response(query, response):
     14     if response is None:
---> 15         return check_array(query, dtype=np.uint32), None
     16     else:
     17         return check_X_y(query, response, dtype=np.uint32)

File ~/test/cblearn/venv/lib/python3.10/site-packages/sklearn/utils/validation.py:904, in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator, input_name)
    899 warnings.simplefilter("error", ComplexWarning)
    900 if dtype is not None and xp.isdtype(dtype, "integral"):
    901     # Conversion float -> int should not contain NaN or
    902     # inf (numpy#14412). We cannot use casting='safe' because
    903     # then conversion float -> int would be disallowed.
--> 904     array = _asarray_with_order(array, order=order, xp=xp)
    905     if xp.isdtype(array.dtype, ("real floating", "complex floating")):
    906         _assert_all_finite(
    907             array,
    908             allow_nan=False,
   (...)
    911             input_name=input_name,
    912         )

File ~/test/cblearn/venv/lib/python3.10/site-packages/sklearn/utils/_array_api.py:380, in _asarray_with_order(array, dtype, order, copy, xp)
    378     array = numpy.array(array, order=order, dtype=dtype)
    379 else:
--> 380     array = numpy.asarray(array, order=order, dtype=dtype)
    382 # At this point array is a NumPy ndarray. We convert it to an array
    383 # container that is consistent with the input's namespace.
    384 return xp.asarray(array)

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (2, 1000000) + inhomogeneous part.

Run with Ubuntu 22.10, Python 3.10, based on latest version from repo installed following contributor instructions.

(cc openjournals/joss-reviews#6139)

@haniyeka
Copy link

haniyeka commented Jan 12, 2024

I get the same error with python 3.9 and Ubuntu 22.04.3.

(cc openjournals/joss-reviews#6139)

dekuenstle added a commit that referenced this issue Jan 16, 2024
dekuenstle added a commit that referenced this issue Jan 25, 2024
* Update dependencies (+ fix broken test)
* Fix error in unit tests if  no remote data flag set
* Fix contributor install instructions  #66
* Do not use the wrapped estimator in the ordinal_embedding example #68
* Fix triplet_format example  #65
* Run all examples when building docs  #65 #68
* Fix warnings when building docs
* Extend install instructions of extra requirements #67
* Fix docstring for dimension test
* Document when h5py is needed and raise better error if it is missing
* Fix missing quote ending string literal
* Explain scikit learn compatibility in docs
@dekuenstle
Copy link
Collaborator

Should be fixed now in the latest release:
https://github.com/cblearn/cblearn/releases/tag/0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants