Skip to content

Commit

Permalink
Fix ChainedAssignmentError warnings in test code
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkn committed May 17, 2024
1 parent a8fb0ff commit 61a9779
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
18 changes: 11 additions & 7 deletions test/plot_methods/hist_plot_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ def setup_arrow_data

def setup_pandas_data
pandas_required
@data = Pandas::DataFrame.new(data: @array_data)
@data[:red] = @data[:red].astype("float64")
@data[:blue] = @data[:blue].astype("float64")
@data[:green] = @data[:green].astype("float64")
data = Pandas::DataFrame.new(data: @array_data)
@data = Pandas::DataFrame.new(data: {
red: data[:red].astype("float64"),
blue: data[:blue].astype("float64"),
green: data[:green].astype("float64")
})
end
end

Expand Down Expand Up @@ -86,9 +88,11 @@ def setup_arrow_data

def setup_pandas_data
pandas_required
@data = Pandas::DataFrame.new(data: @array_data)
@data[:a] = @data[:a].astype("float64")
@data[:c] = @data[:c].astype("category")
data = Pandas::DataFrame.new(data: @array_data)
@data = Pandas::DataFrame.new(data: {
a: data[:a].astype("float64"),
c: data[:c].astype("category")
})
end
end
end
4 changes: 2 additions & 2 deletions test/table/table_group_by_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ def setup_table_by_pandas
@expected_applied_table.adapter.data.each do |key, value|
data[key] = value.to_a
end
data[:a_min] = data[:a_min].map(&:to_f)
data[:a_max] = data[:a_max].map(&:to_f)
df = Pandas::DataFrame.new(data: data)
df[:a_min] = df[:a_min].astype(:float64)
df[:a_max] = df[:a_max].astype(:float64)
@expected_applied_table = Charty::Table.new(df, index: @expected_applied_table.index)
end

Expand Down
9 changes: 6 additions & 3 deletions test/table/table_reset_index_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ def setup_table_by_pandas

@table = Charty::Table.new(Pandas::DataFrame.new(data: @data))

df = Pandas::DataFrame.new(data: {b: @expected_indices.keys}.merge(@expected_applied_data))
df[:a_min] = df[:a_min].astype(:float64)
df[:a_max] = df[:a_max].astype(:float64)
df = Pandas::DataFrame.new(data: {
b: @expected_indices.keys,
a: @expected_applied_data[:a],
a_min: @expected_applied_data[:a_min].map(&:to_f),
a_max: @expected_applied_data[:a_max].map(&:to_f)
})
@expected_result = Charty::Table.new(df)
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/vector/pandas_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def test_aref
5
],
[
@vector[1],
@vector.iloc(1),
@vector["c"],
@vector["d"],
@vector[4]
@vector.iloc(4)
])
end
end
Expand Down

0 comments on commit 61a9779

Please sign in to comment.