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

Integrate Segway Toolkit into Segway #181

Open
wants to merge 95 commits into
base: develop
Choose a base branch
from

Conversation

isaiahah
Copy link
Contributor

No description provided.

Copy link
Member

@EricR86 EricR86 left a comment

Choose a reason for hiding this comment

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

Let me know when you've addressed the changes.

Also can you address the posterior trackfiles in the simplesubseg touchstone folder? Why are they there?

segway/_util.py Outdated Show resolved Hide resolved
segway/gmtk/input_master.py Outdated Show resolved Hide resolved
segway/gmtk/input_master.py Outdated Show resolved Hide resolved
segway/gmtk/input_master.py Outdated Show resolved Hide resolved
segway/gmtk/input_master.py Outdated Show resolved Hide resolved
segway/gmtk/input_master.py Outdated Show resolved Hide resolved
segway/gmtk/input_master.py Outdated Show resolved Hide resolved
segway/input_master.py Outdated Show resolved Hide resolved
segway/input_master.py Outdated Show resolved Hide resolved
segway/run.py Outdated Show resolved Hide resolved
Copy link
Member

@EricR86 EricR86 left a comment

Choose a reason for hiding this comment

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

Looks good! There's only minor comments to address. In general more comments behind the code generating the structure would be very appreciated.

After my comments have been addressed you can ping Michael for a review.

segway/gmtk/input_master.py Outdated Show resolved Hide resolved
segway/input_master.py Outdated Show resolved Hide resolved
segway/input_master.py Outdated Show resolved Hide resolved
segway/input_master.py Show resolved Hide resolved
segway/input_master.py Outdated Show resolved Hide resolved
Copy link
Contributor

@michaelmhoffman michaelmhoffman left a comment

Choose a reason for hiding this comment

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

Great work, will re-review

@@ -1,5 +1,2 @@
% XXXopt: good candidate for a linear combination C deterministic mapper
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please restore this comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, it might be better to move it to whatever Python code calls this so it isn't copied into every project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've moved this comment (verbatim) to the Python code which loads this file. See input_master.py line 121.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about just preamble.tmpl?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@@ -50,10 +57,11 @@ def __new__(cls, *args: NumericArrayLike, keep_shape: bool = False) \
(dimension 1) from a single scalar input value.
"""
# Ensure all arguments belong to the correct type
if not all(isinstance(arg, NumericArrayLike) for arg in args):
if not all((isinstance(arg, float) or isinstance(arg, int) or
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, please replace with at least the tuple (float, int, ndarray). That has been supported for a long time, even if union types won't be directly until Py3.10.

I think NumericArrayLike.get_args() which should get you (float, int, ndarray) should be even better, because it eliminates future potential inconsistency issues.

Please add a comment indicating the issue with NumericArrayLike and at what Python version it won't be an issue anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added checking type with the tuple and a comment explaining why. I've used typing.get_args(NumericArrayLike) to print the types.

raise TypeError("Argument has incompatible type. "
f"Expected {NumericArrayLike}")
raise TypeError("Argument has incompatible type."
"Expected float, int, or ndarray.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Reverse if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reversed the order of these sentences.

# If union iterable, fix. Otherwise, hardwrite
raise TypeError("Argument has incompatible type. "
f"Expected {NumericArrayLike}")
raise TypeError("Argument has incompatible type."
Copy link
Contributor

Choose a reason for hiding this comment

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

Need a space between sentences

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

# if stored items are generic strings, return them out without
# any additional formatting. Otherwise, apply formatting
if self.kind == OBJ_KIND_GENERICSTRING:
lines += self.get_unformatted_lines()
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use += with a list. Switch to lines.extend() or lines.append().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed throughout.

if not isinstance(value, OneLineKind):
# Unless a class where all data is on one line (OneLineArray and
# VirtualEvidence), write the object's remaining lines
if not (isinstance(value, OneLineArray) or
Copy link
Contributor

Choose a reason for hiding this comment

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

isinstance(value, (OneLineArray, VirtualEvidence))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.



class InlineMCSection(InlineSection):
"""
Special InlineSection subclass which contains MC objects.
Attributes:
mean: the InlineSection object stored at InputMaster.mean
covar: the InlineSection object stored at InputMaster.covar
mean: InlineSection object which point to InputMaster.mean
Copy link
Contributor

Choose a reason for hiding this comment

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

which point to -> referred to by

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed throughout.

# if line_before is set, use it to begin the section's lines
lines = []
if self.line_before:
lines += [self.line_before]
Copy link
Contributor

Choose a reason for hiding this comment

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

same as before with .append(), .extend()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed throughout.

@@ -0,0 +1,503 @@
#!/usr/bin/env python

Copy link
Contributor

Choose a reason for hiding this comment

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

For the next round, can you please fix this so that Git knows what it should diff against? It looks like this is modification of old code and I don't think anyone wants us to review it all de novo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file was previously segway_input_master.py. The helper functions and opening section are the only things which were not changed. I haven't yet found a way to change how Git generates the diff, but will at minimum specify the relevant line sections in the next round.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants