Skip to content

Conversation

@tachikoma-li
Copy link
Member

To set check_untyped_defs to True, we need to make sure not to change the type of variable within the function body.
This PR is to fix that issue.

The main change is in _qctrl_expanded_export_content where the type of return value control_info depends on the coordinates. It is a List for CSV and Dict for JSON. However, we can always make control_info as a Dict and change the format is the _export_to_qctrl_expanded_format (which calls _qctrl_expanded_export_content to get control_info) which only save the data to file and therefore does not have a return type but only side effect.

some other minor tweaks:

  • make filename mandatory
  • minor tweak in export_to_file to fix the type issue and remove the error-rasing part
  • minor tweak in new_ramsey_sequence to fix the type issue

@tachikoma-li tachikoma-li requested review from a team and charmasaur December 18, 2020 02:49
def _export_to_qctrl_expanded_format(
self,
filename=None,
filename,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the docstring now that this is no longer optional

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

self.maximum_rabi_rate
] * self.number_of_segments
field_names = sorted(control_info.keys())
with open(filename, "w", newline="") as file:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value for newline here could use an explanatory comment (maybe just a link to https://docs.python.org/3/library/csv.html#id3?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Added.

def export_to_file(
self,
filename=None,
filename,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update docstring

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, did you mean the doc for filename?
Seems it was not optional in the doc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh, sorry. I just assumed it was.

coordinates : str, optional
Indicates the co-ordinate system requested. Must be one of
'cylindrical', 'cartesian' or 'polar'; defaults to 'cylindrical'
'cylindrical', 'cartesian' or 'polar'. Defaults to 'cylindrical'.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I don't think we have the polar option, shall we remove it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I'd guess that's what we used to call cylindrical.

def _export_to_qctrl_expanded_format(
self,
filename=None,
filename,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

self.maximum_rabi_rate
] * self.number_of_segments
field_names = sorted(control_info.keys())
with open(filename, "w", newline="") as file:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Added.

def export_to_file(
self,
filename=None,
filename,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, did you mean the doc for filename?
Seems it was not optional in the doc.

Copy link
Contributor

@charmasaur charmasaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although feel free to remove "polar" too.

coordinates : str, optional
Indicates the co-ordinate system requested. Must be one of
'cylindrical', 'cartesian' or 'polar'; defaults to 'cylindrical'
'cylindrical', 'cartesian' or 'polar'. Defaults to 'cylindrical'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I'd guess that's what we used to call cylindrical.

def export_to_file(
self,
filename=None,
filename,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh, sorry. I just assumed it was.

@tachikoma-li tachikoma-li merged commit 1221328 into master Dec 18, 2020
@tachikoma-li tachikoma-li deleted the mypy branch December 18, 2020 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants