Skip to content

Refactor descriptions#113

Merged
hinerm merged 14 commits into
mainfrom
scijava/scijava-ops-engine/refactor-descriptions
Jan 19, 2024
Merged

Refactor descriptions#113
hinerm merged 14 commits into
mainfrom
scijava/scijava-ops-engine/refactor-descriptions

Conversation

@gselzer

@gselzer gselzer commented Jan 8, 2024

Copy link
Copy Markdown
Member

This PR is (currently) a messy attempt at making the return from DefaultOpEnvironment.help() a lot cleaner to read. We make the following broad changes:

  • The multiline description is condensed into a single line
  • The only name shown is the searched name - no aliases are shown, and I can't think of a reason you'd want to know the aliases for an Op.
  • All Op names are required to belong to a namespace. engine.adapt Ops now use the engine.create and engine.copy names where necessary for adaptation purposes. Other Ops were altered as needed to enforce this requirement.
  • Argument types are now omitted, and only the names are shown.
  • Container and Mutable arguments are now shown using the symbols * and ^, respectively. @ctrueden liked this the best.

Note that this PR is designed to close scijava/scijava#167, and is meant to give @hinerm a starting point since he assigned himself that issue.

Points for further discussion:

  • Using the names, and not the types, makes collapsing OpInfos harder, because right now we only collapse based on equal Strings. But, if the names are scraped from javadoc, we can't stop someone from e.g. making a typo and adding a new entry to the help.
  • Do we think that the new key for container and mutable outputs are visible enough?
  • I never changed the verbose description - how should that change, if at all? With @elevans' help, I edited the verbose descriptions to look similar to the simple descriptions, but they also include type/implementation/description details.

TODO:

  • Once we finalize the design, update the docs!

@gselzer gselzer added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 8, 2024
@gselzer gselzer requested a review from hinerm January 8, 2024 16:19
@gselzer gselzer self-assigned this Jan 8, 2024
@gselzer gselzer force-pushed the scijava/scijava-ops-engine/refactor-descriptions branch from 402bd33 to 3f2fa69 Compare January 8, 2024 19:00

@gselzer gselzer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I like the changes, but as expected with a draft PR it's sloppy

Comment on lines -22 to -26
public final class OpWrappers {

private OpWrappers() {
// Prevent instantiation of static utility class
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Was this not a part of the OpWrappers.vm file?

var infos = SimplificationMatchingRoutine.getInfos(env, req.getName());
var filtered = filterInfos(infos, req);
String opString = filtered.stream() //
.map(Infos::describe) //

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should consider deleting unused methods - there are now 4 different Infos.describe... methods - decide whether we need/want all of them

Comment on lines +149 to +157
return describe(info, null, null);
}

/**
* Generates a {@link String} describing the given {@link OpInfo}
*
* @param info the {@link OpInfo} of interest
* @param name the name that the Op was searched by
* @return a descriptor for {@code info}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Again, figure out how much of this is needed

Comment on lines 59 to 65

String expected = "test.classDescription(\n\t " //
+ "Inputs:\n\t\tjava.lang.Double input1\n\t\tjava.lang.Double input2\n\t " //
+ "Outputs:\n\t\tjava.lang.Double output1\n)\n";
+ "Output:\n\t\tjava.lang.Double output1\n)\n";
String actual = info.toString();
Assertions.assertEquals(expected, actual);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We may want to switch info.toString() to the current Infos.describeMultiline if we like that better

Comment on lines +137 to +138
org.scijava.ops.engine.stats.Mean,
org.scijava.ops.engine.stats.Size;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why is this indented

@@ -99,7 +99,7 @@ public class DefaultTubeness<T extends RealType<T>> implements
private Function<Dimensions, ImgFactory<DoubleType>> createFactoryOp;

//TODO: make sure this works

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Does it work?

*/

package org.scijava.ops.image.slice;
package org.scijava.ops.image.transform.slice.slice;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why is this package slice.slice?

.producer();

Function<Class<T>, T> typeFunc = ops.unary("create") //
Function<Class<T>, T> typeFunc = ops.unary("create.object") //

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Consider coming up with a better name...

*/

package org.scijava.ops.image.project;
package org.scijava.ops.image.transform.project.project;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This package should not have two project

Assertions.assertEquals(expected2, typeAssigns2);
}


Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Can remove this

@hinerm hinerm force-pushed the scijava/scijava-ops-engine/refactor-descriptions branch 2 times, most recently from 0e8c715 to 88d5626 Compare January 19, 2024 18:05
@hinerm hinerm force-pushed the scijava/scijava-ops-engine/refactor-descriptions branch from 43256f7 to baee2b5 Compare January 19, 2024 18:58
@hinerm hinerm marked this pull request as ready for review January 19, 2024 18:59
@hinerm hinerm merged commit 64087be into main Jan 19, 2024
@hinerm hinerm deleted the scijava/scijava-ops-engine/refactor-descriptions branch January 19, 2024 19:17
@gselzer gselzer mentioned this pull request Jan 23, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Unexpected verbose output for ops.help("create")

2 participants