Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
xtnctx authored Dec 2, 2022
1 parent 1b8ddaa commit 43bdc0a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bfrbsysAPI/apis/utils.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import re, os
import pandas as pd

def hex_to_c_array(hex_data) -> str:
c_str = ''

# Declare C variable
c_str += 'unsigned char model[] = {'
c_str += 'unsigned char model[]={'
hex_array = []

for i, val in enumerate(hex_data):
# Construct string from hex
hex_str = format(val, '#04x')

# Add formatting so each line stays within 80 characters
if (i + 1) < len(hex_data):
hex_str += ','
if (i + 1) % 12 == 0:
hex_str += '\n'

hex_array.append(hex_str)

# Add closing brace
c_str += '\n ' + format(' '.join(hex_array)) + '\n};'
c_str += format(''.join(hex_array)) + '};'

return c_str

Expand Down Expand Up @@ -49,3 +48,9 @@ def remove_file(path: str):
os.remove(path)
except PermissionError as e:
print(e)

def callback_string(history) -> str:
hist_df = pd.DataFrame(history.history)
str_callback = hist_df.to_csv(index=False)
return str_callback

0 comments on commit 43bdc0a

Please sign in to comment.