Skip to content

Commit

Permalink
Specify input data type as float (#52)
Browse files Browse the repository at this point in the history
* Fix input data type to float

* Update package version
  • Loading branch information
sbaldu authored Jul 21, 2024
1 parent e9a398d commit a6aceea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions CLUEstering/CLUEstering.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,19 @@ def _read_array(self, input_data: Union[list, np.ndarray]) -> None:
if len(input_data) < 2 or len(input_data) > 11:
raise ValueError("Inadequate data. The supported dimensions are between" +
"1 and 10.")
self.clust_data = clustering_data(np.asarray(input_data[:-1]).T,
np.copy(np.asarray(input_data[:-1]).T),
np.asarray(input_data[-1]),
self.clust_data = clustering_data(np.asarray(input_data[:-1], dtype=float).T,
np.copy(np.asarray(input_data[:-1], dtype=float).T),
np.asarray(input_data[-1], dtype=float),
len(input_data[:-1]),
len(input_data[-1]))
# [[[x0, y0, z0, ...], [x1, y1, z1, ...], ...], [weights]]
else:
if len(input_data) != 2:
raise ValueError("Inadequate data. The data must contain a weight value" +
"for each point.")
self.clust_data = clustering_data(np.asarray(input_data[0]),
np.copy(np.asarray(input_data[0])),
np.asarray(input_data[-1]),
self.clust_data = clustering_data(np.asarray(input_data[0], dtype=float),
np.copy(np.asarray(input_data[0], dtype=float)),
np.asarray(input_data[-1], dtype=float),
len(input_data[0][0]),
len(input_data[-1]))

Expand All @@ -329,7 +329,7 @@ def _read_string(self, input_data: str) -> Union[pd.DataFrame,None]:

if not input_data.endswith('.csv'):
raise ValueError('Wrong type of file. The file is not a csv file.')
df_ = pd.read_csv(input_data)
df_ = pd.read_csv(input_data, dtype=float)
return df_

def _read_dict_df(self, input_data: Union[dict, pd.DataFrame]) -> pd.DataFrame:
Expand All @@ -351,7 +351,7 @@ def _read_dict_df(self, input_data: Union[dict, pd.DataFrame]) -> pd.DataFrame:
Dataframe containing the input data
"""

df_ = pd.DataFrame(input_data, copy=False)
df_ = pd.DataFrame(input_data, copy=False, dtype=float)
return df_

def _handle_dataframe(self, df_: pd.DataFrame) -> None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path
from setuptools import setup

__version__ = "2.2.3"
__version__ = "2.2.4"

this_directory = Path(__file__).parent
long_description = (this_directory/'README.md').read_text()
Expand Down

0 comments on commit a6aceea

Please sign in to comment.