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 typechecking with pandas stubs #269

Merged
merged 4 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",]
requires-python = ">=3.9"
dependencies = [ "qcodes>=0.42.0", "versioningit>=2.0.1", "packaging"]
dependencies = [ "qcodes>=0.42.0", "versioningit>=2.0.1", "packaging", "pandas"]
dynamic = [ "version",]

[[project.maintainers]]
Expand Down Expand Up @@ -47,7 +47,8 @@ test = [
"pytest-cov>=3.0.0",
"coverage[toml]>=6.2",
"pyvisa-sim",
"types-tqdm>=4.64.6"
"types-tqdm>=4.64.6",
"pandas-stubs",
]
docs = [ "sphinx", "sphinx_rtd_theme", "nbsphinx", ]

Expand Down
20 changes: 14 additions & 6 deletions qcodes_contrib_drivers/drivers/BlueFors/BlueFors.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,18 @@ def get_temperature(self, channel: int) -> float:

try:
# There is a space before the day for old BlueFors Control Sofware versions
df.index = pd.to_datetime(df['date']+'-'+df['time'], format=' %d-%m-%y-%H:%M:%S')
except:
date_time = pd.to_datetime(
df["date"] + "-" + df["time"], format=" %d-%m-%y-%H:%M:%S"
)
except Exception:
# There is no space before the day with BlueFors Control Software v2.2
df.index = pd.to_datetime(df['date']+'-'+df['time'], format='%d-%m-%y-%H:%M:%S')

return df.iloc[-1]['y']
date_time = pd.to_datetime(
df["date"] + "-" + df["time"], format="%d-%m-%y-%H:%M:%S"
)
df["date_time"] = date_time
df.set_index("date_time", inplace=True)
astafan8 marked this conversation as resolved.
Show resolved Hide resolved
df.sort_index(inplace=True)
return df.iloc[-1]["y"]
except (PermissionError, OSError) as err:
self.log.warn('Cannot access log file: {}. Returning np.nan instead of the temperature value.'.format(err))
return np.nan
Expand Down Expand Up @@ -199,7 +205,9 @@ def get_pressure(self, channel: int) -> float:
'void'],
header=None)

df.index = pd.to_datetime(df['date']+'-'+df['time'], format='%d-%m-%y-%H:%M:%S')
df["date_time"] = pd.to_datetime(df['date']+'-'+df['time'], format='%d-%m-%y-%H:%M:%S')
df.set_index("date_time", inplace=True)
astafan8 marked this conversation as resolved.
Show resolved Hide resolved
df.sort_index(inplace=True)

return df.iloc[-1]['ch'+str(channel)+'_pressure']
except (PermissionError, OSError) as err:
Expand Down